bgpd, ripngd: Convert to using new agg_table/route

Switch bgp and ripngd to use the new aggregate table and
route data structures.  This was mainly a search and replace
operation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-08-03 13:22:48 -04:00
parent 8e1f651213
commit fe08ba7e11
29 changed files with 750 additions and 717 deletions

View File

@ -23,7 +23,7 @@
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/linklist.h" #include "lib/linklist.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/plist.h" #include "lib/plist.h"
#include "lib/routemap.h" #include "lib/routemap.h"
@ -126,10 +126,10 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
struct rfapi_nve_group_cfg *rfg_vn = NULL; struct rfapi_nve_group_cfg *rfg_vn = NULL;
struct rfapi_nve_group_cfg *rfg_un = NULL; struct rfapi_nve_group_cfg *rfg_un = NULL;
struct route_table *rt_vn; struct agg_table *rt_vn;
struct route_table *rt_un; struct agg_table *rt_un;
struct route_node *rn_vn; struct agg_node *rn_vn;
struct route_node *rn_un; struct agg_node *rn_un;
struct rfapi_nve_group_cfg *rfg; struct rfapi_nve_group_cfg *rfg;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -156,16 +156,16 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
return NULL; return NULL;
} }
rn_vn = route_node_match(rt_vn, vn); /* NB locks node */ rn_vn = agg_node_match(rt_vn, vn); /* NB locks node */
if (rn_vn) { if (rn_vn) {
rfg_vn = rn_vn->info; rfg_vn = rn_vn->info;
route_unlock_node(rn_vn); agg_unlock_node(rn_vn);
} }
rn_un = route_node_match(rt_un, un); /* NB locks node */ rn_un = agg_node_match(rt_un, un); /* NB locks node */
if (rn_un) { if (rn_un) {
rfg_un = rn_un->info; rfg_un = rn_un->info;
route_unlock_node(rn_un); agg_unlock_node(rn_un);
} }
#if BGP_VNC_DEBUG_MATCH_GROUP #if BGP_VNC_DEBUG_MATCH_GROUP
@ -2304,11 +2304,11 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */
if (rfg->vn_node) { if (rfg->vn_node) {
rfg->vn_node->info = NULL; rfg->vn_node->info = NULL;
route_unlock_node(rfg->vn_node); /* frees */ agg_unlock_node(rfg->vn_node); /* frees */
} }
if (rfg->un_node) { if (rfg->un_node) {
rfg->un_node->info = NULL; rfg->un_node->info = NULL;
route_unlock_node(rfg->un_node); /* frees */ agg_unlock_node(rfg->un_node); /* frees */
} }
if (rfg->rfp_cfg) if (rfg->rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg); XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
@ -2468,8 +2468,8 @@ DEFUN (vnc_nve_group_prefix,
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
struct prefix p; struct prefix p;
afi_t afi; afi_t afi;
struct route_table *rt; struct agg_table *rt;
struct route_node *rn; struct agg_node *rn;
int is_un_prefix = 0; int is_un_prefix = 0;
/* make sure it's still in list */ /* make sure it's still in list */
@ -2497,12 +2497,12 @@ DEFUN (vnc_nve_group_prefix,
rt = bgp->rfapi_cfg->nve_groups_vn[afi]; rt = bgp->rfapi_cfg->nve_groups_vn[afi];
} }
rn = route_node_get(rt, &p); /* NB locks node */ rn = agg_node_get(rt, &p); /* NB locks node */
if (rn->info) { if (rn->info) {
/* /*
* There is already a group with this prefix * There is already a group with this prefix
*/ */
route_unlock_node(rn); agg_unlock_node(rn);
if (rn->info != rfg) { if (rn->info != rfg) {
/* /*
* different group name: fail * different group name: fail
@ -2535,7 +2535,7 @@ DEFUN (vnc_nve_group_prefix,
/* detach rfg from previous route table location */ /* detach rfg from previous route table location */
if (rfg->un_node) { if (rfg->un_node) {
rfg->un_node->info = NULL; rfg->un_node->info = NULL;
route_unlock_node(rfg->un_node); /* frees */ agg_unlock_node(rfg->un_node); /* frees */
} }
rfg->un_node = rn; /* back ref */ rfg->un_node = rn; /* back ref */
rfg->un_prefix = p; rfg->un_prefix = p;
@ -2545,7 +2545,7 @@ DEFUN (vnc_nve_group_prefix,
/* detach rfg from previous route table location */ /* detach rfg from previous route table location */
if (rfg->vn_node) { if (rfg->vn_node) {
rfg->vn_node->info = NULL; rfg->vn_node->info = NULL;
route_unlock_node(rfg->vn_node); /* frees */ agg_unlock_node(rfg->vn_node); /* frees */
} }
rfg->vn_node = rn; /* back ref */ rfg->vn_node = rn; /* back ref */
rfg->vn_prefix = p; rfg->vn_prefix = p;
@ -3761,8 +3761,8 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
h->nve_groups_sequential = list_new(); h->nve_groups_sequential = list_new();
assert(h->nve_groups_sequential); assert(h->nve_groups_sequential);
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
h->nve_groups_vn[afi] = route_table_init(); h->nve_groups_vn[afi] = agg_table_init();
h->nve_groups_un[afi] = route_table_init(); h->nve_groups_un[afi] = agg_table_init();
} }
h->default_response_lifetime = h->default_response_lifetime =
BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT; BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT;
@ -3820,8 +3820,8 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
if (h->default_rfp_cfg) if (h->default_rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg); XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
route_table_finish(h->nve_groups_vn[afi]); agg_table_finish(h->nve_groups_vn[afi]);
route_table_finish(h->nve_groups_un[afi]); agg_table_finish(h->nve_groups_un[afi]);
} }
XFREE(MTYPE_RFAPI_CFG, h); XFREE(MTYPE_RFAPI_CFG, h);
} }

View File

@ -47,8 +47,8 @@ typedef enum {
} rfapi_group_cfg_type_t; } rfapi_group_cfg_type_t;
struct rfapi_nve_group_cfg { struct rfapi_nve_group_cfg {
struct route_node *vn_node; /* backref */ struct agg_node *vn_node; /* backref */
struct route_node *un_node; /* backref */ struct agg_node *un_node; /* backref */
rfapi_group_cfg_type_t type; /* NVE|VPN */ rfapi_group_cfg_type_t type; /* NVE|VPN */
char *name; /* unique by type! */ char *name; /* unique by type! */
@ -135,8 +135,8 @@ struct rfapi_cfg {
struct list *l2_groups; /* rfapi_l2_group_cfg list */ struct list *l2_groups; /* rfapi_l2_group_cfg list */
/* three views into the same collection of rfapi_nve_group_cfg */ /* three views into the same collection of rfapi_nve_group_cfg */
struct list *nve_groups_sequential; struct list *nve_groups_sequential;
struct route_table *nve_groups_vn[AFI_MAX]; struct agg_table *nve_groups_vn[AFI_MAX];
struct route_table *nve_groups_un[AFI_MAX]; struct agg_table *nve_groups_un[AFI_MAX];
/* /*
* For Single VRF export to ordinary routing protocols. This is * For Single VRF export to ordinary routing protocols. This is

View File

@ -23,7 +23,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/routemap.h" #include "lib/routemap.h"
@ -203,11 +203,11 @@ int rfapi_ip_addr_cmp(struct rfapi_ip_addr *a1, struct rfapi_ip_addr *a2)
static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
struct rfapi_ip_addr *un_addr, struct rfapi_ip_addr *un_addr,
struct route_node **node) struct agg_node **node)
{ {
struct rfapi *h; struct rfapi *h;
struct prefix p; struct prefix p;
struct route_node *rn; struct agg_node *rn;
int rc; int rc;
afi_t afi; afi_t afi;
@ -228,12 +228,12 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
if ((rc = rfapiRaddr2Qprefix(un_addr, &p))) if ((rc = rfapiRaddr2Qprefix(un_addr, &p)))
return rc; return rc;
rn = route_node_lookup(h->un[afi], &p); rn = agg_node_lookup(h->un[afi], &p);
if (!rn) if (!rn)
return ENOENT; return ENOENT;
route_unlock_node(rn); agg_unlock_node(rn);
*node = rn; *node = rn;
@ -244,7 +244,7 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
struct rfapi_ip_addr *un_addr, struct rfapi_descriptor **rfd) struct rfapi_ip_addr *un_addr, struct rfapi_descriptor **rfd)
{ {
struct route_node *rn; struct agg_node *rn;
int rc; int rc;
rc = rfapi_find_node(bgp, vn_addr, un_addr, &rn); rc = rfapi_find_node(bgp, vn_addr, un_addr, &rn);
@ -1347,8 +1347,8 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,
#define RFD_RTINIT_AFI(rh, ary, afi) \ #define RFD_RTINIT_AFI(rh, ary, afi) \
do { \ do { \
if (!ary[afi]) { \ if (!ary[afi]) { \
ary[afi] = route_table_init(); \ ary[afi] = agg_table_init(); \
ary[afi]->info = rh; \ agg_set_table_info(ary[afi], rh); \
} \ } \
} while (0) } while (0)
@ -1394,7 +1394,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
char buf_un[BUFSIZ]; char buf_un[BUFSIZ];
afi_t afi_vn, afi_un; afi_t afi_vn, afi_un;
struct prefix pfx_un; struct prefix pfx_un;
struct route_node *rn; struct agg_node *rn;
rfapi_time(&rfd->open_time); rfapi_time(&rfd->open_time);
@ -1423,7 +1423,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
assert(afi_vn && afi_un); assert(afi_vn && afi_un);
assert(!rfapiRaddr2Qprefix(&rfd->un_addr, &pfx_un)); assert(!rfapiRaddr2Qprefix(&rfd->un_addr, &pfx_un));
rn = route_node_get(h->un[afi_un], &pfx_un); rn = agg_node_get(h->un[afi_un], &pfx_un);
assert(rn); assert(rn);
rfd->next = rn->info; rfd->next = rn->info;
rn->info = rfd; rn->info = rfd;
@ -1535,7 +1535,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
afi_t afi; afi_t afi;
struct prefix p; struct prefix p;
struct prefix p_original; struct prefix p_original;
struct route_node *rn; struct agg_node *rn;
struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle; struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle;
struct bgp *bgp = rfd->bgp; struct bgp *bgp = rfd->bgp;
struct rfapi_next_hop_entry *pNHE = NULL; struct rfapi_next_hop_entry *pNHE = NULL;
@ -1704,7 +1704,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
} }
if (rn) { if (rn) {
route_lock_node(rn); /* so we can unlock below */ agg_lock_node(rn); /* so we can unlock below */
} else { } else {
/* /*
* returns locked node. Don't unlock yet because the * returns locked node. Don't unlock yet because the
@ -1721,7 +1721,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
assert(rn); assert(rn);
if (!rn->info) { if (!rn->info) {
route_unlock_node(rn); agg_unlock_node(rn);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: VPN route not found, returning ENOENT", __func__); "%s: VPN route not found, returning ENOENT", __func__);
return ENOENT; return ENOENT;
@ -1758,7 +1758,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
&p_original); &p_original);
} }
route_unlock_node(rn); agg_unlock_node(rn);
done: done:
if (ppNextHopEntry) { if (ppNextHopEntry) {
@ -2170,7 +2170,7 @@ int rfapi_close(void *handle)
{ {
struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle; struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle;
int rc; int rc;
struct route_node *node; struct agg_node *node;
struct bgp *bgp; struct bgp *bgp;
struct rfapi *h; struct rfapi *h;
@ -2276,7 +2276,7 @@ int rfapi_close(void *handle)
} }
} }
} }
route_unlock_node(node); agg_unlock_node(node);
} }
/* /*

View File

@ -22,7 +22,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/routemap.h" #include "lib/routemap.h"

View File

@ -27,7 +27,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/log.h" #include "lib/log.h"
@ -80,7 +80,7 @@
*/ */
struct rfapi_withdraw { struct rfapi_withdraw {
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
struct route_node *node; struct agg_node *node;
struct bgp_info *info; struct bgp_info *info;
safi_t safi; /* used only for bulk operations */ safi_t safi; /* used only for bulk operations */
/* /*
@ -88,8 +88,8 @@ struct rfapi_withdraw {
* Normally when a timer expires, lockoffset should be 0. However, if * Normally when a timer expires, lockoffset should be 0. However, if
* the timer expiration function is called directly (e.g., * the timer expiration function is called directly (e.g.,
* rfapiExpireVpnNow), the node could be locked by a preceding * rfapiExpireVpnNow), the node could be locked by a preceding
* route_top() or route_next() in a loop, so we need to pass this * agg_route_top() or agg_route_next() in a loop, so we need to pass
* value in. * this value in.
*/ */
int lockoffset; int lockoffset;
}; };
@ -140,8 +140,8 @@ void rfapiCheckRouteCount()
for (it = h->imports; it; it = it->next) { for (it = h->imports; it; it = it->next) {
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_table *rt; struct agg_table *rt;
struct route_node *rn; struct agg_node *rn;
int holddown_count = 0; int holddown_count = 0;
int local_count = 0; int local_count = 0;
@ -150,7 +150,8 @@ void rfapiCheckRouteCount()
rt = it->imported_vpn[afi]; rt = it->imported_vpn[afi];
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
struct bgp_info *bi; struct bgp_info *bi;
struct bgp_info *next; struct bgp_info *next;
@ -211,11 +212,11 @@ void rfapiCheckRouteCount()
* Validate reference count for a node in an import table * Validate reference count for a node in an import table
* *
* Normally lockoffset is 0 for nodes in quiescent state. However, * Normally lockoffset is 0 for nodes in quiescent state. However,
* route_unlock_node will delete the node if it is called when * agg_unlock_node will delete the node if it is called when
* node->lock == 1, and we have to validate the refcount before * node->lock == 1, and we have to validate the refcount before
* the node is deleted. In this case, we specify lockoffset 1. * the node is deleted. In this case, we specify lockoffset 1.
*/ */
void rfapiCheckRefcount(struct route_node *rn, safi_t safi, int lockoffset) void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset)
{ {
unsigned int count_bi = 0; unsigned int count_bi = 0;
unsigned int count_monitor = 0; unsigned int count_monitor = 0;
@ -613,8 +614,8 @@ struct rfapi_import_table *rfapiMacImportTableGet(struct bgp *bgp, uint32_t lni)
it->rt_import_list = enew; it->rt_import_list = enew;
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
it->imported_vpn[afi] = route_table_init(); it->imported_vpn[afi] = agg_table_init();
it->imported_encap[afi] = route_table_init(); it->imported_encap[afi] = agg_table_init();
} }
it->l2_logical_net_id = lni; it->l2_logical_net_id = lni;
@ -633,10 +634,10 @@ struct rfapi_import_table *rfapiMacImportTableGet(struct bgp *bgp, uint32_t lni)
* Returns pointer to the list of moved monitors * Returns pointer to the list of moved monitors
*/ */
static struct rfapi_monitor_vpn * static struct rfapi_monitor_vpn *
rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset) rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
{ {
struct bgp_info *bi; struct bgp_info *bi;
struct route_node *par; struct agg_node *par;
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
struct rfapi_monitor_vpn *mlast; struct rfapi_monitor_vpn *mlast;
struct rfapi_monitor_vpn *moved; struct rfapi_monitor_vpn *moved;
@ -679,7 +680,8 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
* one route (even if it is only a withdrawn route) with a * one route (even if it is only a withdrawn route) with a
* valid UN address. Call this node "Node P." * valid UN address. Call this node "Node P."
*/ */
for (par = original_vpn_node->parent; par; par = par->parent) { for (par = agg_node_parent(original_vpn_node); par;
par = agg_node_parent(par)) {
for (bi = par->info; bi; bi = bi->next) { for (bi = par->info; bi; bi = bi->next) {
struct prefix pfx; struct prefix pfx;
if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) { if (!rfapiGetUnAddrOfVpnBi(bi, &pfx)) {
@ -699,14 +701,14 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
*/ */
if (!par) { if (!par) {
/* this isn't necessarily 0/0 */ /* this isn't necessarily 0/0 */
par = route_top(original_vpn_node->table); par = agg_route_table_top(original_vpn_node);
/* /*
* If we got the top node but it wasn't 0/0, * If we got the top node but it wasn't 0/0,
* ignore it * ignore it
*/ */
if (par && par->p.prefixlen) { if (par && par->p.prefixlen) {
route_unlock_node(par); /* maybe free */ agg_unlock_node(par); /* maybe free */
par = NULL; par = NULL;
} }
@ -725,7 +727,8 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
pfx_default.family = original_vpn_node->p.family; pfx_default.family = original_vpn_node->p.family;
/* creates default node if none exists */ /* creates default node if none exists */
par = route_node_get(original_vpn_node->table, &pfx_default); par = agg_node_get(agg_get_table(original_vpn_node),
&pfx_default);
++parent_already_refcounted; ++parent_already_refcounted;
} }
@ -764,18 +767,18 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN, RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN,
parent_already_refcounted - movecount); parent_already_refcounted - movecount);
while (movecount > parent_already_refcounted) { while (movecount > parent_already_refcounted) {
route_lock_node(par); agg_lock_node(par);
++parent_already_refcounted; ++parent_already_refcounted;
} }
while (movecount < parent_already_refcounted) { while (movecount < parent_already_refcounted) {
/* unlikely, but code defensively */ /* unlikely, but code defensively */
route_unlock_node(par); agg_unlock_node(par);
--parent_already_refcounted; --parent_already_refcounted;
} }
RFAPI_CHECK_REFCOUNT(original_vpn_node, SAFI_MPLS_VPN, RFAPI_CHECK_REFCOUNT(original_vpn_node, SAFI_MPLS_VPN,
movecount + lockoffset); movecount + lockoffset);
while (movecount--) { while (movecount--) {
route_unlock_node(original_vpn_node); agg_unlock_node(original_vpn_node);
} }
#if DEBUG_MONITOR_MOVE_SHORTER #if DEBUG_MONITOR_MOVE_SHORTER
@ -796,12 +799,12 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
* Implement MONITOR_MOVE_LONGER(new_node) from * Implement MONITOR_MOVE_LONGER(new_node) from
* RFAPI-Import-Event-Handling.txt * RFAPI-Import-Event-Handling.txt
*/ */
static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node) static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node)
{ {
struct rfapi_monitor_vpn *monitor; struct rfapi_monitor_vpn *monitor;
struct rfapi_monitor_vpn *mlast; struct rfapi_monitor_vpn *mlast;
struct bgp_info *bi; struct bgp_info *bi;
struct route_node *par; struct agg_node *par;
RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0); RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0);
@ -824,7 +827,8 @@ static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node)
/* /*
* Find first parent node that has monitors * Find first parent node that has monitors
*/ */
for (par = new_vpn_node->parent; par; par = par->parent) { for (par = agg_node_parent(new_vpn_node); par;
par = agg_node_parent(par)) {
if (RFAPI_MONITOR_VPN(par)) if (RFAPI_MONITOR_VPN(par))
break; break;
} }
@ -860,14 +864,14 @@ static void rfapiMonitorMoveLonger(struct route_node *new_vpn_node)
RFAPI_MONITOR_VPN_W_ALLOC(new_vpn_node) = monitor; RFAPI_MONITOR_VPN_W_ALLOC(new_vpn_node) = monitor;
monitor->node = new_vpn_node; monitor->node = new_vpn_node;
route_lock_node(new_vpn_node); /* incr refcount */ agg_lock_node(new_vpn_node); /* incr refcount */
monitor = mlast ? mlast->next : RFAPI_MONITOR_VPN(par); monitor = mlast ? mlast->next : RFAPI_MONITOR_VPN(par);
RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN, 1); RFAPI_CHECK_REFCOUNT(par, SAFI_MPLS_VPN, 1);
/* decr refcount after we're done with par as this might /* decr refcount after we're done with par as this might
* free it */ * free it */
route_unlock_node(par); agg_unlock_node(par);
continue; continue;
} }
@ -919,10 +923,10 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it)
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_node *rn; struct agg_node *rn;
for (rn = route_top(it->imported_vpn[afi]); rn; for (rn = agg_route_top(it->imported_vpn[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
/* /*
* Each route_node has: * Each route_node has:
* aggregate: points to rfapi_it_extra with monitor * aggregate: points to rfapi_it_extra with monitor
@ -936,8 +940,8 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it)
rfapiMonitorExtraFlush(SAFI_MPLS_VPN, rn); rfapiMonitorExtraFlush(SAFI_MPLS_VPN, rn);
} }
for (rn = route_top(it->imported_encap[afi]); rn; for (rn = agg_route_top(it->imported_encap[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
/* free bgp_info and its children */ /* free bgp_info and its children */
rfapiBgpInfoChainFree(rn->info); rfapiBgpInfoChainFree(rn->info);
rn->info = NULL; rn->info = NULL;
@ -945,8 +949,8 @@ static void rfapiImportTableFlush(struct rfapi_import_table *it)
rfapiMonitorExtraFlush(SAFI_ENCAP, rn); rfapiMonitorExtraFlush(SAFI_ENCAP, rn);
} }
route_table_finish(it->imported_vpn[afi]); agg_table_finish(it->imported_vpn[afi]);
route_table_finish(it->imported_encap[afi]); agg_table_finish(it->imported_encap[afi]);
} }
if (it->monitor_exterior_orphans) { if (it->monitor_exterior_orphans) {
skiplist_free(it->monitor_exterior_orphans); skiplist_free(it->monitor_exterior_orphans);
@ -1295,7 +1299,7 @@ static struct rfapi_next_hop_entry *
rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix, rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
struct bgp_info *bi, /* route to encode */ struct bgp_info *bi, /* route to encode */
uint32_t lifetime, /* use this in nhe */ uint32_t lifetime, /* use this in nhe */
struct route_node *rn) /* req for L2 eth addr */ struct agg_node *rn) /* req for L2 eth addr */
{ {
struct rfapi_next_hop_entry *new; struct rfapi_next_hop_entry *new;
int have_vnc_tunnel_un = 0; int have_vnc_tunnel_un = 0;
@ -1481,7 +1485,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
return new; return new;
} }
int rfapiHasNonRemovedRoutes(struct route_node *rn) int rfapiHasNonRemovedRoutes(struct agg_node *rn)
{ {
struct bgp_info *bi; struct bgp_info *bi;
@ -1501,7 +1505,7 @@ int rfapiHasNonRemovedRoutes(struct route_node *rn)
/* /*
* DEBUG FUNCTION * DEBUG FUNCTION
*/ */
void rfapiDumpNode(struct route_node *rn) void rfapiDumpNode(struct agg_node *rn)
{ {
struct bgp_info *bi; struct bgp_info *bi;
@ -1527,14 +1531,14 @@ void rfapiDumpNode(struct route_node *rn)
#endif #endif
static int rfapiNhlAddNodeRoutes( static int rfapiNhlAddNodeRoutes(
struct route_node *rn, /* in */ struct agg_node *rn, /* in */
struct rfapi_ip_prefix *rprefix, /* in */ struct rfapi_ip_prefix *rprefix, /* in */
uint32_t lifetime, /* in */ uint32_t lifetime, /* in */
int removed, /* in */ int removed, /* in */
struct rfapi_next_hop_entry **head, /* in/out */ struct rfapi_next_hop_entry **head, /* in/out */
struct rfapi_next_hop_entry **tail, /* in/out */ struct rfapi_next_hop_entry **tail, /* in/out */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_node *rfd_rib_node, /* preload this NVE rib node */ struct agg_node *rfd_rib_node, /* preload this NVE rib node */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct bgp_info *bi; struct bgp_info *bi;
@ -1544,16 +1548,18 @@ static int rfapiNhlAddNodeRoutes(
int count = 0; int count = 0;
int is_l2 = (rn->p.family == AF_ETHERNET); int is_l2 = (rn->p.family == AF_ETHERNET);
if (rfd_rib_node && rfd_rib_node->table && rfd_rib_node->table->info) { if (rfd_rib_node) {
struct agg_table *atable = agg_get_table(rfd_rib_node);
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
rfd = (struct rfapi_descriptor *)(rfd_rib_node->table->info); if (atable) {
rfd = agg_get_table_info(atable);
if (rfapiRibFTDFilterRecentPrefix(
rfd, rn, pfx_target_original))
if (rfapiRibFTDFilterRecentPrefix(rfd, rn,
pfx_target_original))
return 0; return 0;
} }
}
seen_nexthops = seen_nexthops =
skiplist_new(0, vnc_prefix_cmp, (void (*)(void *))prefix_free); skiplist_new(0, vnc_prefix_cmp, (void (*)(void *))prefix_free);
@ -1657,13 +1663,13 @@ static int rfapiNhlAddNodeRoutes(
* matches (of course, we still travel down its child subtrees). * matches (of course, we still travel down its child subtrees).
*/ */
static int rfapiNhlAddSubtree( static int rfapiNhlAddSubtree(
struct route_node *rn, /* in */ struct agg_node *rn, /* in */
uint32_t lifetime, /* in */ uint32_t lifetime, /* in */
struct rfapi_next_hop_entry **head, /* in/out */ struct rfapi_next_hop_entry **head, /* in/out */
struct rfapi_next_hop_entry **tail, /* in/out */ struct rfapi_next_hop_entry **tail, /* in/out */
struct route_node *omit_node, /* in */ struct agg_node *omit_node, /* in */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload here */ struct agg_table *rfd_rib_table, /* preload here */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct rfapi_ip_prefix rprefix; struct rfapi_ip_prefix rprefix;
@ -1671,65 +1677,67 @@ static int rfapiNhlAddSubtree(
/* FIXME: need to find a better way here to work without sticking our /* FIXME: need to find a better way here to work without sticking our
* hands in node->link */ * hands in node->link */
if (rn->l_left && rn->l_left != omit_node) { if (agg_node_left(rn) && agg_node_left(rn) != omit_node) {
if (rn->l_left->info) { if (agg_node_left(rn)->info) {
int count = 0; int count = 0;
struct route_node *rib_rn = NULL; struct agg_node *rib_rn = NULL;
rfapiQprefix2Rprefix(&rn->l_left->p, &rprefix); rfapiQprefix2Rprefix(&agg_node_left(rn)->p, &rprefix);
if (rfd_rib_table) { if (rfd_rib_table) {
rib_rn = route_node_get(rfd_rib_table, rib_rn = agg_node_get(rfd_rib_table,
&rn->l_left->p); &agg_node_left(rn)->p);
} }
count = rfapiNhlAddNodeRoutes( count = rfapiNhlAddNodeRoutes(
rn->l_left, &rprefix, lifetime, 0, head, tail, agg_node_left(rn), &rprefix, lifetime, 0, head,
exclude_vnaddr, rib_rn, pfx_target_original);
if (!count) {
count = rfapiNhlAddNodeRoutes(
rn->l_left, &rprefix, lifetime, 1, head,
tail, exclude_vnaddr, rib_rn, tail, exclude_vnaddr, rib_rn,
pfx_target_original); pfx_target_original);
}
rcount += count;
if (rib_rn)
route_unlock_node(rib_rn);
}
}
if (rn->l_right && rn->l_right != omit_node) {
if (rn->l_right->info) {
int count = 0;
struct route_node *rib_rn = NULL;
rfapiQprefix2Rprefix(&rn->l_right->p, &rprefix);
if (rfd_rib_table) {
rib_rn = route_node_get(rfd_rib_table,
&rn->l_right->p);
}
count = rfapiNhlAddNodeRoutes(
rn->l_right, &rprefix, lifetime, 0, head, tail,
exclude_vnaddr, rib_rn, pfx_target_original);
if (!count) { if (!count) {
count = rfapiNhlAddNodeRoutes( count = rfapiNhlAddNodeRoutes(
rn->l_right, &rprefix, lifetime, 1, agg_node_left(rn), &rprefix, lifetime,
head, tail, exclude_vnaddr, rib_rn, 1, head, tail, exclude_vnaddr, rib_rn,
pfx_target_original); pfx_target_original);
} }
rcount += count; rcount += count;
if (rib_rn) if (rib_rn)
route_unlock_node(rib_rn); agg_unlock_node(rib_rn);
} }
} }
if (rn->l_left) { if (agg_node_right(rn) && agg_node_right(rn) != omit_node) {
if (agg_node_right(rn)->info) {
int count = 0;
struct agg_node *rib_rn = NULL;
rfapiQprefix2Rprefix(&agg_node_right(rn)->p, &rprefix);
if (rfd_rib_table) {
rib_rn = agg_node_get(rfd_rib_table,
&agg_node_right(rn)->p);
}
count = rfapiNhlAddNodeRoutes(
agg_node_right(rn), &rprefix, lifetime, 0, head,
tail, exclude_vnaddr, rib_rn,
pfx_target_original);
if (!count) {
count = rfapiNhlAddNodeRoutes(
agg_node_right(rn), &rprefix, lifetime,
1, head, tail, exclude_vnaddr, rib_rn,
pfx_target_original);
}
rcount += count;
if (rib_rn)
agg_unlock_node(rib_rn);
}
}
if (agg_node_left(rn)) {
rcount += rfapiNhlAddSubtree( rcount += rfapiNhlAddSubtree(
rn->l_left, lifetime, head, tail, omit_node, agg_node_left(rn), lifetime, head, tail, omit_node,
exclude_vnaddr, rfd_rib_table, pfx_target_original); exclude_vnaddr, rfd_rib_table, pfx_target_original);
} }
if (rn->l_right) { if (agg_node_right(rn)) {
rcount += rfapiNhlAddSubtree( rcount += rfapiNhlAddSubtree(
rn->l_right, lifetime, head, tail, omit_node, agg_node_right(rn), lifetime, head, tail, omit_node,
exclude_vnaddr, rfd_rib_table, pfx_target_original); exclude_vnaddr, rfd_rib_table, pfx_target_original);
} }
@ -1748,17 +1756,17 @@ static int rfapiNhlAddSubtree(
* next less-specific node (i.e., this node's parent) at the end. * next less-specific node (i.e., this node's parent) at the end.
*/ */
struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
struct route_node *rn, uint32_t lifetime, /* put into nexthop entries */ struct agg_node *rn, uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload here */ struct agg_table *rfd_rib_table, /* preload here */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct rfapi_ip_prefix rprefix; struct rfapi_ip_prefix rprefix;
struct rfapi_next_hop_entry *answer = NULL; struct rfapi_next_hop_entry *answer = NULL;
struct rfapi_next_hop_entry *last = NULL; struct rfapi_next_hop_entry *last = NULL;
struct route_node *parent; struct agg_node *parent;
int count = 0; int count = 0;
struct route_node *rib_rn; struct agg_node *rib_rn;
#if DEBUG_RETURNED_NHL #if DEBUG_RETURNED_NHL
{ {
@ -1773,7 +1781,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
rfapiQprefix2Rprefix(&rn->p, &rprefix); rfapiQprefix2Rprefix(&rn->p, &rprefix);
rib_rn = rfd_rib_table ? route_node_get(rfd_rib_table, &rn->p) : NULL; rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL;
/* /*
* Add non-withdrawn routes at this node * Add non-withdrawn routes at this node
@ -1795,7 +1803,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
rfapiPrintNhl(NULL, answer); rfapiPrintNhl(NULL, answer);
#endif #endif
if (rib_rn) if (rib_rn)
route_unlock_node(rib_rn); agg_unlock_node(rib_rn);
return answer; return answer;
} }
@ -1806,7 +1814,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
exclude_vnaddr, rib_rn, exclude_vnaddr, rib_rn,
pfx_target_original); pfx_target_original);
if (rib_rn) if (rib_rn)
route_unlock_node(rib_rn); agg_unlock_node(rib_rn);
// rfapiPrintNhl(NULL, answer); // rfapiPrintNhl(NULL, answer);
@ -1814,7 +1822,8 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
* walk up the tree until we find a node with non-deleted * walk up the tree until we find a node with non-deleted
* routes, then add them * routes, then add them
*/ */
for (parent = rn->parent; parent; parent = parent->parent) { for (parent = agg_node_parent(rn); parent;
parent = agg_node_parent(parent)) {
if (rfapiHasNonRemovedRoutes(parent)) { if (rfapiHasNonRemovedRoutes(parent)) {
break; break;
} }
@ -1824,8 +1833,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
* Add non-withdrawn routes from less-specific prefix * Add non-withdrawn routes from less-specific prefix
*/ */
if (parent) { if (parent) {
rib_rn = rfd_rib_table rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &parent->p)
? route_node_get(rfd_rib_table, &parent->p)
: NULL; : NULL;
rfapiQprefix2Rprefix(&parent->p, &rprefix); rfapiQprefix2Rprefix(&parent->p, &rprefix);
count += rfapiNhlAddNodeRoutes(parent, &rprefix, lifetime, 0, count += rfapiNhlAddNodeRoutes(parent, &rprefix, lifetime, 0,
@ -1835,7 +1843,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
rn, exclude_vnaddr, rfd_rib_table, rn, exclude_vnaddr, rfd_rib_table,
pfx_target_original); pfx_target_original);
if (rib_rn) if (rib_rn)
route_unlock_node(rib_rn); agg_unlock_node(rib_rn);
} else { } else {
/* /*
* There is no parent with non-removed routes. Still need to * There is no parent with non-removed routes. Still need to
@ -1861,19 +1869,18 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
* Construct nexthop list of all routes in table * Construct nexthop list of all routes in table
*/ */
struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList( struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList(
struct route_table *rt, struct agg_table *rt, uint32_t lifetime, /* put into nexthop entries */
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload this NVE rib table */ struct agg_table *rfd_rib_table, /* preload this NVE rib table */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct route_node *rn; struct agg_node *rn;
struct rfapi_next_hop_entry *biglist = NULL; struct rfapi_next_hop_entry *biglist = NULL;
struct rfapi_next_hop_entry *nhl; struct rfapi_next_hop_entry *nhl;
struct rfapi_next_hop_entry *tail = NULL; struct rfapi_next_hop_entry *tail = NULL;
int count = 0; int count = 0;
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
nhl = rfapiRouteNode2NextHopList(rn, lifetime, exclude_vnaddr, nhl = rfapiRouteNode2NextHopList(rn, lifetime, exclude_vnaddr,
rfd_rib_table, rfd_rib_table,
@ -1898,18 +1905,18 @@ struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList(
} }
struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
struct route_node *rn, struct rfapi_ip_prefix *rprefix, struct agg_node *rn, struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */ uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload NVE rib table */ struct agg_table *rfd_rib_table, /* preload NVE rib table */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
int count = 0; int count = 0;
struct rfapi_next_hop_entry *answer = NULL; struct rfapi_next_hop_entry *answer = NULL;
struct rfapi_next_hop_entry *last = NULL; struct rfapi_next_hop_entry *last = NULL;
struct route_node *rib_rn; struct agg_node *rib_rn;
rib_rn = rfd_rib_table ? route_node_get(rfd_rib_table, &rn->p) : NULL; rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL;
count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last, count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last,
NULL, rib_rn, pfx_target_original); NULL, rib_rn, pfx_target_original);
@ -1928,7 +1935,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
} }
if (rib_rn) if (rib_rn)
route_unlock_node(rib_rn); agg_unlock_node(rib_rn);
#if DEBUG_RETURNED_NHL #if DEBUG_RETURNED_NHL
rfapiPrintNhl(NULL, answer); rfapiPrintNhl(NULL, answer);
@ -1945,13 +1952,13 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList(
uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix, uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */ uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload NVE rib node */ struct agg_table *rfd_rib_table, /* preload NVE rib node */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct rfapi_import_table *it; struct rfapi_import_table *it;
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
struct route_table *rt; struct agg_table *rt;
struct route_node *rn; struct agg_node *rn;
struct rfapi_next_hop_entry *biglist = NULL; struct rfapi_next_hop_entry *biglist = NULL;
struct rfapi_next_hop_entry *nhl; struct rfapi_next_hop_entry *nhl;
struct rfapi_next_hop_entry *tail = NULL; struct rfapi_next_hop_entry *tail = NULL;
@ -1961,7 +1968,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList(
it = rfapiMacImportTableGet(bgp, logical_net_id); it = rfapiMacImportTableGet(bgp, logical_net_id);
rt = it->imported_vpn[AFI_L2VPN]; rt = it->imported_vpn[AFI_L2VPN];
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
nhl = rfapiEthRouteNode2NextHopList( nhl = rfapiEthRouteNode2NextHopList(
rn, rprefix, lifetime, exclude_vnaddr, rfd_rib_table, rn, rprefix, lifetime, exclude_vnaddr, rfd_rib_table,
@ -1989,7 +1996,7 @@ struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList(
* Insert a new bi to the imported route table node, * Insert a new bi to the imported route table node,
* keeping the list of BIs sorted best route first * keeping the list of BIs sorted best route first
*/ */
static void rfapiBgpInfoAttachSorted(struct route_node *rn, static void rfapiBgpInfoAttachSorted(struct agg_node *rn,
struct bgp_info *info_new, afi_t afi, struct bgp_info *info_new, afi_t afi,
safi_t safi) safi_t safi)
{ {
@ -2031,7 +2038,7 @@ static void rfapiBgpInfoAttachSorted(struct route_node *rn,
bgp_attr_intern(info_new->attr); bgp_attr_intern(info_new->attr);
} }
static void rfapiBgpInfoDetach(struct route_node *rn, struct bgp_info *bi) static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_info *bi)
{ {
/* /*
* Remove the route (doubly-linked) * Remove the route (doubly-linked)
@ -2127,7 +2134,7 @@ static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2)
/* /*
* Index on RD and Peer * Index on RD and Peer
*/ */
static void rfapiItBiIndexAdd(struct route_node *rn, /* Import table VPN node */ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */
struct bgp_info *bi) /* new BI */ struct bgp_info *bi) /* new BI */
{ {
struct skiplist *sl; struct skiplist *sl;
@ -2153,15 +2160,15 @@ static void rfapiItBiIndexAdd(struct route_node *rn, /* Import table VPN node */
sl = skiplist_new(0, rfapi_bi_peer_rd_cmp, NULL); sl = skiplist_new(0, rfapi_bi_peer_rd_cmp, NULL);
} }
RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd = sl; RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd = sl;
route_lock_node(rn); /* for skiplist */ agg_lock_node(rn); /* for skiplist */
} }
assert(!skiplist_insert(sl, (void *)bi, (void *)bi)); assert(!skiplist_insert(sl, (void *)bi, (void *)bi));
route_lock_node(rn); /* for skiplist entry */ agg_lock_node(rn); /* for skiplist entry */
/* NB: BIs in import tables are not refcounted */ /* NB: BIs in import tables are not refcounted */
} }
static void rfapiItBiIndexDump(struct route_node *rn) static void rfapiItBiIndexDump(struct agg_node *rn)
{ {
struct skiplist *sl; struct skiplist *sl;
void *cursor = NULL; void *cursor = NULL;
@ -2192,7 +2199,7 @@ static void rfapiItBiIndexDump(struct route_node *rn)
} }
static struct bgp_info *rfapiItBiIndexSearch( static struct bgp_info *rfapiItBiIndexSearch(
struct route_node *rn, /* Import table VPN node */ struct agg_node *rn, /* Import table VPN node */
struct prefix_rd *prd, struct peer *peer, struct prefix_rd *prd, struct peer *peer,
struct prefix *aux_prefix) /* optional L3 addr for L2 ITs */ struct prefix *aux_prefix) /* optional L3 addr for L2 ITs */
{ {
@ -2298,7 +2305,7 @@ static struct bgp_info *rfapiItBiIndexSearch(
return bi_result; return bi_result;
} }
static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */ static void rfapiItBiIndexDel(struct agg_node *rn, /* Import table VPN node */
struct bgp_info *bi) /* old BI */ struct bgp_info *bi) /* old BI */
{ {
struct skiplist *sl; struct skiplist *sl;
@ -2322,7 +2329,7 @@ static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */
} }
assert(!rc); assert(!rc);
route_unlock_node(rn); /* for skiplist entry */ agg_unlock_node(rn); /* for skiplist entry */
/* NB: BIs in import tables are not refcounted */ /* NB: BIs in import tables are not refcounted */
} }
@ -2333,16 +2340,15 @@ static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */
*/ */
static void rfapiMonitorEncapAdd(struct rfapi_import_table *import_table, static void rfapiMonitorEncapAdd(struct rfapi_import_table *import_table,
struct prefix *p, /* VN address */ struct prefix *p, /* VN address */
struct route_node *vpn_rn, /* VPN node */ struct agg_node *vpn_rn, /* VPN node */
struct bgp_info *vpn_bi) /* VPN bi/route */ struct bgp_info *vpn_bi) /* VPN bi/route */
{ {
afi_t afi = family2afi(p->family); afi_t afi = family2afi(p->family);
struct route_node *rn; struct agg_node *rn;
struct rfapi_monitor_encap *m; struct rfapi_monitor_encap *m;
assert(afi); assert(afi);
rn = route_node_get(import_table->imported_encap[afi], rn = agg_node_get(import_table->imported_encap[afi], p); /* locks rn */
p); /* locks rn */
assert(rn); assert(rn);
m = XCALLOC(MTYPE_RFAPI_MONITOR_ENCAP, m = XCALLOC(MTYPE_RFAPI_MONITOR_ENCAP,
@ -2399,7 +2405,7 @@ static void rfapiMonitorEncapDelete(struct bgp_info *vpn_bi)
* freed */ * freed */
rfapiMonitorExtraPrune(SAFI_ENCAP, hme->rn); rfapiMonitorExtraPrune(SAFI_ENCAP, hme->rn);
route_unlock_node(hme->rn); /* decr ref count */ agg_unlock_node(hme->rn); /* decr ref count */
XFREE(MTYPE_RFAPI_MONITOR_ENCAP, hme); XFREE(MTYPE_RFAPI_MONITOR_ENCAP, hme);
vpn_bi->extra->vnc.import.hme = NULL; vpn_bi->extra->vnc.import.hme = NULL;
} }
@ -2533,7 +2539,7 @@ done:
} }
RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, 1 + wcb->lockoffset); RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, 1 + wcb->lockoffset);
route_unlock_node(wcb->node); /* decr ref count */ agg_unlock_node(wcb->node); /* decr ref count */
XFREE(MTYPE_RFAPI_WITHDRAW, wcb); XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
return 0; return 0;
} }
@ -2660,7 +2666,7 @@ static void rfapiCopyUnEncap2VPN(struct bgp_info *encap_bi,
*/ */
static int rfapiWithdrawEncapUpdateCachedUn( static int rfapiWithdrawEncapUpdateCachedUn(
struct rfapi_import_table *import_table, struct bgp_info *encap_bi, struct rfapi_import_table *import_table, struct bgp_info *encap_bi,
struct route_node *vpn_rn, struct bgp_info *vpn_bi) struct agg_node *vpn_rn, struct bgp_info *vpn_bi)
{ {
if (!encap_bi) { if (!encap_bi) {
@ -2762,7 +2768,7 @@ static int rfapiWithdrawTimerEncap(struct thread *t)
/* /*
* for each VPN node referenced in the ENCAP monitors: * for each VPN node referenced in the ENCAP monitors:
*/ */
struct route_node *rn; struct agg_node *rn;
while (!skiplist_first(vpn_node_sl, (void **)&rn, NULL)) { while (!skiplist_first(vpn_node_sl, (void **)&rn, NULL)) {
if (!wcb->node->info) { if (!wcb->node->info) {
struct rfapi_monitor_vpn *moved; struct rfapi_monitor_vpn *moved;
@ -2783,7 +2789,7 @@ static int rfapiWithdrawTimerEncap(struct thread *t)
done: done:
RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_ENCAP, 1); RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_ENCAP, 1);
route_unlock_node(wcb->node); /* decr ref count */ agg_unlock_node(wcb->node); /* decr ref count */
XFREE(MTYPE_RFAPI_WITHDRAW, wcb); XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
skiplist_free(vpn_node_sl); skiplist_free(vpn_node_sl);
return 0; return 0;
@ -2796,7 +2802,7 @@ done:
*/ */
static void static void
rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table, rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table,
struct route_node *rn, struct bgp_info *bi, afi_t afi, struct agg_node *rn, struct bgp_info *bi, afi_t afi,
safi_t safi, safi_t safi,
int (*timer_service_func)(struct thread *)) int (*timer_service_func)(struct thread *))
{ {
@ -2886,7 +2892,7 @@ typedef void(rfapi_bi_filtered_import_f)(struct rfapi_import_table *, int,
static void rfapiExpireEncapNow(struct rfapi_import_table *it, static void rfapiExpireEncapNow(struct rfapi_import_table *it,
struct route_node *rn, struct bgp_info *bi) struct agg_node *rn, struct bgp_info *bi)
{ {
struct rfapi_withdraw *wcb; struct rfapi_withdraw *wcb;
struct thread t; struct thread t;
@ -2939,8 +2945,8 @@ static void rfapiBgpInfoFilteredImportEncap(
uint8_t sub_type, /* part of bgp_info */ uint8_t sub_type, /* part of bgp_info */
uint32_t *label) /* part of bgp_info */ uint32_t *label) /* part of bgp_info */
{ {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct bgp_info *info_new; struct bgp_info *info_new;
struct bgp_info *bi; struct bgp_info *bi;
struct bgp_info *next; struct bgp_info *next;
@ -3034,10 +3040,10 @@ static void rfapiBgpInfoFilteredImportEncap(
} }
/* /*
* route_node_lookup returns a node only if there is at least * agg_node_lookup returns a node only if there is at least
* one route attached. * one route attached.
*/ */
rn = route_node_lookup(rt, p); rn = agg_node_lookup(rt, p);
#if DEBUG_ENCAP_MONITOR #if DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: initial encap lookup(it=%p) rn=%p", vnc_zlog_debug_verbose("%s: initial encap lookup(it=%p) rn=%p",
@ -3047,7 +3053,7 @@ static void rfapiBgpInfoFilteredImportEncap(
if (rn) { if (rn) {
RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 1); RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 1);
route_unlock_node(rn); /* undo lock in route_node_lookup */ agg_unlock_node(rn); /* undo lock in agg_node_lookup */
/* /*
@ -3187,9 +3193,9 @@ static void rfapiBgpInfoFilteredImportEncap(
if (rn) { if (rn) {
if (!replacing) if (!replacing)
route_lock_node(rn); /* incr ref count for new BI */ agg_lock_node(rn); /* incr ref count for new BI */
} else { } else {
rn = route_node_get(rt, p); rn = agg_node_get(rt, p);
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -3254,7 +3260,7 @@ static void rfapiBgpInfoFilteredImportEncap(
struct rfapi_monitor_encap *m; struct rfapi_monitor_encap *m;
struct rfapi_monitor_encap *mnext; struct rfapi_monitor_encap *mnext;
struct route_node *referenced_vpn_prefix; struct agg_node *referenced_vpn_prefix;
/* /*
* Optimized approach: build radix tree on the fly to * Optimized approach: build radix tree on the fly to
@ -3265,9 +3271,9 @@ static void rfapiBgpInfoFilteredImportEncap(
* struct rfapi_monitor_encap, each of which refers to a * struct rfapi_monitor_encap, each of which refers to a
* specific VPN node. * specific VPN node.
*/ */
struct route_table *referenced_vpn_table; struct agg_table *referenced_vpn_table;
referenced_vpn_table = route_table_init(); referenced_vpn_table = agg_table_init();
assert(referenced_vpn_table); assert(referenced_vpn_table);
/* /*
@ -3306,8 +3312,8 @@ static void rfapiBgpInfoFilteredImportEncap(
* per prefix. * per prefix.
*/ */
referenced_vpn_prefix = route_node_get( referenced_vpn_prefix =
referenced_vpn_table, &m->node->p); agg_node_get(referenced_vpn_table, &m->node->p);
assert(referenced_vpn_prefix); assert(referenced_vpn_prefix);
for (mnext = referenced_vpn_prefix->info; mnext; for (mnext = referenced_vpn_prefix->info; mnext;
mnext = mnext->next) { mnext = mnext->next) {
@ -3320,7 +3326,7 @@ static void rfapiBgpInfoFilteredImportEncap(
/* /*
* already have an entry for this VPN node * already have an entry for this VPN node
*/ */
route_unlock_node(referenced_vpn_prefix); agg_unlock_node(referenced_vpn_prefix);
} else { } else {
mnext = XCALLOC( mnext = XCALLOC(
MTYPE_RFAPI_MONITOR_ENCAP, MTYPE_RFAPI_MONITOR_ENCAP,
@ -3335,16 +3341,18 @@ static void rfapiBgpInfoFilteredImportEncap(
/* /*
* for each VPN node referenced in the ENCAP monitors: * for each VPN node referenced in the ENCAP monitors:
*/ */
for (referenced_vpn_prefix = route_top(referenced_vpn_table); for (referenced_vpn_prefix =
referenced_vpn_prefix; referenced_vpn_prefix = route_next( agg_route_top(referenced_vpn_table);
referenced_vpn_prefix)) { referenced_vpn_prefix;
referenced_vpn_prefix =
agg_route_next(referenced_vpn_prefix)) {
while ((m = referenced_vpn_prefix->info)) { while ((m = referenced_vpn_prefix->info)) {
struct route_node *n; struct agg_node *n;
rfapiMonitorMoveLonger(m->node); rfapiMonitorMoveLonger(m->node);
for (n = m->node; n; n = n->parent) { for (n = m->node; n; n = agg_node_parent(n)) {
// rfapiDoRouteCallback(import_table, n, // rfapiDoRouteCallback(import_table, n,
// NULL); // NULL);
} }
@ -3352,18 +3360,18 @@ static void rfapiBgpInfoFilteredImportEncap(
NULL); NULL);
referenced_vpn_prefix->info = m->next; referenced_vpn_prefix->info = m->next;
route_unlock_node(referenced_vpn_prefix); agg_unlock_node(referenced_vpn_prefix);
XFREE(MTYPE_RFAPI_MONITOR_ENCAP, m); XFREE(MTYPE_RFAPI_MONITOR_ENCAP, m);
} }
} }
route_table_finish(referenced_vpn_table); agg_table_finish(referenced_vpn_table);
} }
RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 0); RFAPI_CHECK_REFCOUNT(rn, SAFI_ENCAP, 0);
} }
static void rfapiExpireVpnNow(struct rfapi_import_table *it, static void rfapiExpireVpnNow(struct rfapi_import_table *it,
struct route_node *rn, struct bgp_info *bi, struct agg_node *rn, struct bgp_info *bi,
int lockoffset) int lockoffset)
{ {
struct rfapi_withdraw *wcb; struct rfapi_withdraw *wcb;
@ -3398,9 +3406,9 @@ void rfapiBgpInfoFilteredImportVPN(
uint8_t sub_type, /* part of bgp_info */ uint8_t sub_type, /* part of bgp_info */
uint32_t *label) /* part of bgp_info */ uint32_t *label) /* part of bgp_info */
{ {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct route_node *n; struct agg_node *n;
struct bgp_info *info_new; struct bgp_info *info_new;
struct bgp_info *bi; struct bgp_info *bi;
struct bgp_info *next; struct bgp_info *next;
@ -3408,7 +3416,7 @@ void rfapiBgpInfoFilteredImportVPN(
struct prefix vn_prefix; struct prefix vn_prefix;
struct prefix un_prefix; struct prefix un_prefix;
int un_prefix_valid = 0; int un_prefix_valid = 0;
struct route_node *ern; struct agg_node *ern;
int replacing = 0; int replacing = 0;
int original_had_routes = 0; int original_had_routes = 0;
struct prefix original_nexthop; struct prefix original_nexthop;
@ -3494,17 +3502,17 @@ void rfapiBgpInfoFilteredImportVPN(
memset(&original_nexthop, 0, sizeof(original_nexthop)); memset(&original_nexthop, 0, sizeof(original_nexthop));
/* /*
* route_node_lookup returns a node only if there is at least * agg_node_lookup returns a node only if there is at least
* one route attached. * one route attached.
*/ */
rn = route_node_lookup(rt, p); rn = agg_node_lookup(rt, p);
vnc_zlog_debug_verbose("%s: rn=%p", __func__, rn); vnc_zlog_debug_verbose("%s: rn=%p", __func__, rn);
if (rn) { if (rn) {
RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1); RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1);
route_unlock_node(rn); /* undo lock in route_node_lookup */ agg_unlock_node(rn); /* undo lock in agg_node_lookup */
if (rn->info) if (rn->info)
original_had_routes = 1; original_had_routes = 1;
@ -3667,10 +3675,10 @@ void rfapiBgpInfoFilteredImportVPN(
/* /*
* lookup un address in encap table * lookup un address in encap table
*/ */
ern = route_node_match(import_table->imported_encap[afi], &vn_prefix); ern = agg_node_match(import_table->imported_encap[afi], &vn_prefix);
if (ern) { if (ern) {
rfapiCopyUnEncap2VPN(ern->info, info_new); rfapiCopyUnEncap2VPN(ern->info, info_new);
route_unlock_node(ern); /* undo lock in route_note_match */ agg_unlock_node(ern); /* undo lock in route_note_match */
} else { } else {
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN];
@ -3683,13 +3691,13 @@ void rfapiBgpInfoFilteredImportVPN(
if (rn) { if (rn) {
if (!replacing) if (!replacing)
route_lock_node(rn); agg_lock_node(rn);
} else { } else {
/* /*
* No need to increment reference count, so only "get" * No need to increment reference count, so only "get"
* if the node is not there already * if the node is not there already
*/ */
rn = route_node_get(rt, p); rn = agg_node_get(rt, p);
} }
/* /*
@ -3856,7 +3864,7 @@ void rfapiBgpInfoFilteredImportVPN(
} }
if (!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE)) { if (!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE)) {
for (n = rn; n; n = n->parent) { for (n = rn; n; n = agg_node_parent(n)) {
// rfapiDoRouteCallback(import_table, n, NULL); // rfapiDoRouteCallback(import_table, n, NULL);
} }
rfapiMonitorItNodeChanged(import_table, rn, NULL); rfapiMonitorItNodeChanged(import_table, rn, NULL);
@ -4108,9 +4116,9 @@ static void rfapiProcessPeerDownRt(struct peer *peer,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
afi_t afi, safi_t safi) afi_t afi, safi_t safi)
{ {
struct route_node *rn; struct agg_node *rn;
struct bgp_info *bi; struct bgp_info *bi;
struct route_table *rt; struct agg_table *rt;
int (*timer_service_func)(struct thread *); int (*timer_service_func)(struct thread *);
assert(afi == AFI_IP || afi == AFI_IP6); assert(afi == AFI_IP || afi == AFI_IP6);
@ -4131,7 +4139,7 @@ static void rfapiProcessPeerDownRt(struct peer *peer,
} }
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
for (bi = rn->info; bi; bi = bi->next) { for (bi = rn->info; bi; bi = bi->next) {
if (bi->peer == peer) { if (bi->peer == peer) {
@ -4274,7 +4282,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi)); h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
h->un[afi] = route_table_init(); h->un[afi] = agg_table_init();
} }
/* /*
@ -4282,10 +4290,10 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
*/ */
h->it_ce = XCALLOC(MTYPE_RFAPI_IMPORTTABLE, h->it_ce = XCALLOC(MTYPE_RFAPI_IMPORTTABLE,
sizeof(struct rfapi_import_table)); sizeof(struct rfapi_import_table));
h->it_ce->imported_vpn[AFI_IP] = route_table_init(); h->it_ce->imported_vpn[AFI_IP] = agg_table_init();
h->it_ce->imported_vpn[AFI_IP6] = route_table_init(); h->it_ce->imported_vpn[AFI_IP6] = agg_table_init();
h->it_ce->imported_encap[AFI_IP] = route_table_init(); h->it_ce->imported_encap[AFI_IP] = agg_table_init();
h->it_ce->imported_encap[AFI_IP6] = route_table_init(); h->it_ce->imported_encap[AFI_IP6] = agg_table_init();
rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP, SAFI_MPLS_VPN); rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP, SAFI_MPLS_VPN);
rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP6, SAFI_MPLS_VPN); rfapiBgpTableFilteredImport(bgp, h->it_ce, AFI_IP6, SAFI_MPLS_VPN);
@ -4317,10 +4325,10 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h)
h->resolve_nve_nexthop = NULL; h->resolve_nve_nexthop = NULL;
} }
route_table_finish(h->it_ce->imported_vpn[AFI_IP]); agg_table_finish(h->it_ce->imported_vpn[AFI_IP]);
route_table_finish(h->it_ce->imported_vpn[AFI_IP6]); agg_table_finish(h->it_ce->imported_vpn[AFI_IP6]);
route_table_finish(h->it_ce->imported_encap[AFI_IP]); agg_table_finish(h->it_ce->imported_encap[AFI_IP]);
route_table_finish(h->it_ce->imported_encap[AFI_IP6]); agg_table_finish(h->it_ce->imported_encap[AFI_IP6]);
if (h->import_mac) { if (h->import_mac) {
struct rfapi_import_table *it; struct rfapi_import_table *it;
@ -4346,7 +4354,7 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h)
rfp_stop(h->rfp); rfp_stop(h->rfp);
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
route_table_finish(h->un[afi]); agg_table_finish(h->un[afi]);
} }
XFREE(MTYPE_RFAPI_IMPORTTABLE, h->it_ce); XFREE(MTYPE_RFAPI_IMPORTTABLE, h->it_ce);
@ -4394,8 +4402,8 @@ rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list,
*/ */
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
it->imported_vpn[afi] = route_table_init(); it->imported_vpn[afi] = agg_table_init();
it->imported_encap[afi] = route_table_init(); it->imported_encap[afi] = agg_table_init();
rfapiBgpTableFilteredImport(bgp, it, afi, rfapiBgpTableFilteredImport(bgp, it, afi,
SAFI_MPLS_VPN); SAFI_MPLS_VPN);
@ -4452,8 +4460,8 @@ static void rfapiDeleteRemotePrefixesIt(
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_table *rt; struct agg_table *rt;
struct route_node *rn; struct agg_node *rn;
if (p && (family2afi(p->family) != afi)) { if (p && (family2afi(p->family) != afi)) {
continue; continue;
@ -4466,7 +4474,7 @@ static void rfapiDeleteRemotePrefixesIt(
vnc_zlog_debug_verbose("%s: scanning rt for afi=%d", __func__, vnc_zlog_debug_verbose("%s: scanning rt for afi=%d", __func__,
afi); afi);
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
struct bgp_info *bi; struct bgp_info *bi;
struct bgp_info *next; struct bgp_info *next;

View File

@ -40,10 +40,10 @@ struct rfapi_import_table {
struct ecommunity *rt_import_list; /* copied from nve grp */ struct ecommunity *rt_import_list; /* copied from nve grp */
int refcount; /* nve grps and nves */ int refcount; /* nve grps and nves */
uint32_t l2_logical_net_id; /* L2 only: EVPN Eth Seg Id */ uint32_t l2_logical_net_id; /* L2 only: EVPN Eth Seg Id */
struct route_table *imported_vpn[AFI_MAX]; struct agg_table *imported_vpn[AFI_MAX];
struct rfapi_monitor_vpn *vpn0_queries[AFI_MAX]; struct rfapi_monitor_vpn *vpn0_queries[AFI_MAX];
struct rfapi_monitor_eth *eth0_queries; struct rfapi_monitor_eth *eth0_queries;
struct route_table *imported_encap[AFI_MAX]; struct agg_table *imported_encap[AFI_MAX];
struct skiplist *monitor_exterior_orphans; struct skiplist *monitor_exterior_orphans;
int local_count[AFI_MAX]; int local_count[AFI_MAX];
int remote_count[AFI_MAX]; int remote_count[AFI_MAX];
@ -80,7 +80,7 @@ extern void rfapiCheckRouteCount(void);
extern void rfapiPrintBi(void *stream, struct bgp_info *bi); extern void rfapiPrintBi(void *stream, struct bgp_info *bi);
extern void rfapiShowImportTable(void *stream, const char *label, extern void rfapiShowImportTable(void *stream, const char *label,
struct route_table *rt, int isvpn); struct agg_table *rt, int isvpn);
extern struct rfapi_import_table * extern struct rfapi_import_table *
rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list, rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list,
@ -100,32 +100,31 @@ extern void rfapiImportTableRefDelByIt(struct bgp *bgp,
* next less-specific node (i.e., this node's parent) at the end. * next less-specific node (i.e., this node's parent) at the end.
*/ */
extern struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList( extern struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
struct route_node *rn, uint32_t lifetime, /* put into nexthop entries */ struct agg_node *rn, uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload this NVE rib table */ struct agg_table *rfd_rib_table, /* preload this NVE rib table */
struct prefix *pfx_target_original); /* query target */ struct prefix *pfx_target_original); /* query target */
extern struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList( extern struct rfapi_next_hop_entry *rfapiRouteTable2NextHopList(
struct route_table *rt, struct agg_table *rt, uint32_t lifetime, /* put into nexthop entries */
uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rfd_rib_table, /* preload this NVE rib table */ struct agg_table *rfd_rib_table, /* preload this NVE rib table */
struct prefix *pfx_target_original); /* query target */ struct prefix *pfx_target_original); /* query target */
extern struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList( extern struct rfapi_next_hop_entry *rfapiEthRouteTable2NextHopList(
uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix, uint32_t logical_net_id, struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */ uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rib_route_table, /* preload NVE rib node */ struct agg_table *rib_route_table, /* preload NVE rib node */
struct prefix *pfx_target_original); /* query target */ struct prefix *pfx_target_original); /* query target */
extern int rfapiEcommunitiesIntersect(struct ecommunity *e1, extern int rfapiEcommunitiesIntersect(struct ecommunity *e1,
struct ecommunity *e2); struct ecommunity *e2);
extern void rfapiCheckRefcount(struct route_node *rn, safi_t safi, extern void rfapiCheckRefcount(struct agg_node *rn, safi_t safi,
int lockoffset); int lockoffset);
extern int rfapiHasNonRemovedRoutes(struct route_node *rn); extern int rfapiHasNonRemovedRoutes(struct agg_node *rn);
extern int rfapiProcessDeferredClose(struct thread *t); extern int rfapiProcessDeferredClose(struct thread *t);
@ -153,10 +152,10 @@ extern void rfapiBgpInfoFilteredImportVPN(
uint32_t *label); /* part of bgp_info */ uint32_t *label); /* part of bgp_info */
extern struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList( extern struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
struct route_node *rn, struct rfapi_ip_prefix *rprefix, struct agg_node *rn, struct rfapi_ip_prefix *rprefix,
uint32_t lifetime, /* put into nexthop entries */ uint32_t lifetime, /* put into nexthop entries */
struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
struct route_table *rib_route_table, /* preload NVE rib table */ struct agg_table *rib_route_table, /* preload NVE rib table */
struct prefix *pfx_target_original); /* query target */ struct prefix *pfx_target_original); /* query target */
extern struct rfapi_import_table *rfapiMacImportTableGetNoAlloc(struct bgp *bgp, extern struct rfapi_import_table *rfapiMacImportTableGetNoAlloc(struct bgp *bgp,

View File

@ -28,7 +28,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/log.h" #include "lib/log.h"
@ -68,10 +68,10 @@ static void rfapiMonitorEthDetachImport(struct bgp *bgp,
/* /*
* Debug function, special case * Debug function, special case
*/ */
void rfapiMonitorEthSlCheck(struct route_node *rn, const char *tag1, void rfapiMonitorEthSlCheck(struct agg_node *rn, const char *tag1,
const char *tag2) const char *tag2)
{ {
struct route_node *rn_saved = NULL; struct agg_node *rn_saved = NULL;
static struct skiplist *sl_saved = NULL; static struct skiplist *sl_saved = NULL;
struct skiplist *sl; struct skiplist *sl;
@ -118,12 +118,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp)
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) { for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) {
struct route_node *mrn; struct agg_node *mrn;
if (!rfd->mon) if (!rfd->mon)
continue; continue;
for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { for (mrn = agg_route_top(rfd->mon); mrn;
mrn = agg_route_next(mrn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
for (m = (struct rfapi_monitor_vpn *)(mrn->info); m; for (m = (struct rfapi_monitor_vpn *)(mrn->info); m;
m = m->next) m = m->next)
@ -132,12 +133,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp)
} }
for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) { for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) {
struct route_node *mrn; struct agg_node *mrn;
if (!rfd->mon) if (!rfd->mon)
continue; continue;
for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { for (mrn = agg_route_top(rfd->mon); mrn;
mrn = agg_route_next(mrn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
for (m = (struct rfapi_monitor_vpn *)(mrn->info); m; for (m = (struct rfapi_monitor_vpn *)(mrn->info); m;
@ -158,15 +160,17 @@ void rfapiMonitorCleanCheck(struct bgp *bgp)
assert(!rfd->import_table->vpn0_queries[AFI_IP]); assert(!rfd->import_table->vpn0_queries[AFI_IP]);
assert(!rfd->import_table->vpn0_queries[AFI_IP6]); assert(!rfd->import_table->vpn0_queries[AFI_IP6]);
struct route_node *rn; struct agg_node *rn;
for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP]); for (rn = agg_route_top(
rn; rn = route_next(rn)) { rfd->import_table->imported_vpn[AFI_IP]);
rn; rn = agg_route_next(rn)) {
assert(!RFAPI_MONITOR_VPN(rn)); assert(!RFAPI_MONITOR_VPN(rn));
} }
for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP6]); for (rn = agg_route_top(
rn; rn = route_next(rn)) { rfd->import_table->imported_vpn[AFI_IP6]);
rn; rn = agg_route_next(rn)) {
assert(!RFAPI_MONITOR_VPN(rn)); assert(!RFAPI_MONITOR_VPN(rn));
} }
@ -180,7 +184,7 @@ void rfapiMonitorCheckAttachAllowed(void)
assert(!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE)); assert(!(bgp->rfapi_cfg->flags & BGP_VNC_CONFIG_CALLBACK_DISABLE));
} }
void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn) void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn)
{ {
struct rfapi_it_extra *hie; struct rfapi_it_extra *hie;
struct rfapi_monitor_vpn *v; struct rfapi_monitor_vpn *v;
@ -202,7 +206,7 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
e_next = e->next; e_next = e->next;
e->next = NULL; e->next = NULL;
XFREE(MTYPE_RFAPI_MONITOR_ENCAP, e); XFREE(MTYPE_RFAPI_MONITOR_ENCAP, e);
route_unlock_node(rn); agg_unlock_node(rn);
} }
hie->u.encap.e = NULL; hie->u.encap.e = NULL;
break; break;
@ -212,33 +216,33 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
v_next = v->next; v_next = v->next;
v->next = NULL; v->next = NULL;
XFREE(MTYPE_RFAPI_MONITOR, e); XFREE(MTYPE_RFAPI_MONITOR, e);
route_unlock_node(rn); agg_unlock_node(rn);
} }
hie->u.vpn.v = NULL; hie->u.vpn.v = NULL;
if (hie->u.vpn.e.source) { if (hie->u.vpn.e.source) {
while (!skiplist_delete_first(hie->u.vpn.e.source)) { while (!skiplist_delete_first(hie->u.vpn.e.source)) {
route_unlock_node(rn); agg_unlock_node(rn);
} }
skiplist_free(hie->u.vpn.e.source); skiplist_free(hie->u.vpn.e.source);
hie->u.vpn.e.source = NULL; hie->u.vpn.e.source = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
if (hie->u.vpn.idx_rd) { if (hie->u.vpn.idx_rd) {
/* looping through bi->extra->vnc.import.rd is tbd */ /* looping through bi->extra->vnc.import.rd is tbd */
while (!skiplist_delete_first(hie->u.vpn.idx_rd)) { while (!skiplist_delete_first(hie->u.vpn.idx_rd)) {
route_unlock_node(rn); agg_unlock_node(rn);
} }
skiplist_free(hie->u.vpn.idx_rd); skiplist_free(hie->u.vpn.idx_rd);
hie->u.vpn.idx_rd = NULL; hie->u.vpn.idx_rd = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
if (hie->u.vpn.mon_eth) { if (hie->u.vpn.mon_eth) {
while (!skiplist_delete_first(hie->u.vpn.mon_eth)) { while (!skiplist_delete_first(hie->u.vpn.mon_eth)) {
route_unlock_node(rn); agg_unlock_node(rn);
} }
skiplist_free(hie->u.vpn.mon_eth); skiplist_free(hie->u.vpn.mon_eth);
hie->u.vpn.mon_eth = NULL; hie->u.vpn.mon_eth = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
break; break;
@ -247,13 +251,13 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
} }
XFREE(MTYPE_RFAPI_IT_EXTRA, hie); XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
rn->aggregate = NULL; rn->aggregate = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
/* /*
* If the child lists are empty, release the rfapi_it_extra struct * If the child lists are empty, release the rfapi_it_extra struct
*/ */
void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn) void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn)
{ {
struct rfapi_it_extra *hie; struct rfapi_it_extra *hie;
@ -279,28 +283,28 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn)
return; return;
skiplist_free(hie->u.vpn.mon_eth); skiplist_free(hie->u.vpn.mon_eth);
hie->u.vpn.mon_eth = NULL; hie->u.vpn.mon_eth = NULL;
route_unlock_node(rn); /* uncount skiplist */ agg_unlock_node(rn); /* uncount skiplist */
} }
if (hie->u.vpn.e.source) { if (hie->u.vpn.e.source) {
if (skiplist_count(hie->u.vpn.e.source)) if (skiplist_count(hie->u.vpn.e.source))
return; return;
skiplist_free(hie->u.vpn.e.source); skiplist_free(hie->u.vpn.e.source);
hie->u.vpn.e.source = NULL; hie->u.vpn.e.source = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
if (hie->u.vpn.idx_rd) { if (hie->u.vpn.idx_rd) {
if (skiplist_count(hie->u.vpn.idx_rd)) if (skiplist_count(hie->u.vpn.idx_rd))
return; return;
skiplist_free(hie->u.vpn.idx_rd); skiplist_free(hie->u.vpn.idx_rd);
hie->u.vpn.idx_rd = NULL; hie->u.vpn.idx_rd = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
if (hie->u.vpn.mon_eth) { if (hie->u.vpn.mon_eth) {
if (skiplist_count(hie->u.vpn.mon_eth)) if (skiplist_count(hie->u.vpn.mon_eth))
return; return;
skiplist_free(hie->u.vpn.mon_eth); skiplist_free(hie->u.vpn.mon_eth);
hie->u.vpn.mon_eth = NULL; hie->u.vpn.mon_eth = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
break; break;
@ -309,17 +313,17 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn)
} }
XFREE(MTYPE_RFAPI_IT_EXTRA, hie); XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
rn->aggregate = NULL; rn->aggregate = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
/* /*
* returns locked node * returns locked node
*/ */
struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
struct prefix *p) struct prefix *p)
{ {
afi_t afi; afi_t afi;
struct route_node *rn; struct agg_node *rn;
if (RFAPI_0_PREFIX(p)) { if (RFAPI_0_PREFIX(p)) {
assert(1); assert(1);
@ -341,7 +345,7 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
* if a monitor is moved to another node, there must be * if a monitor is moved to another node, there must be
* corresponding unlock/locks * corresponding unlock/locks
*/ */
for (rn = route_node_match(rfd->import_table->imported_vpn[afi], p); for (rn = agg_node_match(rfd->import_table->imported_vpn[afi], p);
rn;) { rn;) {
struct bgp_info *bi; struct bgp_info *bi;
@ -369,9 +373,9 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
if (bi) if (bi)
break; break;
route_unlock_node(rn); agg_unlock_node(rn);
if ((rn = rn->parent)) { if ((rn = agg_node_parent(rn))) {
route_lock_node(rn); agg_lock_node(rn);
} }
} }
@ -383,7 +387,7 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
/* creates default node if none exists, and increments ref count /* creates default node if none exists, and increments ref count
*/ */
rn = route_node_get(rfd->import_table->imported_vpn[afi], rn = agg_node_get(rfd->import_table->imported_vpn[afi],
&pfx_default); &pfx_default);
} }
@ -396,10 +400,10 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
* returned (for the benefit of caller which might like to use it * returned (for the benefit of caller which might like to use it
* to generate an immediate query response). * to generate an immediate query response).
*/ */
static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd, static struct agg_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd,
struct rfapi_monitor_vpn *m) struct rfapi_monitor_vpn *m)
{ {
struct route_node *rn; struct agg_node *rn;
rfapiMonitorCheckAttachAllowed(); rfapiMonitorCheckAttachAllowed();
@ -438,7 +442,7 @@ static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd,
*/ */
void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd) void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
{ {
struct route_node *mrn; struct agg_node *mrn;
if (!rfd->mon) { if (!rfd->mon) {
/* /*
@ -447,7 +451,7 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
return; return;
} }
for (mrn = route_top(rfd->mon); mrn; mrn = route_next(mrn)) { for (mrn = agg_route_top(rfd->mon); mrn; mrn = agg_route_next(mrn)) {
if (!mrn->info) if (!mrn->info)
continue; continue;
@ -467,11 +471,11 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
* are disabled, this function will not perform a lookup, and the * are disabled, this function will not perform a lookup, and the
* caller will have to do its own lookup. * caller will have to do its own lookup.
*/ */
struct route_node * struct agg_node *rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p) struct prefix *p)
{ {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
struct route_node *rn; struct agg_node *rn;
/* /*
* Initialize nve's monitor list if needed * Initialize nve's monitor list if needed
@ -480,15 +484,15 @@ rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p)
* or be 0/0 so they won't get mixed up. * or be 0/0 so they won't get mixed up.
*/ */
if (!rfd->mon) { if (!rfd->mon) {
rfd->mon = route_table_init(); rfd->mon = agg_table_init();
} }
rn = route_node_get(rfd->mon, p); rn = agg_node_get(rfd->mon, p);
if (rn->info) { if (rn->info) {
/* /*
* received this query before, no further action needed * received this query before, no further action needed
*/ */
rfapiMonitorTimerRestart((struct rfapi_monitor_vpn *)rn->info); rfapiMonitorTimerRestart((struct rfapi_monitor_vpn *)rn->info);
route_unlock_node(rn); agg_unlock_node(rn);
return NULL; return NULL;
} }
@ -575,7 +579,7 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m)
this->next; this->next;
} }
RFAPI_CHECK_REFCOUNT(m->node, SAFI_MPLS_VPN, 1); RFAPI_CHECK_REFCOUNT(m->node, SAFI_MPLS_VPN, 1);
route_unlock_node(m->node); agg_unlock_node(m->node);
} }
m->node = NULL; m->node = NULL;
} }
@ -586,12 +590,12 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m)
void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd) void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd)
{ {
struct route_node *rn; struct agg_node *rn;
if (!rfd->mon) if (!rfd->mon)
return; return;
for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { for (rn = agg_route_top(rfd->mon); rn; rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
rfapiMonitorDetachImport( rfapiMonitorDetachImport(
(struct rfapi_monitor_vpn *)(rn->info)); (struct rfapi_monitor_vpn *)(rn->info));
@ -602,11 +606,11 @@ void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd)
void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd, void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
struct prefix *p) struct prefix *p)
{ {
struct route_node *rn; struct agg_node *rn;
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
assert(rfd->mon); assert(rfd->mon);
rn = route_node_get(rfd->mon, p); /* locks node */ rn = agg_node_get(rfd->mon, p); /* locks node */
m = rn->info; m = rn->info;
assert(m); assert(m);
@ -628,8 +632,8 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/ */
XFREE(MTYPE_RFAPI_MONITOR, m); XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); /* undo original lock when created */ agg_unlock_node(rn); /* undo original lock when created */
route_unlock_node(rn); /* undo lock in route_node_get */ agg_unlock_node(rn); /* undo lock in agg_node_get */
--rfd->monitor_count; --rfd->monitor_count;
--bgp->rfapi->monitor_count; --bgp->rfapi->monitor_count;
@ -640,7 +644,7 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/ */
int rfapiMonitorDelHd(struct rfapi_descriptor *rfd) int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
{ {
struct route_node *rn; struct agg_node *rn;
struct bgp *bgp; struct bgp *bgp;
int count = 0; int count = 0;
@ -649,7 +653,8 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
bgp = bgp_get_default(); bgp = bgp_get_default();
if (rfd->mon) { if (rfd->mon) {
for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { for (rn = agg_route_top(rfd->mon); rn;
rn = agg_route_next(rn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
if ((m = rn->info)) { if ((m = rn->info)) {
if (!(bgp->rfapi_cfg->flags if (!(bgp->rfapi_cfg->flags
@ -664,14 +669,14 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
XFREE(MTYPE_RFAPI_MONITOR, m); XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); /* undo original lock agg_unlock_node(rn); /* undo original lock
when created */ when created */
++count; ++count;
--rfd->monitor_count; --rfd->monitor_count;
--bgp->rfapi->monitor_count; --bgp->rfapi->monitor_count;
} }
} }
route_table_finish(rfd->mon); agg_table_finish(rfd->mon);
rfd->mon = NULL; rfd->mon = NULL;
} }
@ -788,7 +793,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
*/ */
void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
{ {
struct route_node *rn; struct agg_node *rn;
if (AF_ETHERNET == p->family) { if (AF_ETHERNET == p->family) {
struct rfapi_monitor_eth *mon_eth; struct rfapi_monitor_eth *mon_eth;
@ -812,7 +817,8 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
} }
} else { } else {
for (rn = route_top(rfd->mon); rn; rn = route_next(rn)) { for (rn = agg_route_top(rfd->mon); rn;
rn = agg_route_next(rn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
if (!((m = rn->info))) if (!((m = rn->info)))
@ -831,11 +837,11 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
* rfapiRibUpdatePendingNode with this node and all corresponding NVEs. * rfapiRibUpdatePendingNode with this node and all corresponding NVEs.
*/ */
void rfapiMonitorItNodeChanged( void rfapiMonitorItNodeChanged(
struct rfapi_import_table *import_table, struct route_node *it_node, struct rfapi_import_table *import_table, struct agg_node *it_node,
struct rfapi_monitor_vpn *monitor_list) /* for base it node, NULL=all */ struct rfapi_monitor_vpn *monitor_list) /* for base it node, NULL=all */
{ {
struct skiplist *nves_seen; struct skiplist *nves_seen;
struct route_node *rn = it_node; struct agg_node *rn = it_node;
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
afi_t afi = family2afi(rn->p.family); afi_t afi = family2afi(rn->p.family);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
@ -909,7 +915,8 @@ void rfapiMonitorItNodeChanged(
* to them * to them
* because we haven't sent them an initial route. * because we haven't sent them an initial route.
*/ */
if (!rn->parent && !rn->info && it_node->parent) if (!agg_node_parent(rn) && !rn->info
&& it_node->parent)
break; break;
for (; m; m = m->next) { for (; m; m = m->next) {
@ -947,7 +954,7 @@ void rfapiMonitorItNodeChanged(
m->rfd->response_lifetime); m->rfd->response_lifetime);
} }
} }
rn = rn->parent; rn = agg_node_parent(rn);
if (rn) if (rn)
m = RFAPI_MONITOR_VPN(rn); m = RFAPI_MONITOR_VPN(rn);
} while (rn); } while (rn);
@ -1023,8 +1030,7 @@ void rfapiMonitorItNodeChanged(
* omit old node and its subtree * omit old node and its subtree
*/ */
void rfapiMonitorMovedUp(struct rfapi_import_table *import_table, void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
struct route_node *old_node, struct agg_node *old_node, struct agg_node *new_node,
struct route_node *new_node,
struct rfapi_monitor_vpn *monitor_list) struct rfapi_monitor_vpn *monitor_list)
{ {
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
@ -1125,7 +1131,7 @@ static int mon_eth_cmp(void *a, void *b)
static void rfapiMonitorEthAttachImport( static void rfapiMonitorEthAttachImport(
struct rfapi_import_table *it, struct rfapi_import_table *it,
struct route_node *rn, /* it node attach point if non-0 */ struct agg_node *rn, /* it node attach point if non-0 */
struct rfapi_monitor_eth *mon) /* monitor struct to attach */ struct rfapi_monitor_eth *mon) /* monitor struct to attach */
{ {
struct skiplist *sl; struct skiplist *sl;
@ -1162,7 +1168,7 @@ static void rfapiMonitorEthAttachImport(
if (!sl) { if (!sl) {
sl = RFAPI_MONITOR_ETH_W_ALLOC(rn) = sl = RFAPI_MONITOR_ETH_W_ALLOC(rn) =
skiplist_new(0, NULL, NULL); skiplist_new(0, NULL, NULL);
route_lock_node(rn); /* count skiplist mon_eth */ agg_lock_node(rn); /* count skiplist mon_eth */
} }
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
@ -1175,7 +1181,7 @@ static void rfapiMonitorEthAttachImport(
assert(!rc); assert(!rc);
/* count eth monitor */ /* count eth monitor */
route_lock_node(rn); agg_lock_node(rn);
} }
/* /*
@ -1202,7 +1208,7 @@ static void rfapiMonitorEthAttachImportHd(struct bgp *bgp,
struct rfapi_import_table *it; struct rfapi_import_table *it;
struct prefix pfx_mac_buf; struct prefix pfx_mac_buf;
struct route_node *rn; struct agg_node *rn;
it = rfapiMacImportTableGet(bgp, mon->logical_net_id); it = rfapiMacImportTableGet(bgp, mon->logical_net_id);
assert(it); assert(it);
@ -1212,7 +1218,7 @@ static void rfapiMonitorEthAttachImportHd(struct bgp *bgp,
pfx_mac_buf.prefixlen = 48; pfx_mac_buf.prefixlen = 48;
pfx_mac_buf.u.prefix_eth = mon->macaddr; pfx_mac_buf.u.prefix_eth = mon->macaddr;
rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf);
assert(rn); assert(rn);
(void)rfapiMonitorEthAttachImport(it, rn, mon); (void)rfapiMonitorEthAttachImport(it, rn, mon);
@ -1226,7 +1232,7 @@ static void rfapiMonitorEthDetachImport(
struct rfapi_import_table *it; struct rfapi_import_table *it;
struct prefix pfx_mac_buf; struct prefix pfx_mac_buf;
struct skiplist *sl; struct skiplist *sl;
struct route_node *rn; struct agg_node *rn;
int rc; int rc;
it = rfapiMacImportTableGet(bgp, mon->logical_net_id); it = rfapiMacImportTableGet(bgp, mon->logical_net_id);
@ -1262,7 +1268,7 @@ static void rfapiMonitorEthDetachImport(
pfx_mac_buf.prefixlen = 48; pfx_mac_buf.prefixlen = 48;
pfx_mac_buf.u.prefix_eth = mon->macaddr; pfx_mac_buf.u.prefix_eth = mon->macaddr;
rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf);
assert(rn); assert(rn);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
@ -1288,10 +1294,10 @@ static void rfapiMonitorEthDetachImport(
assert(!rc); assert(!rc);
/* uncount eth monitor */ /* uncount eth monitor */
route_unlock_node(rn); agg_unlock_node(rn);
} }
struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp,
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct ethaddr *macaddr, struct ethaddr *macaddr,
uint32_t logical_net_id) uint32_t logical_net_id)
@ -1300,7 +1306,7 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
struct rfapi_monitor_eth mon_buf; struct rfapi_monitor_eth mon_buf;
struct rfapi_monitor_eth *val; struct rfapi_monitor_eth *val;
struct rfapi_import_table *it; struct rfapi_import_table *it;
struct route_node *rn = NULL; struct agg_node *rn = NULL;
struct prefix pfx_mac_buf; struct prefix pfx_mac_buf;
if (!rfd->mon_eth) { if (!rfd->mon_eth) {
@ -1323,7 +1329,7 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
pfx_mac_buf.u.prefix_eth = *macaddr; pfx_mac_buf.u.prefix_eth = *macaddr;
if (!RFAPI_0_ETHERADDR(macaddr)) { if (!RFAPI_0_ETHERADDR(macaddr)) {
rn = route_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf); rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf);
assert(rn); assert(rn);
} }
@ -1453,8 +1459,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
{ {
struct rfapi_import_table *it; struct rfapi_import_table *it;
afi_t afi; afi_t afi;
struct route_table *rt; struct agg_table *rt;
struct route_node *rn; struct agg_node *rn;
void *cursor; void *cursor;
int rc; int rc;
struct rfapi *h = bgp->rfapi; struct rfapi *h = bgp->rfapi;
@ -1485,7 +1491,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
rt = it->imported_vpn[afi]; rt = it->imported_vpn[afi];
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
m = RFAPI_MONITOR_VPN(rn); m = RFAPI_MONITOR_VPN(rn);
if (RFAPI_MONITOR_VPN(rn)) if (RFAPI_MONITOR_VPN(rn))
RFAPI_MONITOR_VPN_W_ALLOC(rn) = NULL; RFAPI_MONITOR_VPN_W_ALLOC(rn) = NULL;
@ -1494,7 +1501,7 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
m->next = m->next =
NULL; /* gratuitous safeness */ NULL; /* gratuitous safeness */
m->node = NULL; m->node = NULL;
route_unlock_node(rn); /* uncount */ agg_unlock_node(rn); /* uncount */
} }
} }
@ -1531,12 +1538,12 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
* Find non-0 monitors (i.e., actual addresses, not FTD * Find non-0 monitors (i.e., actual addresses, not FTD
* monitors) * monitors)
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
struct skiplist *sl; struct skiplist *sl;
sl = RFAPI_MONITOR_ETH(rn); sl = RFAPI_MONITOR_ETH(rn);
while (!skiplist_delete_first(sl)) { while (!skiplist_delete_first(sl)) {
route_unlock_node(rn); /* uncount monitor */ agg_unlock_node(rn); /* uncount monitor */
} }
} }

View File

@ -30,10 +30,10 @@
* to indicate which nves are interested in a prefix/target * to indicate which nves are interested in a prefix/target
*/ */
struct rfapi_monitor_vpn { struct rfapi_monitor_vpn {
struct rfapi_monitor_vpn *next; /* chain from struct route_node */ struct rfapi_monitor_vpn *next; /* chain from struct agg_node */
struct rfapi_descriptor *rfd; /* which NVE requested the route */ struct rfapi_descriptor *rfd; /* which NVE requested the route */
struct prefix p; /* constant: pfx in original request */ struct prefix p; /* constant: pfx in original request */
struct route_node *node; /* node we're currently attached to */ struct agg_node *node; /* node we're currently attached to */
uint32_t flags; uint32_t flags;
#define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */ #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
@ -44,9 +44,9 @@ struct rfapi_monitor_vpn {
struct rfapi_monitor_encap { struct rfapi_monitor_encap {
struct rfapi_monitor_encap *next; struct rfapi_monitor_encap *next;
struct rfapi_monitor_encap *prev; struct rfapi_monitor_encap *prev;
struct route_node *node; /* VPN node */ struct agg_node *node; /* VPN node */
struct bgp_info *bi; /* VPN bi */ struct bgp_info *bi; /* VPN bi */
struct route_node *rn; /* parent node */ struct agg_node *rn; /* parent node */
}; };
struct rfapi_monitor_eth { struct rfapi_monitor_eth {
@ -98,7 +98,7 @@ struct rfapi_it_extra {
((struct rfapi_it_extra \ ((struct rfapi_it_extra \
*)((rn)->aggregate \ *)((rn)->aggregate \
? (rn)->aggregate \ ? (rn)->aggregate \
: (route_lock_node(rn), \ : (agg_lock_node(rn), \
(rn)->aggregate = XCALLOC( \ (rn)->aggregate = XCALLOC( \
MTYPE_RFAPI_IT_EXTRA, \ MTYPE_RFAPI_IT_EXTRA, \
sizeof(struct rfapi_it_extra))))) sizeof(struct rfapi_it_extra)))))
@ -138,14 +138,14 @@ extern void rfapiMonitorCleanCheck(struct bgp *bgp);
extern void rfapiMonitorCheckAttachAllowed(void); extern void rfapiMonitorCheckAttachAllowed(void);
extern void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn); extern void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn);
extern struct route_node * extern struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, struct prefix *p); struct prefix *p);
extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd); extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd);
extern struct route_node *rfapiMonitorAdd(struct bgp *bgp, extern struct agg_node *rfapiMonitorAdd(struct bgp *bgp,
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct prefix *p); struct prefix *p);
@ -164,21 +164,21 @@ extern void rfapiMonitorResponseRemovalOff(struct bgp *bgp);
extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp); extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp);
extern void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn); extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn);
extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd,
struct prefix *p); struct prefix *p);
extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table, extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table,
struct route_node *it_node, struct agg_node *it_node,
struct rfapi_monitor_vpn *monitor_list); struct rfapi_monitor_vpn *monitor_list);
extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table, extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
struct route_node *old_node, struct agg_node *old_node,
struct route_node *new_node, struct agg_node *new_node,
struct rfapi_monitor_vpn *monitor_list); struct rfapi_monitor_vpn *monitor_list);
extern struct route_node *rfapiMonitorEthAdd(struct bgp *bgp, extern struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp,
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct ethaddr *macaddr, struct ethaddr *macaddr,
uint32_t logical_net_id); uint32_t logical_net_id);

View File

@ -21,7 +21,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/skiplist.h" #include "lib/skiplist.h"

View File

@ -47,7 +47,7 @@ struct rfapi_advertised_prefixes {
}; };
struct rfapi_descriptor { struct rfapi_descriptor {
struct route_node *un_node; /* backref to un table */ struct agg_node *un_node; /* backref to un table */
struct rfapi_descriptor *next; /* next vn_addr */ struct rfapi_descriptor *next; /* next vn_addr */
@ -76,7 +76,7 @@ struct rfapi_descriptor {
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
uint32_t monitor_count; uint32_t monitor_count;
struct route_table *mon; /* rfapi_monitors */ struct agg_table *mon; /* rfapi_monitors */
struct skiplist *mon_eth; /* ethernet monitors */ struct skiplist *mon_eth; /* ethernet monitors */
/* /*
@ -85,10 +85,10 @@ struct rfapi_descriptor {
* rsp_times last time we sent response containing pfx * rsp_times last time we sent response containing pfx
*/ */
uint32_t rib_prefix_count; /* pfxes with routes */ uint32_t rib_prefix_count; /* pfxes with routes */
struct route_table *rib[AFI_MAX]; struct agg_table *rib[AFI_MAX];
struct route_table *rib_pending[AFI_MAX]; struct agg_table *rib_pending[AFI_MAX];
struct work_queue *updated_responses_queue; struct work_queue *updated_responses_queue;
struct route_table *rsp_times[AFI_MAX]; struct agg_table *rsp_times[AFI_MAX];
uint32_t rsp_counter; /* dedup initial rsp */ uint32_t rsp_counter; /* dedup initial rsp */
time_t rsp_time; /* dedup initial rsp */ time_t rsp_time; /* dedup initial rsp */
@ -171,7 +171,7 @@ struct rfapi_global_stats {
* check vn address to get exact match. * check vn address to get exact match.
*/ */
struct rfapi { struct rfapi {
struct route_table *un[AFI_MAX]; struct agg_table *un[AFI_MAX];
struct rfapi_import_table *imports; /* IPv4, IPv6 */ struct rfapi_import_table *imports; /* IPv4, IPv6 */
struct list descriptors; /* debug & resolve-nve imports */ struct list descriptors; /* debug & resolve-nve imports */
@ -198,8 +198,8 @@ struct rfapi {
* bgp unicast or zebra, we need to keep track of information * bgp unicast or zebra, we need to keep track of information
* related to expiring the routes according to the VNC lifetime * related to expiring the routes according to the VNC lifetime
*/ */
struct route_table *rt_export_bgp[AFI_MAX]; struct agg_table *rt_export_bgp[AFI_MAX];
struct route_table *rt_export_zebra[AFI_MAX]; struct agg_table *rt_export_zebra[AFI_MAX];
/* /*
* For VNC->BGP unicast exports in CE mode, we need a * For VNC->BGP unicast exports in CE mode, we need a

View File

@ -27,7 +27,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/log.h" #include "lib/log.h"
@ -150,10 +150,10 @@ void rfapiRibCheckCounts(
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_node *rn; struct agg_node *rn;
for (rn = route_top(rfd->rib[afi]); rn; for (rn = agg_route_top(rfd->rib[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
struct skiplist *sl = rn->info; struct skiplist *sl = rn->info;
struct skiplist *dsl = rn->aggregate; struct skiplist *dsl = rn->aggregate;
@ -175,8 +175,8 @@ void rfapiRibCheckCounts(
++t_pfx_deleted; ++t_pfx_deleted;
} }
} }
for (rn = route_top(rfd->rib_pending[afi]); rn; for (rn = agg_route_top(rfd->rib_pending[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
struct list *l = rn->info; /* sorted by cost */ struct list *l = rn->info; /* sorted by cost */
struct skiplist *sl = rn->aggregate; struct skiplist *sl = rn->aggregate;
@ -286,7 +286,7 @@ struct rfapi_rib_tcb {
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
struct skiplist *sl; struct skiplist *sl;
struct rfapi_info *ri; struct rfapi_info *ri;
struct route_node *rn; struct agg_node *rn;
int flags; int flags;
#define RFAPI_RIB_TCB_FLAG_DELETED 0x00000001 #define RFAPI_RIB_TCB_FLAG_DELETED 0x00000001
}; };
@ -325,7 +325,7 @@ static int rfapiRibExpireTimer(struct thread *t)
RFAPI_RIB_PREFIX_COUNT_DECR(tcb->rfd, bgp->rfapi); RFAPI_RIB_PREFIX_COUNT_DECR(tcb->rfd, bgp->rfapi);
} }
skiplist_free(tcb->sl); skiplist_free(tcb->sl);
route_unlock_node(tcb->rn); agg_unlock_node(tcb->rn);
} }
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb); XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
@ -335,9 +335,9 @@ static int rfapiRibExpireTimer(struct thread *t)
return 0; return 0;
} }
static void static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
rfapiRibStartTimer(struct rfapi_descriptor *rfd, struct rfapi_info *ri, struct rfapi_info *ri,
struct route_node *rn, /* route node attached to */ struct agg_node *rn, /* route node attached to */
int deleted) int deleted)
{ {
struct thread *t = ri->timer; struct thread *t = ri->timer;
@ -486,12 +486,12 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
#endif #endif
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_node *pn; struct agg_node *pn;
struct route_node *rn; struct agg_node *rn;
if (rfd->rib_pending[afi]) { if (rfd->rib_pending[afi]) {
for (pn = route_top(rfd->rib_pending[afi]); pn; for (pn = agg_route_top(rfd->rib_pending[afi]); pn;
pn = route_next(pn)) { pn = agg_route_next(pn)) {
if (pn->aggregate) { if (pn->aggregate) {
/* /*
* free references into the rfapi_info * free references into the rfapi_info
@ -502,7 +502,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
(struct skiplist (struct skiplist
*)(pn->aggregate)); *)(pn->aggregate));
pn->aggregate = NULL; pn->aggregate = NULL;
route_unlock_node( agg_unlock_node(
pn); /* skiplist deleted */ pn); /* skiplist deleted */
} }
/* /*
@ -516,13 +516,13 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
} }
pn->info = NULL; pn->info = NULL;
/* linklist or 1 deleted */ /* linklist or 1 deleted */
route_unlock_node(pn); agg_unlock_node(pn);
} }
} }
} }
if (rfd->rib[afi]) { if (rfd->rib[afi]) {
for (rn = route_top(rfd->rib[afi]); rn; for (rn = agg_route_top(rfd->rib[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
struct rfapi_info *ri; struct rfapi_info *ri;
@ -541,7 +541,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
skiplist_free( skiplist_free(
(struct skiplist *)rn->info); (struct skiplist *)rn->info);
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
RFAPI_RIB_PREFIX_COUNT_DECR(rfd, RFAPI_RIB_PREFIX_COUNT_DECR(rfd,
bgp->rfapi); bgp->rfapi);
} }
@ -566,7 +566,7 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
*)(rn->aggregate)); *)(rn->aggregate));
rn->aggregate = NULL; rn->aggregate = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
} }
} }
@ -601,15 +601,18 @@ void rfapiRibFree(struct rfapi_descriptor *rfd)
* Free radix trees * Free radix trees
*/ */
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
route_table_finish(rfd->rib_pending[afi]); if (rfd->rib_pending[afi])
agg_table_finish(rfd->rib_pending[afi]);
rfd->rib_pending[afi] = NULL; rfd->rib_pending[afi] = NULL;
route_table_finish(rfd->rib[afi]); if (rfd->rib[afi])
agg_table_finish(rfd->rib[afi]);
rfd->rib[afi] = NULL; rfd->rib[afi] = NULL;
/* NB route_table_finish frees only prefix nodes, not chained /* NB agg_table_finish frees only prefix nodes, not chained
* info */ * info */
route_table_finish(rfd->rsp_times[afi]); if (rfd->rsp_times[afi])
agg_table_finish(rfd->rsp_times[afi]);
rfd->rib[afi] = NULL; rfd->rib[afi] = NULL;
} }
} }
@ -730,7 +733,7 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri,
* !0 do not include route in response * !0 do not include route in response
*/ */
int rfapiRibPreloadBi( int rfapiRibPreloadBi(
struct route_node *rfd_rib_node, /* NULL = don't preload or filter */ struct agg_node *rfd_rib_node, /* NULL = don't preload or filter */
struct prefix *pfx_vn, struct prefix *pfx_un, uint32_t lifetime, struct prefix *pfx_vn, struct prefix *pfx_un, uint32_t lifetime,
struct bgp_info *bi) struct bgp_info *bi)
{ {
@ -738,7 +741,7 @@ int rfapiRibPreloadBi(
struct skiplist *slRibPt = NULL; struct skiplist *slRibPt = NULL;
struct rfapi_info *ori = NULL; struct rfapi_info *ori = NULL;
struct rfapi_rib_key rk; struct rfapi_rib_key rk;
struct route_node *trn; struct agg_node *trn;
afi_t afi; afi_t afi;
if (!rfd_rib_node) if (!rfd_rib_node)
@ -746,7 +749,7 @@ int rfapiRibPreloadBi(
afi = family2afi(rfd_rib_node->p.family); afi = family2afi(rfd_rib_node->p.family);
rfd = (struct rfapi_descriptor *)(rfd_rib_node->table->info); rfd = agg_get_table_info(agg_get_table(rfd_rib_node));
memset((void *)&rk, 0, sizeof(rk)); memset((void *)&rk, 0, sizeof(rk));
rk.vn = *pfx_vn; rk.vn = *pfx_vn;
@ -784,7 +787,7 @@ int rfapiRibPreloadBi(
if (!slRibPt) { if (!slRibPt) {
slRibPt = skiplist_new(0, rfapi_rib_key_cmp, NULL); slRibPt = skiplist_new(0, rfapi_rib_key_cmp, NULL);
rfd_rib_node->info = slRibPt; rfd_rib_node->info = slRibPt;
route_lock_node(rfd_rib_node); agg_lock_node(rfd_rib_node);
RFAPI_RIB_PREFIX_COUNT_INCR(rfd, rfd->bgp->rfapi); RFAPI_RIB_PREFIX_COUNT_INCR(rfd, rfd->bgp->rfapi);
} }
skiplist_insert(slRibPt, &ori->rk, ori); skiplist_insert(slRibPt, &ori->rk, ori);
@ -802,11 +805,11 @@ int rfapiRibPreloadBi(
/* /*
* Update last sent time for prefix * Update last sent time for prefix
*/ */
trn = route_node_get(rfd->rsp_times[afi], trn = agg_node_get(rfd->rsp_times[afi],
&rfd_rib_node->p); /* locks trn */ &rfd_rib_node->p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock(); trn->info = (void *)(uintptr_t)bgp_clock();
if (trn->lock > 1) if (trn->lock > 1)
route_unlock_node(trn); agg_unlock_node(trn);
return 0; return 0;
} }
@ -837,7 +840,7 @@ int rfapiRibPreloadBi(
*/ */
static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
afi_t afi, afi_t afi,
struct route_node *pn, /* pending node */ struct agg_node *pn, /* pending node */
struct rfapi_next_hop_entry **head, struct rfapi_next_hop_entry **head,
struct rfapi_next_hop_entry **tail) struct rfapi_next_hop_entry **tail)
{ {
@ -845,7 +848,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
struct listnode *nnode = NULL; struct listnode *nnode = NULL;
struct rfapi_info *ri = NULL; /* happy valgrind */ struct rfapi_info *ri = NULL; /* happy valgrind */
struct rfapi_ip_prefix hp = {0}; /* pfx to put in NHE */ struct rfapi_ip_prefix hp = {0}; /* pfx to put in NHE */
struct route_node *rn = NULL; struct agg_node *rn = NULL;
struct skiplist *slRibPt = NULL; /* rib list */ struct skiplist *slRibPt = NULL; /* rib list */
struct skiplist *slPendPt = NULL; struct skiplist *slPendPt = NULL;
struct list *lPendCost = NULL; struct list *lPendCost = NULL;
@ -875,7 +878,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
/* /*
* Find corresponding RIB node * Find corresponding RIB node
*/ */
rn = route_node_get(rfd->rib[afi], &pn->p); /* locks rn */ rn = agg_node_get(rfd->rib[afi], &pn->p); /* locks rn */
/* /*
* RIB skiplist has key=rfapi_addr={vn,un}, val = rfapi_info, * RIB skiplist has key=rfapi_addr={vn,un}, val = rfapi_info,
@ -945,30 +948,30 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
skiplist_free(slRibPt); skiplist_free(slRibPt);
rn->info = slRibPt = NULL; rn->info = slRibPt = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
lPendCost = pn->info = NULL; lPendCost = pn->info = NULL;
route_unlock_node(pn); agg_unlock_node(pn);
goto callback; goto callback;
} }
if (slRibPt) { if (slRibPt) {
skiplist_free(slRibPt); skiplist_free(slRibPt);
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
assert(!slPendPt); assert(!slPendPt);
if (slPendPt) { /* TBD I think we can toss this block */ if (slPendPt) { /* TBD I think we can toss this block */
skiplist_free(slPendPt); skiplist_free(slPendPt);
pn->aggregate = NULL; pn->aggregate = NULL;
route_unlock_node(pn); agg_unlock_node(pn);
} }
pn->info = NULL; pn->info = NULL;
route_unlock_node(pn); agg_unlock_node(pn);
route_unlock_node(rn); /* route_node_get() */ agg_unlock_node(rn); /* agg_node_get() */
if (rib_node_started_nonempty) { if (rib_node_started_nonempty) {
RFAPI_RIB_PREFIX_COUNT_DECR(rfd, bgp->rfapi); RFAPI_RIB_PREFIX_COUNT_DECR(rfd, bgp->rfapi);
@ -1076,7 +1079,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (skiplist_empty(slRibPt)) { if (skiplist_empty(slRibPt)) {
skiplist_free(slRibPt); skiplist_free(slRibPt);
slRibPt = rn->info = NULL; slRibPt = rn->info = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
} }
} }
@ -1142,7 +1145,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
slRibPt = skiplist_new( slRibPt = skiplist_new(
0, rfapi_rib_key_cmp, NULL); 0, rfapi_rib_key_cmp, NULL);
rn->info = slRibPt; rn->info = slRibPt;
route_lock_node(rn); agg_lock_node(rn);
} }
skiplist_insert(slRibPt, &ori->rk, ori); skiplist_insert(slRibPt, &ori->rk, ori);
@ -1192,7 +1195,7 @@ callback:
for (ALL_LIST_ELEMENTS(lPendCost, node, nnode, ri)) { for (ALL_LIST_ELEMENTS(lPendCost, node, nnode, ri)) {
struct rfapi_next_hop_entry *new; struct rfapi_next_hop_entry *new;
struct route_node *trn; struct agg_node *trn;
new = XCALLOC(MTYPE_RFAPI_NEXTHOP, new = XCALLOC(MTYPE_RFAPI_NEXTHOP,
sizeof(struct rfapi_next_hop_entry)); sizeof(struct rfapi_next_hop_entry));
@ -1244,11 +1247,11 @@ callback:
/* /*
* update this NVE's timestamp for this prefix * update this NVE's timestamp for this prefix
*/ */
trn = route_node_get(rfd->rsp_times[afi], trn = agg_node_get(rfd->rsp_times[afi],
&pn->p); /* locks trn */ &pn->p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock(); trn->info = (void *)(uintptr_t)bgp_clock();
if (trn->lock > 1) if (trn->lock > 1)
route_unlock_node(trn); agg_unlock_node(trn);
rfapiRfapiIpAddr2Str(&new->vn_address, buf, BUFSIZ); rfapiRfapiIpAddr2Str(&new->vn_address, buf, BUFSIZ);
rfapiRfapiIpAddr2Str(&new->un_address, buf2, BUFSIZ); rfapiRfapiIpAddr2Str(&new->un_address, buf2, BUFSIZ);
@ -1347,7 +1350,7 @@ callback:
0, rfapi_rib_key_cmp, 0, rfapi_rib_key_cmp,
(void (*)(void *)) (void (*)(void *))
rfapi_info_free); rfapi_info_free);
route_lock_node(rn); agg_lock_node(rn);
} }
RFAPI_RIB_CHECK_COUNTS(0, delete_list->count); RFAPI_RIB_CHECK_COUNTS(0, delete_list->count);
@ -1438,18 +1441,18 @@ callback:
RFAPI_RIB_CHECK_COUNTS(0, 0); RFAPI_RIB_CHECK_COUNTS(0, 0);
/* /*
* Reset pending lists. The final route_unlock_node() will probably * Reset pending lists. The final agg_unlock_node() will probably
* cause the pending node to be released. * cause the pending node to be released.
*/ */
if (slPendPt) { if (slPendPt) {
skiplist_free(slPendPt); skiplist_free(slPendPt);
pn->aggregate = NULL; pn->aggregate = NULL;
route_unlock_node(pn); agg_unlock_node(pn);
} }
if (lPendCost) { if (lPendCost) {
list_delete_and_null(&lPendCost); list_delete_and_null(&lPendCost);
pn->info = NULL; pn->info = NULL;
route_unlock_node(pn); agg_unlock_node(pn);
} }
RFAPI_RIB_CHECK_COUNTS(0, 0); RFAPI_RIB_CHECK_COUNTS(0, 0);
@ -1466,7 +1469,7 @@ callback:
if (sendingsomeroutes) if (sendingsomeroutes)
rfapiMonitorTimersRestart(rfd, &pn->p); rfapiMonitorTimersRestart(rfd, &pn->p);
route_unlock_node(rn); /* route_node_get() */ agg_unlock_node(rn); /* agg_node_get() */
RFAPI_RIB_CHECK_COUNTS(1, 0); RFAPI_RIB_CHECK_COUNTS(1, 0);
} }
@ -1484,7 +1487,7 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi)
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
struct rfapi_next_hop_entry *head = NULL; struct rfapi_next_hop_entry *head = NULL;
struct rfapi_next_hop_entry *tail = NULL; struct rfapi_next_hop_entry *tail = NULL;
struct route_node *rn; struct agg_node *rn;
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
vnc_zlog_debug_verbose("%s: rfd=%p, afi=%d", __func__, rfd, afi); vnc_zlog_debug_verbose("%s: rfd=%p, afi=%d", __func__, rfd, afi);
@ -1495,7 +1498,8 @@ static void rib_do_callback_onepass(struct rfapi_descriptor *rfd, afi_t afi)
assert(bgp->rfapi); assert(bgp->rfapi);
for (rn = route_top(rfd->rib_pending[afi]); rn; rn = route_next(rn)) { for (rn = agg_route_top(rfd->rib_pending[afi]); rn;
rn = agg_route_next(rn)) {
process_pending_node(bgp, rfd, afi, rn, &head, &tail); process_pending_node(bgp, rfd, afi, rn, &head, &tail);
} }
@ -1585,11 +1589,11 @@ static void updated_responses_queue_init(struct rfapi_descriptor *rfd)
void rfapiRibUpdatePendingNode( void rfapiRibUpdatePendingNode(
struct bgp *bgp, struct rfapi_descriptor *rfd, struct bgp *bgp, struct rfapi_descriptor *rfd,
struct rfapi_import_table *it, /* needed for L2 */ struct rfapi_import_table *it, /* needed for L2 */
struct route_node *it_node, uint32_t lifetime) struct agg_node *it_node, uint32_t lifetime)
{ {
struct prefix *prefix; struct prefix *prefix;
struct bgp_info *bi; struct bgp_info *bi;
struct route_node *pn; struct agg_node *pn;
afi_t afi; afi_t afi;
uint32_t queued_flag; uint32_t queued_flag;
int count = 0; int count = 0;
@ -1609,7 +1613,7 @@ void rfapiRibUpdatePendingNode(
prefix2str(prefix, buf, sizeof(buf)); prefix2str(prefix, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf); vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf);
pn = route_node_get(rfd->rib_pending[afi], prefix); pn = agg_node_get(rfd->rib_pending[afi], prefix);
assert(pn); assert(pn);
vnc_zlog_debug_verbose("%s: pn->info=%p, pn->aggregate=%p", __func__, vnc_zlog_debug_verbose("%s: pn->info=%p, pn->aggregate=%p", __func__,
@ -1622,7 +1626,7 @@ void rfapiRibUpdatePendingNode(
*/ */
skiplist_free((struct skiplist *)(pn->aggregate)); skiplist_free((struct skiplist *)(pn->aggregate));
pn->aggregate = NULL; pn->aggregate = NULL;
route_unlock_node(pn); /* skiplist deleted */ agg_unlock_node(pn); /* skiplist deleted */
} }
@ -1634,7 +1638,7 @@ void rfapiRibUpdatePendingNode(
list_delete_and_null((struct list **)(&pn->info)); list_delete_and_null((struct list **)(&pn->info));
} }
pn->info = NULL; pn->info = NULL;
route_unlock_node(pn); /* linklist or 1 deleted */ agg_unlock_node(pn); /* linklist or 1 deleted */
} }
/* /*
@ -1689,7 +1693,7 @@ void rfapiRibUpdatePendingNode(
if (!pn->aggregate) { if (!pn->aggregate) {
pn->aggregate = pn->aggregate =
skiplist_new(0, rfapi_rib_key_cmp, NULL); skiplist_new(0, rfapi_rib_key_cmp, NULL);
route_lock_node(pn); agg_lock_node(pn);
} }
/* /*
@ -1715,7 +1719,7 @@ void rfapiRibUpdatePendingNode(
pn->info = list_new(); pn->info = list_new();
((struct list *)(pn->info))->del = ((struct list *)(pn->info))->del =
(void (*)(void *))rfapi_info_free; (void (*)(void *))rfapi_info_free;
route_lock_node(pn); agg_lock_node(pn);
} }
listnode_add((struct list *)(pn->info), ri); listnode_add((struct list *)(pn->info), ri);
@ -1730,10 +1734,10 @@ void rfapiRibUpdatePendingNode(
assert(!pn->aggregate); assert(!pn->aggregate);
pn->info = (void *)1; /* magic value means this node has no pn->info = (void *)1; /* magic value means this node has no
routes */ routes */
route_lock_node(pn); agg_lock_node(pn);
} }
route_unlock_node(pn); /* route_node_get */ agg_unlock_node(pn); /* agg_node_get */
queued_flag = RFAPI_QUEUED_FLAG(afi); queued_flag = RFAPI_QUEUED_FLAG(afi);
@ -1757,25 +1761,30 @@ void rfapiRibUpdatePendingNode(
void rfapiRibUpdatePendingNodeSubtree( void rfapiRibUpdatePendingNodeSubtree(
struct bgp *bgp, struct rfapi_descriptor *rfd, struct bgp *bgp, struct rfapi_descriptor *rfd,
struct rfapi_import_table *it, struct route_node *it_node, struct rfapi_import_table *it, struct agg_node *it_node,
struct route_node *omit_subtree, /* may be NULL */ struct agg_node *omit_subtree, /* may be NULL */
uint32_t lifetime) uint32_t lifetime)
{ {
/* FIXME: need to find a better way here to work without sticking our /* FIXME: need to find a better way here to work without sticking our
* hands in node->link */ * hands in node->link */
if (it_node->l_left && (it_node->l_left != omit_subtree)) { if (agg_node_left(it_node)
if (it_node->l_left->info) && (agg_node_left(it_node) != omit_subtree)) {
rfapiRibUpdatePendingNode(bgp, rfd, it, it_node->l_left, if (agg_node_left(it_node)->info)
lifetime); rfapiRibUpdatePendingNode(
rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, it_node->l_left, bgp, rfd, it, agg_node_left(it_node), lifetime);
rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it,
agg_node_left(it_node),
omit_subtree, lifetime); omit_subtree, lifetime);
} }
if (it_node->l_right && (it_node->l_right != omit_subtree)) { if (agg_node_right(it_node)
if (it_node->l_right->info) && (agg_node_right(it_node) != omit_subtree)) {
if (agg_node_right(it_node)->info)
rfapiRibUpdatePendingNode(bgp, rfd, it, rfapiRibUpdatePendingNode(bgp, rfd, it,
it_node->l_right, lifetime); agg_node_right(it_node),
rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it, it_node->l_right, lifetime);
rfapiRibUpdatePendingNodeSubtree(bgp, rfd, it,
agg_node_right(it_node),
omit_subtree, lifetime); omit_subtree, lifetime);
} }
} }
@ -1788,13 +1797,13 @@ void rfapiRibUpdatePendingNodeSubtree(
*/ */
int rfapiRibFTDFilterRecentPrefix( int rfapiRibFTDFilterRecentPrefix(
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct route_node *it_rn, /* import table node */ struct agg_node *it_rn, /* import table node */
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct bgp *bgp = rfd->bgp; struct bgp *bgp = rfd->bgp;
afi_t afi = family2afi(it_rn->p.family); afi_t afi = family2afi(it_rn->p.family);
time_t prefix_time; time_t prefix_time;
struct route_node *trn; struct agg_node *trn;
/* /*
* Not in FTD mode, so allow prefix * Not in FTD mode, so allow prefix
@ -1833,10 +1842,10 @@ int rfapiRibFTDFilterRecentPrefix(
/* /*
* check this NVE's timestamp for this prefix * check this NVE's timestamp for this prefix
*/ */
trn = route_node_get(rfd->rsp_times[afi], &it_rn->p); /* locks trn */ trn = agg_node_get(rfd->rsp_times[afi], &it_rn->p); /* locks trn */
prefix_time = (time_t)trn->info; prefix_time = (time_t)trn->info;
if (trn->lock > 1) if (trn->lock > 1)
route_unlock_node(trn); agg_unlock_node(trn);
#if DEBUG_FTD_FILTER_RECENT #if DEBUG_FTD_FILTER_RECENT
vnc_zlog_debug_verbose("%s: last sent time %lu, last allowed time %lu", vnc_zlog_debug_verbose("%s: last sent time %lu, last allowed time %lu",
@ -1883,9 +1892,9 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
afi_t afi; afi_t afi;
struct rfapi_info *ri; struct rfapi_info *ri;
int need_insert; int need_insert;
struct route_node *rn; struct agg_node *rn;
int rib_node_started_nonempty = 0; int rib_node_started_nonempty = 0;
struct route_node *trn; struct agg_node *trn;
int allowed = 0; int allowed = 0;
/* save in case we delete nhp */ /* save in case we delete nhp */
@ -1947,13 +1956,13 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
/* /*
* Look up prefix in RIB * Look up prefix in RIB
*/ */
rn = route_node_get(rfd->rib[afi], &pfx); /* locks rn */ rn = agg_node_get(rfd->rib[afi], &pfx); /* locks rn */
if (rn->info) { if (rn->info) {
rib_node_started_nonempty = 1; rib_node_started_nonempty = 1;
} else { } else {
rn->info = skiplist_new(0, rfapi_rib_key_cmp, NULL); rn->info = skiplist_new(0, rfapi_rib_key_cmp, NULL);
route_lock_node(rn); agg_lock_node(rn);
} }
/* /*
@ -2063,15 +2072,15 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiRibStartTimer(rfd, ri, rn, 0); rfapiRibStartTimer(rfd, ri, rn, 0);
RFAPI_RIB_CHECK_COUNTS(0, 0); RFAPI_RIB_CHECK_COUNTS(0, 0);
route_unlock_node(rn); agg_unlock_node(rn);
/* /*
* update this NVE's timestamp for this prefix * update this NVE's timestamp for this prefix
*/ */
trn = route_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */ trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock(); trn->info = (void *)(uintptr_t)bgp_clock();
if (trn->lock > 1) if (trn->lock > 1)
route_unlock_node(trn); agg_unlock_node(trn);
{ {
char str_pfx[PREFIX_STRLEN]; char str_pfx[PREFIX_STRLEN];
@ -2108,7 +2117,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
} }
void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it, void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
afi_t afi, struct route_node *it_node) afi_t afi, struct agg_node *it_node)
{ {
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
struct listnode *node; struct listnode *node;
@ -2124,7 +2133,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* identifies the rfd that owns it. * identifies the rfd that owns it.
*/ */
struct rfapi_monitor_eth *m; struct rfapi_monitor_eth *m;
struct route_node *rn; struct agg_node *rn;
struct skiplist *sl; struct skiplist *sl;
void *cursor; void *cursor;
int rc; int rc;
@ -2154,12 +2163,12 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* NVE, it's OK to send an update with the * NVE, it's OK to send an update with the
* delete * delete
*/ */
if ((rn = route_node_lookup(m->rfd->rib[afi], if ((rn = agg_node_lookup(m->rfd->rib[afi],
&it_node->p))) { &it_node->p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, m->rfd, it, it_node, bgp, m->rfd, it, it_node,
m->rfd->response_lifetime); m->rfd->response_lifetime);
route_unlock_node(rn); agg_unlock_node(rn);
} }
} }
} }
@ -2177,7 +2186,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* this * this
* NVE, it's OK to send an update with the delete * NVE, it's OK to send an update with the delete
*/ */
if ((rn = route_node_lookup(m->rfd->rib[afi], if ((rn = agg_node_lookup(m->rfd->rib[afi],
&it_node->p))) { &it_node->p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, m->rfd, it, it_node, bgp, m->rfd, it, it_node,
@ -2192,7 +2201,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, node, for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, node,
rfd)) { rfd)) {
struct route_node *rn; struct agg_node *rn;
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: comparing rfd(%p)->import_table=%p to it=%p", "%s: comparing rfd(%p)->import_table=%p to it=%p",
@ -2209,12 +2218,12 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* prefix * prefix
* previously, we should send an updated response. * previously, we should send an updated response.
*/ */
if ((rn = route_node_lookup(rfd->rib[afi], if ((rn = agg_node_lookup(rfd->rib[afi],
&it_node->p))) { &it_node->p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, rfd, it, it_node, bgp, rfd, it, it_node,
rfd->response_lifetime); rfd->response_lifetime);
route_unlock_node(rn); agg_unlock_node(rn);
} }
} }
} }
@ -2406,13 +2415,13 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_node *rn; struct agg_node *rn;
if (!rfd->rib[afi]) if (!rfd->rib[afi])
continue; continue;
for (rn = route_top(rfd->rib[afi]); rn; for (rn = agg_route_top(rfd->rib[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
struct skiplist *sl; struct skiplist *sl;
char str_pfx[PREFIX_STRLEN]; char str_pfx[PREFIX_STRLEN];

View File

@ -93,17 +93,17 @@ extern void rfapiRibFree(struct rfapi_descriptor *rfd);
extern void rfapiRibUpdatePendingNode(struct bgp *bgp, extern void rfapiRibUpdatePendingNode(struct bgp *bgp,
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct rfapi_import_table *it, struct rfapi_import_table *it,
struct route_node *it_node, struct agg_node *it_node,
uint32_t lifetime); uint32_t lifetime);
extern void rfapiRibUpdatePendingNodeSubtree(struct bgp *bgp, extern void rfapiRibUpdatePendingNodeSubtree(struct bgp *bgp,
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct rfapi_import_table *it, struct rfapi_import_table *it,
struct route_node *it_node, struct agg_node *it_node,
struct route_node *omit_subtree, struct agg_node *omit_subtree,
uint32_t lifetime); uint32_t lifetime);
extern int rfapiRibPreloadBi(struct route_node *rfd_rib_node, extern int rfapiRibPreloadBi(struct agg_node *rfd_rib_node,
struct prefix *pfx_vn, struct prefix *pfx_un, struct prefix *pfx_vn, struct prefix *pfx_un,
uint32_t lifetime, struct bgp_info *bi); uint32_t lifetime, struct bgp_info *bi);
@ -113,7 +113,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
extern void rfapiRibPendingDeleteRoute(struct bgp *bgp, extern void rfapiRibPendingDeleteRoute(struct bgp *bgp,
struct rfapi_import_table *it, afi_t afi, struct rfapi_import_table *it, afi_t afi,
struct route_node *it_node); struct agg_node *it_node);
extern void rfapiRibShowResponsesSummary(void *stream); extern void rfapiRibShowResponsesSummary(void *stream);
@ -124,7 +124,7 @@ extern void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
extern int rfapiRibFTDFilterRecentPrefix( extern int rfapiRibFTDFilterRecentPrefix(
struct rfapi_descriptor *rfd, struct rfapi_descriptor *rfd,
struct route_node *it_rn, /* import table node */ struct agg_node *it_rn, /* import table node */
struct prefix *pfx_target_original); /* query target */ struct prefix *pfx_target_original); /* query target */
extern void rfapiFreeRfapiUnOptionChain(struct rfapi_un_option *p); extern void rfapiFreeRfapiUnOptionChain(struct rfapi_un_option *p);

View File

@ -23,7 +23,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/routemap.h" #include "lib/routemap.h"
@ -742,7 +742,7 @@ static void rfapiDebugPrintMonitorEncap(void *stream,
m->bi, HVTYNL); m->bi, HVTYNL);
} }
void rfapiShowItNode(void *stream, struct route_node *rn) void rfapiShowItNode(void *stream, struct agg_node *rn)
{ {
struct bgp_info *bi; struct bgp_info *bi;
char buf[BUFSIZ]; char buf[BUFSIZ];
@ -766,10 +766,10 @@ void rfapiShowItNode(void *stream, struct route_node *rn)
/* doesn't show montors */ /* doesn't show montors */
} }
void rfapiShowImportTable(void *stream, const char *label, void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt,
struct route_table *rt, int isvpn) int isvpn)
{ {
struct route_node *rn; struct agg_node *rn;
char buf[BUFSIZ]; char buf[BUFSIZ];
int (*fp)(void *, const char *, ...); int (*fp)(void *, const char *, ...);
@ -782,7 +782,7 @@ void rfapiShowImportTable(void *stream, const char *label,
fp(out, "Import Table [%s]%s", label, HVTYNL); fp(out, "Import Table [%s]%s", label, HVTYNL);
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
struct bgp_info *bi; struct bgp_info *bi;
if (rn->p.family == AF_ETHERNET) { if (rn->p.family == AF_ETHERNET) {
@ -851,7 +851,7 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
for (ALL_LIST_ELEMENTS_RO(&h->descriptors, node, rfd)) { for (ALL_LIST_ELEMENTS_RO(&h->descriptors, node, rfd)) {
struct route_node *rn; struct agg_node *rn;
int printedquerier = 0; int printedquerier = 0;
@ -868,8 +868,8 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
* IP Queries * IP Queries
*/ */
if (rfd->mon) { if (rfd->mon) {
for (rn = route_top(rfd->mon); rn; for (rn = agg_route_top(rfd->mon); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
char buf_remain[BUFSIZ]; char buf_remain[BUFSIZ];
char buf_pfx[BUFSIZ]; char buf_pfx[BUFSIZ];
@ -1012,7 +1012,7 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
} }
static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream, static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
struct route_node *rn, struct bgp_info *bi) struct agg_node *rn, struct bgp_info *bi)
{ {
int (*fp)(void *, const char *, ...); int (*fp)(void *, const char *, ...);
struct vty *vty; struct vty *vty;
@ -1218,13 +1218,13 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream,
for (afi = AFI_IP; afi < AFI_MAX; ++afi) { for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
struct route_node *rn; struct agg_node *rn;
if (!it->imported_vpn[afi]) if (!it->imported_vpn[afi])
continue; continue;
for (rn = route_top(it->imported_vpn[afi]); rn; for (rn = agg_route_top(it->imported_vpn[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
struct bgp_info *bi; struct bgp_info *bi;
int count_only; int count_only;

View File

@ -124,7 +124,7 @@ extern char *rfapiMonitorVpn2Str(struct rfapi_monitor_vpn *m, char *buf,
extern const char *rfapiRfapiIpPrefix2Str(struct rfapi_ip_prefix *p, char *buf, extern const char *rfapiRfapiIpPrefix2Str(struct rfapi_ip_prefix *p, char *buf,
int bufsize); int bufsize);
extern void rfapiShowItNode(void *stream, struct route_node *rn); extern void rfapiShowItNode(void *stream, struct agg_node *rn);
extern char *rfapiEthAddr2Str(const struct ethaddr *ea, char *buf, int bufsize); extern char *rfapiEthAddr2Str(const struct ethaddr *ea, char *buf, int bufsize);

View File

@ -25,7 +25,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/log.h" #include "lib/log.h"
#include "lib/stream.h" #include "lib/stream.h"
@ -54,7 +54,7 @@
static void vnc_direct_add_rn_group_rd(struct bgp *bgp, static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
struct route_node *rn, struct attr *attr, struct agg_node *rn, struct attr *attr,
afi_t afi, afi_t afi,
struct rfapi_descriptor *irfd); struct rfapi_descriptor *irfd);
@ -172,7 +172,7 @@ static int getce(struct bgp *bgp, struct attr *attr, struct prefix *pfx_ce)
} }
void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
struct bgp_info *bi) struct bgp_info *bi)
{ {
struct attr *attr = bi->attr; struct attr *attr = bi->attr;
@ -327,7 +327,7 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn,
/* /*
* "Withdrawing a Route" export process * "Withdrawing a Route" export process
*/ */
void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn,
struct bgp_info *bi) struct bgp_info *bi)
{ {
afi_t afi = family2afi(rn->p.family); afi_t afi = family2afi(rn->p.family);
@ -404,7 +404,7 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn,
static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi) static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi)
{ {
struct route_node *rn; struct agg_node *rn;
struct bgp_info *ri; struct bgp_info *ri;
vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi);
@ -430,8 +430,8 @@ static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi)
/* /*
* Go through entire ce import table and export to BGP unicast. * Go through entire ce import table and export to BGP unicast.
*/ */
for (rn = route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn; for (rn = agg_route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn;
rn = route_next(rn)) { rn = agg_route_next(rn)) {
if (!rn->info) if (!rn->info)
continue; continue;
@ -513,7 +513,7 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
* Export methods that proxy nexthop BEGIN * Export methods that proxy nexthop BEGIN
***********************************************************************/ ***********************************************************************/
static struct ecommunity *vnc_route_origin_ecom(struct route_node *rn) static struct ecommunity *vnc_route_origin_ecom(struct agg_node *rn)
{ {
struct ecommunity *new; struct ecommunity *new;
struct bgp_info *bi; struct bgp_info *bi;
@ -586,7 +586,7 @@ static struct ecommunity *vnc_route_origin_ecom_single(struct in_addr *origin)
static int static int
encap_attr_export(struct attr *new, struct attr *orig, encap_attr_export(struct attr *new, struct attr *orig,
struct prefix *new_nexthop, struct prefix *new_nexthop,
struct route_node *rn) /* for VN addrs for ecom list */ struct agg_node *rn) /* for VN addrs for ecom list */
/* if rn is 0, use route's nexthop */ /* if rn is 0, use route's nexthop */
{ {
struct prefix orig_nexthop; struct prefix orig_nexthop;
@ -692,7 +692,7 @@ encap_attr_export(struct attr *new, struct attr *orig,
*/ */
void vnc_direct_bgp_add_prefix(struct bgp *bgp, void vnc_direct_bgp_add_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn) struct agg_node *rn)
{ {
struct attr attr = {0}; struct attr attr = {0};
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -803,7 +803,7 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp,
*/ */
void vnc_direct_bgp_del_prefix(struct bgp *bgp, void vnc_direct_bgp_del_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn) struct agg_node *rn)
{ {
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct rfapi_rfg_name *rfgn; struct rfapi_rfg_name *rfgn;
@ -965,8 +965,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
*/ */
if (rfgn->rfg == rfg) { if (rfgn->rfg == rfg) {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct attr attr = {0}; struct attr attr = {0};
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
@ -987,7 +987,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
@ -1111,8 +1112,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
*/ */
if (rfg && rfgn->rfg == rfg) { if (rfg && rfgn->rfg == rfg) {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
import_table = rfg->rfapi_import_table; import_table = rfg->rfapi_import_table;
@ -1128,7 +1129,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
@ -1159,7 +1161,7 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
static void vnc_direct_add_rn_group_rd(struct bgp *bgp, static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
struct route_node *rn, struct attr *attr, struct agg_node *rn, struct attr *attr,
afi_t afi, struct rfapi_descriptor *irfd) afi_t afi, struct rfapi_descriptor *irfd)
{ {
struct prefix nhp; struct prefix nhp;
@ -1279,8 +1281,8 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
afi_t afi) afi_t afi)
{ {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct attr attr = {0}; struct attr attr = {0};
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
@ -1311,7 +1313,7 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp,
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
@ -1366,7 +1368,7 @@ void vnc_direct_bgp_add_group(struct bgp *bgp, struct rfapi_nve_group_cfg *rfg)
static void vnc_direct_del_rn_group_rd(struct bgp *bgp, static void vnc_direct_del_rn_group_rd(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
struct route_node *rn, afi_t afi, struct agg_node *rn, afi_t afi,
struct rfapi_descriptor *irfd) struct rfapi_descriptor *irfd)
{ {
if (irfd == NULL) if (irfd == NULL)
@ -1388,8 +1390,8 @@ static void vnc_direct_bgp_del_group_afi(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
afi_t afi) afi_t afi)
{ {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
vnc_zlog_debug_verbose("%s: entry", __func__); vnc_zlog_debug_verbose("%s: entry", __func__);
@ -1412,7 +1414,7 @@ static void vnc_direct_bgp_del_group_afi(struct bgp *bgp,
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn))
if (rn->info) { if (rn->info) {
if (rfg->type == RFAPI_GROUP_CFG_VRF) if (rfg->type == RFAPI_GROUP_CFG_VRF)
vnc_direct_del_rn_group_rd(bgp, rfg, rn, afi, vnc_direct_del_rn_group_rd(bgp, rfg, rn, afi,
@ -1473,14 +1475,14 @@ void vnc_direct_bgp_reexport_group_afi(struct bgp *bgp,
} }
static void vnc_direct_bgp_unexport_table(afi_t afi, struct route_table *rt, static void vnc_direct_bgp_unexport_table(afi_t afi, struct agg_table *rt,
struct list *nve_list) struct list *nve_list)
{ {
if (nve_list) { if (nve_list) {
struct route_node *rn; struct agg_node *rn;
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {

View File

@ -29,19 +29,19 @@
#include "rfapi_private.h" #include "rfapi_private.h"
extern void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, extern void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
struct bgp_info *bi); struct bgp_info *bi);
extern void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, extern void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn,
struct bgp_info *bi); struct bgp_info *bi);
extern void vnc_direct_bgp_add_prefix(struct bgp *bgp, extern void vnc_direct_bgp_add_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn); struct agg_node *rn);
extern void vnc_direct_bgp_del_prefix(struct bgp *bgp, extern void vnc_direct_bgp_del_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn); struct agg_node *rn);
extern void vnc_direct_bgp_add_nve(struct bgp *bgp, extern void vnc_direct_bgp_add_nve(struct bgp *bgp,
struct rfapi_descriptor *rfd); struct rfapi_descriptor *rfd);

View File

@ -21,7 +21,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/memory.h" #include "lib/memory.h"
#include "lib/vty.h" #include "lib/vty.h"
@ -33,11 +33,11 @@
#include "bgpd/rfapi/rfapi_import.h" #include "bgpd/rfapi/rfapi_import.h"
#include "bgpd/rfapi/vnc_debug.h" #include "bgpd/rfapi/vnc_debug.h"
struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
struct prefix *p) struct prefix *p)
{ {
struct route_table *t = NULL; struct agg_table *t = NULL;
struct route_node *rn = NULL; struct agg_node *rn = NULL;
afi_t afi; afi_t afi;
if (!bgp || !bgp->rfapi) if (!bgp || !bgp->rfapi)
@ -49,27 +49,27 @@ struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
switch (type) { switch (type) {
case EXPORT_TYPE_BGP: case EXPORT_TYPE_BGP:
if (!bgp->rfapi->rt_export_bgp[afi]) if (!bgp->rfapi->rt_export_bgp[afi])
bgp->rfapi->rt_export_bgp[afi] = route_table_init(); bgp->rfapi->rt_export_bgp[afi] = agg_table_init();
t = bgp->rfapi->rt_export_bgp[afi]; t = bgp->rfapi->rt_export_bgp[afi];
break; break;
case EXPORT_TYPE_ZEBRA: case EXPORT_TYPE_ZEBRA:
if (!bgp->rfapi->rt_export_zebra[afi]) if (!bgp->rfapi->rt_export_zebra[afi])
bgp->rfapi->rt_export_zebra[afi] = route_table_init(); bgp->rfapi->rt_export_zebra[afi] = agg_table_init();
t = bgp->rfapi->rt_export_zebra[afi]; t = bgp->rfapi->rt_export_zebra[afi];
break; break;
} }
if (t) if (t)
rn = route_node_get(t, p); rn = agg_node_get(t, p);
return rn; return rn;
} }
struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
struct prefix *p) struct prefix *p)
{ {
struct route_table *t = NULL; struct agg_table *t = NULL;
struct route_node *rn = NULL; struct agg_node *rn = NULL;
afi_t afi; afi_t afi;
if (!bgp || !bgp->rfapi) if (!bgp || !bgp->rfapi)
@ -81,19 +81,19 @@ struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
switch (type) { switch (type) {
case EXPORT_TYPE_BGP: case EXPORT_TYPE_BGP:
if (!bgp->rfapi->rt_export_bgp[afi]) if (!bgp->rfapi->rt_export_bgp[afi])
bgp->rfapi->rt_export_bgp[afi] = route_table_init(); bgp->rfapi->rt_export_bgp[afi] = agg_table_init();
t = bgp->rfapi->rt_export_bgp[afi]; t = bgp->rfapi->rt_export_bgp[afi];
break; break;
case EXPORT_TYPE_ZEBRA: case EXPORT_TYPE_ZEBRA:
if (!bgp->rfapi->rt_export_zebra[afi]) if (!bgp->rfapi->rt_export_zebra[afi])
bgp->rfapi->rt_export_zebra[afi] = route_table_init(); bgp->rfapi->rt_export_zebra[afi] = agg_table_init();
t = bgp->rfapi->rt_export_zebra[afi]; t = bgp->rfapi->rt_export_zebra[afi];
break; break;
} }
if (t) if (t)
rn = route_node_lookup(t, p); rn = agg_node_lookup(t, p);
return rn; return rn;
} }
@ -101,7 +101,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
struct prefix *p, struct peer *peer, struct prefix *p, struct peer *peer,
uint8_t type, uint8_t subtype) uint8_t type, uint8_t subtype)
{ {
struct route_node *etn; struct agg_node *etn;
struct vnc_export_info *eti; struct vnc_export_info *eti;
etn = vnc_etn_get(bgp, etype, p); etn = vnc_etn_get(bgp, etype, p);
@ -116,7 +116,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
} }
if (eti) { if (eti) {
route_unlock_node(etn); agg_unlock_node(etn);
} else { } else {
eti = XCALLOC(MTYPE_RFAPI_ETI, sizeof(struct vnc_export_info)); eti = XCALLOC(MTYPE_RFAPI_ETI, sizeof(struct vnc_export_info));
assert(eti); assert(eti);
@ -134,7 +134,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
void vnc_eti_delete(struct vnc_export_info *goner) void vnc_eti_delete(struct vnc_export_info *goner)
{ {
struct route_node *etn; struct agg_node *etn;
struct vnc_export_info *eti; struct vnc_export_info *eti;
struct vnc_export_info *eti_prev = NULL; struct vnc_export_info *eti_prev = NULL;
@ -160,7 +160,7 @@ void vnc_eti_delete(struct vnc_export_info *goner)
goner->node = NULL; goner->node = NULL;
XFREE(MTYPE_RFAPI_ETI, goner); XFREE(MTYPE_RFAPI_ETI, goner);
route_unlock_node(etn); agg_unlock_node(etn);
} }
struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp, struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
@ -168,7 +168,7 @@ struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
struct prefix *p, struct peer *peer, struct prefix *p, struct peer *peer,
uint8_t type, uint8_t subtype) uint8_t type, uint8_t subtype)
{ {
struct route_node *etn; struct agg_node *etn;
struct vnc_export_info *eti; struct vnc_export_info *eti;
etn = vnc_etn_lookup(bgp, etype, p); etn = vnc_etn_lookup(bgp, etype, p);
@ -183,7 +183,7 @@ struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
} }
} }
route_unlock_node(etn); agg_unlock_node(etn);
if (eti && eti->timer) if (eti && eti->timer)
return eti; return eti;

View File

@ -37,7 +37,7 @@ typedef enum vnc_export_type {
struct vnc_export_info { struct vnc_export_info {
struct vnc_export_info *next; struct vnc_export_info *next;
struct route_node *node; struct agg_node *node;
struct peer *peer; struct peer *peer;
uint8_t type; uint8_t type;
uint8_t subtype; uint8_t subtype;
@ -45,11 +45,11 @@ struct vnc_export_info {
struct thread *timer; struct thread *timer;
}; };
extern struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type, extern struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
struct prefix *p); struct prefix *p);
extern struct route_node * extern struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type, struct prefix *p); struct prefix *p);
extern struct vnc_export_info *vnc_eti_get(struct bgp *bgp, extern struct vnc_export_info *vnc_eti_get(struct bgp *bgp,
vnc_export_type_t etype, vnc_export_type_t etype,

View File

@ -25,7 +25,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/vty.h" #include "lib/vty.h"
#include "lib/log.h" #include "lib/log.h"
#include "lib/memory.h" #include "lib/memory.h"
@ -1737,9 +1737,9 @@ static void vnc_import_bgp_exterior_add_route_it(
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop); rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop);
for (it = h->imports; it; it = it->next) { for (it = h->imports; it; it = it->next) {
struct route_table *table; struct agg_table *table;
struct route_node *rn; struct agg_node *rn;
struct route_node *par; struct agg_node *par;
struct bgp_info *bi_interior; struct bgp_info *bi_interior;
int have_usable_route; int have_usable_route;
@ -1753,7 +1753,7 @@ static void vnc_import_bgp_exterior_add_route_it(
table = it->imported_vpn[afi]; table = it->imported_vpn[afi];
for (rn = route_node_match(table, &pfx_orig_nexthop), for (rn = agg_node_match(table, &pfx_orig_nexthop),
have_usable_route = 0; have_usable_route = 0;
(!have_usable_route) && rn;) { (!have_usable_route) && rn;) {
@ -1821,9 +1821,9 @@ static void vnc_import_bgp_exterior_add_route_it(
0, NULL, 0, NULL,
(void (*)(void *)) (void (*)(void *))
prefix_free); prefix_free);
route_lock_node(rn); /* for skiplist */ agg_lock_node(rn); /* for skiplist */
} }
route_lock_node(rn); /* for skiplist entry */ agg_lock_node(rn); /* for skiplist entry */
prefix_copy(pfx_mon, prefix); prefix_copy(pfx_mon, prefix);
if (!skiplist_insert( if (!skiplist_insert(
RFAPI_MONITOR_EXTERIOR(rn)->source, RFAPI_MONITOR_EXTERIOR(rn)->source,
@ -1832,14 +1832,14 @@ static void vnc_import_bgp_exterior_add_route_it(
bgp_info_lock(info); bgp_info_lock(info);
} }
} }
par = rn->parent; par = agg_node_parent(rn);
if (par) if (par)
route_lock_node(par); agg_lock_node(par);
route_unlock_node(rn); agg_unlock_node(rn);
rn = par; rn = par;
} }
if (rn) if (rn)
route_unlock_node(rn); agg_unlock_node(rn);
if (!have_usable_route) { if (!have_usable_route) {
struct prefix *pfx_mon = prefix_new(); struct prefix *pfx_mon = prefix_new();
@ -1928,15 +1928,15 @@ void vnc_import_bgp_exterior_del_route(
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop); rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_orig_nexthop);
for (it = h->imports; it; it = it->next) { for (it = h->imports; it; it = it->next) {
struct route_table *table; struct agg_table *table;
struct route_node *rn; struct agg_node *rn;
struct route_node *par; struct agg_node *par;
struct bgp_info *bi_interior; struct bgp_info *bi_interior;
int have_usable_route; int have_usable_route;
table = it->imported_vpn[afi]; table = it->imported_vpn[afi];
for (rn = route_node_match(table, &pfx_orig_nexthop), for (rn = agg_node_match(table, &pfx_orig_nexthop),
have_usable_route = 0; have_usable_route = 0;
(!have_usable_route) && rn;) { (!have_usable_route) && rn;) {
@ -1987,7 +1987,7 @@ void vnc_import_bgp_exterior_del_route(
info, NULL)) { info, NULL)) {
bgp_info_unlock(info); bgp_info_unlock(info);
route_unlock_node( agg_unlock_node(
rn); /* sl entry rn); /* sl entry
*/ */
} }
@ -2002,7 +2002,7 @@ void vnc_import_bgp_exterior_del_route(
RFAPI_MONITOR_EXTERIOR( RFAPI_MONITOR_EXTERIOR(
rn) rn)
->source = NULL; ->source = NULL;
route_unlock_node( agg_unlock_node(
rn); /* skiplist rn); /* skiplist
itself itself
*/ */
@ -2010,14 +2010,14 @@ void vnc_import_bgp_exterior_del_route(
} }
} }
} }
par = rn->parent; par = agg_node_parent(rn);
if (par) if (par)
route_lock_node(par); agg_lock_node(par);
route_unlock_node(rn); agg_unlock_node(rn);
rn = par; rn = par;
} }
if (rn) if (rn)
route_unlock_node(rn); agg_unlock_node(rn);
if (!have_usable_route) { if (!have_usable_route) {
if (!skiplist_delete(it->monitor_exterior_orphans, info, if (!skiplist_delete(it->monitor_exterior_orphans, info,
@ -2038,11 +2038,11 @@ void vnc_import_bgp_exterior_del_route(
*/ */
void vnc_import_bgp_exterior_add_route_interior( void vnc_import_bgp_exterior_add_route_interior(
struct bgp *bgp, struct rfapi_import_table *it, struct bgp *bgp, struct rfapi_import_table *it,
struct route_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_info *bi_interior) /* VPN IT route */ struct bgp_info *bi_interior) /* VPN IT route */
{ {
afi_t afi = family2afi(rn_interior->p.family); afi_t afi = family2afi(rn_interior->p.family);
struct route_node *par; struct agg_node *par;
struct bgp_info *bi_exterior; struct bgp_info *bi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */ struct prefix *pfx_exterior; /* exterior pfx */
void *cursor; void *cursor;
@ -2161,7 +2161,8 @@ void vnc_import_bgp_exterior_add_route_interior(
* Look up the tree for possible pulldown candidates. * Look up the tree for possible pulldown candidates.
* Find nearest parent with an exterior route monitor * Find nearest parent with an exterior route monitor
*/ */
for (par = rn_interior->parent; par; par = par->parent) { for (par = agg_node_parent(rn_interior); par;
par = agg_node_parent(par)) {
if (RFAPI_HAS_MONITOR_EXTERIOR(par)) if (RFAPI_HAS_MONITOR_EXTERIOR(par))
break; break;
} }
@ -2211,13 +2212,13 @@ void vnc_import_bgp_exterior_add_route_interior(
->source = skiplist_new( ->source = skiplist_new(
0, NULL, 0, NULL,
(void (*)(void *))prefix_free); (void (*)(void *))prefix_free);
route_lock_node(rn_interior); agg_lock_node(rn_interior);
} }
skiplist_insert( skiplist_insert(
RFAPI_MONITOR_EXTERIOR(rn_interior) RFAPI_MONITOR_EXTERIOR(rn_interior)
->source, ->source,
bi_exterior, pfx_mon); bi_exterior, pfx_mon);
route_lock_node(rn_interior); agg_lock_node(rn_interior);
/* /*
* Delete constructed exterior routes based on * Delete constructed exterior routes based on
@ -2291,12 +2292,12 @@ void vnc_import_bgp_exterior_add_route_interior(
skiplist_delete(RFAPI_MONITOR_EXTERIOR(par)->source, skiplist_delete(RFAPI_MONITOR_EXTERIOR(par)->source,
bi_exterior, NULL); bi_exterior, NULL);
route_unlock_node(par); /* sl entry */ agg_unlock_node(par); /* sl entry */
} }
if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(par)->source)) { if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(par)->source)) {
skiplist_free(RFAPI_MONITOR_EXTERIOR(par)->source); skiplist_free(RFAPI_MONITOR_EXTERIOR(par)->source);
RFAPI_MONITOR_EXTERIOR(par)->source = NULL; RFAPI_MONITOR_EXTERIOR(par)->source = NULL;
route_unlock_node(par); /* sl itself */ agg_unlock_node(par); /* sl itself */
} }
} }
@ -2353,12 +2354,12 @@ void vnc_import_bgp_exterior_add_route_interior(
skiplist_new( skiplist_new(
0, NULL, 0, NULL,
(void (*)(void *))prefix_free); (void (*)(void *))prefix_free);
route_lock_node(rn_interior); /* sl */ agg_lock_node(rn_interior); /* sl */
} }
skiplist_insert( skiplist_insert(
RFAPI_MONITOR_EXTERIOR(rn_interior)->source, RFAPI_MONITOR_EXTERIOR(rn_interior)->source,
bi_exterior, pfx_mon); bi_exterior, pfx_mon);
route_lock_node(rn_interior); /* sl entry */ agg_lock_node(rn_interior); /* sl entry */
if (!list_adopted) { if (!list_adopted) {
list_adopted = list_new(); list_adopted = list_new();
} }
@ -2397,7 +2398,7 @@ void vnc_import_bgp_exterior_add_route_interior(
} }
if (list_adopted) { if (list_adopted) {
struct listnode *node; struct listnode *node;
struct route_node *bi_exterior; struct agg_node *bi_exterior;
for (ALL_LIST_ELEMENTS_RO(list_adopted, node, bi_exterior)) { for (ALL_LIST_ELEMENTS_RO(list_adopted, node, bi_exterior)) {
skiplist_delete(it->monitor_exterior_orphans, skiplist_delete(it->monitor_exterior_orphans,
@ -2419,11 +2420,11 @@ void vnc_import_bgp_exterior_add_route_interior(
*/ */
void vnc_import_bgp_exterior_del_route_interior( void vnc_import_bgp_exterior_del_route_interior(
struct bgp *bgp, struct rfapi_import_table *it, struct bgp *bgp, struct rfapi_import_table *it,
struct route_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_info *bi_interior) /* VPN IT route */ struct bgp_info *bi_interior) /* VPN IT route */
{ {
afi_t afi = family2afi(rn_interior->p.family); afi_t afi = family2afi(rn_interior->p.family);
struct route_node *par; struct agg_node *par;
struct bgp_info *bi_exterior; struct bgp_info *bi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */ struct prefix *pfx_exterior; /* exterior pfx */
void *cursor; void *cursor;
@ -2509,7 +2510,8 @@ void vnc_import_bgp_exterior_del_route_interior(
* If none is found, par will end up NULL, and we will move * If none is found, par will end up NULL, and we will move
* the monitors to the orphan list for this import table * the monitors to the orphan list for this import table
*/ */
for (par = rn_interior->parent; par; par = par->parent) { for (par = agg_node_parent(rn_interior); par;
par = agg_node_parent(par)) {
if (RFAPI_MONITOR_EXTERIOR(par)->valid_interior_count) if (RFAPI_MONITOR_EXTERIOR(par)->valid_interior_count)
break; break;
} }
@ -2540,11 +2542,11 @@ void vnc_import_bgp_exterior_del_route_interior(
skiplist_new( skiplist_new(
0, NULL, 0, NULL,
(void (*)(void *))prefix_free); (void (*)(void *))prefix_free);
route_lock_node(par); /* sl */ agg_lock_node(par); /* sl */
} }
skiplist_insert(RFAPI_MONITOR_EXTERIOR(par)->source, skiplist_insert(RFAPI_MONITOR_EXTERIOR(par)->source,
bi_exterior, pfx_mon); bi_exterior, pfx_mon);
route_lock_node(par); /* sl entry */ agg_lock_node(par); /* sl entry */
/* Add constructed exterior routes based on parent */ /* Add constructed exterior routes based on parent */
for (bi = par->info; bi; bi = bi->next) { for (bi = par->info; bi; bi = bi->next) {
@ -2596,12 +2598,12 @@ void vnc_import_bgp_exterior_del_route_interior(
skiplist_delete_first( skiplist_delete_first(
RFAPI_MONITOR_EXTERIOR(rn_interior)->source); RFAPI_MONITOR_EXTERIOR(rn_interior)->source);
route_unlock_node(rn_interior); /* sl entry */ agg_unlock_node(rn_interior); /* sl entry */
} }
if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(rn_interior)->source)) { if (skiplist_empty(RFAPI_MONITOR_EXTERIOR(rn_interior)->source)) {
skiplist_free(RFAPI_MONITOR_EXTERIOR(rn_interior)->source); skiplist_free(RFAPI_MONITOR_EXTERIOR(rn_interior)->source);
RFAPI_MONITOR_EXTERIOR(rn_interior)->source = NULL; RFAPI_MONITOR_EXTERIOR(rn_interior)->source = NULL;
route_unlock_node(rn_interior); /* sl itself */ agg_unlock_node(rn_interior); /* sl itself */
} }
} }

View File

@ -29,12 +29,12 @@
extern void vnc_import_bgp_exterior_add_route_interior( extern void vnc_import_bgp_exterior_add_route_interior(
struct bgp *bgp, struct rfapi_import_table *it, struct bgp *bgp, struct rfapi_import_table *it,
struct route_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_info *bi_interior); /* VPN IT route */ struct bgp_info *bi_interior); /* VPN IT route */
extern void vnc_import_bgp_exterior_del_route_interior( extern void vnc_import_bgp_exterior_del_route_interior(
struct bgp *bgp, struct rfapi_import_table *it, struct bgp *bgp, struct rfapi_import_table *it,
struct route_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_info *bi_interior); /* VPN IT route */ struct bgp_info *bi_interior); /* VPN IT route */
extern void extern void

View File

@ -25,7 +25,7 @@
#include "lib/zebra.h" #include "lib/zebra.h"
#include "lib/prefix.h" #include "lib/prefix.h"
#include "lib/table.h" #include "lib/agg_table.h"
#include "lib/log.h" #include "lib/log.h"
#include "lib/command.h" #include "lib/command.h"
#include "lib/zclient.h" #include "lib/zclient.h"
@ -556,7 +556,7 @@ static void import_table_to_nve_list_zebra(struct bgp *bgp,
static void vnc_zebra_add_del_prefix(struct bgp *bgp, static void vnc_zebra_add_del_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn, struct agg_node *rn,
int add) /* !0 = add, 0 = del */ int add) /* !0 = add, 0 = del */
{ {
struct list *nves; struct list *nves;
@ -611,14 +611,14 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
void vnc_zebra_add_prefix(struct bgp *bgp, void vnc_zebra_add_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn) struct agg_node *rn)
{ {
vnc_zebra_add_del_prefix(bgp, import_table, rn, 1); vnc_zebra_add_del_prefix(bgp, import_table, rn, 1);
} }
void vnc_zebra_del_prefix(struct bgp *bgp, void vnc_zebra_del_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn) struct agg_node *rn)
{ {
vnc_zebra_add_del_prefix(bgp, import_table, rn, 0); vnc_zebra_add_del_prefix(bgp, import_table, rn, 0);
} }
@ -678,8 +678,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/ */
if (rfgn->rfg == rfg) { if (rfgn->rfg == rfg) {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
import_table = rfg->rfapi_import_table; import_table = rfg->rfapi_import_table;
@ -692,7 +692,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd,
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
@ -721,8 +722,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
struct rfapi_nve_group_cfg *rfg, struct rfapi_nve_group_cfg *rfg,
afi_t afi, int add) afi_t afi, int add)
{ {
struct route_table *rt = NULL; struct agg_table *rt = NULL;
struct route_node *rn; struct agg_node *rn;
struct rfapi_import_table *import_table; struct rfapi_import_table *import_table;
uint8_t family = afi2family(afi); uint8_t family = afi2family(afi);
@ -773,7 +774,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
/* /*
* Walk the NVE-Group's VNC Import table * Walk the NVE-Group's VNC Import table
*/ */
for (rn = route_top(rt); rn; rn = route_next(rn)) { for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
vnc_zebra_route_msg(&rn->p, vnc_zebra_route_msg(&rn->p,
nexthop_count, nexthop_count,

View File

@ -29,11 +29,11 @@
extern void vnc_zebra_add_prefix(struct bgp *bgp, extern void vnc_zebra_add_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn); struct agg_node *rn);
extern void vnc_zebra_del_prefix(struct bgp *bgp, extern void vnc_zebra_del_prefix(struct bgp *bgp,
struct rfapi_import_table *import_table, struct rfapi_import_table *import_table,
struct route_node *rn); struct agg_node *rn);
extern void vnc_zebra_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd); extern void vnc_zebra_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd);

View File

@ -230,7 +230,7 @@ void *rfp_start(struct thread_master *master, struct rfapi_rfp_cfg **cfgp,
/* initilize struct rfapi_rfp_cfg, see rfapi.h */ /* initilize struct rfapi_rfp_cfg, see rfapi.h */
global_rfi.rfapi_config.download_type = global_rfi.rfapi_config.download_type =
RFAPI_RFP_DOWNLOAD_FULL; /* default=partial */ RFAPI_RFP_DOWNLOAD_PARTIAL; /* default=partial */
global_rfi.rfapi_config.ftd_advertisement_interval = global_rfi.rfapi_config.ftd_advertisement_interval =
RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL; RFAPI_RFP_CFG_DEFAULT_FTD_ADVERTISEMENT_INTERVAL;
global_rfi.rfapi_config.holddown_factor = global_rfi.rfapi_config.holddown_factor =

View File

@ -31,7 +31,7 @@
#include "stream.h" #include "stream.h"
#include "zclient.h" #include "zclient.h"
#include "command.h" #include "command.h"
#include "table.h" #include "agg_table.h"
#include "thread.h" #include "thread.h"
#include "privs.h" #include "privs.h"
#include "vrf.h" #include "vrf.h"
@ -159,14 +159,15 @@ static int ripng_if_ipv6_lladdress_check(struct interface *ifp)
static int ripng_if_down(struct interface *ifp) static int ripng_if_down(struct interface *ifp)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_interface *ri; struct ripng_interface *ri;
struct list *list = NULL; struct list *list = NULL;
struct listnode *listnode = NULL, *nextnode = NULL; struct listnode *listnode = NULL, *nextnode = NULL;
if (ripng) if (ripng)
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->table); rp;
rp = agg_route_next(rp))
if ((list = rp->info) != NULL) if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS(list, listnode, nextnode, for (ALL_LIST_ELEMENTS(list, listnode, nextnode,
rinfo)) rinfo))
@ -479,7 +480,7 @@ int ripng_interface_address_delete(int command, struct zclient *zclient,
vector ripng_enable_if; vector ripng_enable_if;
/* RIPng enable network table. */ /* RIPng enable network table. */
struct route_table *ripng_enable_network; struct agg_table *ripng_enable_network;
/* Lookup RIPng enable network. */ /* Lookup RIPng enable network. */
/* Check wether the interface has at least a connected prefix that /* Check wether the interface has at least a connected prefix that
@ -492,7 +493,7 @@ static int ripng_enable_network_lookup_if(struct interface *ifp)
for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) {
struct prefix *p; struct prefix *p;
struct route_node *n; struct agg_node *n;
p = connected->address; p = connected->address;
@ -501,10 +502,10 @@ static int ripng_enable_network_lookup_if(struct interface *ifp)
address.prefix = p->u.prefix6; address.prefix = p->u.prefix6;
address.prefixlen = IPV6_MAX_BITLEN; address.prefixlen = IPV6_MAX_BITLEN;
n = route_node_match(ripng_enable_network, n = agg_node_match(ripng_enable_network,
(struct prefix *)&address); (struct prefix *)&address);
if (n) { if (n) {
route_unlock_node(n); agg_unlock_node(n);
return 1; return 1;
} }
} }
@ -521,7 +522,7 @@ static int ripng_enable_network_lookup2(struct connected *connected)
p = connected->address; p = connected->address;
if (p->family == AF_INET6) { if (p->family == AF_INET6) {
struct route_node *node; struct agg_node *node;
address.family = p->family; address.family = p->family;
address.prefix = p->u.prefix6; address.prefix = p->u.prefix6;
@ -529,11 +530,11 @@ static int ripng_enable_network_lookup2(struct connected *connected)
/* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within
* ripng_enable_network */ * ripng_enable_network */
node = route_node_match(ripng_enable_network, node = agg_node_match(ripng_enable_network,
(struct prefix *)&address); (struct prefix *)&address);
if (node) { if (node) {
route_unlock_node(node); agg_unlock_node(node);
return 1; return 1;
} }
} }
@ -544,12 +545,12 @@ static int ripng_enable_network_lookup2(struct connected *connected)
/* Add RIPng enable network. */ /* Add RIPng enable network. */
static int ripng_enable_network_add(struct prefix *p) static int ripng_enable_network_add(struct prefix *p)
{ {
struct route_node *node; struct agg_node *node;
node = route_node_get(ripng_enable_network, p); node = agg_node_get(ripng_enable_network, p);
if (node->info) { if (node->info) {
route_unlock_node(node); agg_unlock_node(node);
return -1; return -1;
} else } else
node->info = (void *)1; node->info = (void *)1;
@ -563,17 +564,17 @@ static int ripng_enable_network_add(struct prefix *p)
/* Delete RIPng enable network. */ /* Delete RIPng enable network. */
static int ripng_enable_network_delete(struct prefix *p) static int ripng_enable_network_delete(struct prefix *p)
{ {
struct route_node *node; struct agg_node *node;
node = route_node_lookup(ripng_enable_network, p); node = agg_node_lookup(ripng_enable_network, p);
if (node) { if (node) {
node->info = NULL; node->info = NULL;
/* Unlock info lock. */ /* Unlock info lock. */
route_unlock_node(node); agg_unlock_node(node);
/* Unlock lookup lock. */ /* Unlock lookup lock. */
route_unlock_node(node); agg_unlock_node(node);
return 1; return 1;
} }
@ -771,13 +772,14 @@ void ripng_clean_network()
{ {
unsigned int i; unsigned int i;
char *str; char *str;
struct route_node *rn; struct agg_node *rn;
/* ripng_enable_network */ /* ripng_enable_network */
for (rn = route_top(ripng_enable_network); rn; rn = route_next(rn)) for (rn = agg_route_top(ripng_enable_network); rn;
rn = agg_route_next(rn))
if (rn->info) { if (rn->info) {
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
} }
/* ripng_enable_if */ /* ripng_enable_if */
@ -877,12 +879,12 @@ int ripng_network_write(struct vty *vty, int config_mode)
{ {
unsigned int i; unsigned int i;
const char *ifname; const char *ifname;
struct route_node *node; struct agg_node *node;
char buf[BUFSIZ]; char buf[BUFSIZ];
/* Write enable network. */ /* Write enable network. */
for (node = route_top(ripng_enable_network); node; for (node = agg_route_top(ripng_enable_network); node;
node = route_next(node)) node = agg_route_next(node))
if (node->info) { if (node->info) {
struct prefix *p = &node->p; struct prefix *p = &node->p;
vty_out(vty, "%s%s/%d\n", vty_out(vty, "%s%s/%d\n",
@ -1124,7 +1126,7 @@ void ripng_if_init()
hook_register_prio(if_del, 0, ripng_if_delete_hook); hook_register_prio(if_del, 0, ripng_if_delete_hook);
/* RIPng enable network init. */ /* RIPng enable network init. */
ripng_enable_network = route_table_init(); ripng_enable_network = agg_table_init();
/* RIPng enable interface init. */ /* RIPng enable interface init. */
ripng_enable_if = vector_init(1); ripng_enable_if = vector_init(1);

View File

@ -22,7 +22,7 @@
#include <zebra.h> #include <zebra.h>
#include "prefix.h" #include "prefix.h"
#include "table.h" #include "agg_table.h"
#include "memory.h" #include "memory.h"
#include "if.h" #include "if.h"
#include "vty.h" #include "vty.h"
@ -44,13 +44,12 @@ void ripng_aggregate_free(struct ripng_aggregate *aggregate)
} }
/* Aggregate count increment check. */ /* Aggregate count increment check. */
void ripng_aggregate_increment(struct route_node *child, void ripng_aggregate_increment(struct agg_node *child, struct ripng_info *rinfo)
struct ripng_info *rinfo)
{ {
struct route_node *np; struct agg_node *np;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
for (np = child; np; np = np->parent) for (np = child; np; np = agg_node_parent(np))
if ((aggregate = np->aggregate) != NULL) { if ((aggregate = np->aggregate) != NULL) {
aggregate->count++; aggregate->count++;
rinfo->suppress++; rinfo->suppress++;
@ -58,13 +57,12 @@ void ripng_aggregate_increment(struct route_node *child,
} }
/* Aggregate count decrement check. */ /* Aggregate count decrement check. */
void ripng_aggregate_decrement(struct route_node *child, void ripng_aggregate_decrement(struct agg_node *child, struct ripng_info *rinfo)
struct ripng_info *rinfo)
{ {
struct route_node *np; struct agg_node *np;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
for (np = child; np; np = np->parent) for (np = child; np; np = agg_node_parent(np))
if ((aggregate = np->aggregate) != NULL) { if ((aggregate = np->aggregate) != NULL) {
aggregate->count--; aggregate->count--;
rinfo->suppress--; rinfo->suppress--;
@ -72,14 +70,14 @@ void ripng_aggregate_decrement(struct route_node *child,
} }
/* Aggregate count decrement check for a list. */ /* Aggregate count decrement check for a list. */
void ripng_aggregate_decrement_list(struct route_node *child, struct list *list) void ripng_aggregate_decrement_list(struct agg_node *child, struct list *list)
{ {
struct route_node *np; struct agg_node *np;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct ripng_info *rinfo = NULL; struct ripng_info *rinfo = NULL;
struct listnode *node = NULL; struct listnode *node = NULL;
for (np = child; np; np = np->parent) for (np = child; np; np = agg_node_parent(np))
if ((aggregate = np->aggregate) != NULL) if ((aggregate = np->aggregate) != NULL)
aggregate->count -= listcount(list); aggregate->count -= listcount(list);
@ -90,8 +88,8 @@ void ripng_aggregate_decrement_list(struct route_node *child, struct list *list)
/* RIPng routes treatment. */ /* RIPng routes treatment. */
int ripng_aggregate_add(struct prefix *p) int ripng_aggregate_add(struct prefix *p)
{ {
struct route_node *top; struct agg_node *top;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct ripng_aggregate *sub; struct ripng_aggregate *sub;
@ -99,7 +97,7 @@ int ripng_aggregate_add(struct prefix *p)
struct listnode *node = NULL; struct listnode *node = NULL;
/* Get top node for aggregation. */ /* Get top node for aggregation. */
top = route_node_get(ripng->table, p); top = agg_node_get(ripng->table, p);
/* Allocate new aggregate. */ /* Allocate new aggregate. */
aggregate = ripng_aggregate_new(); aggregate = ripng_aggregate_new();
@ -108,7 +106,7 @@ int ripng_aggregate_add(struct prefix *p)
top->aggregate = aggregate; top->aggregate = aggregate;
/* Suppress routes match to the aggregate. */ /* Suppress routes match to the aggregate. */
for (rp = route_lock_node(top); rp; rp = route_next_until(rp, top)) { for (rp = agg_lock_node(top); rp; rp = agg_route_next_until(rp, top)) {
/* Suppress normal route. */ /* Suppress normal route. */
if ((list = rp->info) != NULL) if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) {
@ -128,8 +126,8 @@ int ripng_aggregate_add(struct prefix *p)
/* Delete RIPng static route. */ /* Delete RIPng static route. */
int ripng_aggregate_delete(struct prefix *p) int ripng_aggregate_delete(struct prefix *p)
{ {
struct route_node *top; struct agg_node *top;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct ripng_aggregate *sub; struct ripng_aggregate *sub;
@ -137,13 +135,13 @@ int ripng_aggregate_delete(struct prefix *p)
struct listnode *node = NULL; struct listnode *node = NULL;
/* Get top node for aggregation. */ /* Get top node for aggregation. */
top = route_node_get(ripng->table, p); top = agg_node_get(ripng->table, p);
/* Allocate new aggregate. */ /* Allocate new aggregate. */
aggregate = top->aggregate; aggregate = top->aggregate;
/* Suppress routes match to the aggregate. */ /* Suppress routes match to the aggregate. */
for (rp = route_lock_node(top); rp; rp = route_next_until(rp, top)) { for (rp = agg_lock_node(top); rp; rp = agg_route_next_until(rp, top)) {
/* Suppress normal route. */ /* Suppress normal route. */
if ((list = rp->info) != NULL) if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, node, rinfo)) {
@ -160,8 +158,8 @@ int ripng_aggregate_delete(struct prefix *p)
top->aggregate = NULL; top->aggregate = NULL;
ripng_aggregate_free(aggregate); ripng_aggregate_free(aggregate);
route_unlock_node(top); agg_unlock_node(top);
route_unlock_node(top); agg_unlock_node(top);
return 0; return 0;
} }

View File

@ -42,11 +42,11 @@ struct ripng_aggregate {
uint16_t tag_out; uint16_t tag_out;
}; };
extern void ripng_aggregate_increment(struct route_node *rp, extern void ripng_aggregate_increment(struct agg_node *rp,
struct ripng_info *rinfo); struct ripng_info *rinfo);
extern void ripng_aggregate_decrement(struct route_node *rp, extern void ripng_aggregate_decrement(struct agg_node *rp,
struct ripng_info *rinfo); struct ripng_info *rinfo);
extern void ripng_aggregate_decrement_list(struct route_node *rp, extern void ripng_aggregate_decrement_list(struct agg_node *rp,
struct list *list); struct list *list);
extern int ripng_aggregate_add(struct prefix *p); extern int ripng_aggregate_add(struct prefix *p);
extern int ripng_aggregate_delete(struct prefix *p); extern int ripng_aggregate_delete(struct prefix *p);

View File

@ -23,7 +23,7 @@
#include "command.h" #include "command.h"
#include "prefix.h" #include "prefix.h"
#include "table.h" #include "agg_table.h"
#include "stream.h" #include "stream.h"
#include "memory.h" #include "memory.h"
#include "routemap.h" #include "routemap.h"
@ -37,7 +37,7 @@
struct zclient *zclient = NULL; struct zclient *zclient = NULL;
/* Send ECMP routes to zebra. */ /* Send ECMP routes to zebra. */
static void ripng_zebra_ipv6_send(struct route_node *rp, uint8_t cmd) static void ripng_zebra_ipv6_send(struct agg_node *rp, uint8_t cmd)
{ {
struct list *list = (struct list *)rp->info; struct list *list = (struct list *)rp->info;
struct zapi_route api; struct zapi_route api;
@ -100,13 +100,13 @@ static void ripng_zebra_ipv6_send(struct route_node *rp, uint8_t cmd)
} }
/* Add/update ECMP routes to zebra. */ /* Add/update ECMP routes to zebra. */
void ripng_zebra_ipv6_add(struct route_node *rp) void ripng_zebra_ipv6_add(struct agg_node *rp)
{ {
ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_ADD); ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_ADD);
} }
/* Delete ECMP routes from zebra. */ /* Delete ECMP routes from zebra. */
void ripng_zebra_ipv6_delete(struct route_node *rp) void ripng_zebra_ipv6_delete(struct agg_node *rp)
{ {
ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_DELETE); ripng_zebra_ipv6_send(rp, ZEBRA_ROUTE_DELETE);
} }

View File

@ -27,7 +27,7 @@
#include "memory.h" #include "memory.h"
#include "if.h" #include "if.h"
#include "stream.h" #include "stream.h"
#include "table.h" #include "agg_table.h"
#include "command.h" #include "command.h"
#include "sockopt.h" #include "sockopt.h"
#include "distribute.h" #include "distribute.h"
@ -394,7 +394,7 @@ static int ripng_lladdr_check(struct interface *ifp, struct in6_addr *addr)
static int ripng_garbage_collect(struct thread *t) static int ripng_garbage_collect(struct thread *t)
{ {
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct route_node *rp; struct agg_node *rp;
rinfo = THREAD_ARG(t); rinfo = THREAD_ARG(t);
rinfo->t_garbage_collect = NULL; rinfo->t_garbage_collect = NULL;
@ -409,7 +409,7 @@ static int ripng_garbage_collect(struct thread *t)
listnode_delete(rp->info, rinfo); listnode_delete(rp->info, rinfo);
if (list_isempty((struct list *)rp->info)) { if (list_isempty((struct list *)rp->info)) {
list_delete_and_null((struct list **)&rp->info); list_delete_and_null((struct list **)&rp->info);
route_unlock_node(rp); agg_unlock_node(rp);
} }
/* Free RIPng routing information. */ /* Free RIPng routing information. */
@ -426,7 +426,7 @@ static void ripng_timeout_update(struct ripng_info *rinfo);
*/ */
struct ripng_info *ripng_ecmp_add(struct ripng_info *rinfo_new) struct ripng_info *ripng_ecmp_add(struct ripng_info *rinfo_new)
{ {
struct route_node *rp = rinfo_new->rp; struct agg_node *rp = rinfo_new->rp;
struct ripng_info *rinfo = NULL; struct ripng_info *rinfo = NULL;
struct list *list = NULL; struct list *list = NULL;
@ -465,7 +465,7 @@ struct ripng_info *ripng_ecmp_add(struct ripng_info *rinfo_new)
*/ */
struct ripng_info *ripng_ecmp_replace(struct ripng_info *rinfo_new) struct ripng_info *ripng_ecmp_replace(struct ripng_info *rinfo_new)
{ {
struct route_node *rp = rinfo_new->rp; struct agg_node *rp = rinfo_new->rp;
struct list *list = (struct list *)rp->info; struct list *list = (struct list *)rp->info;
struct ripng_info *rinfo = NULL, *tmp_rinfo = NULL; struct ripng_info *rinfo = NULL, *tmp_rinfo = NULL;
struct listnode *node = NULL, *nextnode = NULL; struct listnode *node = NULL, *nextnode = NULL;
@ -522,7 +522,7 @@ struct ripng_info *ripng_ecmp_replace(struct ripng_info *rinfo_new)
*/ */
struct ripng_info *ripng_ecmp_delete(struct ripng_info *rinfo) struct ripng_info *ripng_ecmp_delete(struct ripng_info *rinfo)
{ {
struct route_node *rp = rinfo->rp; struct agg_node *rp = rinfo->rp;
struct list *list = (struct list *)rp->info; struct list *list = (struct list *)rp->info;
RIPNG_TIMER_OFF(rinfo->t_timeout); RIPNG_TIMER_OFF(rinfo->t_timeout);
@ -664,7 +664,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
{ {
int ret; int ret;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo = NULL, newinfo; struct ripng_info *rinfo = NULL, newinfo;
struct ripng_interface *ri; struct ripng_interface *ri;
struct in6_addr *nexthop; struct in6_addr *nexthop;
@ -773,7 +773,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
nexthop = &from->sin6_addr; nexthop = &from->sin6_addr;
/* Lookup RIPng routing table. */ /* Lookup RIPng routing table. */
rp = route_node_get(ripng->table, (struct prefix *)&p); rp = agg_node_get(ripng->table, (struct prefix *)&p);
newinfo.rp = rp; newinfo.rp = rp;
newinfo.nexthop = *nexthop; newinfo.nexthop = *nexthop;
@ -798,7 +798,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
if (rte->metric > rinfo->metric) { if (rte->metric > rinfo->metric) {
/* New route has a greater metric. /* New route has a greater metric.
* Discard it. */ * Discard it. */
route_unlock_node(rp); agg_unlock_node(rp);
return; return;
} }
@ -821,7 +821,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
/* Redistributed route check. */ /* Redistributed route check. */
if (rinfo->type != ZEBRA_ROUTE_RIPNG if (rinfo->type != ZEBRA_ROUTE_RIPNG
&& rinfo->metric != RIPNG_METRIC_INFINITY) { && rinfo->metric != RIPNG_METRIC_INFINITY) {
route_unlock_node(rp); agg_unlock_node(rp);
return; return;
} }
@ -830,7 +830,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
&& ((rinfo->sub_type == RIPNG_ROUTE_STATIC) && ((rinfo->sub_type == RIPNG_ROUTE_STATIC)
|| (rinfo->sub_type == RIPNG_ROUTE_DEFAULT)) || (rinfo->sub_type == RIPNG_ROUTE_DEFAULT))
&& rinfo->metric != RIPNG_METRIC_INFINITY) { && rinfo->metric != RIPNG_METRIC_INFINITY) {
route_unlock_node(rp); agg_unlock_node(rp);
return; return;
} }
} }
@ -844,7 +844,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
if (rte->metric != RIPNG_METRIC_INFINITY) if (rte->metric != RIPNG_METRIC_INFINITY)
ripng_ecmp_add(&newinfo); ripng_ecmp_add(&newinfo);
else else
route_unlock_node(rp); agg_unlock_node(rp);
} else { } else {
/* If there is an existing route, compare the next hop address /* If there is an existing route, compare the next hop address
to the address of the router from which the datagram came. to the address of the router from which the datagram came.
@ -890,7 +890,7 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
ripng_timeout_update(rinfo); ripng_timeout_update(rinfo);
/* Unlock tempolary lock of the route. */ /* Unlock tempolary lock of the route. */
route_unlock_node(rp); agg_unlock_node(rp);
} }
} }
@ -899,7 +899,7 @@ void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p,
ifindex_t ifindex, struct in6_addr *nexthop, ifindex_t ifindex, struct in6_addr *nexthop,
route_tag_t tag) route_tag_t tag)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo = NULL, newinfo; struct ripng_info *rinfo = NULL, newinfo;
struct list *list = NULL; struct list *list = NULL;
@ -909,7 +909,7 @@ void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p,
if (IN6_IS_ADDR_LOOPBACK(&p->prefix)) if (IN6_IS_ADDR_LOOPBACK(&p->prefix))
return; return;
rp = route_node_get(ripng->table, (struct prefix *)p); rp = agg_node_get(ripng->table, (struct prefix *)p);
memset(&newinfo, 0, sizeof(struct ripng_info)); memset(&newinfo, 0, sizeof(struct ripng_info));
newinfo.type = type; newinfo.type = type;
@ -928,7 +928,7 @@ void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p,
if (rinfo->type == ZEBRA_ROUTE_CONNECT if (rinfo->type == ZEBRA_ROUTE_CONNECT
&& rinfo->sub_type == RIPNG_ROUTE_INTERFACE && rinfo->sub_type == RIPNG_ROUTE_INTERFACE
&& rinfo->metric != RIPNG_METRIC_INFINITY) { && rinfo->metric != RIPNG_METRIC_INFINITY) {
route_unlock_node(rp); agg_unlock_node(rp);
return; return;
} }
@ -941,13 +941,13 @@ void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p,
if (type != ZEBRA_ROUTE_RIPNG if (type != ZEBRA_ROUTE_RIPNG
|| ((sub_type != RIPNG_ROUTE_STATIC) || ((sub_type != RIPNG_ROUTE_STATIC)
&& (sub_type != RIPNG_ROUTE_DEFAULT))) { && (sub_type != RIPNG_ROUTE_DEFAULT))) {
route_unlock_node(rp); agg_unlock_node(rp);
return; return;
} }
} }
ripng_ecmp_replace(&newinfo); ripng_ecmp_replace(&newinfo);
route_unlock_node(rp); agg_unlock_node(rp);
} else } else
ripng_ecmp_add(&newinfo); ripng_ecmp_add(&newinfo);
@ -972,7 +972,7 @@ void ripng_redistribute_add(int type, int sub_type, struct prefix_ipv6 *p,
void ripng_redistribute_delete(int type, int sub_type, struct prefix_ipv6 *p, void ripng_redistribute_delete(int type, int sub_type, struct prefix_ipv6 *p,
ifindex_t ifindex) ifindex_t ifindex)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
if (IN6_IS_ADDR_LINKLOCAL(&p->prefix)) if (IN6_IS_ADDR_LINKLOCAL(&p->prefix))
@ -980,7 +980,7 @@ void ripng_redistribute_delete(int type, int sub_type, struct prefix_ipv6 *p,
if (IN6_IS_ADDR_LOOPBACK(&p->prefix)) if (IN6_IS_ADDR_LOOPBACK(&p->prefix))
return; return;
rp = route_node_lookup(ripng->table, (struct prefix *)p); rp = agg_node_lookup(ripng->table, (struct prefix *)p);
if (rp) { if (rp) {
struct list *list = rp->info; struct list *list = rp->info;
@ -1014,21 +1014,21 @@ void ripng_redistribute_delete(int type, int sub_type, struct prefix_ipv6 *p,
ripng_event(RIPNG_TRIGGERED_UPDATE, 0); ripng_event(RIPNG_TRIGGERED_UPDATE, 0);
} }
} }
route_unlock_node(rp); agg_unlock_node(rp);
} }
} }
/* Withdraw redistributed route. */ /* Withdraw redistributed route. */
void ripng_redistribute_withdraw(int type) void ripng_redistribute_withdraw(int type)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo = NULL; struct ripng_info *rinfo = NULL;
struct list *list = NULL; struct list *list = NULL;
if (!ripng) if (!ripng)
return; return;
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp))
if ((list = rp->info) != NULL) { if ((list = rp->info) != NULL) {
rinfo = listgetdata(listhead(list)); rinfo = listgetdata(listhead(list));
if ((rinfo->type == type) if ((rinfo->type == type)
@ -1199,7 +1199,7 @@ static void ripng_request_process(struct ripng_packet *packet, int size,
caddr_t lim; caddr_t lim;
struct rte *rte; struct rte *rte;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_interface *ri; struct ripng_interface *ri;
@ -1255,14 +1255,13 @@ static void ripng_request_process(struct ripng_packet *packet, int size,
p.prefixlen = rte->prefixlen; p.prefixlen = rte->prefixlen;
apply_mask_ipv6(&p); apply_mask_ipv6(&p);
rp = route_node_lookup(ripng->table, rp = agg_node_lookup(ripng->table, (struct prefix *)&p);
(struct prefix *)&p);
if (rp) { if (rp) {
rinfo = listgetdata( rinfo = listgetdata(
listhead((struct list *)rp->info)); listhead((struct list *)rp->info));
rte->metric = rinfo->metric; rte->metric = rinfo->metric;
route_unlock_node(rp); agg_unlock_node(rp);
} else } else
rte->metric = RIPNG_METRIC_INFINITY; rte->metric = RIPNG_METRIC_INFINITY;
} }
@ -1361,12 +1360,12 @@ static int ripng_read(struct thread *thread)
/* Walk down the RIPng routing table then clear changed flag. */ /* Walk down the RIPng routing table then clear changed flag. */
static void ripng_clear_changed_flag(void) static void ripng_clear_changed_flag(void)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo = NULL; struct ripng_info *rinfo = NULL;
struct list *list = NULL; struct list *list = NULL;
struct listnode *listnode = NULL; struct listnode *listnode = NULL;
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp))
if ((list = rp->info) != NULL) if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
UNSET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED); UNSET_FLAG(rinfo->flags, RIPNG_RTF_CHANGED);
@ -1535,7 +1534,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
int route_type) int route_type)
{ {
int ret; int ret;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_interface *ri; struct ripng_interface *ri;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
@ -1558,7 +1557,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
ripng_rte_list = ripng_rte_new(); ripng_rte_list = ripng_rte_new();
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
if ((list = rp->info) != NULL if ((list = rp->info) != NULL
&& (rinfo = listgetdata(listhead(list))) != NULL && (rinfo = listgetdata(listhead(list))) != NULL
&& rinfo->suppress == 0) { && rinfo->suppress == 0) {
@ -1807,9 +1806,9 @@ static int ripng_create(void)
ripng->obuf = stream_new(RIPNG_MAX_PACKET_SIZE); ripng->obuf = stream_new(RIPNG_MAX_PACKET_SIZE);
/* Initialize RIPng routig table. */ /* Initialize RIPng routig table. */
ripng->table = route_table_init(); ripng->table = agg_table_init();
ripng->route = route_table_init(); ripng->route = agg_table_init();
ripng->aggregate = route_table_init(); ripng->aggregate = agg_table_init();
/* Make socket. */ /* Make socket. */
ripng->sock = ripng_make_socket(); ripng->sock = ripng_make_socket();
@ -1952,7 +1951,7 @@ DEFUN (show_ipv6_ripng,
IPV6_STR IPV6_STR
"Show RIPng routes\n") "Show RIPng routes\n")
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct prefix_ipv6 *p; struct prefix_ipv6 *p;
@ -1971,7 +1970,7 @@ DEFUN (show_ipv6_ripng,
" (i) - interface, (a/S) - aggregated/Suppressed\n\n" " (i) - interface, (a/S) - aggregated/Suppressed\n\n"
" Network Next Hop Via Metric Tag Time\n"); " Network Next Hop Via Metric Tag Time\n");
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
if ((aggregate = rp->aggregate) != NULL) { if ((aggregate = rp->aggregate) != NULL) {
p = (struct prefix_ipv6 *)&rp->p; p = (struct prefix_ipv6 *)&rp->p;
@ -2125,13 +2124,13 @@ DEFUN (clear_ipv6_rip,
IPV6_STR IPV6_STR
"Clear IPv6 RIP database\n") "Clear IPv6 RIP database\n")
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct list *list; struct list *list;
struct listnode *listnode; struct listnode *listnode;
/* Clear received RIPng routes */ /* Clear received RIPng routes */
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
list = rp->info; list = rp->info;
if (list == NULL) if (list == NULL)
continue; continue;
@ -2155,7 +2154,7 @@ DEFUN (clear_ipv6_rip,
if (list_isempty(list)) { if (list_isempty(list)) {
list_delete_and_null(&list); list_delete_and_null(&list);
rp->info = NULL; rp->info = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
} }
} }
@ -2206,7 +2205,7 @@ DEFUN (ripng_route,
int idx_ipv6addr = 1; int idx_ipv6addr = 1;
int ret; int ret;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct agg_node *rp;
ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg, ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg,
(struct prefix_ipv6 *)&p); (struct prefix_ipv6 *)&p);
@ -2216,10 +2215,10 @@ DEFUN (ripng_route,
} }
apply_mask_ipv6(&p); apply_mask_ipv6(&p);
rp = route_node_get(ripng->route, (struct prefix *)&p); rp = agg_node_get(ripng->route, (struct prefix *)&p);
if (rp->info) { if (rp->info) {
vty_out(vty, "There is already same static route.\n"); vty_out(vty, "There is already same static route.\n");
route_unlock_node(rp); agg_unlock_node(rp);
return CMD_WARNING; return CMD_WARNING;
} }
rp->info = (void *)1; rp->info = (void *)1;
@ -2240,7 +2239,7 @@ DEFUN (no_ripng_route,
int idx_ipv6addr = 2; int idx_ipv6addr = 2;
int ret; int ret;
struct prefix_ipv6 p; struct prefix_ipv6 p;
struct route_node *rp; struct agg_node *rp;
ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg, ret = str2prefix_ipv6(argv[idx_ipv6addr]->arg,
(struct prefix_ipv6 *)&p); (struct prefix_ipv6 *)&p);
@ -2250,17 +2249,17 @@ DEFUN (no_ripng_route,
} }
apply_mask_ipv6(&p); apply_mask_ipv6(&p);
rp = route_node_lookup(ripng->route, (struct prefix *)&p); rp = agg_node_lookup(ripng->route, (struct prefix *)&p);
if (!rp) { if (!rp) {
vty_out(vty, "Can't find static route.\n"); vty_out(vty, "Can't find static route.\n");
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0); ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p, 0);
route_unlock_node(rp); agg_unlock_node(rp);
rp->info = NULL; rp->info = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -2274,7 +2273,7 @@ DEFUN (ripng_aggregate_address,
int idx_ipv6_prefixlen = 1; int idx_ipv6_prefixlen = 1;
int ret; int ret;
struct prefix p; struct prefix p;
struct route_node *node; struct agg_node *node;
ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg,
(struct prefix_ipv6 *)&p); (struct prefix_ipv6 *)&p);
@ -2284,10 +2283,10 @@ DEFUN (ripng_aggregate_address,
} }
/* Check aggregate alredy exist or not. */ /* Check aggregate alredy exist or not. */
node = route_node_get(ripng->aggregate, &p); node = agg_node_get(ripng->aggregate, &p);
if (node->info) { if (node->info) {
vty_out(vty, "There is already same aggregate route.\n"); vty_out(vty, "There is already same aggregate route.\n");
route_unlock_node(node); agg_unlock_node(node);
return CMD_WARNING; return CMD_WARNING;
} }
node->info = (void *)1; node->info = (void *)1;
@ -2307,7 +2306,7 @@ DEFUN (no_ripng_aggregate_address,
int idx_ipv6_prefixlen = 2; int idx_ipv6_prefixlen = 2;
int ret; int ret;
struct prefix p; struct prefix p;
struct route_node *rn; struct agg_node *rn;
ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg,
(struct prefix_ipv6 *)&p); (struct prefix_ipv6 *)&p);
@ -2316,14 +2315,14 @@ DEFUN (no_ripng_aggregate_address,
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
rn = route_node_lookup(ripng->aggregate, &p); rn = agg_node_lookup(ripng->aggregate, &p);
if (!rn) { if (!rn) {
vty_out(vty, "Can't find aggregate route.\n"); vty_out(vty, "Can't find aggregate route.\n");
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
route_unlock_node(rn); agg_unlock_node(rn);
rn->info = NULL; rn->info = NULL;
route_unlock_node(rn); agg_unlock_node(rn);
ripng_aggregate_delete(&p); ripng_aggregate_delete(&p);
@ -2582,7 +2581,7 @@ DEFUN (no_ripng_default_information_originate,
/* Update ECMP routes to zebra when ECMP is disabled. */ /* Update ECMP routes to zebra when ECMP is disabled. */
static void ripng_ecmp_disable(void) static void ripng_ecmp_disable(void)
{ {
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo, *tmp_rinfo; struct ripng_info *rinfo, *tmp_rinfo;
struct list *list; struct list *list;
struct listnode *node, *nextnode; struct listnode *node, *nextnode;
@ -2590,7 +2589,7 @@ static void ripng_ecmp_disable(void)
if (!ripng) if (!ripng)
return; return;
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp))
if ((list = rp->info) != NULL && listcount(list) > 1) { if ((list = rp->info) != NULL && listcount(list) > 1) {
rinfo = listgetdata(listhead(list)); rinfo = listgetdata(listhead(list));
if (!ripng_route_rte(rinfo)) if (!ripng_route_rte(rinfo))
@ -2655,7 +2654,7 @@ static int ripng_config_write(struct vty *vty)
int ripng_network_write(struct vty *, int); int ripng_network_write(struct vty *, int);
void ripng_redistribute_write(struct vty *, int); void ripng_redistribute_write(struct vty *, int);
int write = 0; int write = 0;
struct route_node *rp; struct agg_node *rp;
if (ripng) { if (ripng) {
@ -2678,7 +2677,8 @@ static int ripng_config_write(struct vty *vty)
config_write_ripng_offset_list(vty); config_write_ripng_offset_list(vty);
/* RIPng aggregate routes. */ /* RIPng aggregate routes. */
for (rp = route_top(ripng->aggregate); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->aggregate); rp;
rp = agg_route_next(rp))
if (rp->info != NULL) if (rp->info != NULL)
vty_out(vty, " aggregate-address %s/%d\n", vty_out(vty, " aggregate-address %s/%d\n",
inet6_ntoa(rp->p.u.prefix6), inet6_ntoa(rp->p.u.prefix6),
@ -2689,7 +2689,8 @@ static int ripng_config_write(struct vty *vty)
vty_out(vty, " allow-ecmp\n"); vty_out(vty, " allow-ecmp\n");
/* RIPng static routes. */ /* RIPng static routes. */
for (rp = route_top(ripng->route); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->route); rp;
rp = agg_route_next(rp))
if (rp->info != NULL) if (rp->info != NULL)
vty_out(vty, " route %s/%d\n", vty_out(vty, " route %s/%d\n",
inet6_ntoa(rp->p.u.prefix6), inet6_ntoa(rp->p.u.prefix6),
@ -2811,7 +2812,7 @@ static void ripng_distribute_update_all_wrapper(struct access_list *notused)
void ripng_clean() void ripng_clean()
{ {
int i; int i;
struct route_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct list *list = NULL; struct list *list = NULL;
@ -2819,7 +2820,8 @@ void ripng_clean()
if (ripng) { if (ripng) {
/* Clear RIPng routes */ /* Clear RIPng routes */
for (rp = route_top(ripng->table); rp; rp = route_next(rp)) { for (rp = agg_route_top(ripng->table); rp;
rp = agg_route_next(rp)) {
if ((list = rp->info) != NULL) { if ((list = rp->info) != NULL) {
rinfo = listgetdata(listhead(list)); rinfo = listgetdata(listhead(list));
if (ripng_route_rte(rinfo)) if (ripng_route_rte(rinfo))
@ -2834,13 +2836,13 @@ void ripng_clean()
} }
list_delete_and_null(&list); list_delete_and_null(&list);
rp->info = NULL; rp->info = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
} }
if ((aggregate = rp->aggregate) != NULL) { if ((aggregate = rp->aggregate) != NULL) {
ripng_aggregate_free(aggregate); ripng_aggregate_free(aggregate);
rp->aggregate = NULL; rp->aggregate = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
} }
} }
@ -2862,17 +2864,19 @@ void ripng_clean()
} }
/* Static RIPng route configuration. */ /* Static RIPng route configuration. */
for (rp = route_top(ripng->route); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->route); rp;
rp = agg_route_next(rp))
if (rp->info) { if (rp->info) {
rp->info = NULL; rp->info = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
} }
/* RIPng aggregated prefixes */ /* RIPng aggregated prefixes */
for (rp = route_top(ripng->aggregate); rp; rp = route_next(rp)) for (rp = agg_route_top(ripng->aggregate); rp;
rp = agg_route_next(rp))
if (rp->info) { if (rp->info) {
rp->info = NULL; rp->info = NULL;
route_unlock_node(rp); agg_unlock_node(rp);
} }
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) for (i = 0; i < ZEBRA_ROUTE_MAX; i++)

View File

@ -109,13 +109,13 @@ struct ripng {
struct stream *obuf; struct stream *obuf;
/* RIPng routing information base. */ /* RIPng routing information base. */
struct route_table *table; struct agg_table *table;
/* RIPng only static route information. */ /* RIPng only static route information. */
struct route_table *route; struct agg_table *route;
/* RIPng aggregate route information. */ /* RIPng aggregate route information. */
struct route_table *aggregate; struct agg_table *aggregate;
/* RIPng threads. */ /* RIPng threads. */
struct thread *t_read; struct thread *t_read;
@ -198,7 +198,7 @@ struct ripng_info {
uint8_t metric_out; uint8_t metric_out;
uint16_t tag_out; uint16_t tag_out;
struct route_node *rp; struct agg_node *rp;
}; };
#ifdef notyet #ifdef notyet
@ -377,8 +377,8 @@ extern void ripng_redistribute_withdraw(int type);
extern void ripng_distribute_update_interface(struct interface *); extern void ripng_distribute_update_interface(struct interface *);
extern void ripng_if_rmap_update_interface(struct interface *); extern void ripng_if_rmap_update_interface(struct interface *);
extern void ripng_zebra_ipv6_add(struct route_node *); extern void ripng_zebra_ipv6_add(struct agg_node *node);
extern void ripng_zebra_ipv6_delete(struct route_node *); extern void ripng_zebra_ipv6_delete(struct agg_node *node);
extern void ripng_redistribute_clean(void); extern void ripng_redistribute_clean(void);
extern int ripng_redistribute_check(int); extern int ripng_redistribute_check(int);