networkd: classless routes served by DHCP are created incorrectly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd |
Fix Released
|
Unknown
|
|||
systemd (Ubuntu) |
Fix Released
|
Low
|
Unassigned | ||
Jammy |
Fix Released
|
Low
|
Unassigned | ||
Lunar |
Fix Released
|
Low
|
Unassigned |
Bug Description
[Impact]
Classless static routes served by DHCP are ignored by networkd in some cases. Specifically, the gateway is not being set for routes whenever the route destination is in the assigned network. This is a regression in behavior since Focal.
[Test Plan]
This is basically taken from systemd-
$ cat > /etc/systemd/
[Match]
Name=veth-peer
[Network]
IPv6AcceptRA=no
Address=2600::1/0
Address=
EOF
$ cat > /etc/systemd/
[Match]
Name=veth99
[Network]
DHCP=ipv4
IPv6AcceptRA=false
[DHCPv4]
UseRoutes=yes
EOF
$ cat > /etc/systemd/
[NetDev]
Name=veth99
Kind=veth
MACAddress=
[Peer]
Name=veth-peer
MACAddress=
EOF
$ mkdir -p /etc/systemd/
$ cat > /etc/systemd/
[Service]
Environment=
EOF
$ systemctl daemon-reload
$ systemctl restart systemd-networkd
$ mkdir -p /run/networkd-ci
$ dnsmasq --log-facility=
$ systemctl restart systemd-networkd
On an affected machine, the route to 192.168.5.64 on veth99 will be missing it's gateway address:
$ ip r show dev veth99 192.168.5.64/26
192.168.5.64/26 proto dhcp scope link src 192.168.5.181 metric 1024
And, there will be a log message explaining that this was done intentionally:
$ journalctl -u systemd-networkd --grep=
Aug 03 16:58:49 mantic2 systemd-
On a fixed machine, the route for to 192.168.5.64 will correctly have its gateway configured:
$ ip r show dev veth99 192.168.5.64/26
192.168.5.64/26 via 192.168.5.5 proto dhcp src 192.168.5.181 metric 1024
[Where problems could occur]
The patch is in the DHCPv4 client code for handling routes from the DHCP server. It adds a flag, force_use_gw, to an internal function that essentially overrides the "ignore" behavior whenever classless static routes have been given. If we saw regressions, it would be related to creation of static routes handed down by DHCPv4 servers.
[Original Description]
After upgrading 20.04 systems to 22.04, the classless routes served via DHCP are not being registered correctly - they are missing the gateway address.
Expected routes - these are taken from a 20.04 system on the same network:
$ ip route
default via 10.10.1.1 dev enp24s0 proto dhcp src 10.10.64.12 metric 100
10.0.0.0/8 dev enp24s0 proto kernel scope link src 10.10.64.12
10.88.88.0/24 via 10.10.1.2 dev enp24s0 proto dhcp src 10.10.64.12 metric 100
10.96.0.0/11 via 10.10.1.2 dev enp24s0 proto dhcp src 10.10.64.12 metric 100
Actual routes - these are the routes created in one of the affected 22.04 systems:
$ ip route
default via 10.10.1.1 dev bond0 proto dhcp src 10.10.48.20 metric 100
8.8.8.8 via 10.10.1.1 dev bond0 proto dhcp src 10.10.48.20 metric 100
10.0.0.0/8 dev bond0 proto kernel scope link src 10.10.48.20 metric 100
10.10.1.1 dev bond0 proto dhcp scope link src 10.10.48.20 metric 100
10.10.1.2 dev bond0 proto dhcp scope link src 10.10.48.20 metric 100
10.88.88.0/24 dev bond0 proto dhcp scope link src 10.10.48.20 metric 100
10.96.0.0/11 dev bond0 proto dhcp scope link src 10.10.48.20 metric 100
Note the routes for 10.88.88.0/24 and 10.96.0.0/11 are missing the "via" gateway address, and therefore don't work.
(For some reason there are also static routes created for DNS server (8.8.8.8) and known gateways (10.10.1.1 and 10.10.1.2). These are redundant but harmless.)
Both the working and non-working systems are being managed by netplan. The non-working system has a bonded interface but I have checked that is not the cause of the problem - using a physical interface directly has the same result.
I have attached the files /etc/netplan/
Affected system:
Ubuntu version: Ubuntu 22.04.2 LTS
systemd version: 249.11-0ubuntu3.6
Older system not affected:
Ubuntu version: Ubuntu 20.04.5 LTS
systemd version: 245.4-4ubuntu3.19
Related branches
- Lukas Märdian: Approve
-
Diff: 434 lines (+299/-55)9 files modifieddebian/patches/lp2009743/network-dhcp4-do-not-ignore-the-gateway-even-if-the-desti.patch (+60/-0)
debian/patches/lp2009743/test-network-add-one-more-testcase-for-DHCPv4-classless-r.patch (+36/-0)
debian/patches/lp2013543-core-reorder-systemd-arguments-on-reexec.patch (+58/-0)
debian/patches/lp2028180-udev-rules-fix-nvme-symlink-creation-on-namespace-changes.patch (+59/-0)
debian/patches/lp2031683-sd-bus-bus_message_type_from_string-is-not-pure.patch (+62/-0)
debian/patches/series (+5/-1)
debian/systemd.postinst (+18/-15)
debian/tests/tests-in-lxd (+1/-1)
dev/null (+0/-38)
- Lukas Märdian: Approve
-
Diff: 796 lines (+623/-45)16 files modifieddebian/patches/lp1977630-fix_machinectl_pull_tar.patch (+81/-0)
debian/patches/lp1978079-efi-pstore-not-cleared-on-boot.patch (+5/-4)
debian/patches/lp1991829-add-CAP_LINUX_IMMUTABLE-to-systemd-machined-so-it-ca.patch (+29/-0)
debian/patches/lp1999275/binfmt-check-if-binfmt-is-mounted-before-applying-rules.patch (+80/-0)
debian/patches/lp1999275/binfmt-util-also-check-if-binfmt-is-mounted-in-read-write.patch (+41/-0)
debian/patches/lp1999275/binfmt-util-split-out-binfmt_mounted.patch (+69/-0)
debian/patches/lp1999275/unit-check-more-specific-path-to-be-written-by-systemd-bi.patch (+26/-0)
debian/patches/lp2009743/network-dhcp4-do-not-ignore-the-gateway-even-if-the-desti.patch (+59/-0)
debian/patches/lp2009743/test-network-add-one-more-testcase-for-DHCPv4-classless-r.patch (+33/-0)
debian/patches/lp2013543-core-reorder-systemd-arguments-on-reexec.patch (+58/-0)
debian/patches/lp2025563-shutdown-get-only-active-md-arrays.patch (+67/-0)
debian/patches/lp2028180-udev-rules-fix-nvme-symlink-creation-on-namespace-changes.patch (+47/-0)
debian/patches/series (+11/-1)
debian/systemd.postinst (+16/-1)
debian/tests/tests-in-lxd (+1/-1)
dev/null (+0/-38)
- Lukas Märdian: Approve
-
Diff: 356 lines (+271/-1)11 files modifieddebian/changelog (+30/-0)
debian/libsystemd-dev.install (+1/-0)
debian/patches/lp2009743/network-dhcp4-do-not-ignore-the-gateway-even-if-the-desti.patch (+57/-0)
debian/patches/lp2009743/test-network-add-one-more-testcase-for-DHCPv4-classless-r.patch (+33/-0)
debian/patches/lp2013543-core-reorder-systemd-arguments-on-reexec.patch (+57/-0)
debian/patches/meson.build-disable-Wformat-overflow-on-gcc-with-O3.patch (+26/-0)
debian/patches/series (+4/-0)
debian/rules (+1/-0)
debian/systemd.postinst (+17/-1)
debian/tests/build-with-static-libsystemd (+38/-0)
debian/tests/control (+7/-0)
Changed in systemd (Ubuntu): | |
status: | Incomplete → New |
Changed in systemd: | |
status: | Unknown → New |
Changed in systemd (Ubuntu): | |
status: | New → Triaged |
Changed in systemd: | |
status: | New → Fix Released |
tags: | added: systemd-sru-next |
Changed in systemd (Ubuntu Jammy): | |
status: | New → Triaged |
Changed in systemd (Ubuntu Lunar): | |
status: | New → Triaged |
Changed in systemd (Ubuntu Jammy): | |
importance: | Undecided → Low |
Changed in systemd (Ubuntu Lunar): | |
importance: | Undecided → Low |
description: | updated |
Changed in systemd (Ubuntu): | |
status: | Triaged → Fix Committed |
Changed in systemd (Ubuntu Lunar): | |
status: | Triaged → In Progress |
Changed in systemd (Ubuntu Jammy): | |
status: | Triaged → In Progress |
Status changed to 'Confirmed' because the bug affects multiple users.