]> git.ipfire.org Git - thirdparty/systemd.git/commit
dhcp: handle multiple addresses for "Router" (option 3) in DHCP library
authorThomas Haller <thaller@redhat.com>
Fri, 14 Dec 2018 10:10:57 +0000 (11:10 +0100)
committerThomas Haller <thaller@redhat.com>
Mon, 18 Feb 2019 12:34:22 +0000 (13:34 +0100)
commitf8862395e8f802e4106a07ceaaf02b6a1faa5a6d
tree74cf06148c05d2a59c7571c726fcbc41a3e8cfeb
parentc24b68216222156a45c5a8a918e7a44c144e9555
dhcp: handle multiple addresses for "Router" (option 3) in DHCP library

The Router DHCP option may contain a list of one or more
routers ([1]). Extend the API of sd_dhcp_lease to return a
list instead of only the first.

Note that networkd still only uses the first router (if present).
Aside from extending the internal API of the DHCP client, there
is almost no change in behavior. The only visible difference in
behavior is that the "ROUTER" variable in the lease file is now a
list of addresses.

Note how RFC 2132 does not define certain IP addresses as invalid for the
router option. Still, previously sd_dhcp_lease_get_router() would never
return a "0.0.0.0" address. In fact, the previous API could not
differenciate whether no router option was present, whether it
was invalid, or whether its first router was "0.0.0.0". No longer let
the DHCP client library impose additional restrictions that are not
part of RFC. Instead, the caller should handle this. The patch does
that, and networkd only consideres the first router entry if it is not
"0.0.0.0".

[1] https://tools.ietf.org/html/rfc2132#section-3.5
src/libsystemd-network/dhcp-lease-internal.h
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/test-dhcp-client.c
src/network/networkd-dhcp4.c
src/systemd/sd-dhcp-lease.h