]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: cleanup zebra policy context
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 21 Mar 2018 16:52:41 +0000 (17:52 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 25 May 2018 13:49:38 +0000 (15:49 +0200)
Upon the remote daemon leaving, some contexts may have to be flushed.
This commit does the change. IPset and IPSet Entries and iptables are
flushed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/zebra_pbr.c

index 050c93dbfcadcc3d246bf468ca8b97ca701c8aff..7ab6c944309b0b12f41107ed7f7a8b781d2bd291 100644 (file)
@@ -320,6 +320,36 @@ static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data)
        }
 }
 
+static void zebra_pbr_cleanup_ipset(struct hash_backet *b, void *data)
+{
+       struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
+       struct zebra_pbr_ipset *ipset = b->data;
+       int *sock = data;
+
+       if (ipset->sock == *sock)
+               hash_release(zns->ipset_hash, ipset);
+}
+
+static void zebra_pbr_cleanup_ipset_entry(struct hash_backet *b, void *data)
+{
+       struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
+       struct zebra_pbr_ipset_entry *ipset = b->data;
+       int *sock = data;
+
+       if (ipset->sock == *sock)
+               hash_release(zns->ipset_entry_hash, ipset);
+}
+
+static void zebra_pbr_cleanup_iptable(struct hash_backet *b, void *data)
+{
+       struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
+       struct zebra_pbr_iptable *iptable = b->data;
+       int *sock = data;
+
+       if (iptable->sock == *sock)
+               hash_release(zns->iptable_hash, iptable);
+}
+
 static int zebra_pbr_client_close_cleanup(struct zserv *client)
 {
        int sock = client->sock;
@@ -328,6 +358,12 @@ static int zebra_pbr_client_close_cleanup(struct zserv *client)
        if (!sock)
                return 0;
        hash_iterate(zns->rules_hash, zebra_pbr_cleanup_rules, &sock);
+       hash_iterate(zns->iptable_hash,
+                    zebra_pbr_cleanup_iptable, &sock);
+       hash_iterate(zns->ipset_entry_hash,
+                    zebra_pbr_cleanup_ipset_entry, &sock);
+       hash_iterate(zns->ipset_hash,
+                    zebra_pbr_cleanup_ipset, &sock);
        return 1;
 }