config: make RA reachableTime configurable via uci
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 11 May 2017 16:44:17 +0000 (18:44 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 11 May 2017 16:55:25 +0000 (18:55 +0200)
Allow to specify the router advertisement reachable time via the uci
parameter ra_reachabletime. If reachable time is not configured the
value is set to 0 in RA message meaning undefined.

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

diff --git a/README b/README
index 1099297d39d66c6360d43b829873608475db9c62..1bcc08777f2bf12e49b62f834f342d559704f626 100644 (file)
--- a/README
+++ b/README
@@ -69,59 +69,61 @@ 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
-ra_hoplimit    integer 0                       Current hoplimit to be advertised
-                                               in RA messages
-ra_mtu         integer 0                       MTU to be advertised in
-                                               RA messages
-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
+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
+ra_reachabletime       integer 0                       Reachable Time in milliseconds to be
+                                                       advertised in RA messages
+ra_hoplimit            integer 0                       Current hoplimit to be advertised
+                                                       in RA messages
+ra_mtu                 integer 0                       MTU to be advertised in
+                                                       RA messages
+ndproxy_routing                bool    1                       Learn routes from NDP
+ndproxy_slave          bool    0                       NDProxy external slave
 
 
 Sections of type host (static leases)
index 1f6877ab68e9786a9e1df72ab66a99511f542f8e..211ac1fd7a9a9b49df2d4c751c84dfab6bdc3091 100644 (file)
@@ -50,6 +50,7 @@ enum {
        IFACE_ATTR_RA_MAXINTERVAL,
        IFACE_ATTR_RA_LIFETIME,
        IFACE_ATTR_RA_USELEASETIME,
+       IFACE_ATTR_RA_REACHABLETIME,
        IFACE_ATTR_RA_HOPLIMIT,
        IFACE_ATTR_RA_MTU,
        IFACE_ATTR_PD_MANAGER,
@@ -90,6 +91,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
        [IFACE_ATTR_RA_MAXINTERVAL] = { .name = "ra_maxinterval", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_RA_LIFETIME] = { .name = "ra_lifetime", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_RA_USELEASETIME] = { .name = "ra_useleasetime", .type = BLOBMSG_TYPE_BOOL },
+       [IFACE_ATTR_RA_REACHABLETIME] = { .name = "ra_reachabletime", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_RA_HOPLIMIT] = { .name = "ra_hoplimit", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_RA_MTU] = { .name = "ra_mtu", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_NDPROXY_ROUTING] = { .name = "ndproxy_routing", .type = BLOBMSG_TYPE_BOOL },
@@ -598,6 +600,12 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        if ((c = tb[IFACE_ATTR_RA_MANAGEMENT]))
                iface->managed = blobmsg_get_u32(c);
 
+       if ((c = tb[IFACE_ATTR_RA_REACHABLETIME])) {
+               iface->ra_reachabletime = blobmsg_get_u32(c);
+               if (iface->ra_reachabletime > 3600000)
+                       goto err;
+       }
+
        if ((c = tb[IFACE_ATTR_RA_HOPLIMIT])) {
                iface->ra_hoplimit = blobmsg_get_u32(c);
                if (iface->ra_hoplimit > 255)
index 28c81eb9f8f942f5568cff28136f71d9d0c97344..a50fd7664b2d8c1be77367bcb362801b8f4416f8 100644 (file)
@@ -162,6 +162,7 @@ struct interface {
        int ra_maxinterval;
        int ra_mininterval;
        int ra_lifetime;
+       uint32_t ra_reachabletime;
        uint32_t ra_hoplimit;
        uint32_t ra_mtu;
 
index faf9e9d03c6be3d8ce0c659e4a193b9127d43242..7600e2f0a7ae503bcba1e3509ef24796a976b712 100644 (file)
@@ -295,6 +295,9 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                adv.h.nd_ra_flags_reserved |= ND_RA_PREF_LOW;
        else if (iface->route_preference > 0)
                adv.h.nd_ra_flags_reserved |= ND_RA_PREF_HIGH;
+
+       adv.h.nd_ra_reachable = htonl(iface->ra_reachabletime);
+
        odhcpd_get_mac(iface, adv.lladdr.data);
 
        // If not currently shutting down