summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-05-11 18:44:17 +0200
committerHans Dedecker <dedeckeh@gmail.com>2017-05-11 18:55:25 +0200
commit2cb6b4872a1981f2acce40018107481c82a529dc (patch)
treedef05548fa37707289f43de4e8ca1f1240217d2a /src
parente4504db88c5b501142cc97a08876d924d673f605 (diff)
config: make RA reachableTime configurable via uci
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>
Diffstat (limited to 'src')
-rw-r--r--src/config.c8
-rw-r--r--src/odhcpd.h1
-rw-r--r--src/router.c3
3 files changed, 12 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 1f6877a..211ac1f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -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)
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 28c81eb..a50fd76 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -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;
diff --git a/src/router.c b/src/router.c
index faf9e9d..7600e2f 100644
--- a/src/router.c
+++ b/src/router.c
@@ -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