summaryrefslogtreecommitdiff
path: root/bgpd/rfapi/rfapi_monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/rfapi/rfapi_monitor.c')
-rw-r--r--bgpd/rfapi/rfapi_monitor.c181
1 files changed, 94 insertions, 87 deletions
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index 30182ba7a6..59387240fa 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -28,7 +28,7 @@
#include "lib/zebra.h"
#include "lib/prefix.h"
-#include "lib/table.h"
+#include "lib/agg_table.h"
#include "lib/vty.h"
#include "lib/memory.h"
#include "lib/log.h"
@@ -68,10 +68,10 @@ static void rfapiMonitorEthDetachImport(struct bgp *bgp,
/*
* 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)
{
- struct route_node *rn_saved = NULL;
+ struct agg_node *rn_saved = NULL;
static struct skiplist *sl_saved = NULL;
struct skiplist *sl;
@@ -118,12 +118,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp)
struct rfapi_descriptor *rfd;
for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) {
- struct route_node *mrn;
+ struct agg_node *mrn;
if (!rfd->mon)
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;
for (m = (struct rfapi_monitor_vpn *)(mrn->info); m;
m = m->next)
@@ -132,12 +133,13 @@ void rfapiMonitorDupCheck(struct bgp *bgp)
}
for (ALL_LIST_ELEMENTS_RO(&bgp->rfapi->descriptors, hnode, rfd)) {
- struct route_node *mrn;
+ struct agg_node *mrn;
if (!rfd->mon)
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;
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_IP6]);
- struct route_node *rn;
+ struct agg_node *rn;
- for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP]);
- rn; rn = route_next(rn)) {
+ for (rn = agg_route_top(
+ rfd->import_table->imported_vpn[AFI_IP]);
+ rn; rn = agg_route_next(rn)) {
assert(!RFAPI_MONITOR_VPN(rn));
}
- for (rn = route_top(rfd->import_table->imported_vpn[AFI_IP6]);
- rn; rn = route_next(rn)) {
+ for (rn = agg_route_top(
+ rfd->import_table->imported_vpn[AFI_IP6]);
+ rn; rn = agg_route_next(rn)) {
assert(!RFAPI_MONITOR_VPN(rn));
}
@@ -180,7 +184,7 @@ void rfapiMonitorCheckAttachAllowed(void)
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_monitor_vpn *v;
@@ -202,7 +206,7 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
e_next = e->next;
e->next = NULL;
XFREE(MTYPE_RFAPI_MONITOR_ENCAP, e);
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
hie->u.encap.e = NULL;
break;
@@ -212,33 +216,33 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
v_next = v->next;
v->next = NULL;
XFREE(MTYPE_RFAPI_MONITOR, e);
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
hie->u.vpn.v = NULL;
if (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);
hie->u.vpn.e.source = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
if (hie->u.vpn.idx_rd) {
/* looping through bi->extra->vnc.import.rd is tbd */
while (!skiplist_delete_first(hie->u.vpn.idx_rd)) {
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
skiplist_free(hie->u.vpn.idx_rd);
hie->u.vpn.idx_rd = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
if (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);
hie->u.vpn.mon_eth = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
break;
@@ -247,13 +251,13 @@ void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn)
}
XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
rn->aggregate = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
/*
* 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;
@@ -279,28 +283,28 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn)
return;
skiplist_free(hie->u.vpn.mon_eth);
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 (skiplist_count(hie->u.vpn.e.source))
return;
skiplist_free(hie->u.vpn.e.source);
hie->u.vpn.e.source = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
if (hie->u.vpn.idx_rd) {
if (skiplist_count(hie->u.vpn.idx_rd))
return;
skiplist_free(hie->u.vpn.idx_rd);
hie->u.vpn.idx_rd = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
if (hie->u.vpn.mon_eth) {
if (skiplist_count(hie->u.vpn.mon_eth))
return;
skiplist_free(hie->u.vpn.mon_eth);
hie->u.vpn.mon_eth = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
break;
@@ -309,17 +313,17 @@ void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn)
}
XFREE(MTYPE_RFAPI_IT_EXTRA, hie);
rn->aggregate = NULL;
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
/*
* returns locked node
*/
-struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
- struct prefix *p)
+struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
+ struct prefix *p)
{
afi_t afi;
- struct route_node *rn;
+ struct agg_node *rn;
if (RFAPI_0_PREFIX(p)) {
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
* 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;) {
struct bgp_info *bi;
@@ -369,9 +373,9 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
if (bi)
break;
- route_unlock_node(rn);
- if ((rn = rn->parent)) {
- route_lock_node(rn);
+ agg_unlock_node(rn);
+ if ((rn = agg_node_parent(rn))) {
+ agg_lock_node(rn);
}
}
@@ -383,8 +387,8 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
/* creates default node if none exists, and increments ref count
*/
- rn = route_node_get(rfd->import_table->imported_vpn[afi],
- &pfx_default);
+ rn = agg_node_get(rfd->import_table->imported_vpn[afi],
+ &pfx_default);
}
return rn;
@@ -396,10 +400,10 @@ struct route_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
* returned (for the benefit of caller which might like to use it
* to generate an immediate query response).
*/
-static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd,
- struct rfapi_monitor_vpn *m)
+static struct agg_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd,
+ struct rfapi_monitor_vpn *m)
{
- struct route_node *rn;
+ struct agg_node *rn;
rfapiMonitorCheckAttachAllowed();
@@ -438,7 +442,7 @@ static struct route_node *rfapiMonitorAttachImport(struct rfapi_descriptor *rfd,
*/
void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
{
- struct route_node *mrn;
+ struct agg_node *mrn;
if (!rfd->mon) {
/*
@@ -447,7 +451,7 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
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)
continue;
@@ -467,11 +471,11 @@ void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd)
* are disabled, this function will not perform a lookup, and the
* caller will have to do its own lookup.
*/
-struct route_node *
-rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix *p)
+struct agg_node *rfapiMonitorAdd(struct bgp *bgp, struct rfapi_descriptor *rfd,
+ struct prefix *p)
{
struct rfapi_monitor_vpn *m;
- struct route_node *rn;
+ struct agg_node *rn;
/*
* 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.
*/
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) {
/*
* received this query before, no further action needed
*/
rfapiMonitorTimerRestart((struct rfapi_monitor_vpn *)rn->info);
- route_unlock_node(rn);
+ agg_unlock_node(rn);
return NULL;
}
@@ -575,7 +579,7 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m)
this->next;
}
RFAPI_CHECK_REFCOUNT(m->node, SAFI_MPLS_VPN, 1);
- route_unlock_node(m->node);
+ agg_unlock_node(m->node);
}
m->node = NULL;
}
@@ -586,12 +590,12 @@ rfapiMonitorDetachImport(struct rfapi_monitor_vpn *m)
void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd)
{
- struct route_node *rn;
+ struct agg_node *rn;
if (!rfd->mon)
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) {
rfapiMonitorDetachImport(
(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,
struct prefix *p)
{
- struct route_node *rn;
+ struct agg_node *rn;
struct rfapi_monitor_vpn *m;
assert(rfd->mon);
- rn = route_node_get(rfd->mon, p); /* locks node */
+ rn = agg_node_get(rfd->mon, p); /* locks node */
m = rn->info;
assert(m);
@@ -628,8 +632,8 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/
XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL;
- route_unlock_node(rn); /* undo original lock when created */
- route_unlock_node(rn); /* undo lock in route_node_get */
+ agg_unlock_node(rn); /* undo original lock when created */
+ agg_unlock_node(rn); /* undo lock in agg_node_get */
--rfd->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)
{
- struct route_node *rn;
+ struct agg_node *rn;
struct bgp *bgp;
int count = 0;
@@ -649,7 +653,8 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
bgp = bgp_get_default();
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;
if ((m = rn->info)) {
if (!(bgp->rfapi_cfg->flags
@@ -664,14 +669,14 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL;
- route_unlock_node(rn); /* undo original lock
+ agg_unlock_node(rn); /* undo original lock
when created */
++count;
--rfd->monitor_count;
--bgp->rfapi->monitor_count;
}
}
- route_table_finish(rfd->mon);
+ agg_table_finish(rfd->mon);
rfd->mon = NULL;
}
@@ -788,7 +793,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
*/
void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
{
- struct route_node *rn;
+ struct agg_node *rn;
if (AF_ETHERNET == p->family) {
struct rfapi_monitor_eth *mon_eth;
@@ -812,7 +817,8 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
}
} 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;
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.
*/
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 skiplist *nves_seen;
- struct route_node *rn = it_node;
+ struct agg_node *rn = it_node;
struct bgp *bgp = bgp_get_default();
afi_t afi = family2afi(rn->p.family);
#if DEBUG_L2_EXTRA
@@ -909,7 +915,8 @@ void rfapiMonitorItNodeChanged(
* to them
* 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;
for (; m; m = m->next) {
@@ -947,7 +954,7 @@ void rfapiMonitorItNodeChanged(
m->rfd->response_lifetime);
}
}
- rn = rn->parent;
+ rn = agg_node_parent(rn);
if (rn)
m = RFAPI_MONITOR_VPN(rn);
} while (rn);
@@ -1023,8 +1030,7 @@ void rfapiMonitorItNodeChanged(
* omit old node and its subtree
*/
void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
- struct route_node *old_node,
- struct route_node *new_node,
+ struct agg_node *old_node, struct agg_node *new_node,
struct rfapi_monitor_vpn *monitor_list)
{
struct bgp *bgp = bgp_get_default();
@@ -1125,7 +1131,7 @@ static int mon_eth_cmp(void *a, void *b)
static void rfapiMonitorEthAttachImport(
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 skiplist *sl;
@@ -1162,7 +1168,7 @@ static void rfapiMonitorEthAttachImport(
if (!sl) {
sl = RFAPI_MONITOR_ETH_W_ALLOC(rn) =
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
@@ -1175,7 +1181,7 @@ static void rfapiMonitorEthAttachImport(
assert(!rc);
/* 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 prefix pfx_mac_buf;
- struct route_node *rn;
+ struct agg_node *rn;
it = rfapiMacImportTableGet(bgp, mon->logical_net_id);
assert(it);
@@ -1212,7 +1218,7 @@ static void rfapiMonitorEthAttachImportHd(struct bgp *bgp,
pfx_mac_buf.prefixlen = 48;
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);
(void)rfapiMonitorEthAttachImport(it, rn, mon);
@@ -1226,7 +1232,7 @@ static void rfapiMonitorEthDetachImport(
struct rfapi_import_table *it;
struct prefix pfx_mac_buf;
struct skiplist *sl;
- struct route_node *rn;
+ struct agg_node *rn;
int rc;
it = rfapiMacImportTableGet(bgp, mon->logical_net_id);
@@ -1262,7 +1268,7 @@ static void rfapiMonitorEthDetachImport(
pfx_mac_buf.prefixlen = 48;
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);
#if DEBUG_L2_EXTRA
@@ -1288,19 +1294,19 @@ static void rfapiMonitorEthDetachImport(
assert(!rc);
/* uncount eth monitor */
- route_unlock_node(rn);
+ agg_unlock_node(rn);
}
-struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
- struct rfapi_descriptor *rfd,
- struct ethaddr *macaddr,
- uint32_t logical_net_id)
+struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp,
+ struct rfapi_descriptor *rfd,
+ struct ethaddr *macaddr,
+ uint32_t logical_net_id)
{
int rc;
struct rfapi_monitor_eth mon_buf;
struct rfapi_monitor_eth *val;
struct rfapi_import_table *it;
- struct route_node *rn = NULL;
+ struct agg_node *rn = NULL;
struct prefix pfx_mac_buf;
if (!rfd->mon_eth) {
@@ -1323,7 +1329,7 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
pfx_mac_buf.u.prefix_eth = *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);
}
@@ -1453,8 +1459,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
{
struct rfapi_import_table *it;
afi_t afi;
- struct route_table *rt;
- struct route_node *rn;
+ struct agg_table *rt;
+ struct agg_node *rn;
void *cursor;
int rc;
struct rfapi *h = bgp->rfapi;
@@ -1485,7 +1491,8 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
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);
if (RFAPI_MONITOR_VPN(rn))
RFAPI_MONITOR_VPN_W_ALLOC(rn) = NULL;
@@ -1494,7 +1501,7 @@ void rfapiMonitorCallbacksOff(struct bgp *bgp)
m->next =
NULL; /* gratuitous safeness */
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
* 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;
sl = RFAPI_MONITOR_ETH(rn);
while (!skiplist_delete_first(sl)) {
- route_unlock_node(rn); /* uncount monitor */
+ agg_unlock_node(rn); /* uncount monitor */
}
}