]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/ndisc: drop outdated PREF64 prefixes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 5 Sep 2023 15:44:42 +0000 (00:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 5 Sep 2023 16:22:43 +0000 (01:22 +0900)
Follow-up for 6e8f5e4c1f5fcdb3b63343268936f9c269b6a209.

Addresses https://github.com/systemd/systemd/pull/29009#issuecomment-1705741844.

src/network/networkd-ndisc.c

index e8606506916e0697c535aca80b66bd546b2993ae..4038cd7347270a349052c6de7031b63596e7ccbf 100644 (file)
@@ -1134,6 +1134,7 @@ static int ndisc_drop_outdated(Link *link, usec_t timestamp_usec) {
         NDiscDNSSL *dnssl;
         NDiscRDNSS *rdnss;
         NDiscCaptivePortal *cp;
+        NDiscPREF64 *p64;
         Address *address;
         Route *route;
         int r = 0, k;
@@ -1194,6 +1195,15 @@ static int ndisc_drop_outdated(Link *link, usec_t timestamp_usec) {
                 updated = true;
         }
 
+        SET_FOREACH(p64, link->ndisc_pref64) {
+                if (p64->lifetime_usec >= timestamp_usec)
+                        continue; /* the pref64 prefix is still valid */
+
+                free(set_remove(link->ndisc_pref64, p64));
+                /* The pref64 prefix is not exported through the state file, hence it is not necessary to set
+                 * the 'updated' flag. */
+        }
+
         if (updated)
                 link_dirty(link);
 
@@ -1220,6 +1230,7 @@ static int ndisc_setup_expire(Link *link) {
         NDiscCaptivePortal *cp;
         NDiscDNSSL *dnssl;
         NDiscRDNSS *rdnss;
+        NDiscPREF64 *p64;
         Address *address;
         Route *route;
         int r;
@@ -1256,6 +1267,9 @@ static int ndisc_setup_expire(Link *link) {
         SET_FOREACH(cp, link->ndisc_captive_portals)
                 lifetime_usec = MIN(lifetime_usec, cp->lifetime_usec);
 
+        SET_FOREACH(p64, link->ndisc_pref64)
+                lifetime_usec = MIN(lifetime_usec, p64->lifetime_usec);
+
         if (lifetime_usec == USEC_INFINITY)
                 return 0;