Merge pull request #2277 from pguibert6WIND/fix_case_zclient_broken

zebra: upon zclient breaking, flush PBR entries
This commit is contained in:
Donald Sharp 2018-05-22 14:44:31 -04:00 committed by GitHub
commit b861cb7d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -51,6 +51,7 @@
#include "zebra/label_manager.h" #include "zebra/label_manager.h"
#include "zebra/zebra_netns_notify.h" #include "zebra/zebra_netns_notify.h"
#include "zebra/zebra_rnh.h" #include "zebra/zebra_rnh.h"
#include "zebra/zebra_pbr.h"
#define ZEBRA_PTM_SUPPORT #define ZEBRA_PTM_SUPPORT
@ -342,6 +343,7 @@ int main(int argc, char **argv)
zebra_mpls_init(); zebra_mpls_init();
zebra_mpls_vty_init(); zebra_mpls_vty_init();
zebra_pw_vty_init(); zebra_pw_vty_init();
zebra_pbr_init();
/* For debug purpose. */ /* For debug purpose. */
/* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */

View 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); struct zebra_ns *zns = zebra_ns_lookup(NS_DEFAULT);
if (!sock)
return 0;
hash_iterate(zns->rules_hash, zebra_pbr_cleanup_rules, &sock); 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) static void *pbr_ipset_alloc_intern(void *arg)

View 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 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 void zebra_pbr_rules_free(void *arg);
extern uint32_t zebra_pbr_rules_hash_key(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); 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 uint32_t zebra_pbr_iptable_hash_key(void *arg);
extern int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2); extern int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
extern void zebra_pbr_init(void);
#endif /* _ZEBRA_PBR_H */ #endif /* _ZEBRA_PBR_H */