From: Philippe Guibert Date: Wed, 21 Mar 2018 16:52:41 +0000 (+0100) Subject: zebra: cleanup zebra policy context X-Git-Tag: frr-6.1-dev~395^2~28 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c2ef5232ae52eff42790d69514e3515716af349b;p=matthieu%2Ffrr.git zebra: cleanup zebra policy context 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 --- diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 050c93dbfc..7ab6c94430 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -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; }