Skip to content
Permalink
Browse files

zebra: Consolidate meta_queue_map into route_info

The route_info data structure already had a mapping of route type
to admin distance.  Consolidate the meta_queue_map information
into this route_info data structure.  This is to reduce the number
of places we need to remember to touch when adding a new routing
protocol.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information...
donaldsharp committed Jan 2, 2019
1 parent d52fa66 commit 73547a754ea5f06a01f1a6d0abf47e3163a673d4
Showing with 26 additions and 55 deletions.
  1. +26 −55 zebra/zebra_rib.c
@@ -73,31 +73,32 @@ extern int allow_delete;
static const struct {
int key;
int distance;
uint8_t meta_q_map;
} route_info[ZEBRA_ROUTE_MAX] = {
[ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0},
[ZEBRA_ROUTE_KERNEL] = {ZEBRA_ROUTE_KERNEL, 0},
[ZEBRA_ROUTE_CONNECT] = {ZEBRA_ROUTE_CONNECT, 0},
[ZEBRA_ROUTE_STATIC] = {ZEBRA_ROUTE_STATIC, 1},
[ZEBRA_ROUTE_RIP] = {ZEBRA_ROUTE_RIP, 120},
[ZEBRA_ROUTE_RIPNG] = {ZEBRA_ROUTE_RIPNG, 120},
[ZEBRA_ROUTE_OSPF] = {ZEBRA_ROUTE_OSPF, 110},
[ZEBRA_ROUTE_OSPF6] = {ZEBRA_ROUTE_OSPF6, 110},
[ZEBRA_ROUTE_ISIS] = {ZEBRA_ROUTE_ISIS, 115},
[ZEBRA_ROUTE_BGP] = {ZEBRA_ROUTE_BGP, 20 /* IBGP is 200. */},
[ZEBRA_ROUTE_PIM] = {ZEBRA_ROUTE_PIM, 255},
[ZEBRA_ROUTE_EIGRP] = {ZEBRA_ROUTE_EIGRP, 90},
[ZEBRA_ROUTE_NHRP] = {ZEBRA_ROUTE_NHRP, 10},
[ZEBRA_ROUTE_HSLS] = {ZEBRA_ROUTE_HSLS, 255},
[ZEBRA_ROUTE_OLSR] = {ZEBRA_ROUTE_OLSR, 255},
[ZEBRA_ROUTE_TABLE] =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HRP, 10, 2},
[ZEBRA_ROUTE_HSLS] = {ZEBRA_ROUTE_HSLS, 255, 4},
[ZEBRA_ROUTE_OLSR] = {ZEBRA_ROUTE_OLSR, 255, 4},
[ZEBRA_ROUTE_TABLE] = {ZEBRA_ROUTE_TABLE, 150, 1},
[ZEBRA_ROUTE_LDP] = {ZEBRA_ROUTE_LDP, 150, 4},
[ZEBRA_ROUTE_VNC] = {ZEBRA_ROUTE_VNC, 20, 3},
[ZEBRA_ROUTE_VNC_DIRECT] = {ZEBRA_ROUTE_VNC_DIRECT, 20, 3},
[ZEBRA_ROUTE_VNC_DIRECT_RH] = {ZEBRA_ROUTE_VNC_DIRECT_RH, 20, 3},
[ZEBRA_ROUTE_BGP_DIRECT] = {ZEBRA_ROUTE_BGP_DIRECT, 20, 3},
[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},

/* no entry/default: 150 */
};
@@ -2143,36 +2144,6 @@ static wq_item_status meta_queue_process(struct work_queue *dummy, void *data)
return mq->size ? WQ_REQUEUE : WQ_SUCCESS;
}

/*
* Map from rib types to queue type (priority) in meta queue
*/
static const uint8_t meta_queue_map[ZEBRA_ROUTE_MAX] = {
[ZEBRA_ROUTE_SYSTEM] = 4,
[ZEBRA_ROUTE_KERNEL] = 0,
[ZEBRA_ROUTE_CONNECT] = 0,
[ZEBRA_ROUTE_STATIC] = 1,
[ZEBRA_ROUTE_RIP] = 2,
[ZEBRA_ROUTE_RIPNG] = 2,
[ZEBRA_ROUTE_OSPF] = 2,
[ZEBRA_ROUTE_OSPF6] = 2,
[ZEBRA_ROUTE_ISIS] = 2,
[ZEBRA_ROUTE_BGP] = 3,
[ZEBRA_ROUTE_PIM] = 4, // Shouldn't happen but for safety
[ZEBRA_ROUTE_EIGRP] = 2,
[ZEBRA_ROUTE_NHRP] = 2,
[ZEBRA_ROUTE_HSLS] = 4,
[ZEBRA_ROUTE_OLSR] = 4,
[ZEBRA_ROUTE_TABLE] = 1,
[ZEBRA_ROUTE_LDP] = 4,
[ZEBRA_ROUTE_VNC] = 3,
[ZEBRA_ROUTE_VNC_DIRECT] = 3,
[ZEBRA_ROUTE_VNC_DIRECT_RH] = 3,
[ZEBRA_ROUTE_BGP_DIRECT] = 3,
[ZEBRA_ROUTE_BGP_DIRECT_EXT] = 3,
[ZEBRA_ROUTE_BABEL] = 2,
[ZEBRA_ROUTE_ALL] = 4, // Shouldn't happen but for safety
};

/* Look into the RN and queue it into one or more priority queues,
* increasing the size for each data push done.
*/
@@ -2181,7 +2152,7 @@ static void rib_meta_queue_add(struct meta_queue *mq, struct route_node *rn)
struct route_entry *re;

RNODE_FOREACH_RE (rn, re) {
uint8_t qindex = meta_queue_map[re->type];
uint8_t qindex = route_info[re->type].meta_q_map;
struct zebra_vrf *zvrf;

/* Invariant: at this point we always have rn->info set. */

0 comments on commit 73547a7

Please sign in to comment.
You can’t perform that action at this time.