]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Allow for deletion of rules when the originator goes away
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 01:06:44 +0000 (21:06 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 14:17:41 +0000 (10:17 -0400)
When zebra detects that the originator has dissapeared
delete all rules associated with that client.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/zebra_pbr.c
zebra/zebra_pbr.h
zebra/zserv.c

index 4da09dc538d72798dfc0e17ca5cf6fc5d59209ff..090ec2c502d5b38f09c0c05602384fd75cecf49b 100644 (file)
@@ -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.
  */
index 4b28b6ec35f0cb5e507c15f11e3681df2ec20897..f910d8e742b8555eae08dd359daa4c3aa26b8099 100644 (file)
@@ -132,7 +132,10 @@ extern void kernel_pbr_rule_add_del_status(struct zebra_pbr_rule *rule,
  */
 extern int kernel_pbr_rule_del(struct zebra_pbr_rule *rule);
 
+extern void zebra_pbr_client_close_cleanup(int sock);
+
 extern void zebra_pbr_rules_free(void *arg);
 extern uint32_t zebra_pbr_rules_hash_key(void *arg);
 extern int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
+
 #endif /* _ZEBRA_PBR_H */
index 57b1be4b8b2bc8cb74187ac31a78cfa01e4f9fc1..5a903f051c114454f589e689db39b67c035db8d8 100644 (file)
@@ -2631,6 +2631,9 @@ static void zebra_client_free(struct zserv *client)
        /* Send client de-registration to BFD */
        zebra_ptm_bfd_client_deregister(client->proto);
 
+       /* Cleanup any rules installed from this client */
+       zebra_pbr_client_close_cleanup(client->sock);
+
        /* Cleanup any registered nexthops - across all VRFs. */
        zebra_client_close_cleanup_rnh(client);