From: Donald Sharp Date: Wed, 6 Feb 2019 19:21:36 +0000 (-0500) Subject: zebra: Abstract the rib_dest_t creation X-Git-Tag: 7.1_pulled~129^2~7 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=434434f70404a3b491117442462b554e83764339;p=mirror%2Ffrr.git zebra: Abstract the rib_dest_t creation Abstract the creation of the rib_dest_t so that we can call it from multiple places. Signed-off-by: Donald Sharp --- diff --git a/zebra/rib.h b/zebra/rib.h index ced6692b9b..2e0a73aa8b 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -430,6 +430,11 @@ static inline struct zebra_vrf *rib_dest_vrf(rib_dest_t *dest) return rib_table_info(rib_dest_table(dest))->zvrf; } +/* + * Create the rib_dest_t and attach it to the specified node + */ +extern rib_dest_t *zebra_rib_create_dest(struct route_node *rn); + /* * rib_tables_iter_init */ diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index ad07331152..5d98d61645 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2314,6 +2314,18 @@ static void rib_queue_init(void) return; } +rib_dest_t *zebra_rib_create_dest(struct route_node *rn) +{ + rib_dest_t *dest; + + dest = XCALLOC(MTYPE_RIB_DEST, sizeof(rib_dest_t)); + route_lock_node(rn); /* rn route table reference */ + rn->info = dest; + dest->rnode = rn; + + return dest; +} + /* RIB updates are processed via a queue of pointers to route_nodes. * * The queue length is bounded by the maximal size of the routing table, @@ -2366,10 +2378,7 @@ static void rib_link(struct route_node *rn, struct route_entry *re, int process) if (IS_ZEBRA_DEBUG_RIB_DETAILED) rnode_debug(rn, re->vrf_id, "rn %p adding dest", rn); - dest = XCALLOC(MTYPE_RIB_DEST, sizeof(rib_dest_t)); - route_lock_node(rn); /* rn route table reference */ - rn->info = dest; - dest->rnode = rn; + dest = zebra_rib_create_dest(rn); } head = dest->routes;