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 Changes Requested
Delegated to: Ansuel Smith
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(-)

Comments

Christian Marangi Nov. 16, 2024, 3:13 p.m. UTC | #1
On Fri, May 10, 2024 at 12:30:41AM +0200, Paul Donald wrote:
> From: Paul Donald <newtwen@gmail.com>
> 
> Attempt to be helpful.

Better commit description please. (also apply this to every other
comment, declerative comments and NOT as continuation of title)

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

I would keep LOG_ERR, also space before ? and drop the ( ).

>  	}
>  
>  	if ((c = tb[IFACE_ATTR_RA_RETRANSTIME])) {
> -- 
> 2.44.0
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
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])) {