diff mbox series

[RFC,08/14] router: clamp prefix valid_lt to interface valid_lifetime

Message ID 20240509223213.97389-9-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>

Before:
==
ICMPv6 Option (Prefix information : fd26:3c30:a222::/64)
    Type: Prefix information (3)
    Length: 4 (32 bytes)
    Prefix Length: 64
    Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
    Valid Lifetime: Infinity (4294967295)
    Preferred Lifetime: Infinity (4294967295)
    Reserved
    Prefix: fd26:3c30:a222::

==After (valid_lifetime set to 6 hours):==
ICMPv6 Option (Prefix information : fd26:3c30:a222::/64)
    Type: Prefix information (3)
    Length: 4 (32 bytes)
    Prefix Length: 64
    Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
    Valid Lifetime: 21600 (6 hours)
    Preferred Lifetime: 21600 (6 hours)
    Reserved
    Prefix: fd26:3c30:a222::
==

Signed-off-by: Paul Donald <newtwen@gmail.com>
---
 src/router.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Christian Marangi Nov. 16, 2024, 3:09 p.m. UTC | #1
On Fri, May 10, 2024 at 12:30:40AM +0200, Paul Donald wrote:
> From: Paul Donald <newtwen@gmail.com>
> 
> Before:
> ==
> ICMPv6 Option (Prefix information : fd26:3c30:a222::/64)
>     Type: Prefix information (3)
>     Length: 4 (32 bytes)
>     Prefix Length: 64
>     Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
>     Valid Lifetime: Infinity (4294967295)
>     Preferred Lifetime: Infinity (4294967295)
>     Reserved
>     Prefix: fd26:3c30:a222::
> 
> ==After (valid_lifetime set to 6 hours):==
> ICMPv6 Option (Prefix information : fd26:3c30:a222::/64)
>     Type: Prefix information (3)
>     Length: 4 (32 bytes)
>     Prefix Length: 64
>     Flag: 0xc0, On-link flag(L), Autonomous address-configuration flag(A)
>     Valid Lifetime: 21600 (6 hours)
>     Preferred Lifetime: 21600 (6 hours)
>     Reserved
>     Prefix: fd26:3c30:a222::
> ==
> 
> Signed-off-by: Paul Donald <newtwen@gmail.com>

More info on this? Maybe why? Scenario this fix?

> ---
>  src/router.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/router.c b/src/router.c
> index b859c46..00752af 100644
> --- a/src/router.c
> +++ b/src/router.c
> @@ -600,6 +600,13 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
>  
>  			if (iface->ra_useleasetime && valid_lt > iface->dhcp_leasetime)
>  				valid_lt = iface->dhcp_leasetime;
> +
> +			/* currently the only way to control ULA valid_lifetime */
> +			if (valid_lt > iface->valid_lifetime) {
> +				// set to possibly user mandated valid_lifetime

Use /* */ for consistent comments.

> +				valid_lt = iface->valid_lifetime;
> +			}
> +
>  		}
>  
>  		if (preferred_lt > valid_lt) {
> -- 
> 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/router.c b/src/router.c
index b859c46..00752af 100644
--- a/src/router.c
+++ b/src/router.c
@@ -600,6 +600,13 @@  static int send_router_advert(struct interface *iface, const struct in6_addr *fr
 
 			if (iface->ra_useleasetime && valid_lt > iface->dhcp_leasetime)
 				valid_lt = iface->dhcp_leasetime;
+
+			/* currently the only way to control ULA valid_lifetime */
+			if (valid_lt > iface->valid_lifetime) {
+				// set to possibly user mandated valid_lifetime
+				valid_lt = iface->valid_lifetime;
+			}
+
 		}
 
 		if (preferred_lt > valid_lt) {