Page MenuHomeVyOS Platform

op-mode: "renew dhcp interface <name>" does not check if it's an actual DHCP interface
Closed, ResolvedPublicBUG

Description

The op-mode script simply calls sudo systemctl restart "dhclient@$4.service"

Which consists out of:

[email protected]:~$ systemctl cat [email protected]
# /lib/systemd/system/[email protected]
[Unit]
Description=DHCP client on %i
Documentation=man:dhclient(8)
StartLimitIntervalSec=0
After=vyos-router.service

[Service]
Type=exec
ExecStart=/sbin/dhclient -4 -d $DHCLIENT_OPTS
ExecStop=/sbin/dhclient -4 -r $DHCLIENT_OPTS
Restart=always
RestartPreventExitStatus=
RestartSec=10
RuntimeDirectoryPreserve=yes
TimeoutStopSec=20
SendSIGKILL=true
FinalKillSignal=SIGABRT

[Install]
WantedBy=multi-user.target

With no additional information about a client interface at all.

This results in useless dhclient processes

root       47812  4.7  0.0   5848  3584 ?        Ss   00:30   0:00 /sbin/dhclient -4 -d
root       48121  0.0  0.0   4188  3072 ?        S    00:30   0:00  \_ /bin/sh /sbin/dhclient-script
root       48148 50.0  0.2  18776 11264 ?        R    00:30   0:00      \_ python3 -

Which also assign client leases to all local interfaces, if we receive one valid DHCPOFFER

[email protected]:~$ show interfaces
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface    IP Address         MAC                VRF        MTU  S/L    Description
-----------  -----------------  -----------------  -------  -----  -----  -------------
dum0         172.18.254.201/32  1e:7f:da:51:a0:a2  default   1500  u/u
eth0         -                  00:50:56:bf:c5:6d  default   1500  u/u
eth0.10      172.16.33.201/24   00:50:56:bf:c5:6d  default   1500  u/u
             172.16.33.102/24
eth0.201     172.18.201.10/24   00:50:56:bf:c5:6d  default   1500  u/u
eth1         172.16.33.131/24   00:50:56:b3:38:c5  default   1500  u/u

172.16.33.102/24 and 172.16.33.131/24 are stray DHCP addresses

Details

Difficulty level
Easy (less than an hour)
Version
1.4.0-epa2
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Stricter validation
Issue type
Bug (incorrect behavior)