summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_pbr.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-03-16 02:06:44 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-03-16 15:17:41 +0100
commite69aa084193bcadc7a48c99c381741e8ff307658 (patch)
tree1058ac30ee80d864921b7c5543a41b47a1f3a31c /zebra/zebra_pbr.c
parentMerge pull request #1885 from msablic/pim_mtrace_client (diff)
downloadfrr-e69aa084193bcadc7a48c99c381741e8ff307658.tar.xz
frr-e69aa084193bcadc7a48c99c381741e8ff307658.zip
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 <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_pbr.c')
-rw-r--r--zebra/zebra_pbr.c19
1 files changed, 19 insertions, 0 deletions
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.
*/