[PATCH v3 4/9] router: Limit prefix preferred_lt to valid_lt in accordance with RFC4861

Paul Donald newtwen+github at gmail.com
Mon Apr 8 20:04:05 PDT 2024


From: Paul Donald <newtwen at gmail.com>

Follow-up fix for bc9d317f2921ae6b529f2c9f8de79b75992e206f

https://www.rfc-editor.org/rfc/rfc4861#page-44

Signed-off-by: Paul Donald <newtwen at gmail.com>
Reviewed-by: Daniel Golle <daniel at makrotopia.org>
---
 src/router.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/router.c b/src/router.c
index 61d0e69..c35180d 100644
--- a/src/router.c
+++ b/src/router.c
@@ -603,6 +603,13 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
 				valid_lt = iface->dhcp_leasetime;
 		}
 
+		if (preferred_lt > valid_lt) {
+			/* RFC4861 § 6.2.1
+			This value [AdvPreferredLifetime] MUST NOT be larger than AdvValidLifetime.
+			*/
+			preferred_lt = valid_lt;
+		}
+
 		if (minvalid > valid_lt)
 			minvalid = valid_lt;
 
-- 
2.44.0




More information about the openwrt-devel mailing list