From: Roy Marples Date: Tue, 26 Mar 2019 00:40:57 +0000 (+0000) Subject: DHCPv6: Allow nooptions dhcp6_unicast to work. X-Git-Tag: v7.2.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d77499f9ec2514aef052ee93ca95db6ac880ac2;p=thirdparty%2Fdhcpcd.git DHCPv6: Allow nooptions dhcp6_unicast to work. This allows dhcpcd to ignore any server set unicast option which doesn't work. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 6e83a70f..cc226787 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -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. */