From a9e9bc4c67ac9fa8aecf5f20954a58093705831b Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Fri, 12 May 2017 10:53:25 +0200 Subject: [PATCH] config: make RA retransTime configurable via uci Allow to specify the router advertisement retrans time via the uci parameter ra_retranstime. If retransmit time is not configured the value is set to 0 in RA message meaning undefined. --- README | 2 ++ src/config.c | 5 +++++ src/odhcpd.h | 1 + src/router.c | 1 + 4 files changed, 9 insertions(+) diff --git a/README b/README index 1bcc087..fbcd993 100644 --- a/README +++ b/README @@ -118,6 +118,8 @@ ra_useleasetime bool 0 Use configured leasetime as valid lifetime of a prefix ra_reachabletime integer 0 Reachable Time in milliseconds to be advertised in RA messages +ra_retranstime integer 0 Retransmit 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 diff --git a/src/config.c b/src/config.c index 211ac1f..9348985 100644 --- a/src/config.c +++ b/src/config.c @@ -51,6 +51,7 @@ enum { IFACE_ATTR_RA_LIFETIME, IFACE_ATTR_RA_USELEASETIME, IFACE_ATTR_RA_REACHABLETIME, + IFACE_ATTR_RA_RETRANSTIME, IFACE_ATTR_RA_HOPLIMIT, IFACE_ATTR_RA_MTU, IFACE_ATTR_PD_MANAGER, @@ -92,6 +93,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [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_RETRANSTIME] = { .name = "ra_retranstime", .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 }, @@ -606,6 +608,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr goto err; } + if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) + iface->ra_retranstime = blobmsg_get_u32(c); + 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 a50fd76..bb4702e 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -163,6 +163,7 @@ struct interface { int ra_mininterval; int ra_lifetime; uint32_t ra_reachabletime; + uint32_t ra_retranstime; uint32_t ra_hoplimit; uint32_t ra_mtu; diff --git a/src/router.c b/src/router.c index 7600e2f..8a2f816 100644 --- a/src/router.c +++ b/src/router.c @@ -297,6 +297,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add adv.h.nd_ra_flags_reserved |= ND_RA_PREF_HIGH; adv.h.nd_ra_reachable = htonl(iface->ra_reachabletime); + adv.h.nd_ra_retransmit = htonl(iface->ra_retranstime); odhcpd_get_mac(iface, adv.lladdr.data); -- 2.11.0