]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: upon zclient breaking, flush PBR entries
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 22 May 2018 10:22:08 +0000 (12:22 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 22 May 2018 15:41:27 +0000 (17:41 +0200)
In case, the BGP or PBR daemon leaves, the PBR contexts created by this
daemon are flushed.

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

index da9fe95123c5dd3a3bd6707aaee8cd2d381e10f5..9c721f0a7ee9683c1752ac4c0cecd9c69d069910 100644 (file)
@@ -51,6 +51,7 @@
 #include "zebra/label_manager.h"
 #include "zebra/zebra_netns_notify.h"
 #include "zebra/zebra_rnh.h"
+#include "zebra/zebra_pbr.h"
 
 #define ZEBRA_PTM_SUPPORT
 
@@ -342,6 +343,7 @@ int main(int argc, char **argv)
        zebra_mpls_init();
        zebra_mpls_vty_init();
        zebra_pw_vty_init();
+       zebra_pbr_init();
 
 /* For debug purpose. */
 /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */
index 93c523bf5026300b22d83039492bc9e90ce4bdde..54a9cdbc5b8fb3b19bb3fefda34b73a3369023f5 100644 (file)
@@ -320,11 +320,20 @@ static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data)
        }
 }
 
-void zebra_pbr_client_close_cleanup(int sock)
+static int zebra_pbr_client_close_cleanup(struct zserv *client)
 {
+       int sock = client->sock;
        struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
 
+       if (!sock)
+               return 0;
        hash_iterate(zns->rules_hash, zebra_pbr_cleanup_rules, &sock);
+       return 1;
+}
+
+void zebra_pbr_init(void)
+{
+       hook_register(zapi_client_close, zebra_pbr_client_close_cleanup);
 }
 
 static void *pbr_ipset_alloc_intern(void *arg)
index 0ac629cc659d7d254d55551196283e372a34414d..6b5cd1e8d12ec82d3f5c3d280fb85224dfb8b628 100644 (file)
@@ -182,8 +182,6 @@ extern void kernel_pbr_iptable_add_del_status(struct zebra_pbr_iptable *iptable,
  */
 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);
@@ -205,4 +203,5 @@ extern void zebra_pbr_iptable_free(void *arg);
 extern uint32_t zebra_pbr_iptable_hash_key(void *arg);
 extern int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
 
+extern void zebra_pbr_init(void);
 #endif /* _ZEBRA_PBR_H */