*/
#include "zebra.h"
+#include <pthread.h>
+#include "lib/frratomic.h"
+
#include "zebra_router.h"
#include "zebra_memory.h"
#include "zebra_pbr.h"
info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info));
info->zvrf = zvrf;
info->afi = afi;
- info->safi = SAFI_UNICAST;
+ info->safi = safi;
route_table_set_info(zrt->table, info);
zrt->table->cleanup = zebra_rtable_node_cleanup;
return cnt;
}
+void zebra_router_show_table_summary(struct vty *vty)
+{
+ struct zebra_router_table *zrt;
+
+ vty_out(vty,
+ "VRF NS ID VRF ID AFI SAFI Table Count\n");
+ vty_out(vty,
+ "---------------------------------------------------------------------------\n");
+ RB_FOREACH (zrt, zebra_router_table_head, &zrouter.tables) {
+ rib_table_info_t *info = route_table_get_info(zrt->table);
+
+ vty_out(vty, "%-16s%5d %9d %7s %15s %8d %10lu\n", info->zvrf->vrf->name,
+ zrt->ns_id, info->zvrf->vrf->vrf_id,
+ afi2str(zrt->afi), safi2str(zrt->safi),
+ zrt->tableid,
+ zrt->table->count);
+ }
+}
+
void zebra_router_sweep_route(void)
{
struct zebra_router_table *zrt;
{
void *table_info;
- rib_close_table(zrt->table);
-
table_info = route_table_get_info(zrt->table);
route_table_finish(zrt->table);
+ RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt);
+
XFREE(MTYPE_RIB_TABLE_INFO, table_info);
XFREE(MTYPE_ZEBRA_NS, zrt);
}
+void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,
+ afi_t afi, safi_t safi)
+{
+ struct zebra_router_table finder;
+ struct zebra_router_table *zrt;
+
+ memset(&finder, 0, sizeof(finder));
+ finder.afi = afi;
+ finder.safi = safi;
+ finder.tableid = tableid;
+ finder.ns_id = zvrf->zns->ns_id;
+ zrt = RB_FIND(zebra_router_table_head, &zrouter.tables, &finder);
+
+ if (!zrt)
+ return;
+
+ zebra_router_free_table(zrt);
+}
+
+uint32_t zebra_router_get_next_sequence(void)
+{
+ return 1
+ + atomic_fetch_add_explicit(&zrouter.sequence_num, 1,
+ memory_order_relaxed);
+}
+
void zebra_router_terminate(void)
{
struct zebra_router_table *zrt, *tmp;
- RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp) {
- RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt);
+ RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp)
zebra_router_free_table(zrt);
- }
+
+ work_queue_free_and_null(&zrouter.ribq);
+ meta_queue_free(zrouter.mq);
zebra_vxlan_disable();
zebra_mlag_terminate();
void zebra_router_init(void)
{
+ zrouter.sequence_num = 0;
+
+ zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;
+
zebra_vxlan_init();
zebra_mlag_init();