Bug 1911241

Summary: better deal with ipv6 address in dns config
Product: Red Hat Enterprise Linux 8 Reporter: Mingyu Shi <mshi>
Component: nmstateAssignee: Fernando F. Mancera <ferferna>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: low Docs Contact:
Priority: low    
Version: 8.4CC: ferferna, fge, jiji, jishi, network-qe, till
Target Milestone: rcKeywords: Triaged
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmstate-1.1.1-0.1.alpha1.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:34:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mingyu Shi 2020-12-28 10:42:28 UTC
Description of problem:
Similar with #bz1760800 , when ipv6 dns is written in, for example, full format, nmstate can't deal with it.

Version-Release number of selected component (if applicable):
nmstate-1.0.0-1.el8.noarch
nispor-1.0.1-2.el8.x86_64
NetworkManager-1.30.0-0.5.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
echo "---
dns-resolver:
  config:
    search:
    - veth0.lan
    - veth0.lan0
    server:
    - 10.68.5.26
    - 10.72.17.5
    - 8.8.8.8
    - 0000:0000:0000:0000:0000:0000:0000:0100
routes:
  config:
  - destination: 0.0.0.0/0
    next-hop-address: 1.0.0.254
    next-hop-interface: veth0
  - destination: ::/0
    next-hop-address: 100::254
    next-hop-interface: veth0
interfaces:
- name: veth0
  type: ethernet
  state: up
  ipv4:
    address:
    - ip: 1.0.0.1
      prefix-length: 24
    enabled: true
  ipv6:
    address:
    - ip: 100::1
      prefix-length: 64
    enabled: true" | nmstatectl set

Actual results:
Failed

Expected results:
No failure and convert expanded ipv6 address to compressed address.

Additional info:
Traceback (most recent call last):
  File "/usr/bin/nmstatectl", line 11, in <module>
    load_entry_point('nmstate==1.0.0', 'console_scripts', 'nmstatectl')()
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 70, in main
    return args.func(args)
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 269, in apply
    args.save_to_disk,
  File "/usr/lib/python3.6/site-packages/nmstatectl/nmstatectl.py", line 309, in apply_state
    save_to_disk=save_to_disk,
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 71, in apply
    _apply_ifaces_state(plugins, net_state, verify_change, save_to_disk)
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 115, in _apply_ifaces_state
    _verify_change(plugins, net_state)
  File "/usr/lib/python3.6/site-packages/libnmstate/netapplier.py", line 120, in _verify_change
    net_state.verify(current_state)
  File "/usr/lib/python3.6/site-packages/libnmstate/net_state.py", line 65, in verify
    self._dns.verify(current_state.get(DNS.KEY))
  File "/usr/lib/python3.6/site-packages/libnmstate/dns.py", line 195, in verify
    {DNS.KEY: cur_dns.config},
libnmstate.error.NmstateVerificationError: 
desired
=======
---
dns-resolver:
  search:
  - veth0.lan
  - veth0.lan0
  server:
  - 10.68.5.26
  - 10.72.17.5
  - 8.8.8.8
  - 0000:0000:0000:0000:0000:0000:0000:0100

current
=======
---
dns-resolver:
  search:
  - veth0.lan
  - veth0.lan0
  server:
  - 10.68.5.26
  - 10.72.17.5
  - 8.8.8.8
  - ::100

difference
==========
--- desired
+++ current
@@ -7,4 +7,4 @@
   - 10.68.5.26
   - 10.72.17.5
   - 8.8.8.8
-  - 0000:0000:0000:0000:0000:0000:0000:0100
+  - ::100

Comment 3 Fernando F. Mancera 2021-08-09 16:17:42 UTC
Upstream patch: https://github.com/nmstate/nmstate/pull/1693

Comment 7 Gris Ge 2021-09-22 07:56:29 UTC
Tested using nmstate-1.0 branch and nmstate-1.1 branch using yaml


```
---
dns-resolver:
  config:
    search: []
    server:
    - "0000:0000:0000:0000:0000:0000:0000:0100"
    - 8.8.4.4
interfaces:
  - name: eth1
    type: ethernet
    state: up
    ipv4:
      address:
      - ip: 192.0.2.251
        prefix-length: 24
      dhcp: false
      enabled: true
    ipv6:
      address:
      - ip: 2001:db8:1::1
        prefix-length: 64
      dhcp: false
      enabled: true
      autoconf: false
routes:
  config:
  - destination: 0.0.0.0/0
    next-hop-address: 192.0.2.1
    next-hop-interface: eth1
  - destination: ::/0
    next-hop-address: 2001:db8:1::3
    next-hop-interface: eth1
```

Comment 8 Mingyu Shi 2021-10-11 10:29:38 UTC
Verified with versions:
nmstate-1.1.1-0.1.alpha1.el8.noarch
nispor-1.1.1-1.el8.x86_64
NetworkManager-1.34.0-0.2.el8.x86_64

1. DNS with static ipv6:
[18:25:53@hpe-dl380pgen8-02-vm-9 ~]0# nmstatectl set dns6_static.yaml
/tmp/nmstatelog/2021-10-11-18:25:57-859112499.log
Desired state applied: 
---
dns-resolver:
  config:
    server:
    - 3000:0000:0000:0000:0000:0000:0000:0000
    - 0000:0000:0000:0000:0000:0000:0000:0100
    - 0000:0000:000F:0000:0000:0000:0000:0100
    - 3001:db8::1:1:1:1:1
    - 3001:db8:0:0:0:0:2:1
    - 3001:db8::0:1
    - '3002:0:0:1:0:0:0:1'
    - 3003:dB8:0:0:1:0:0:1
    - 3004:db8::1:0:0:1
    - 3005:DB8:0:0:1::1
    - 0:0:0:0:0:FFFF:192.0.2.1
    - ::FFFF:192.0.2.2
    - 03:0000:000:00:0::4
routes:
  config:
  - destination: ::/0
    metric: 20550
    next-hop-address: 8::9
    next-hop-interface: veth0
    table-id: 250
interfaces:
- name: veth0
  type: ethernet
  state: up
  ipv6:
    enabled: true
    address:
    - ip: 8::8
      prefix-length: 64
/tmp/nmstatelog/2021-10-11-18:25:57-859112499.0.log nmstatectl set dns6_static.yaml return 0
[18:26:00@hpe-dl380pgen8-02-vm-9 ~]0# nmstatectl show | yq3 r - dns-resolver
config:
  search: []
  server:
    - '3000::'
    - ::100
    - 0:0:f::100
    - 3001:db8:0:1:1:1:1:1
    - 3001:db8::2:1
    - 3001:db8::1
    - 3002:0:0:1::1
    - 3003:db8::1:0:0:1
    - 3004:db8::1:0:0:1
    - 3005:db8::1:0:0:1
    - ::ffff:192.0.2.1
    - ::ffff:192.0.2.2
    - 3::4
running:
  search:
    - hpe2.lab.eng.bos.redhat.com
  server:
    - '3000::'
    - ::100
    - 0:0:f::100
    - 3001:db8:0:1:1:1:1:1
    - 3001:db8::2:1
    - 3001:db8::1
    - 3002:0:0:1::1
    - 3003:db8::1:0:0:1
    - 3004:db8::1:0:0:1
    - 3005:db8::1:0:0:1
    - ::ffff:192.0.2.1
    - ::ffff:192.0.2.2
    - 3::4
    - 10.19.42.41
    - 10.11.5.19
    - 10.5.30.160
[18:26:21@hpe-dl380pgen8-02-vm-9 ~]0# cat /etc/resolv.conf 
# Generated by NetworkManager
search hpe2.lab.eng.bos.redhat.com
nameserver 3000::
nameserver ::100
nameserver 0:0:f::100
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver 3001:db8:0:1:1:1:1:1
nameserver 3001:db8::2:1
nameserver 3001:db8::1
nameserver 3002:0:0:1::1
nameserver 3003:db8::1:0:0:1
nameserver 3004:db8::1:0:0:1
nameserver 3005:db8::1:0:0:1
nameserver 192.0.2.1
nameserver 192.0.2.2
nameserver 3::4
nameserver 10.19.42.41
nameserver 10.11.5.19
nameserver 10.5.30.160


2. DNS with DHCPv6(auto-dns=false):
[18:16:24@hpe-dl380pgen8-02-vm-9 ~]0# nmstatectl set dns6.yaml 
/tmp/nmstatelog/2021-10-11-18:16:29-569349971.log
Desired state applied: 
---
dns-resolver:
  config:
    server:
    - 3000:0000:0000:0000:0000:0000:0000:0000
    - 0000:0000:0000:0000:0000:0000:0000:0100
    - 0000:0000:000F:0000:0000:0000:0000:0100
    - 3001:db8::1:1:1:1:1
    - 3001:db8:0:0:0:0:2:1
    - 3001:db8::0:1
    - '3002:0:0:1:0:0:0:1'
    - 3003:dB8:0:0:1:0:0:1
    - 3004:db8::1:0:0:1
    - 3005:DB8:0:0:1::1
    - 0:0:0:0:0:FFFF:192.0.2.1
    - ::FFFF:192.0.2.2
    - 03:0000:000:00:0::4
interfaces:
- name: veth0
  type: ethernet
  state: up
  ipv6:
    enabled: true
    auto-dns: false
    dhcp: true
/tmp/nmstatelog/2021-10-11-18:16:29-569349971.0.log nmstatectl set dns6.yaml return 0
[18:16:49@hpe-dl380pgen8-02-vm-9 ~]1# nmstatectl show | yq3 r - dns-resolver
config:
  search: []
  server:
    - '3000::'
    - ::100
    - 0:0:f::100
    - 3001:db8:0:1:1:1:1:1
    - 3001:db8::2:1
    - 3001:db8::1
    - 3002:0:0:1::1
    - 3003:db8::1:0:0:1
    - 3004:db8::1:0:0:1
    - 3005:db8::1:0:0:1
    - ::ffff:192.0.2.1
    - ::ffff:192.0.2.2
    - 3::4
running:
  search:
    - hpe2.lab.eng.bos.redhat.com
  server:
    - 10.19.42.41
    - 10.11.5.19
    - 10.5.30.160

Comment 10 errata-xmlrpc 2022-05-10 13:34:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (nmstate bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:1772