]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Read in on startup arbitrary tables
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 04:02:56 +0000 (00:02 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Mar 2018 14:18:58 +0000 (10:18 -0400)
When we receive an arbitrary table over the netlink bus
save it for later perusal and sweep any routes that
we may have created from an earlier run.

The current redistribute code is limited to
ZEBRA_KERNEL_TABLE_MAX.  I left this alone for the
moment because I believe it needs to be converted
to a RB tree instead of a flat array.  Which is more
work for the future.  Additionally this proposed
change might necessitate some cli changes or rethinks.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/redistribute.c
zebra/rib.h
zebra/zebra_ns.c
zebra/zebra_ns.h
zebra/zebra_rib.c

index 3a66aea45f897ef6d9f7d1b61987d0c50c129669..89c17b069aab07617a721ecab5c128d95fe288af 100644 (file)
@@ -58,7 +58,8 @@ int is_zebra_import_table_enabled(afi_t afi, u_int32_t table_id)
        if (afi == AFI_MAX)
                return 0;
 
-       if (is_zebra_valid_kernel_table(table_id))
+       if (is_zebra_valid_kernel_table(table_id) &&
+           table_id < ZEBRA_KERNEL_TABLE_MAX)
                return zebra_import_table_used[afi][table_id];
        return 0;
 }
index b5d8c6e8ebf8100421717e84ac88b5807981afd1..44e0a9ce40e0653188a3684f6c5f06d43c697eef 100644 (file)
@@ -326,6 +326,7 @@ extern struct route_entry *rib_lookup_ipv4(struct prefix_ipv4 *, vrf_id_t);
 extern void rib_update(vrf_id_t, rib_update_event_t);
 extern void rib_weed_tables(void);
 extern void rib_sweep_route(void);
+extern void rib_sweep_table(struct route_table *);
 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);
index 2c7b85e614f4bb4f8ce9c7ab8616087119d0f3c9..29c179245bf9398a1275fee0d1b0b0dc0cde32cd 100644 (file)
@@ -177,6 +177,17 @@ unsigned long zebra_ns_score_proto(u_char proto, u_short instance)
        return cnt;
 }
 
+void zebra_ns_sweep_route(void)
+{
+       struct zebra_ns_table *znst;
+       struct zebra_ns *zns;
+
+       zns = zebra_ns_lookup(NS_DEFAULT);
+
+       RB_FOREACH (znst, zebra_ns_table_head, &zns->ns_tables)
+               rib_sweep_table(znst->table);
+}
+
 struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
                                       struct zebra_vrf *zvrf, uint32_t tableid,
                                       afi_t afi)
index f6b8f5f9b34694c2d31c164fd90024a13de3af68..6655e5c019043d9119138e21770055b141b8f799 100644 (file)
@@ -92,4 +92,5 @@ extern struct route_table *zebra_ns_get_table(struct zebra_ns *zns,
 int zebra_ns_config_write(struct vty *vty, struct ns *ns);
 
 unsigned long zebra_ns_score_proto(u_char proto, u_short instance);
+void zebra_ns_sweep_route(void);
 #endif
index 35c74daea5e8b4f760ad17a0f2b892cf48c2f203..73b20320ada698036fef384098acc4ba8d616ca1 100644 (file)
@@ -139,9 +139,6 @@ uint8_t route_distance(int type)
 
 int is_zebra_valid_kernel_table(u_int32_t table_id)
 {
-       if ((table_id > ZEBRA_KERNEL_TABLE_MAX))
-               return 0;
-
 #ifdef linux
        if ((table_id == RT_TABLE_UNSPEC) || (table_id == RT_TABLE_LOCAL)
            || (table_id == RT_TABLE_COMPAT))
@@ -2739,7 +2736,7 @@ void rib_weed_tables(void)
 }
 
 /* Delete self installed routes after zebra is relaunched.  */
-static void rib_sweep_table(struct route_table *table)
+void rib_sweep_table(struct route_table *table)
 {
        struct route_node *rn;
        struct route_entry *re;
@@ -2800,6 +2797,8 @@ void rib_sweep_route(void)
                rib_sweep_table(zvrf->table[AFI_IP][SAFI_UNICAST]);
                rib_sweep_table(zvrf->table[AFI_IP6][SAFI_UNICAST]);
        }
+
+       zebra_ns_sweep_route();
 }
 
 /* Remove specific by protocol routes from 'table'. */