]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
RFC3315 Section 12.1 is a little vague about adding bits to the prefix.
authorRoy Marples <roy@marples.name>
Thu, 21 Apr 2016 19:27:31 +0000 (19:27 +0000)
committerRoy Marples <roy@marples.name>
Thu, 21 Apr 2016 19:27:31 +0000 (19:27 +0000)
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.

dhcp6.c
dhcpcd.conf.5.in
if-options.c
ipv6.c

diff --git a/dhcp6.c b/dhcp6.c
index 6bdf616857f3468077d4ca19444978359f7fbd24..f93071f6b51f7d60398de00e7ef34151478e8444 100644 (file)
--- 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,
index 1a3c676db6b2dcaa1c35627d55ede01db43e4534..d6d2198c5f104518b53b723222026ba02f909c04 100644 (file)
@@ -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.
index 037ba3e505eecec67ffd5d6889a1852dee6054a1..75d381d8f21955c903e7df954eb528b5c22a4c98 100644 (file)
@@ -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 1c16e08a9ab9b89a998a3e3a55dd8377b92f080a..3bd52068ede3d60eddcd324475d2e5a8a7a84980 100644 (file)
--- 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. */