From: Donald Sharp Date: Fri, 16 Mar 2018 03:30:17 +0000 (-0400) Subject: zebra: Upon client disconnect remove routes from all tables X-Git-Tag: frr-5.0-dev~138^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=47a08aa968e451b81030e010d41da6def3d2c577;p=mirror%2Ffrr.git zebra: Upon client disconnect remove routes from all tables It is possible for clients to install routes into tables that they desire. Modify the code to delete these routes from these tables as well. Signed-off-by: Donald Sharp --- diff --git a/zebra/rib.h b/zebra/rib.h index 0ee89e015a..b5d8c6e8eb 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -329,6 +329,8 @@ extern void rib_sweep_route(void); extern void rib_close_table(struct route_table *); extern void rib_init(void); extern unsigned long rib_score_proto(u_char proto, u_short instance); +extern unsigned long rib_score_proto_table(u_char proto, u_short instance, + struct route_table *table); extern void rib_queue_add(struct route_node *rn); extern void meta_queue_free(struct meta_queue *mq); extern int zebra_rib_labeled_unicast(struct route_entry *re); diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index 192e8ad413..2c7b85e614 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -37,6 +37,7 @@ #include "zebra_netns_notify.h" #include "zebra_netns_id.h" #include "zebra_pbr.h" +#include "rib.h" extern struct zebra_privs_t zserv_privs; @@ -162,6 +163,20 @@ struct route_table *zebra_ns_find_table(struct zebra_ns *zns, uint32_t tableid, return NULL; } +unsigned long zebra_ns_score_proto(u_char proto, u_short instance) +{ + struct zebra_ns *zns; + struct zebra_ns_table *znst; + unsigned long cnt = 0; + + zns = zebra_ns_lookup(NS_DEFAULT); + + RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables) + cnt += rib_score_proto_table(proto, instance, znst->table); + + return cnt; +} + struct route_table *zebra_ns_get_table(struct zebra_ns *zns, struct zebra_vrf *zvrf, uint32_t tableid, afi_t afi) diff --git a/zebra/zebra_ns.h b/zebra/zebra_ns.h index 19ecba1f0e..f6b8f5f9b3 100644 --- a/zebra/zebra_ns.h +++ b/zebra/zebra_ns.h @@ -90,4 +90,6 @@ extern struct route_table *zebra_ns_get_table(struct zebra_ns *zns, struct zebra_vrf *zvrf, uint32_t tableid, afi_t afi); int zebra_ns_config_write(struct vty *vty, struct ns *ns); + +unsigned long zebra_ns_score_proto(u_char proto, u_short instance); #endif diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 26dd48733e..35c74daea5 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2803,8 +2803,8 @@ void rib_sweep_route(void) } /* Remove specific by protocol routes from 'table'. */ -static unsigned long rib_score_proto_table(u_char proto, u_short instance, - struct route_table *table) +unsigned long rib_score_proto_table(u_char proto, u_short instance, + struct route_table *table) { struct route_node *rn; struct route_entry *re; @@ -2841,6 +2841,8 @@ unsigned long rib_score_proto(u_char proto, u_short instance) proto, instance, zvrf->table[AFI_IP6][SAFI_UNICAST]); + cnt += zebra_ns_score_proto(proto, instance); + return cnt; }