]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp6-client: handle IAID with value zero
authorThomas Haller <thaller@redhat.com>
Fri, 23 Nov 2018 12:42:13 +0000 (13:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 16:09:29 +0000 (17:09 +0100)
config_parse_iaid(), dhcp_identifier_set_iaid() and sd_dhcp6_client_set_iaid() all
allow for the IAID to be zero. Also, RFC 3315 makes no mention that zero
would be invalid.

However, client_ensure_iaid() would take an IAID of zero as a sign that
the values was unset. Fix that by keeping track whether IAID is
initialized.

src/libsystemd-network/sd-dhcp6-client.c

index c81c0f095585ee5076a4bc5ce4374b55d2653dea..555ae5f5ec0cb0b34bdee2d4c2262523cc72f091 100644 (file)
@@ -56,6 +56,7 @@ struct sd_dhcp6_client {
         struct sd_dhcp6_lease *lease;
         int fd;
         bool information_request;
+        bool has_iaid;
         be16_t *req_opts;
         size_t req_opts_allocated;
         size_t req_opts_len;
@@ -267,6 +268,7 @@ int sd_dhcp6_client_set_iaid(sd_dhcp6_client *client, uint32_t iaid) {
 
         client->ia_na.ia_na.id = htobe32(iaid);
         client->ia_pd.ia_pd.id = htobe32(iaid);
+        client->has_iaid = true;
 
         return 0;
 }
@@ -790,7 +792,7 @@ static int client_ensure_iaid(sd_dhcp6_client *client) {
 
         assert(client);
 
-        if (client->ia_na.ia_na.id)
+        if (client->has_iaid)
                 return 0;
 
         r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, true, &iaid);
@@ -799,6 +801,7 @@ static int client_ensure_iaid(sd_dhcp6_client *client) {
 
         client->ia_na.ia_na.id = iaid;
         client->ia_pd.ia_pd.id = iaid;
+        client->has_iaid = true;
 
         return 0;
 }