diff options
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 626583a848..10be5d8fa5 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -71,7 +71,7 @@ extern int allow_delete; /* Each route type's string and default distance value. */ static const struct { int key; - int distance; + uint8_t distance; uint8_t meta_q_map; } route_info[ZEBRA_ROUTE_MAX] = { [ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0, 4}, @@ -98,6 +98,10 @@ static const struct { [ZEBRA_ROUTE_BGP_DIRECT_EXT] = {ZEBRA_ROUTE_BGP_DIRECT_EXT, 20, 3}, [ZEBRA_ROUTE_BABEL] = {ZEBRA_ROUTE_BABEL, 100, 2}, [ZEBRA_ROUTE_SHARP] = {ZEBRA_ROUTE_SHARP, 150, 4}, + [ZEBRA_ROUTE_PBR] = {ZEBRA_ROUTE_PBR, 200, 4}, + [ZEBRA_ROUTE_BFD] = {ZEBRA_ROUTE_BFD, 255, 4}, + [ZEBRA_ROUTE_OPENFABRIC] = {ZEBRA_ROUTE_OPENFABRIC, 115, 2}, + /* Any new route type added to zebra, should be mirrored here */ /* no entry/default: 150 */ }; @@ -470,8 +474,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re, if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug( "\t%s: Interface %s is not unnumbered", - __PRETTY_FUNCTION__, - ifp ? ifp->name : "Unknown"); + __PRETTY_FUNCTION__, ifp->name); return 0; } } @@ -3386,9 +3389,33 @@ static int rib_dplane_results(struct dplane_ctx_q *ctxlist) return 0; } +/* + * Ensure there are no empty slots in the route_info array. + * Every route type in zebra should be present there. + */ +static void check_route_info(void) +{ + int len = array_size(route_info); + + /* + * ZEBRA_ROUTE_SYSTEM is special cased since + * its key is 0 anyway. + * + * ZEBRA_ROUTE_ALL is also ignored. + */ + for (int i = 0; i < len; i++) { + if (i == ZEBRA_ROUTE_SYSTEM || i == ZEBRA_ROUTE_ALL) + continue; + assert(route_info[i].key); + assert(route_info[i].meta_q_map < MQ_SIZE); + } +} + /* Routing information base initialize. */ void rib_init(void) { + check_route_info(); + rib_queue_init(); /* Init dataplane, and register for results */ |
