[RFC PATCH 12/14] config: clamp ra_mtu into 1280-65535 range

Christian Marangi ansuelsmth at gmail.com
Sat Nov 16 07:16:34 PST 2024


On Fri, May 10, 2024 at 12:30:44AM +0200, Paul Donald wrote:
> From: Paul Donald <newtwen at gmail.com>
> 
> (ipv6 packets can be up to 4GB in size...)
> 
> The old logic had a logic error of || instead of &&

I would ask you to move the fix in a dedicated patch separate from this
series (so I can merge it quicker)

> 
> Signed-off-by: Paul Donald <newtwen at gmail.com>
> ---
>  src/config.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/config.c b/src/config.c
> index 160d7db..f4eaa3b 100644
> --- a/src/config.c
> +++ b/src/config.c
> @@ -971,11 +971,10 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
>  	if ((c = tb[IFACE_ATTR_RA_MTU])) {
>  		uint32_t ra_mtu = blobmsg_get_u32(c);
>  
> -		if (ra_mtu >= 1280 || ra_mtu <= 65535)
> -			iface->ra_mtu = ra_mtu;
> -		else
> -			syslog(LOG_ERR, "Invalid %s value configured for interface '%s'",
> -					iface_attrs[IFACE_ATTR_RA_MTU].name, iface->name);
> +		iface->ra_mtu = (ra_mtu < 1280) ? 1280 : (ra_mtu > 65535) ? 65535 : ra_mtu;
> +		if (!(ra_mtu >= 1280 && ra_mtu <= 65535))
> +			syslog(LOG_INFO, "Clamped invalid %s value configured for interface '%s' to %d",
> +					iface_attrs[IFACE_ATTR_RA_MTU].name, iface->name, iface->ra_mtu);

Lets use comments and full if condition instead of nested ? :.

Also as other comments I would still use LOG_ERR.

>  	}
>  
>  	if ((c = tb[IFACE_ATTR_RA_SLAAC]))
> -- 
> 2.44.0
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

-- 
	Ansuel



More information about the openwrt-devel mailing list