Page MenuHomeVyOS Platform

Unable to remove DHCP client from interface when dynamic IPv6 address is configured
In progress, HighPublicBUG

Description

It looks like https://vyos.dev/T6972 introduced a bug that makes it so you cannot commit interface changes when an interface has a dynamic IPv6 address and the user is trying to remove it from being a DHCP client

bitplumber@vyos# run show interfaces
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface    IP Address                         MAC                VRF        MTU  S/L    Description
-----------  ---------------------------------  -----------------  -------  -----  -----  -------------
eth0         172.233.33.164/24                  f2:3c:93:d7:f5:8a  default   1500  u/u
             2600:3c0e::f03c:93ff:fed7:f58a/64

yzguy@router.ams1# delete interfaces ethernet eth0 address dhcp

yzguy@router.ams1# compare
[interfaces ethernet eth0]
- address "dhcp"
yzguy@router.ams1# commit
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 139, in run_script
    script.apply(c)
  File "/usr/libexec/vyos//conf_mode/interfaces_ethernet.py", line 336, in apply
    e.update(ethernet)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/ethernet.py", line 532, in update
    super().update(config)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1663, in update
    self.del_addr('dhcp')
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1280, in del_addr
    self.set_dhcp(False)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1430, in set_dhcp
    self.del_addr(address)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1285, in del_addr
    self._cmd(f'{netns_cmd} ip addr del {addr} dev {self.ifname}')
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 64, in _cmd
    return cmd(command, self.debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/utils/process.py", line 155, in cmd
    raise OSError(code, feedback)
FileNotFoundError: [Errno 2] failed to run command:  ip addr del 2600:3c0e::f03c:93ff:fed7:f58a dev eth0
returned:
exit code: 2

You must pass an IP with the CIDR to the ip del command or it will error because the address cannot be found

yzguy@router.ams1# sudo ip addr del 2600:3c0e::f03c:93ff:fed7:f58a dev eth0
Error: ipv6: address not found.
[edit]
yzguy@router.ams1# sudo ip addr del 2600:3c0e::f03c:93ff:fed7:f58a/64 dev eth0
[edit]

The comment above the code specifically is

# We will force removal of any dynamic IPv4 address from the interface

So it may also have been meant to only deal with IPv4 addresses, but since it's not looking at specifically inet addresses, eg address_info['family'] it is also looking at IPv6 addresses

Details

Version
1.5-rolling-202501031241
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

tmp['address_info'] looks like

[{'dynamic': True,
  'family': 'inet6',
  'local': '2600:3c0e::f03c:93ff:fed7:f58a',
  'mngtmpaddr': True,
  'preferred_life_time': 1791,
  'prefixlen': 64,
  'protocol': 'kernel_ra',
  'scope': 'global',
  'valid_life_time': 5391},
 {'family': 'inet6',
  'local': 'fe80::f03c:93ff:fed7:f58a',
  'preferred_life_time': 4294967295,
  'prefixlen': 64,
  'scope': 'link',
  'valid_life_time': 4294967295}]

Each dict in the list is address_info in the loop

yzguy renamed this task from Unable to swap from DHCP/SLAAC address to static to Unable to remove DHCP client from interface when dynamic IPv6 address is configured.Jan 5 2025, 3:33 AM
yzguy updated the task description. (Show Details)
c-po changed the task status from Open to In progress.Jan 5 2025, 6:29 AM
c-po assigned this task to yzguy.
c-po triaged this task as High priority.
c-po subscribed.