networkd-dhcp4 does not set prefsrc for dhcp-provided classless or static routes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd |
Fix Released
|
Unknown
|
|||
systemd (Ubuntu) |
Fix Released
|
Medium
|
Dan Streetman | ||
Bionic |
Fix Released
|
Medium
|
Dan Streetman | ||
Cosmic |
Won't Fix
|
Medium
|
Dan Streetman | ||
Disco |
Fix Released
|
Medium
|
Dan Streetman | ||
Eoan |
Fix Released
|
Medium
|
Dan Streetman |
Bug Description
[impact]
the systemd networkd dhcp4 client sets the prefsrc for the default route added when a dhcp server provides only the gateway; but if the dhcp server provides classless route(s), those are configured instead, and the prefsrc is not set for those.
Normally this is ok, but if the dhcp client system has other address(es) configured on the interface using dhcp, then the src for packets sent through a classless/static route might not be the same as the address provided by the dhcp server.
If the gateway/router provided in the dhcp classless/static route(s) only allows traffic from the address provided to the dhcp client, then traffic from the dhcp client may be dropped by the gateway/router.
[test case]
set up a dhcp server system (e.g. ubuntu with dnsmasq installed and configured) and a dhcp client system. For example on the dhcp server, use this dnsmasq config:
interface=ens8
bind-interfaces
domain=
dhcp-option=
dhcp-range=
On the dhcp client system, use networkd config such as:
$ cat /etc/systemd/
[Match]
Name=ens8
[Network]
DHCP=ipv4
LinkLocalAddres
Address=
Reboot the client, or restart networkd, and it should result in:
$ ip -4 a show ens8
3: ens8: <BROADCAST,
inet 10.10.0.5/24 brd 10.10.0.255 scope global ens8
valid_lft forever preferred_lft forever
inet 10.10.0.75/24 brd 10.10.0.255 scope global secondary dynamic ens8
valid_lft 3580sec preferred_lft 3580sec
$ ip r
default via 10.10.0.1 dev ens8 proto dhcp src 10.10.0.75 metric 1024
10.10.0.0/24 dev ens8 proto kernel scope link src 10.10.0.5
10.10.0.1 dev ens8 proto dhcp scope link src 10.10.0.75 metric 1024
Note that, because networkd completes the static ip configuration before the dhcp reply is returned and processed, the static address is used for the subnet-local routing. But for global routing through the gateway, the dhcp-provided address is used:
$ ip r get 1.1.1.1
1.1.1.1 via 10.10.0.1 dev ens8 src 10.10.0.75 uid 1000
Now on the server, add a classless route:
dhcp-option=
and restart dnsmasq on the server. Then on the client, reboot. It should now have:
$ ip -4 a show ens8
3: ens8: <BROADCAST,
inet 10.10.0.5/24 brd 10.10.0.255 scope global ens8
valid_lft forever preferred_lft forever
inet 10.10.0.75/24 brd 10.10.0.255 scope global secondary dynamic ens8
valid_lft 3585sec preferred_lft 3585sec
$ ip r
default via 10.10.0.1 dev ens8 proto dhcp metric 1024
10.10.0.0/24 dev ens8 proto kernel scope link src 10.10.0.5
Now, the global route will use the static address, not the dhcp-provided address:
$ ip r get 1.1.1.1
1.1.1.1 via 10.10.0.1 dev ens8 src 10.10.0.5 uid 1000
If the router, 10.10.0.1, only will forward traffic sent from the dhcp address it provided, 10.10.0.75, then this configuration will result in the client being unable to reach anything through the router, because all its packets will have a source address of 10.10.0.5, which the router would drop/reject.
[regression potential]
this only affects dhcp routes provided by a dhcp server using the 'static' or 'classless' route dhcp options. Since this behavior is currently the default when a system doesn't add static address(es) to interfaces that also get dhcp addresses, this is likely not a change in behavior for the vast majority of systems. And any systems that do add static address(es) would usually be able to route through a gateway from either the dhcp-provided, or static, address. So the regression potential for this change should be low.
[other info]
Note that systemd in Eoan is being upgraded to upstream 242, so I am not adding this to Eoan now, as I don't want to disturb the merge. If needed after the merge, I'll add to Eoan.
Related branches
- Robert Ancell (community): Approve
- Shih-Yuan Lee (community): Needs Resubmitting
- Dimitri John Ledkov: Pending requested
-
Diff: 432 lines (+392/-0)6 files modifieddebian/changelog (+33/-0)
debian/patches/hwdb-revert-airplane-mode-keys-handling-on-Dell.patch (+33/-0)
debian/patches/lp1668771-resolved-switch-cache-option-to-a-tri-state-option-s.patch (+229/-0)
debian/patches/lp1833671-networkd-keep-bond-slave-up-if-already-attached.patch (+50/-0)
debian/patches/lp1835581-src-network-networkd-dhcp4.c-set-prefsrc-for-classle.patch (+43/-0)
debian/patches/series (+4/-0)
Changed in systemd (Ubuntu Disco): | |
assignee: | nobody → Dan Streetman (ddstreet) |
Changed in systemd (Ubuntu Bionic): | |
assignee: | nobody → Dan Streetman (ddstreet) |
Changed in systemd (Ubuntu Disco): | |
importance: | Undecided → Medium |
Changed in systemd (Ubuntu Cosmic): | |
importance: | Undecided → Medium |
Changed in systemd (Ubuntu Bionic): | |
importance: | Undecided → Medium |
Changed in systemd (Ubuntu Disco): | |
status: | New → In Progress |
Changed in systemd (Ubuntu Cosmic): | |
status: | New → In Progress |
Changed in systemd (Ubuntu Bionic): | |
status: | New → In Progress |
Changed in systemd (Ubuntu Cosmic): | |
assignee: | nobody → Dan Streetman (ddstreet) |
tags: | added: ddstreet-next systemd |
Changed in systemd: | |
status: | Unknown → Fix Released |
Changed in systemd (Ubuntu Cosmic): | |
status: | In Progress → Won't Fix |
tags: | added: sts sts-sponsor sts-sponsor-ddstreet |
description: | updated |
tags: | removed: ddstreet-next sts-sponsor-ddstreet |
Changed in systemd (Ubuntu Eoan): | |
status: | Fix Committed → In Progress |
Changed in systemd (Ubuntu Eoan): | |
status: | In Progress → Fix Committed |
Changed in systemd (Ubuntu Eoan): | |
status: | Fix Released → In Progress |
tags: | added: ddstreet eoan |
Changed in systemd (Ubuntu): | |
status: | In Progress → Fix Released |
upstream PR: https:/ /github. com/systemd/ systemd/ pull/12970