changeset 3524:ea1ace34f274 draft

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.
author Roy Marples <roy@marples.name>
date Thu, 21 Apr 2016 19:27:31 +0000
parents f574f4ded79b
children 79557d9831e5
files dhcp6.c dhcpcd.conf.5.in if-options.c ipv6.c
diffstat 4 files changed, 18 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp6.c	Wed Apr 20 08:37:23 2016 +0000
+++ b/dhcp6.c	Thu Apr 21 19:27:31 2016 +0000
@@ -409,10 +409,7 @@
 		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 @@
 			    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,
--- a/dhcpcd.conf.5.in	Wed Apr 20 08:37:23 2016 +0000
+++ b/dhcpcd.conf.5.in	Thu Apr 21 19:27:31 2016 +0000
@@ -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 @@
 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 @@
   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.
--- a/if-options.c	Wed Apr 20 08:37:23 2016 +0000
+++ b/if-options.c	Thu Apr 21 19:27:31 2016 +0000
@@ -1444,13 +1444,6 @@
 						    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 @@
 					    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;
 				}
 			}
--- a/ipv6.c	Wed Apr 20 08:37:23 2016 +0000
+++ b/ipv6.c	Thu Apr 21 19:27:31 2016 +0000
@@ -510,8 +510,7 @@
 	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 @@
 	       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. */