diff mbox series

[RFC,02/14] router: Apply updated values from RFC8319 (updates RFC4861) to RA/ND

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

https://www.rfc-editor.org/rfc/rfc8319#section-4

Signed-off-by: Paul Donald <newtwen@gmail.com>
---
 src/router.c |  6 ++++--
 src/router.h | 23 ++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

Comments

Christian Marangi Nov. 16, 2024, 2:49 p.m. UTC | #1
On Fri, May 10, 2024 at 12:30:34AM +0200, Paul Donald wrote:
> From: Paul Donald <newtwen@gmail.com>
> 
> https://www.rfc-editor.org/rfc/rfc8319#section-4
> 
> Signed-off-by: Paul Donald <newtwen@gmail.com>
> ---
>  src/router.c |  6 ++++--
>  src/router.h | 23 ++++++++++++++++++++++-
>  2 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/src/router.c b/src/router.c
> index 7f5658b..ae0c545 100644
> --- a/src/router.c
> +++ b/src/router.c
> @@ -382,8 +382,10 @@ static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival)
>  		lifetime = iface->ra_lifetime;
>  		if (lifetime > 0 && lifetime < maxival)
>  			lifetime = maxival;
> -		else if (lifetime > 9000)
> -			lifetime = 9000;
> +		/* // RouterLifetime is a 16 bit packet field: skip this check
> +		else if (lifetime > RouterLifetime_MAX)
> +			lifetime = RouterLifetime_MAX;
> +		*/

This looks wrong... iface->ra_lifetime is int so it can go over 65535.
Value still needs to be clamped.

>  	}
>  
>  	return lifetime;
> diff --git a/src/router.h b/src/router.h
> index 0444da8..1f8d156 100644
> --- a/src/router.h
> +++ b/src/router.h
> @@ -32,8 +32,29 @@ struct icmpv6_opt {
>  
>  #define MaxInitialRtrAdvInterval	16
>  #define MaxInitialRtAdvs		3
> -#define MaxRtrAdvInterval		1800
> +/* RFC8319 §4
> +	This document updates §4.2 and 6.2.1 of [RFC4861] to change
> +	the following router configuration variables.
> +
> +	In §6.2.1, inside the paragraph that defines
> +	MaxRtrAdvInterval, change 1800 to 65535 seconds.
> +
> +	In §6.2.1, inside the paragraph that defines
> +	AdvDefaultLifetime, change 9000 to 65535 seconds.
> +*/
> +#define MaxRtrAdvInterval_CEILING		65535
>  #define MinRtrAdvInterval		3
> +#define AdvDefaultLifetime_CEILING		65535
> +/* RFC8319 §4
> +	This document updates §4.2 and 6.2.1 of [RFC4861] to change
> +	the following router configuration variables.
> +
> +	In §4.2, inside the paragraph that defines Router Lifetime,
> +	change 9000 to 65535 seconds.
> +
> +	Note: this is 16 bit Router Lifetime field in RA packets
> +*/
> +#define RouterLifetime_MAX					65535
>

Please, let try to keep commit bisectable, following RFC change, lets
just change the max value to 65535 without dropping and introducing new
defines. (also we drop MaxRtrAdvInterval here but in router.c is still
used)
diff mbox series

Patch

diff --git a/src/router.c b/src/router.c
index 7f5658b..ae0c545 100644
--- a/src/router.c
+++ b/src/router.c
@@ -382,8 +382,10 @@  static uint32_t calc_ra_lifetime(struct interface *iface, uint32_t maxival)
 		lifetime = iface->ra_lifetime;
 		if (lifetime > 0 && lifetime < maxival)
 			lifetime = maxival;
-		else if (lifetime > 9000)
-			lifetime = 9000;
+		/* // RouterLifetime is a 16 bit packet field: skip this check
+		else if (lifetime > RouterLifetime_MAX)
+			lifetime = RouterLifetime_MAX;
+		*/
 	}
 
 	return lifetime;
diff --git a/src/router.h b/src/router.h
index 0444da8..1f8d156 100644
--- a/src/router.h
+++ b/src/router.h
@@ -32,8 +32,29 @@  struct icmpv6_opt {
 
 #define MaxInitialRtrAdvInterval	16
 #define MaxInitialRtAdvs		3
-#define MaxRtrAdvInterval		1800
+/* RFC8319 §4
+	This document updates §4.2 and 6.2.1 of [RFC4861] to change
+	the following router configuration variables.
+
+	In §6.2.1, inside the paragraph that defines
+	MaxRtrAdvInterval, change 1800 to 65535 seconds.
+
+	In §6.2.1, inside the paragraph that defines
+	AdvDefaultLifetime, change 9000 to 65535 seconds.
+*/
+#define MaxRtrAdvInterval_CEILING		65535
 #define MinRtrAdvInterval		3
+#define AdvDefaultLifetime_CEILING		65535
+/* RFC8319 §4
+	This document updates §4.2 and 6.2.1 of [RFC4861] to change
+	the following router configuration variables.
+
+	In §4.2, inside the paragraph that defines Router Lifetime,
+	change 9000 to 65535 seconds.
+
+	Note: this is 16 bit Router Lifetime field in RA packets
+*/
+#define RouterLifetime_MAX					65535
 
 #define ND_RA_FLAG_PROXY		0x4
 #define ND_RA_PREF_HIGH			(1 << 3)