From: Paul Donald Date: Fri, 10 Oct 2025 11:45:48 +0000 (+0200) Subject: config: cap ra_reachabletime to RFC maximum instead of logging error X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=208eb10307c101346065c2127092f0b222d763d0;p=project%2Fodhcpd.git config: cap ra_reachabletime to RFC maximum instead of logging error Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcpd/pull/225 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/config.c b/src/config.c index 7f11281..0441b12 100644 --- a/src/config.c +++ b/src/config.c @@ -1359,11 +1359,13 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_REACHABLETIME])) { uint32_t ra_reachabletime = blobmsg_get_u32(c); - if (ra_reachabletime <= 3600000) - iface->ra_reachabletime = ra_reachabletime; - else - syslog(LOG_ERR, "Invalid %s value configured for interface '%s'", - iface_attrs[IFACE_ATTR_RA_REACHABLETIME].name, iface->name); + /* RFC4861 §6.2.1 : AdvReachableTime : + * MUST be no greater than 3,600,000 msec + */ + iface->ra_reachabletime = ra_reachabletime <= AdvReachableTime ? ra_reachabletime : AdvReachableTime; + if(ra_reachabletime > AdvReachableTime) + syslog(LOG_WARNING, "Clamped invalid %s value configured for interface '%s' to %d", + iface_attrs[IFACE_ATTR_RA_REACHABLETIME].name, iface->name, iface->ra_reachabletime); } if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) { diff --git a/src/router.h b/src/router.h index 6609f43..2cd5469 100644 --- a/src/router.h +++ b/src/router.h @@ -66,6 +66,10 @@ struct icmpv6_opt { define is used to cap values to a sane ceiling, i.e. ND_VALID_LIMIT. */ #define RouterLifetime 5400 +/* RFC4861 §6.2.1 : AdvReachableTime : + * MUST be no greater than 3,600,000 msec + */ +#define AdvReachableTime 3600000 #define ND_RA_FLAG_PROXY 0x4 #define ND_RA_PREF_HIGH (1 << 3)