dhcpv6: assign all viable DHCPv6 addresses by default (FS#402, FS#524)
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 2 Aug 2017 20:32:08 +0000 (22:32 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 1 Oct 2017 16:07:46 +0000 (18:07 +0200)
Some client implementations expect DHCPv6 addresses to be assigned for
every prefix present in a RA as reported in FS#524; if not done the
client implementations spam the DHCPv6 server with SOLICIT messages
trying to get an DHCPv6 address for every prefix.
When ra_managed is set to 1 and an ULA prefix is configured; the DHCPv6
server will only assign an ULA DHCPv6 addresses which possibly leads to
DNS issues.

Fix these problems by providing dhcpv6_assignall config option which
assigns all viable DHCPv6 addresses to a client by default.
This is a trade off as it means client implementations will be assigned
more IPv6 addresses and lose the ability to quickly renumber clients
which don't support reconfigure accept in case of wan prefix change

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
README
src/config.c
src/dhcpv6-ia.c
src/odhcpd.h

diff --git a/README b/README
index ebb2d994ffc598b7f3527c06f655b4a4119c40b9..93c7f54178354b086e2f64bd2da9b55704ac3e14 100644 (file)
--- a/README
+++ b/README
@@ -67,55 +67,59 @@ loglevel    integer 6                       Syslog level priority (0-7)
 
 Sections of type dhcp (configure DHCP / DHCPv6 / RA / NDP service)
 
-Option         Type    Default                 Description
-interface      string  <name of UCI section>   logical OpenWrt interface
-ifname         string  <resolved from logical> physical network interface
-networkid      string  same as ifname          compat. alias for ifname
-ignore         bool    0                       do not serve this interface
-                                               unless overridden by ra, ndp,
-                                               dhcpv4 or dhcpv6 options
-master         bool    0                       is a master interface
-                                               for relaying
-
-ra             string  disabled                Router Advert service
-               [disabled|server|relay|hybrid]
-dhcpv6         string  disabled                DHCPv6 service
-               [disabled|server|relay|hybrid]
-dhcpv4         string  disabled                DHCPv4 service
-               [disabled|server]
-ndp            string  disabled                Neighbor Discovery Proxy
-               [disabled|relay|hybrid]
-
-dynamicdhcp    bool    1                       dynamically create leases
-                                               for DHCPv4 and DHCPv6
-router          list    <local address>         Routers to announce
-                                                accepts IPv4 only
-dns            list    <local address>         DNS servers to announce
-                                               accepts IPv4 and IPv6
-domain         list    <local search domain>   Search domains to announce
-
-leasetime      string  12h                     DHCPv4 address leasetime
-start          integer 100                     DHCPv4 pool start
-limit          integer 150                     DHCPv4 pool size
-
-ra_default     integer 0                       Override default route
-               0: default, 1: ignore no public address, 2: ignore all
-ra_management  integer 1                       RA management mode
-               0: no M-Flag but A-Flag, 1: both M and A, 2: M but not A
-ra_offlink     bool    0                       Announce prefixes off-link
-ra_preference  string  medium                  Route(r) preference
-               [medium|high|low]
-ra_maxinterval integer 600                     Maximum time allowed between
-                                               sending unsolicited RA
-ra_mininterval integer 200                     Minimum time allowed between
-                                               sending unsolicited RA
-ra_lifetime    integer 1800                    Value to be placed in Router
-                                               Lifetime field of RA
-ra_useleasetime        bool    0                       Use configured leasetime as
-                                               limit for the preferred and
-                                               valid lifetime of a prefix
-ndproxy_routing        bool    1                       Learn routes from NDP
-ndproxy_slave  bool    0                       NDProxy external slave
+Option                 Type    Default                 Description
+interface              string  <name of UCI section>   logical OpenWrt interface
+ifname                 string  <resolved from logical> physical network interface
+networkid              string  same as ifname          compat. alias for ifname
+ignore                 bool    0                       do not serve this interface
+                                                       unless overridden by ra, ndp,
+                                                       dhcpv4 or dhcpv6 options
+master                 bool    0                       is a master interface
+                                                       for relaying
+
+ra                     string  disabled                Router Advert service
+                       [disabled|server|relay|hybrid]
+dhcpv6                 string  disabled                DHCPv6 service
+                       [disabled|server|relay|hybrid]
+dhcpv4                 string  disabled                DHCPv4 service
+                       [disabled|server]
+ndp                    string  disabled                Neighbor Discovery Proxy
+                       [disabled|relay|hybrid]
+
+dynamicdhcp            bool    1                       Dynamically create leases
+                                                       for DHCPv4 and DHCPv6
+dhcpv6_assignall       bool    1                       Assign all viable DHCPv6 addresses
+                                                       in statefull mode; if disabled
+                                                       only the DHCPv6 address having the
+                                                       longest preferred lifetime is assigned
+router                 list    <local address>         Routers to announce
+                                                       accepts IPv4 only
+dns                    list    <local address>         DNS servers to announce
+                                                       accepts IPv4 and IPv6
+domain                 list    <local search domain>   Search domains to announce
+
+leasetime              string  12h                     DHCPv4 address leasetime
+start                  integer 100                     DHCPv4 pool start
+limit                  integer 150                     DHCPv4 pool size
+
+ra_default             integer 0                       Override default route
+                       0: default, 1: ignore no public address, 2: ignore all
+ra_management          integer 1                       RA management mode
+                       0: no M-Flag but A-Flag, 1: both M and A, 2: M but not A
+ra_offlink             bool    0                       Announce prefixes off-link
+ra_preference          string  medium                  Route(r) preference
+                       [medium|high|low]
+ra_maxinterval         integer 600                     Maximum time allowed between
+                                                       sending unsolicited RA
+ra_mininterval         integer 200                     Minimum time allowed between
+                                                       sending unsolicited RA
+ra_lifetime            integer 1800                    Value to be placed in Router
+                                                       Lifetime field of RA
+ra_useleasetime                bool    0                       Use configured leasetime as
+                                                       limit for the preferred and
+                                                       valid lifetime of a prefix
+ndproxy_routing                bool    1                       Learn routes from NDP
+ndproxy_slave          bool    0                       NDProxy external slave
 
 
 Sections of type host (static leases)
index 943f2430326cb40e251f1dc67e7b0caca2dc333a..e89ac0e275b6faf209a0f1083b93e8ec9eeb2af4 100644 (file)
@@ -40,6 +40,7 @@ enum {
        IFACE_ATTR_DOMAIN,
        IFACE_ATTR_FILTER_CLASS,
        IFACE_ATTR_DHCPV6_RAW,
+       IFACE_ATTR_DHCPV6_ASSIGNALL,
        IFACE_ATTR_RA_DEFAULT,
        IFACE_ATTR_RA_MANAGEMENT,
        IFACE_ATTR_RA_OFFLINK,
@@ -76,6 +77,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
        [IFACE_ATTR_DOMAIN] = { .name = "domain", .type = BLOBMSG_TYPE_ARRAY },
        [IFACE_ATTR_FILTER_CLASS] = { .name = "filter_class", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_DHCPV6_RAW] = { .name = "dhcpv6_raw", .type = BLOBMSG_TYPE_STRING },
+       [IFACE_ATTR_DHCPV6_ASSIGNALL] = { .name ="dhcpv6_assignall", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_PD_MANAGER] = { .name = "pd_manager", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_PD_CER] = { .name = "pd_cer", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_RA_DEFAULT] = { .name = "ra_default", .type = BLOBMSG_TYPE_INT32 },
@@ -195,6 +197,7 @@ static void set_interface_defaults(struct interface *iface)
        iface->managed = 1;
        iface->learn_routes = 1;
        iface->dhcpv4_leasetime = 43200;
+       iface->dhcpv6_assignall = true;
        iface->ra_maxinterval = 600;
        iface->ra_mininterval = iface->ra_maxinterval/3;
        iface->ra_lifetime = -1;
@@ -580,6 +583,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                odhcpd_unhexlify(iface->dhcpv6_raw, iface->dhcpv6_raw_len, blobmsg_get_string(c));
        }
 
+       if ((c = tb[IFACE_ATTR_DHCPV6_ASSIGNALL]))
+               iface->dhcpv6_assignall = blobmsg_get_bool(c);
+
        if ((c = tb[IFACE_ATTR_RA_DEFAULT]))
                iface->default_router = blobmsg_get_u32(c);
 
index 3275da5f74959d28d79a2ccfdd75d9a827c7ae61..8236457b1d589525462b9a4cbda04d77f6777088 100644 (file)
@@ -35,7 +35,7 @@
 #include <sys/timerfd.h>
 
 #define ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs) \
-    ((iface)->managed == RELAYD_MANAGED_NO_AFLAG || (i) == (m) || \
+    ((iface)->dhcpv6_assignall || (i) == (m) || \
      (addrs)[(i)].prefix > 64)
 
 static void free_dhcpv6_assignment(struct dhcpv6_assignment *c);
index 4ddadbee635ae1c7d21c6dfed424b5f5690f05a7..f1a11199f4c04c8ff20daa912f15eae44894f633 100644 (file)
@@ -177,8 +177,10 @@ struct interface {
        uint8_t *search;
        size_t search_len;
 
+       // DHCPV6
        void *dhcpv6_raw;
        size_t dhcpv6_raw_len;
+       bool dhcpv6_assignall;
 
        char *upstream;
        size_t upstream_len;