diff mbox series

[5/9] router: Limit prefix preferred_lt to valid_lt in accordance with RFC4861

Message ID 20240405005510.19778-6-newtwen+github@gmail.com
State Superseded
Headers show
Series odhcpd patchset | expand

Commit Message

Paul Donald April 5, 2024, 12:53 a.m. UTC
From: Paul Donald <newtwen@gmail.com>

Follow-up fix for bc9d317f2921ae6b529f2c9f8de79b75992e206f

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

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

Patch

diff --git a/src/router.c b/src/router.c
index 3890c0b..a1a7829 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;