router: limit prefix preferred_lt to valid_lt in accordance with RFC4861
authorPaul Donald <newtwen@gmail.com>
Tue, 9 Apr 2024 03:04:05 +0000 (05:04 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 7 May 2024 22:06:23 +0000 (00:06 +0200)
Follow-up fix for bc9d317f2921 ("dhcpv6-ia: fix invalid preferred
lifetime").

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

Fixes: bc9d317f2921 ("dhcpv6-ia: fix invalid preferred lifetime")
Signed-off-by: Paul Donald <newtwen@gmail.com>
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
[ fix comment format and improve commit title ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
src/router.c

index 6eba161b4c8283b857e2e8cb225f870f47f5a964..b69feb32c0499c5854f4541002c609549b5ed165 100644 (file)
@@ -603,6 +603,15 @@ 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;