]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Upon client disconnect remove routes from all tables
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 03:30:17 +0000 (23:30 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 14:18:07 +0000 (10:18 -0400)
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 <sharpd@cumulusnetworks.com>
zebra/rib.h
zebra/zebra_ns.c
zebra/zebra_ns.h
zebra/zebra_rib.c

index 0ee89e015a13a5596f2d79833f53873458c2d135..b5d8c6e8ebf8100421717e84ac88b5807981afd1 100644 (file)
@@ -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);
index 192e8ad4137e39ed505b20930dfd3b54cd0d6ba7..2c7b85e614f4bb4f8ce9c7ab8616087119d0f3c9 100644 (file)
@@ -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)
index 19ecba1f0e764cab1a8c937a6aa8b8eef35aa66b..f6b8f5f9b34694c2d31c164fd90024a13de3af68 100644 (file)
@@ -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
index 26dd48733e6d3180ea13974a228e6ee9c249db54..35c74daea5e8b4f760ad17a0f2b892cf48c2f203 100644 (file)
@@ -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;
 }