diff mbox series

[RFC,09/14] config: clamp ra_reachabletime to RFC maximum (instead of complaining)

Message ID 20240509223213.97389-10-newtwen+github@gmail.com
State New
Headers show
Series odhcpd config value clamping | expand

Commit Message

Paul Donald May 9, 2024, 10:30 p.m. UTC
From: Paul Donald <newtwen@gmail.com>

Attempt to be helpful.

Signed-off-by: Paul Donald <newtwen@gmail.com>
---
 src/config.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/config.c b/src/config.c
index 6b3cb01..54fb9b5 100644
--- a/src/config.c
+++ b/src/config.c
@@ -939,11 +939,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#section-6.2.1 : AdvReachableTime : 
+		 * MUST be no greater than 3,600,000 msec
+		 */
+		iface->ra_reachabletime = (ra_reachabletime <= 3600000)? ra_reachabletime : 3600000;
+		if(ra_reachabletime > 3600000)
+			syslog(LOG_INFO, "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])) {