From e69aa084193bcadc7a48c99c381741e8ff307658 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Mar 2018 21:06:44 -0400 Subject: zebra: Allow for deletion of rules when the originator goes away When zebra detects that the originator has dissapeared delete all rules associated with that client. Signed-off-by: Donald Sharp --- zebra/zebra_pbr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'zebra/zebra_pbr.c') diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 4da09dc53..090ec2c50 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -133,6 +133,25 @@ void zebra_pbr_del_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule) __PRETTY_FUNCTION__); } +static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data) +{ + struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT); + struct zebra_pbr_rule *rule = b->data; + int *sock = data; + + if (rule->sock == *sock) { + kernel_del_pbr_rule(rule); + hash_release(zns->rules_hash, rule); + } +} + +void zebra_pbr_client_close_cleanup(int sock) +{ + struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT); + + hash_iterate(zns->rules_hash, zebra_pbr_cleanup_rules, &sock); +} + /* * Handle success or failure of rule (un)install in the kernel. */ -- cgit v1.2.3