From: Roy Marples Date: Thu, 21 Apr 2016 19:27:31 +0000 (+0000) Subject: RFC3315 Section 12.1 is a little vague about adding bits to the prefix. X-Git-Tag: v6.11.0~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=663d44bf12e0f7178fc7a54837690275e7b24bd3;p=thirdparty%2Fdhcpcd.git RFC3315 Section 12.1 is a little vague about adding bits to the prefix. The correct interpretation is that we must add bits to the prefix length, thus having a sla_id of 0 is valid because the prefix_length is always extended. --- diff --git a/dhcp6.c b/dhcp6.c index 6bdf6168..f93071f6 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -409,10 +409,7 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp, sla = &asla; } else if (sla->prefix_len == 0) { asla.sla = sla->sla; - if (asla.sla == 0) - asla.prefix_len = prefix->prefix_len; - else - asla.prefix_len = 0; + asla.prefix_len = 0; sla = &asla; } if (sla->prefix_len == 0) { @@ -455,9 +452,7 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp, prefix->prefix_len); } - if (sla->sla == 0) { - *addr = prefix->prefix; - } else if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len, + if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len, sla->sla, addr, sla->prefix_len) == -1) { sa = inet_ntop(AF_INET6, &prefix->prefix, diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index 1a3c676d..d6d2198c 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 16, 2016 +.Dd April 21, 2016 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -336,13 +336,11 @@ In this case is increased to the highest multiple of 8 that can accommodate the .Ar sla_id . .Ar sla_id -is an integer and is added to the prefix which must fit inside +is an integer which must be unique inside the +.Ar iaid +and is added to the prefix which must fit inside .Ar prefix_len less the length of the delegated prefix. -.Ar sla_id -can be 0 only if the Delegated Prefix is assigned to one interface. -This violates RFC3633 12.1 and should only be used if the Delegated Prefix -length is 64 and you need to delegate it to a downstream interface. You can specify multiple .Ar interface / .Ar sla_id / @@ -373,8 +371,6 @@ interface eth0 ia_na 1 # request an IPv6 address ia_pd 2 eth1/0 # request a PD and assign it to eth1 ia_pd 3 eth2/1 eth3/2 # req a PD and assign it to eth2 and eth3 - # we cannot use SLA 0 above because we are - # assinging the PD to more than one interface .Ed .It Ic ipv4only Only configure IPv4. diff --git a/if-options.c b/if-options.c index 037ba3e5..75d381d8 100644 --- a/if-options.c +++ b/if-options.c @@ -1444,13 +1444,6 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, ifname); goto err_sla; } - if (sla->sla == 0) { - logger(ctx, LOG_WARNING, - "%s: sla of 0 is not " - "RFC3633 (section 12.1) " - "compliant", - ifname); - } } p = np; } @@ -1507,13 +1500,13 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, sla->ifname); goto err_sla; } - if (slap->sla_set && - (slap->sla == 0 || sla->sla == 0)) + if (slap->sla_set && sla->sla_set && + slap->sla == sla->sla) { logger(ctx, LOG_ERR, "%s: cannot" - " assign multiple prefixes" - " with a SLA of 0", - ifname); + " assign the same SLA %u" + " more than once", + sla->ifname, sla->sla); goto err_sla; } } diff --git a/ipv6.c b/ipv6.c index 1c16e08a..3bd52068 100644 --- a/ipv6.c +++ b/ipv6.c @@ -510,8 +510,7 @@ ipv6_userprefix( uint64_t vh, vl, user_low, user_high; if (prefix_len < 1 || prefix_len > 128 || - result_len < 1 || result_len > 128 || - user_number == 0) + result_len < 1 || result_len > 128) { errno = EINVAL; return -1; @@ -525,6 +524,12 @@ ipv6_userprefix( return -1; } + /* If user_number is zero, just copy the prefix into the result. */ + if (user_number == 0) { + *result = *prefix; + return 0; + } + /* Shift user_number so it fit's just inside result_len. * Shifting by 0 or sizeof(user_number) is undefined, * so we cater for that. */