Skip to content

Commit

Permalink
bgpd, ripngd: Convert to using new agg_table/route
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
donaldsharp committed Aug 30, 2018
1 parent 3a77d6d commit 046e0c1
Show file tree
Hide file tree
Showing 29 changed files with 747 additions and 717 deletions.
42 changes: 21 additions & 21 deletions bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "lib/prefix.h"
#include "lib/memory.h"
#include "lib/linklist.h"
#include "lib/table.h"
#include "lib/agg_table.h"
#include "lib/plist.h"
#include "lib/routemap.h"

Expand Down Expand Up @@ -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_un = NULL;

struct route_table *rt_vn;
struct route_table *rt_un;
struct route_node *rn_vn;
struct route_node *rn_un;
struct agg_table *rt_vn;
struct agg_table *rt_un;
struct agg_node *rn_vn;
struct agg_node *rn_un;

struct rfapi_nve_group_cfg *rfg;
struct listnode *node, *nnode;
Expand All @@ -156,16 +156,16 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
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) {
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) {
rfg_un = rn_un->info;
route_unlock_node(rn_un);
agg_unlock_node(rn_un);
}

#if BGP_VNC_DEBUG_MATCH_GROUP
Expand Down Expand Up @@ -2304,11 +2304,11 @@ static void bgp_rfapi_delete_nve_group(struct vty *vty, /* NULL = no output */

if (rfg->vn_node) {
rfg->vn_node->info = NULL;
route_unlock_node(rfg->vn_node); /* frees */
agg_unlock_node(rfg->vn_node); /* frees */
}
if (rfg->un_node) {
rfg->un_node->info = NULL;
route_unlock_node(rfg->un_node); /* frees */
agg_unlock_node(rfg->un_node); /* frees */
}
if (rfg->rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
Expand Down Expand Up @@ -2468,8 +2468,8 @@ DEFUN (vnc_nve_group_prefix,
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
struct prefix p;
afi_t afi;
struct route_table *rt;
struct route_node *rn;
struct agg_table *rt;
struct agg_node *rn;
int is_un_prefix = 0;

/* make sure it's still in list */
Expand Down Expand Up @@ -2497,12 +2497,12 @@ DEFUN (vnc_nve_group_prefix,
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) {
/*
* There is already a group with this prefix
*/
route_unlock_node(rn);
agg_unlock_node(rn);
if (rn->info != rfg) {
/*
* different group name: fail
Expand Down Expand Up @@ -2535,7 +2535,7 @@ DEFUN (vnc_nve_group_prefix,
/* detach rfg from previous route table location */
if (rfg->un_node) {
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_prefix = p;
Expand All @@ -2545,7 +2545,7 @@ DEFUN (vnc_nve_group_prefix,
/* detach rfg from previous route table location */
if (rfg->vn_node) {
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_prefix = p;
Expand Down Expand Up @@ -3761,8 +3761,8 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
h->nve_groups_sequential = list_new();
assert(h->nve_groups_sequential);
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
h->nve_groups_vn[afi] = route_table_init();
h->nve_groups_un[afi] = route_table_init();
h->nve_groups_vn[afi] = agg_table_init();
h->nve_groups_un[afi] = agg_table_init();
}
h->default_response_lifetime =
BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT;
Expand Down Expand Up @@ -3820,8 +3820,8 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
if (h->default_rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
route_table_finish(h->nve_groups_vn[afi]);
route_table_finish(h->nve_groups_un[afi]);
agg_table_finish(h->nve_groups_vn[afi]);
agg_table_finish(h->nve_groups_un[afi]);
}
XFREE(MTYPE_RFAPI_CFG, h);
}
Expand Down
8 changes: 4 additions & 4 deletions bgpd/rfapi/bgp_rfapi_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ typedef enum {
} rfapi_group_cfg_type_t;

struct rfapi_nve_group_cfg {
struct route_node *vn_node; /* backref */
struct route_node *un_node; /* backref */
struct agg_node *vn_node; /* backref */
struct agg_node *un_node; /* backref */

rfapi_group_cfg_type_t type; /* NVE|VPN */
char *name; /* unique by type! */
Expand Down Expand Up @@ -135,8 +135,8 @@ struct rfapi_cfg {
struct list *l2_groups; /* rfapi_l2_group_cfg list */
/* three views into the same collection of rfapi_nve_group_cfg */
struct list *nve_groups_sequential;
struct route_table *nve_groups_vn[AFI_MAX];
struct route_table *nve_groups_un[AFI_MAX];
struct agg_table *nve_groups_vn[AFI_MAX];
struct agg_table *nve_groups_un[AFI_MAX];

/*
* For Single VRF export to ordinary routing protocols. This is
Expand Down
32 changes: 16 additions & 16 deletions bgpd/rfapi/rfapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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/routemap.h"
Expand Down Expand Up @@ -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,
struct rfapi_ip_addr *un_addr,
struct route_node **node)
struct agg_node **node)
{
struct rfapi *h;
struct prefix p;
struct route_node *rn;
struct agg_node *rn;
int rc;
afi_t afi;

Expand All @@ -228,12 +228,12 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
if ((rc = rfapiRaddr2Qprefix(un_addr, &p)))
return rc;

rn = route_node_lookup(h->un[afi], &p);
rn = agg_node_lookup(h->un[afi], &p);

if (!rn)
return ENOENT;

route_unlock_node(rn);
agg_unlock_node(rn);

*node = rn;

Expand All @@ -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,
struct rfapi_ip_addr *un_addr, struct rfapi_descriptor **rfd)
{
struct route_node *rn;
struct agg_node *rn;
int rc;

rc = rfapi_find_node(bgp, vn_addr, un_addr, &rn);
Expand Down Expand Up @@ -1347,8 +1347,8 @@ static int rfapi_open_inner(struct rfapi_descriptor *rfd, struct bgp *bgp,
#define RFD_RTINIT_AFI(rh, ary, afi) \
do { \
if (!ary[afi]) { \
ary[afi] = route_table_init(); \
ary[afi]->info = rh; \
ary[afi] = agg_table_init(); \
agg_set_table_info(ary[afi], rh); \
} \
} while (0)

Expand Down Expand Up @@ -1394,7 +1394,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
char buf_un[BUFSIZ];
afi_t afi_vn, afi_un;
struct prefix pfx_un;
struct route_node *rn;
struct agg_node *rn;


rfapi_time(&rfd->open_time);
Expand Down Expand Up @@ -1423,7 +1423,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
assert(afi_vn && afi_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);
rfd->next = rn->info;
rn->info = rfd;
Expand Down Expand Up @@ -1535,7 +1535,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
afi_t afi;
struct prefix p;
struct prefix p_original;
struct route_node *rn;
struct agg_node *rn;
struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle;
struct bgp *bgp = rfd->bgp;
struct rfapi_next_hop_entry *pNHE = NULL;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
}

if (rn) {
route_lock_node(rn); /* so we can unlock below */
agg_lock_node(rn); /* so we can unlock below */
} else {
/*
* returns locked node. Don't unlock yet because the
Expand All @@ -1721,7 +1721,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,

assert(rn);
if (!rn->info) {
route_unlock_node(rn);
agg_unlock_node(rn);
vnc_zlog_debug_verbose(
"%s: VPN route not found, returning ENOENT", __func__);
return ENOENT;
Expand Down Expand Up @@ -1758,7 +1758,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
&p_original);
}

route_unlock_node(rn);
agg_unlock_node(rn);

done:
if (ppNextHopEntry) {
Expand Down Expand Up @@ -2170,7 +2170,7 @@ int rfapi_close(void *handle)
{
struct rfapi_descriptor *rfd = (struct rfapi_descriptor *)handle;
int rc;
struct route_node *node;
struct agg_node *node;
struct bgp *bgp;
struct rfapi *h;

Expand Down Expand Up @@ -2276,7 +2276,7 @@ int rfapi_close(void *handle)
}
}
}
route_unlock_node(node);
agg_unlock_node(node);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion bgpd/rfapi/rfapi_ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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/routemap.h"
Expand Down
Loading

0 comments on commit 046e0c1

Please sign in to comment.