Introduce a garbage collector for stale entries in ipv6_prefixd that are
no longer managed by the controller (e.g. if the processing has been
disabled setting ipv6_prefix_delegation to false on all logical router
ports)

Tested-by: Jianlin Shi <ji...@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianc...@redhat.com>
---
 controller/pinctrl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 3230bb386..f0d63b9a6 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -578,6 +578,7 @@ enum {
 
 struct ipv6_prefixd_state {
     long long int next_announce;
+    long long int last_used;
     struct in6_addr ipv6_addr;
     struct eth_addr ea;
     struct eth_addr cmac;
@@ -1128,11 +1129,13 @@ fill_ipv6_prefix_state(struct ovsdb_idl_txn 
*ovnsb_idl_txn,
             sbrec_port_binding_set_options(pb, &options);
             smap_destroy(&options);
         }
+        pfd->last_used = time_msec();
     }
 
     return changed;
 }
 
+#define IPV6_PREFIXD_STALE_TIMEOUT  180000LL
 static void
 prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
                      struct ovsdb_idl_index *sbrec_port_binding_by_name,
@@ -1210,6 +1213,15 @@ prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
         }
     }
 
+    struct shash_node *iter, *next;
+    SHASH_FOR_EACH_SAFE (iter, next, &ipv6_prefixd) {
+        struct ipv6_prefixd_state *pfd = iter->data;
+        if (pfd->last_used + IPV6_PREFIXD_STALE_TIMEOUT < time_msec()) {
+            free(pfd);
+            shash_delete(&ipv6_prefixd, iter);
+        }
+    }
+
     if (changed) {
         notify_pinctrl_handler();
     }
-- 
2.25.4

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to