config: cap ra_retranstime and warn instead of only logging an error
authorPaul Donald <[email protected]>
Fri, 10 Oct 2025 11:43:23 +0000 (13:43 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 13 Oct 2025 07:53:36 +0000 (09:53 +0200)
Set to the currently defined maximum of 60,000msec via a define.

Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/225
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/config.c
src/router.h

index 8cc43db9e68bfdc6aae3d7bb5f935c63ac98053c..05daf5deb5b441eed130a2ffb241ba74de4ea3f4 100644 (file)
@@ -1371,11 +1371,10 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) {
                uint32_t ra_retranstime = blobmsg_get_u32(c);
 
-               if (ra_retranstime <= 60000)
-                       iface->ra_retranstime = ra_retranstime;
-               else
-                       syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
-                                       iface_attrs[IFACE_ATTR_RA_RETRANSTIME].name, iface->name);
+               iface->ra_retranstime = ra_retranstime <= RETRANS_TIMER_MAX ? ra_retranstime : RETRANS_TIMER_MAX;
+               if (ra_retranstime > RETRANS_TIMER_MAX)
+                       syslog(LOG_WARNING, "Clamped invalid %s value configured for interface '%s' to %d",
+                                       iface_attrs[IFACE_ATTR_RA_RETRANSTIME].name, iface->name, iface->ra_retranstime);
        }
 
        if ((c = tb[IFACE_ATTR_RA_HOPLIMIT])) {
index 6358493782489262c60ddfcf699a2368a03934a4..6d826665a2ef514681120ff4704c19071a53e67a 100644 (file)
@@ -78,6 +78,11 @@ struct icmpv6_opt {
        Note: this value is an 8 bit int, so max 255.
 */
 #define AdvCurHopLimit                                 255
+/* RFC4861 §10 - constants
+       Node constants:
+               RETRANS_TIMER                 1,000 milliseconds
+*/
+#define RETRANS_TIMER_MAX                              60000
 
 #define ND_RA_FLAG_PROXY               0x4
 #define ND_RA_PREF_HIGH                        (1 << 3)