]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCPv6: Allow nooptions dhcp6_unicast to work.
authorRoy Marples <roy@marples.name>
Tue, 26 Mar 2019 00:40:57 +0000 (00:40 +0000)
committerRoy Marples <roy@marples.name>
Tue, 26 Mar 2019 00:40:57 +0000 (00:40 +0000)
This allows dhcpcd to ignore any server set unicast option which
doesn't work.

src/dhcp6.c

index 6e83a70fdf2f6826053eb85a1af4a7568c3dfcc6..cc226787093cbfc627658c0c992c138a2ef34e55 100644 (file)
@@ -797,8 +797,7 @@ dhcp6_makemessage(struct interface *ifp)
                m = state->new;
                ml = state->new_len;
        }
-       unicast = NULL;
-       /* Depending on state, get the unicast address */
+
        switch(state->state) {
        case DH6S_INIT: /* FALLTHROUGH */
        case DH6S_DISCOVER:
@@ -806,7 +805,6 @@ dhcp6_makemessage(struct interface *ifp)
                break;
        case DH6S_REQUEST:
                type = DHCP6_REQUEST;
-               unicast = dhcp6_findmoption(m, ml, D6_OPTION_UNICAST, &uni_len);
                break;
        case DH6S_CONFIRM:
                type = DHCP6_CONFIRM;
@@ -816,20 +814,33 @@ dhcp6_makemessage(struct interface *ifp)
                break;
        case DH6S_RENEW:
                type = DHCP6_RENEW;
-               unicast = dhcp6_findmoption(m, ml, D6_OPTION_UNICAST, &uni_len);
                break;
        case DH6S_INFORM:
                type = DHCP6_INFORMATION_REQ;
                break;
        case DH6S_RELEASE:
                type = DHCP6_RELEASE;
-               unicast = dhcp6_findmoption(m, ml, D6_OPTION_UNICAST, &uni_len);
                break;
        default:
                errno = EINVAL;
                return -1;
        }
 
+       switch(state->state) {
+       case DH6S_REQUEST: /* FALLTHROUGH */
+       case DH6S_RENEW:   /* FALLTHROUGH */
+       case DH6S_RELEASE:
+               if (has_option_mask(ifo->nomask6, D6_OPTION_UNICAST)) {
+                       unicast = NULL;
+                       break;
+               }
+               unicast = dhcp6_findmoption(m, ml, D6_OPTION_UNICAST, &uni_len);
+               break;
+       default:
+               unicast = NULL;
+               break;
+       }
+
        /* In non master mode we listen and send from fixed addresses.
         * We should try and match an address we have to unicast to,
         * but for now this is the safest policy. */