]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/dhcpv6.c
Fix handling of DHCPv6 replies containing unrequested IA_NA/IA_PD options
[odhcp6c.git] / src / dhcpv6.c
index 597d239b5daa3451d4d00b3ce57407b779a21afd..6ae6f7a02fd8d9040fc8b676cd81a73d361d21c6 100644 (file)
@@ -885,7 +885,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
 {
        uint8_t *odata;
        uint16_t otype, olen;
-       uint32_t refresh = UINT32_MAX;
+       uint32_t refresh = 86400;
        int ret = 1;
        bool handled_status_codes[_DHCPV6_Status_Max] = { false, };
 
@@ -947,6 +947,10 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
                                && olen > -4 + sizeof(struct dhcpv6_ia_hdr)) {
                        struct dhcpv6_ia_hdr *ia_hdr = (void*)(&odata[-4]);
 
+                       if ((na_mode == IA_MODE_NONE && otype == DHCPV6_OPT_IA_NA) ||
+                           (pd_mode == IA_MODE_NONE && otype == DHCPV6_OPT_IA_PD))
+                               continue;
+
                        // Test ID
                        if (ia_hdr->iaid != htonl(1) && otype == DHCPV6_OPT_IA_NA)
                                continue;
@@ -1213,7 +1217,7 @@ static int dhcpv6_parse_ia(void *opt, void *end)
                        }
 
                        if (ok) {
-                               odhcp6c_update_entry(STATE_IA_PD, &entry);
+                               odhcp6c_update_entry(STATE_IA_PD, &entry, 0, false);
                                parsed_ia++;
                        }
 
@@ -1248,7 +1252,7 @@ static int dhcpv6_parse_ia(void *opt, void *end)
                                        entry.class = sdata[0] << 8 | sdata[1];
 #endif
 
-                       odhcp6c_update_entry(STATE_IA_NA, &entry);
+                       odhcp6c_update_entry(STATE_IA_NA, &entry, 0, false);
                        parsed_ia++;
                }
        }