summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-dhcp-client.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-14 11:10:57 +0100
committerThomas Haller <thaller@redhat.com>2019-02-18 13:34:22 +0100
commitf8862395e8f802e4106a07ceaaf02b6a1faa5a6d (patch)
tree74cf06148c05d2a59c7571c726fcbc41a3e8cfeb /src/libsystemd-network/test-dhcp-client.c
parentc24b68216222156a45c5a8a918e7a44c144e9555 (diff)
downloadsystemd-f8862395e8f802e4106a07ceaaf02b6a1faa5a6d.tar.gz
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
Diffstat (limited to 'src/libsystemd-network/test-dhcp-client.c')
-rw-r--r--src/libsystemd-network/test-dhcp-client.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index fe6788d91b..0431e2c3f5 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -423,6 +423,7 @@ static void test_addr_acq_acquired(sd_dhcp_client *client, int event,
sd_event *e = userdata;
sd_dhcp_lease *lease;
struct in_addr addr;
+ const struct in_addr *addrs;
assert_se(client);
assert_se(event == SD_DHCP_CLIENT_EVENT_IP_ACQUIRE);
@@ -438,9 +439,9 @@ static void test_addr_acq_acquired(sd_dhcp_client *client, int event,
assert_se(memcmp(&addr.s_addr, &test_addr_acq_ack[285],
sizeof(addr.s_addr)) == 0);
- assert_se(sd_dhcp_lease_get_router(lease, &addr) >= 0);
- assert_se(memcmp(&addr.s_addr, &test_addr_acq_ack[308],
- sizeof(addr.s_addr)) == 0);
+ assert_se(sd_dhcp_lease_get_router(lease, &addrs) == 1);
+ assert_se(memcmp(&addrs[0].s_addr, &test_addr_acq_ack[308],
+ sizeof(addrs[0].s_addr)) == 0);
if (verbose)
printf(" DHCP address acquired\n");