bgp: rename bgp_node to bgp_dest

This is the bulk part extracted from "bgpd: Convert from `struct
bgp_node` to `struct bgp_dest`".  It should not result in any functional
change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
Donald Sharp 2020-03-26 19:11:58 -04:00 committed by David Lamparter
parent 6d7824f29c
commit 9bcb3eef54
50 changed files with 2118 additions and 2041 deletions

View File

@ -180,14 +180,14 @@ bool bgp_addpath_tx_path(enum bgp_addpath_strat strat, struct bgp_path_info *pi)
static void bgp_addpath_flush_type_rn(struct bgp *bgp, afi_t afi, safi_t safi, static void bgp_addpath_flush_type_rn(struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_addpath_strat addpath_type, enum bgp_addpath_strat addpath_type,
struct bgp_node *rn) struct bgp_dest *dest)
{ {
struct bgp_path_info *pi; struct bgp_path_info *pi;
idalloc_drain_pool( idalloc_drain_pool(
bgp->tx_addpath.id_allocators[afi][safi][addpath_type], bgp->tx_addpath.id_allocators[afi][safi][addpath_type],
&(rn->tx_addpath.free_ids[addpath_type])); &(dest->tx_addpath.free_ids[addpath_type]));
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (pi->tx_addpath.addpath_tx_id[addpath_type] if (pi->tx_addpath.addpath_tx_id[addpath_type]
!= IDALLOC_INVALID) { != IDALLOC_INVALID) {
idalloc_free( idalloc_free(
@ -210,24 +210,24 @@ static void bgp_addpath_flush_type_rn(struct bgp *bgp, afi_t afi, safi_t safi,
static void bgp_addpath_flush_type(struct bgp *bgp, afi_t afi, safi_t safi, static void bgp_addpath_flush_type(struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_addpath_strat addpath_type) enum bgp_addpath_strat addpath_type)
{ {
struct bgp_node *rn, *nrn; struct bgp_dest *dest, *ndest;
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (!table) if (!table)
continue; continue;
for (nrn = bgp_table_top(table); nrn; for (ndest = bgp_table_top(table); ndest;
nrn = bgp_route_next(nrn)) ndest = bgp_route_next(ndest))
bgp_addpath_flush_type_rn(bgp, afi, safi, bgp_addpath_flush_type_rn(bgp, afi, safi,
addpath_type, nrn); addpath_type, ndest);
} else { } else {
bgp_addpath_flush_type_rn(bgp, afi, safi, addpath_type, bgp_addpath_flush_type_rn(bgp, afi, safi, addpath_type,
rn); dest);
} }
} }
@ -257,7 +257,7 @@ static void bgp_addpath_populate_path(struct id_alloc *allocator,
static void bgp_addpath_populate_type(struct bgp *bgp, afi_t afi, safi_t safi, static void bgp_addpath_populate_type(struct bgp *bgp, afi_t afi, safi_t safi,
enum bgp_addpath_strat addpath_type) enum bgp_addpath_strat addpath_type)
{ {
struct bgp_node *rn, *nrn; struct bgp_dest *dest, *ndest;
char buf[200]; char buf[200];
struct id_alloc *allocator; struct id_alloc *allocator;
@ -276,25 +276,25 @@ static void bgp_addpath_populate_type(struct bgp *bgp, afi_t afi, safi_t safi,
allocator = bgp->tx_addpath.id_allocators[afi][safi][addpath_type]; allocator = bgp->tx_addpath.id_allocators[afi][safi][addpath_type];
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
struct bgp_path_info *bi; struct bgp_path_info *bi;
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (!table) if (!table)
continue; continue;
for (nrn = bgp_table_top(table); nrn; for (ndest = bgp_table_top(table); ndest;
nrn = bgp_route_next(nrn)) ndest = bgp_route_next(ndest))
for (bi = bgp_node_get_bgp_path_info(nrn); bi; for (bi = bgp_dest_get_bgp_path_info(ndest); bi;
bi = bi->next) bi = bi->next)
bgp_addpath_populate_path(allocator, bi, bgp_addpath_populate_path(allocator, bi,
addpath_type); addpath_type);
} else { } else {
for (bi = bgp_node_get_bgp_path_info(rn); bi; for (bi = bgp_dest_get_bgp_path_info(dest); bi;
bi = bi->next) bi = bi->next)
bgp_addpath_populate_path(allocator, bi, bgp_addpath_populate_path(allocator, bi,
addpath_type); addpath_type);
@ -426,8 +426,8 @@ void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,
* best-per-as updates from needing to do a separate withdraw and update just to * best-per-as updates from needing to do a separate withdraw and update just to
* swap out which path is sent. * swap out which path is sent.
*/ */
void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi, void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_dest *bn, afi_t afi,
safi_t safi) safi_t safi)
{ {
int i; int i;
struct bgp_path_info *pi; struct bgp_path_info *pi;
@ -442,7 +442,7 @@ void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi,
continue; continue;
/* Free Unused IDs back to the pool.*/ /* Free Unused IDs back to the pool.*/
for (pi = bgp_node_get_bgp_path_info(bn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(bn); pi; pi = pi->next) {
if (pi->tx_addpath.addpath_tx_id[i] != IDALLOC_INVALID if (pi->tx_addpath.addpath_tx_id[i] != IDALLOC_INVALID
&& !bgp_addpath_tx_path(i, pi)) { && !bgp_addpath_tx_path(i, pi)) {
idalloc_free_to_pool(pool_ptr, idalloc_free_to_pool(pool_ptr,
@ -453,7 +453,7 @@ void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi,
} }
/* Give IDs to paths that need them (pulling from the pool) */ /* Give IDs to paths that need them (pulling from the pool) */
for (pi = bgp_node_get_bgp_path_info(bn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(bn); pi; pi = pi->next) {
if (pi->tx_addpath.addpath_tx_id[i] == IDALLOC_INVALID if (pi->tx_addpath.addpath_tx_id[i] == IDALLOC_INVALID
&& bgp_addpath_tx_path(i, pi)) { && bgp_addpath_tx_path(i, pi)) {
pi->tx_addpath.addpath_tx_id[i] = pi->tx_addpath.addpath_tx_id[i] =

View File

@ -65,7 +65,7 @@ bool bgp_addpath_tx_path(enum bgp_addpath_strat strat,
void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi, void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,
enum bgp_addpath_strat addpath_type); enum bgp_addpath_strat addpath_type);
void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi, void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_dest *dest, afi_t afi,
safi_t safi); safi_t safi);
void bgp_addpath_type_changed(struct bgp *bgp); void bgp_addpath_type_changed(struct bgp *bgp);

View File

@ -144,7 +144,7 @@ void bgp_advertise_unintern(struct hash *hash, struct bgp_advertise_attr *baa)
} }
} }
bool bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn, bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
@ -153,7 +153,7 @@ bool bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
safi_t safi; safi_t safi;
int addpath_capable; int addpath_capable;
RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out) RB_FOREACH (adj, bgp_adj_out_rb, &dest->adj_out)
SUBGRP_FOREACH_PEER (adj->subgroup, paf) SUBGRP_FOREACH_PEER (adj->subgroup, paf)
if (paf->peer == peer) { if (paf->peer == peer) {
afi = SUBGRP_AFI(adj->subgroup); afi = SUBGRP_AFI(adj->subgroup);
@ -178,12 +178,12 @@ bool bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
} }
void bgp_adj_in_set(struct bgp_node *rn, struct peer *peer, struct attr *attr, void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
uint32_t addpath_id) uint32_t addpath_id)
{ {
struct bgp_adj_in *adj; struct bgp_adj_in *adj;
for (adj = rn->adj_in; adj; adj = adj->next) { for (adj = dest->adj_in; adj; adj = adj->next) {
if (adj->peer == peer && adj->addpath_rx_id == addpath_id) { if (adj->peer == peer && adj->addpath_rx_id == addpath_id) {
if (adj->attr != attr) { if (adj->attr != attr) {
bgp_attr_unintern(&adj->attr); bgp_attr_unintern(&adj->attr);
@ -197,25 +197,25 @@ void bgp_adj_in_set(struct bgp_node *rn, struct peer *peer, struct attr *attr,
adj->attr = bgp_attr_intern(attr); adj->attr = bgp_attr_intern(attr);
adj->uptime = bgp_clock(); adj->uptime = bgp_clock();
adj->addpath_rx_id = addpath_id; adj->addpath_rx_id = addpath_id;
BGP_ADJ_IN_ADD(rn, adj); BGP_ADJ_IN_ADD(dest, adj);
bgp_lock_node(rn); bgp_dest_lock_node(dest);
} }
void bgp_adj_in_remove(struct bgp_node *rn, struct bgp_adj_in *bai) void bgp_adj_in_remove(struct bgp_dest *dest, struct bgp_adj_in *bai)
{ {
bgp_attr_unintern(&bai->attr); bgp_attr_unintern(&bai->attr);
BGP_ADJ_IN_DEL(rn, bai); BGP_ADJ_IN_DEL(dest, bai);
peer_unlock(bai->peer); /* adj_in peer reference */ peer_unlock(bai->peer); /* adj_in peer reference */
XFREE(MTYPE_BGP_ADJ_IN, bai); XFREE(MTYPE_BGP_ADJ_IN, bai);
} }
bool bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer, bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
uint32_t addpath_id) uint32_t addpath_id)
{ {
struct bgp_adj_in *adj; struct bgp_adj_in *adj;
struct bgp_adj_in *adj_next; struct bgp_adj_in *adj_next;
adj = rn->adj_in; adj = dest->adj_in;
if (!adj) if (!adj)
return false; return false;
@ -224,8 +224,8 @@ bool bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
adj_next = adj->next; adj_next = adj->next;
if (adj->peer == peer && adj->addpath_rx_id == addpath_id) { if (adj->peer == peer && adj->addpath_rx_id == addpath_id) {
bgp_adj_in_remove(rn, adj); bgp_adj_in_remove(dest, adj);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
adj = adj_next; adj = adj_next;

View File

@ -48,7 +48,7 @@ struct bgp_advertise {
struct bgp_advertise *prev; struct bgp_advertise *prev;
/* Prefix information. */ /* Prefix information. */
struct bgp_node *rn; struct bgp_dest *dest;
/* Reference pointer. */ /* Reference pointer. */
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
@ -74,7 +74,7 @@ struct bgp_adj_out {
TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train; TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
/* Prefix information. */ /* Prefix information. */
struct bgp_node *rn; struct bgp_dest *dest;
uint32_t addpath_tx_id; uint32_t addpath_tx_id;
@ -139,11 +139,11 @@ struct bgp_synchronize {
#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in) #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
/* Prototypes. */ /* Prototypes. */
extern bool bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t); extern bool bgp_adj_out_lookup(struct peer *, struct bgp_dest *, uint32_t);
extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *, extern void bgp_adj_in_set(struct bgp_dest *, struct peer *, struct attr *,
uint32_t); uint32_t);
extern bool bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t); extern bool bgp_adj_in_unset(struct bgp_dest *, struct peer *, uint32_t);
extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *); extern void bgp_adj_in_remove(struct bgp_dest *, struct bgp_adj_in *);
extern void bgp_sync_init(struct peer *); extern void bgp_sync_init(struct peer *);
extern void bgp_sync_delete(struct peer *); extern void bgp_sync_delete(struct peer *);

View File

@ -922,7 +922,7 @@ afibreak:
} }
struct bgp_table *table = bmp->targets->bgp->rib[afi][safi]; struct bgp_table *table = bmp->targets->bgp->rib[afi][safi];
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi = NULL, *bpiter; struct bgp_path_info *bpi = NULL, *bpiter;
struct bgp_adj_in *adjin = NULL, *adjiter; struct bgp_adj_in *adjin = NULL, *adjiter;
@ -943,7 +943,7 @@ afibreak:
return true; return true;
} }
bmp->syncpeerid = 0; bmp->syncpeerid = 0;
prefix_copy(&bmp->syncpos, bgp_node_get_prefix(bn)); prefix_copy(&bmp->syncpos, bgp_dest_get_prefix(bn));
} }
if (bmp->targets->afimon[afi][safi] & BMP_MON_POSTPOLICY) { if (bmp->targets->afimon[afi][safi] & BMP_MON_POSTPOLICY) {
@ -991,7 +991,7 @@ afibreak:
bmp->syncpeerid = adjin->peer->qobj_node.nid; bmp->syncpeerid = adjin->peer->qobj_node.nid;
} }
const struct prefix *bn_p = bgp_node_get_prefix(bn); const struct prefix *bn_p = bgp_dest_get_prefix(bn);
if (bpi) if (bpi)
bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L, bn_p, bpi->attr, bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L, bn_p, bpi->attr,
@ -1025,7 +1025,7 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
{ {
struct bmp_queue_entry *bqe; struct bmp_queue_entry *bqe;
struct peer *peer; struct peer *peer;
struct bgp_node *bn; struct bgp_dest *bn;
bool written = false; bool written = false;
bqe = bmp_pull(bmp); bqe = bmp_pull(bmp);
@ -1129,8 +1129,8 @@ static void bmp_wrerr(struct bmp *bmp, struct pullwr *pullwr, bool eof)
bmp_free(bmp); bmp_free(bmp);
} }
static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp, static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp, afi_t afi,
afi_t afi, safi_t safi, struct bgp_node *bn, struct peer *peer) safi_t safi, struct bgp_dest *bn, struct peer *peer)
{ {
struct bmp *bmp; struct bmp *bmp;
struct bmp_queue_entry *bqe, bqeref; struct bmp_queue_entry *bqe, bqeref;
@ -1141,7 +1141,7 @@ static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
return; return;
memset(&bqeref, 0, sizeof(bqeref)); memset(&bqeref, 0, sizeof(bqeref));
prefix_copy(&bqeref.p, bgp_node_get_prefix(bn)); prefix_copy(&bqeref.p, bgp_dest_get_prefix(bn));
bqeref.peerid = peer->qobj_node.nid; bqeref.peerid = peer->qobj_node.nid;
bqeref.afi = afi; bqeref.afi = afi;
bqeref.safi = safi; bqeref.safi = safi;
@ -1169,7 +1169,7 @@ static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
} }
static int bmp_process(struct bgp *bgp, afi_t afi, safi_t safi, static int bmp_process(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_node *bn, struct peer *peer, bool withdraw) struct bgp_dest *bn, struct peer *peer, bool withdraw)
{ {
struct bmp_bgp *bmpbgp = bmp_bgp_find(peer->bgp); struct bmp_bgp *bmpbgp = bmp_bgp_find(peer->bgp);
struct bmp_targets *bt; struct bmp_targets *bt;

View File

@ -148,17 +148,18 @@ static int bgp_reuse_timer(struct thread *t)
/* if (figure-of-merit < reuse). */ /* if (figure-of-merit < reuse). */
if (bdi->penalty < bdc->reuse_limit) { if (bdi->penalty < bdc->reuse_limit) {
/* Reuse the route. */ /* Reuse the route. */
bgp_path_info_unset_flag(bdi->rn, bdi->path, bgp_path_info_unset_flag(bdi->dest, bdi->path,
BGP_PATH_DAMPED); BGP_PATH_DAMPED);
bdi->suppress_time = 0; bdi->suppress_time = 0;
if (bdi->lastrecord == BGP_RECORD_UPDATE) { if (bdi->lastrecord == BGP_RECORD_UPDATE) {
bgp_path_info_unset_flag(bdi->rn, bdi->path, bgp_path_info_unset_flag(bdi->dest, bdi->path,
BGP_PATH_HISTORY); BGP_PATH_HISTORY);
bgp_aggregate_increment( bgp_aggregate_increment(
bgp, bgp_node_get_prefix(bdi->rn), bgp, bgp_dest_get_prefix(bdi->dest),
bdi->path, bdi->afi, bdi->safi); bdi->path, bdi->afi, bdi->safi);
bgp_process(bgp, bdi->rn, bdi->afi, bdi->safi); bgp_process(bgp, bdi->dest, bdi->afi,
bdi->safi);
} }
if (bdi->penalty <= bdc->reuse_limit / 2.0) if (bdi->penalty <= bdc->reuse_limit / 2.0)
@ -175,7 +176,7 @@ static int bgp_reuse_timer(struct thread *t)
} }
/* A route becomes unreachable (RFC2439 Section 4.8.2). */ /* A route becomes unreachable (RFC2439 Section 4.8.2). */
int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn, int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t safi, int attr_change) afi_t afi, safi_t safi, int attr_change)
{ {
time_t t_now; time_t t_now;
@ -200,7 +201,7 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
bdi = XCALLOC(MTYPE_BGP_DAMP_INFO, bdi = XCALLOC(MTYPE_BGP_DAMP_INFO,
sizeof(struct bgp_damp_info)); sizeof(struct bgp_damp_info));
bdi->path = path; bdi->path = path;
bdi->rn = rn; bdi->dest = dest;
bdi->penalty = bdi->penalty =
(attr_change ? DEFAULT_PENALTY / 2 : DEFAULT_PENALTY); (attr_change ? DEFAULT_PENALTY / 2 : DEFAULT_PENALTY);
bdi->flap = 1; bdi->flap = 1;
@ -226,13 +227,13 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
bdi->flap++; bdi->flap++;
} }
assert((rn == bdi->rn) && (path == bdi->path)); assert((dest == bdi->dest) && (path == bdi->path));
bdi->lastrecord = BGP_RECORD_WITHDRAW; bdi->lastrecord = BGP_RECORD_WITHDRAW;
bdi->t_updated = t_now; bdi->t_updated = t_now;
/* Make this route as historical status. */ /* Make this route as historical status. */
bgp_path_info_set_flag(rn, path, BGP_PATH_HISTORY); bgp_path_info_set_flag(dest, path, BGP_PATH_HISTORY);
/* Remove the route from a reuse list if it is on one. */ /* Remove the route from a reuse list if it is on one. */
if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)) { if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)) {
@ -247,7 +248,7 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
/* If not suppressed before, do annonunce this withdraw and /* If not suppressed before, do annonunce this withdraw and
insert into reuse_list. */ insert into reuse_list. */
if (bdi->penalty >= bdc->suppress_value) { if (bdi->penalty >= bdc->suppress_value) {
bgp_path_info_set_flag(rn, path, BGP_PATH_DAMPED); bgp_path_info_set_flag(dest, path, BGP_PATH_DAMPED);
bdi->suppress_time = t_now; bdi->suppress_time = t_now;
BGP_DAMP_LIST_DEL(bdc, bdi); BGP_DAMP_LIST_DEL(bdc, bdi);
bgp_reuse_list_add(bdi, bdc); bgp_reuse_list_add(bdi, bdc);
@ -256,8 +257,8 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
return BGP_DAMP_USED; return BGP_DAMP_USED;
} }
int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, afi_t afi, int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
safi_t safi) afi_t afi, safi_t safi)
{ {
time_t t_now; time_t t_now;
struct bgp_damp_info *bdi; struct bgp_damp_info *bdi;
@ -268,7 +269,7 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, afi_t afi,
return BGP_DAMP_USED; return BGP_DAMP_USED;
t_now = bgp_clock(); t_now = bgp_clock();
bgp_path_info_unset_flag(rn, path, BGP_PATH_HISTORY); bgp_path_info_unset_flag(dest, path, BGP_PATH_HISTORY);
bdi->lastrecord = BGP_RECORD_UPDATE; bdi->lastrecord = BGP_RECORD_UPDATE;
bdi->penalty = bdi->penalty =
@ -279,7 +280,7 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, afi_t afi,
status = BGP_DAMP_USED; status = BGP_DAMP_USED;
else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED) else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
&& (bdi->penalty < bdc->reuse_limit)) { && (bdi->penalty < bdc->reuse_limit)) {
bgp_path_info_unset_flag(rn, path, BGP_PATH_DAMPED); bgp_path_info_unset_flag(dest, path, BGP_PATH_DAMPED);
bgp_reuse_list_delete(bdi, bdc); bgp_reuse_list_delete(bdi, bdc);
BGP_DAMP_LIST_ADD(bdc, bdi); BGP_DAMP_LIST_ADD(bdc, bdi);
bdi->suppress_time = 0; bdi->suppress_time = 0;
@ -312,11 +313,11 @@ void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw, afi_t afi,
else else
BGP_DAMP_LIST_DEL(bdc, bdi); BGP_DAMP_LIST_DEL(bdc, bdi);
bgp_path_info_unset_flag(bdi->rn, path, bgp_path_info_unset_flag(bdi->dest, path,
BGP_PATH_HISTORY | BGP_PATH_DAMPED); BGP_PATH_HISTORY | BGP_PATH_DAMPED);
if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw) if (bdi->lastrecord == BGP_RECORD_WITHDRAW && withdraw)
bgp_path_info_delete(bdi->rn, path); bgp_path_info_delete(bdi->dest, path);
XFREE(MTYPE_BGP_DAMP_INFO, bdi); XFREE(MTYPE_BGP_DAMP_INFO, bdi);
} }

View File

@ -21,6 +21,8 @@
#ifndef _QUAGGA_BGP_DAMP_H #ifndef _QUAGGA_BGP_DAMP_H
#define _QUAGGA_BGP_DAMP_H #define _QUAGGA_BGP_DAMP_H
#include "bgpd/bgp_table.h"
/* Structure maintained on a per-route basis. */ /* Structure maintained on a per-route basis. */
struct bgp_damp_info { struct bgp_damp_info {
/* Doubly linked list. This information must be linked to /* Doubly linked list. This information must be linked to
@ -47,7 +49,7 @@ struct bgp_damp_info {
struct bgp_path_info *path; struct bgp_path_info *path;
/* Back reference to bgp_node. */ /* Back reference to bgp_node. */
struct bgp_node *rn; struct bgp_dest *dest;
/* Current index in the reuse_list. */ /* Current index in the reuse_list. */
int index; int index;
@ -133,9 +135,9 @@ struct bgp_damp_config {
extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int, extern int bgp_damp_enable(struct bgp *, afi_t, safi_t, time_t, unsigned int,
unsigned int, time_t); unsigned int, time_t);
extern int bgp_damp_disable(struct bgp *, afi_t, safi_t); extern int bgp_damp_disable(struct bgp *, afi_t, safi_t);
extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn, extern int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t safi, int attr_change); afi_t afi, safi_t safi, int attr_change);
extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, extern int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t saff); afi_t afi, safi_t saff);
extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw, extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw,
afi_t afi, safi_t safi); afi_t afi, safi_t safi);

View File

@ -2539,11 +2539,11 @@ bool bgp_debug_update(struct peer *peer, const struct prefix *p,
return false; return false;
} }
bool bgp_debug_bestpath(struct bgp_node *rn) bool bgp_debug_bestpath(struct bgp_dest *dest)
{ {
if (BGP_DEBUG(bestpath, BESTPATH)) { if (BGP_DEBUG(bestpath, BESTPATH)) {
if (bgp_debug_per_prefix( if (bgp_debug_per_prefix(
bgp_node_get_prefix(rn), term_bgp_debug_bestpath, bgp_dest_get_prefix(dest), term_bgp_debug_bestpath,
BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes)) BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes))
return true; return true;
} }

View File

@ -168,7 +168,7 @@ extern int bgp_debug_neighbor_events(struct peer *peer);
extern int bgp_debug_keepalive(struct peer *peer); extern int bgp_debug_keepalive(struct peer *peer);
extern bool bgp_debug_update(struct peer *peer, const struct prefix *p, extern bool bgp_debug_update(struct peer *peer, const struct prefix *p,
struct update_group *updgrp, unsigned int inbound); struct update_group *updgrp, unsigned int inbound);
extern bool bgp_debug_bestpath(struct bgp_node *rn); extern bool bgp_debug_bestpath(struct bgp_dest *dest);
extern bool bgp_debug_zebra(const struct prefix *p); extern bool bgp_debug_zebra(const struct prefix *p);
extern const char * extern const char *

View File

@ -302,13 +302,13 @@ static void bgp_dump_routes_index_table(struct bgp *bgp)
static struct bgp_path_info * static struct bgp_path_info *
bgp_dump_route_node_record(int afi, struct bgp_node *rn, bgp_dump_route_node_record(int afi, struct bgp_dest *dest,
struct bgp_path_info *path, unsigned int seq) struct bgp_path_info *path, unsigned int seq)
{ {
struct stream *obuf; struct stream *obuf;
size_t sizep; size_t sizep;
size_t endp; size_t endp;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
obuf = bgp_dump_obuf; obuf = bgp_dump_obuf;
stream_reset(obuf); stream_reset(obuf);
@ -391,7 +391,7 @@ static unsigned int bgp_dump_routes_func(int afi, int first_run,
unsigned int seq) unsigned int seq)
{ {
struct bgp_path_info *path; struct bgp_path_info *path;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp *bgp; struct bgp *bgp;
struct bgp_table *table; struct bgp_table *table;
@ -412,10 +412,10 @@ static unsigned int bgp_dump_routes_func(int afi, int first_run,
/* Walk down each BGP route. */ /* Walk down each BGP route. */
table = bgp->rib[afi][SAFI_UNICAST]; table = bgp->rib[afi][SAFI_UNICAST];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
path = bgp_node_get_bgp_path_info(rn); path = bgp_dest_get_bgp_path_info(dest);
while (path) { while (path) {
path = bgp_dump_route_node_record(afi, rn, path, seq); path = bgp_dump_route_node_record(afi, dest, path, seq);
seq++; seq++;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ static inline int is_route_parent_evpn(struct bgp_path_info *ri)
{ {
struct bgp_path_info *parent_ri; struct bgp_path_info *parent_ri;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
/* If not imported (or doesn't have a parent), bail. */ /* If not imported (or doesn't have a parent), bail. */
if (ri->sub_type != BGP_ROUTE_IMPORTED || if (ri->sub_type != BGP_ROUTE_IMPORTED ||
@ -96,10 +96,10 @@ static inline int is_route_parent_evpn(struct bgp_path_info *ri)
; ;
/* See if of family L2VPN/EVPN */ /* See if of family L2VPN/EVPN */
rn = parent_ri->net; dest = parent_ri->net;
if (!rn) if (!dest)
return 0; return 0;
table = bgp_node_table(rn); table = bgp_dest_table(dest);
if (table && if (table &&
table->afi == AFI_L2VPN && table->afi == AFI_L2VPN &&
table->safi == SAFI_EVPN) table->safi == SAFI_EVPN)
@ -120,7 +120,7 @@ static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
{ {
struct bgp_path_info *parent_pi; struct bgp_path_info *parent_pi;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
if (pi->sub_type != BGP_ROUTE_IMPORTED || if (pi->sub_type != BGP_ROUTE_IMPORTED ||
!pi->extra || !pi->extra ||
@ -128,10 +128,10 @@ static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
return true; return true;
parent_pi = (struct bgp_path_info *)pi->extra->parent; parent_pi = (struct bgp_path_info *)pi->extra->parent;
rn = parent_pi->net; dest = parent_pi->net;
if (!rn) if (!dest)
return true; return true;
table = bgp_node_table(rn); table = bgp_dest_table(dest);
if (table && if (table &&
table->afi == AFI_L2VPN && table->afi == AFI_L2VPN &&
table->safi == SAFI_EVPN) table->safi == SAFI_EVPN)

View File

@ -274,15 +274,15 @@ static void show_import_rt_entry(struct hash_bucket *bucket, void *args[])
} }
static void bgp_evpn_show_route_rd_header(struct vty *vty, static void bgp_evpn_show_route_rd_header(struct vty *vty,
struct bgp_node *rd_rn, struct bgp_dest *rd_dest,
json_object *json, json_object *json, char *rd_str,
char *rd_str, int len) int len)
{ {
uint16_t type; uint16_t type;
struct rd_as rd_as; struct rd_as rd_as;
struct rd_ip rd_ip; struct rd_ip rd_ip;
const uint8_t *pnt; const uint8_t *pnt;
const struct prefix *p = bgp_node_get_prefix(rd_rn); const struct prefix *p = bgp_dest_get_prefix(rd_dest);
pnt = p->u.val; pnt = p->u.val;
@ -634,7 +634,7 @@ static void show_esi_routes(struct bgp *bgp,
json_object *json) json_object *json)
{ {
int header = 1; int header = 1;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
uint32_t prefix_cnt, path_cnt; uint32_t prefix_cnt, path_cnt;
uint64_t tbl_ver; uint64_t tbl_ver;
@ -642,13 +642,13 @@ static void show_esi_routes(struct bgp *bgp,
prefix_cnt = path_cnt = 0; prefix_cnt = path_cnt = 0;
tbl_ver = es->route_table->version; tbl_ver = es->route_table->version;
for (rn = bgp_table_top(es->route_table); rn; for (dest = bgp_table_top(es->route_table); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
int add_prefix_to_json = 0; int add_prefix_to_json = 0;
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
json_object *json_paths = NULL; json_object *json_paths = NULL;
json_object *json_prefix = NULL; json_object *json_prefix = NULL;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str, bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str,
sizeof(prefix_str)); sizeof(prefix_str));
@ -656,7 +656,7 @@ static void show_esi_routes(struct bgp *bgp,
if (json) if (json)
json_prefix = json_object_new_object(); json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn); pi = bgp_dest_get_bgp_path_info(dest);
if (pi) { if (pi) {
/* Overall header/legend displayed once. */ /* Overall header/legend displayed once. */
if (header) { if (header) {
@ -724,7 +724,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
struct vty *vty, struct in_addr vtep_ip, struct vty *vty, struct in_addr vtep_ip,
json_object *json, int detail) json_object *json, int detail)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
struct bgp_table *table; struct bgp_table *table;
int header = detail ? 0 : 1; int header = detail ? 0 : 1;
@ -735,18 +735,18 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
table = vpn->route_table; table = vpn->route_table;
tbl_ver = table->version; tbl_ver = table->version;
for (rn = bgp_table_top(table); rn; for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
rn = bgp_route_next(rn)) {
const struct prefix_evpn *evp = const struct prefix_evpn *evp =
(const struct prefix_evpn *)bgp_node_get_prefix(rn); (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
int add_prefix_to_json = 0; int add_prefix_to_json = 0;
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
json_object *json_paths = NULL; json_object *json_paths = NULL;
json_object *json_prefix = NULL; json_object *json_prefix = NULL;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
bgp_evpn_route2str((const struct prefix_evpn *)p, prefix_str, bgp_evpn_route2str(
sizeof(prefix_str)); (struct prefix_evpn *)bgp_dest_get_prefix(dest),
prefix_str, sizeof(prefix_str));
if (type && evp->prefix.route_type != type) if (type && evp->prefix.route_type != type)
continue; continue;
@ -754,7 +754,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
if (json) if (json)
json_prefix = json_object_new_object(); json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn); pi = bgp_dest_get_bgp_path_info(dest);
if (pi) { if (pi) {
/* Overall header/legend displayed once. */ /* Overall header/legend displayed once. */
if (header) { if (header) {
@ -784,7 +784,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
json_path = json_object_new_array(); json_path = json_object_new_array();
if (detail) if (detail)
route_vty_out_detail(vty, bgp, rn, pi, route_vty_out_detail(vty, bgp, dest, pi,
AFI_L2VPN, SAFI_EVPN, AFI_L2VPN, SAFI_EVPN,
json_path); json_path);
else else
@ -1167,8 +1167,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
afi_t afi = AFI_L2VPN; afi_t afi = AFI_L2VPN;
struct bgp *bgp; struct bgp *bgp;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_node *rm; struct bgp_dest *rm;
struct bgp_path_info *pi; struct bgp_path_info *pi;
int rd_header; int rd_header;
int header = 1; int header = 1;
@ -1196,16 +1196,16 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (use_json) if (use_json)
json = json_object_new_object(); json = json_object_new_object();
for (rn = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); rn; for (dest = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
uint64_t tbl_ver; uint64_t tbl_ver;
json_object *json_nroute = NULL; json_object *json_nroute = NULL;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
if (prd && memcmp(p->u.val, prd->val, 8) != 0) if (prd && memcmp(p->u.val, prd->val, 8) != 0)
continue; continue;
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (!table) if (!table)
continue; continue;
@ -1213,7 +1213,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
tbl_ver = table->version; tbl_ver = table->version;
for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) { for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm)) {
pi = bgp_node_get_bgp_path_info(rm); pi = bgp_dest_get_bgp_path_info(rm);
if (pi == NULL) if (pi == NULL)
continue; continue;
@ -1294,8 +1294,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (use_json) if (use_json)
json_nroute = json_nroute =
json_object_new_object(); json_object_new_object();
bgp_evpn_show_route_rd_header(vty, rn, bgp_evpn_show_route_rd_header(
json_nroute, rd_str, vty, dest, json_nroute, rd_str,
RD_ADDRSTRLEN); RD_ADDRSTRLEN);
rd_header = 0; rd_header = 0;
} }
@ -1304,16 +1304,16 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (option == SHOW_DISPLAY_TAGS) if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag( route_vty_out_tag(
vty, bgp_node_get_prefix(rm), vty, bgp_dest_get_prefix(rm),
pi, no_display, SAFI_EVPN, pi, no_display, SAFI_EVPN,
json_array); json_array);
else if (option == SHOW_DISPLAY_OVERLAY) else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay( route_vty_out_overlay(
vty, bgp_node_get_prefix(rm), vty, bgp_dest_get_prefix(rm),
pi, no_display, json_array); pi, no_display, json_array);
else else
route_vty_out(vty, route_vty_out(vty,
bgp_node_get_prefix(rm), bgp_dest_get_prefix(rm),
pi, no_display, SAFI_EVPN, pi, no_display, SAFI_EVPN,
json_array); json_array);
no_display = 1; no_display = 1;
@ -1324,7 +1324,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (use_json && json_array) { if (use_json && json_array) {
const struct prefix *p = const struct prefix *p =
bgp_node_get_prefix(rm); bgp_dest_get_prefix(rm);
json_prefix_info = json_object_new_object(); json_prefix_info = json_object_new_object();
@ -2323,7 +2323,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
{ {
struct bgpevpn *vpn; struct bgpevpn *vpn;
struct prefix_evpn p; struct prefix_evpn p;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
uint32_t path_cnt = 0; uint32_t path_cnt = 0;
afi_t afi; afi_t afi;
@ -2342,8 +2342,8 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
/* See if route exists. */ /* See if route exists. */
build_evpn_type3_prefix(&p, orig_ip); build_evpn_type3_prefix(&p, orig_ip);
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p); dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) { if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json) if (!json)
vty_out(vty, "%% Network not in table\n"); vty_out(vty, "%% Network not in table\n");
return; return;
@ -2353,17 +2353,16 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
json_paths = json_object_new_array(); json_paths = json_object_new_array();
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json); route_vty_out_detail_header(vty, bgp, dest, NULL, afi, safi, json);
/* Display each path for this prefix. */ /* Display each path for this prefix. */
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
json_object *json_path = NULL; json_object *json_path = NULL;
if (json) if (json)
json_path = json_object_new_array(); json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi, route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
json_path);
if (json) if (json)
json_object_array_add(json_paths, json_path); json_object_array_add(json_paths, json_path);
@ -2392,7 +2391,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
{ {
struct bgpevpn *vpn; struct bgpevpn *vpn;
struct prefix_evpn p; struct prefix_evpn p;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
uint32_t path_cnt = 0; uint32_t path_cnt = 0;
afi_t afi; afi_t afi;
@ -2412,8 +2411,8 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
/* See if route exists. Look for both non-sticky and sticky. */ /* See if route exists. Look for both non-sticky and sticky. */
build_evpn_type2_prefix(&p, mac, ip); build_evpn_type2_prefix(&p, mac, ip);
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p); dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) { if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json) if (!json)
vty_out(vty, "%% Network not in table\n"); vty_out(vty, "%% Network not in table\n");
return; return;
@ -2423,17 +2422,16 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
json_paths = json_object_new_array(); json_paths = json_object_new_array();
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json); route_vty_out_detail_header(vty, bgp, dest, NULL, afi, safi, json);
/* Display each path for this prefix. */ /* Display each path for this prefix. */
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
json_object *json_path = NULL; json_object *json_path = NULL;
if (json) if (json)
json_path = json_object_new_array(); json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi, route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
json_path);
if (json) if (json)
json_object_array_add(json_paths, json_path); json_object_array_add(json_paths, json_path);
@ -2502,7 +2500,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
struct ipaddr *ip, json_object *json) struct ipaddr *ip, json_object *json)
{ {
struct prefix_evpn p; struct prefix_evpn p;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
@ -2515,9 +2513,9 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
/* See if route exists. Look for both non-sticky and sticky. */ /* See if route exists. Look for both non-sticky and sticky. */
build_evpn_type2_prefix(&p, mac, ip); build_evpn_type2_prefix(&p, mac, ip);
rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
(struct prefix *)&p, prd); (struct prefix *)&p, prd);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) { if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json) if (!json)
vty_out(vty, "%% Network not in table\n"); vty_out(vty, "%% Network not in table\n");
return; return;
@ -2526,20 +2524,19 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
bgp_evpn_route2str(&p, prefix_str, sizeof(prefix_str)); bgp_evpn_route2str(&p, prefix_str, sizeof(prefix_str));
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, rn, prd, afi, safi, json); route_vty_out_detail_header(vty, bgp, dest, prd, afi, safi, json);
if (json) if (json)
json_paths = json_object_new_array(); json_paths = json_object_new_array();
/* Display each path for this prefix. */ /* Display each path for this prefix. */
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
json_object *json_path = NULL; json_object *json_path = NULL;
if (json) if (json)
json_path = json_object_new_array(); json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi, route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
json_path);
if (json) if (json)
json_object_array_add(json_paths, json_path); json_object_array_add(json_paths, json_path);
@ -2565,9 +2562,9 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
struct prefix_rd *prd, int type, struct prefix_rd *prd, int type,
json_object *json) json_object *json)
{ {
struct bgp_node *rd_rn; struct bgp_dest *rd_dest;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
int rd_header = 1; int rd_header = 1;
afi_t afi; afi_t afi;
@ -2583,11 +2580,11 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
prefix_rd2str(prd, rd_str, sizeof(rd_str)); prefix_rd2str(prd, rd_str, sizeof(rd_str));
rd_rn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd); rd_dest = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd);
if (!rd_rn) if (!rd_dest)
return; return;
table = bgp_node_get_bgp_table_info(rd_rn); table = bgp_dest_get_bgp_table_info(rd_dest);
if (table == NULL) if (table == NULL)
return; return;
@ -2597,9 +2594,9 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
} }
/* Display all prefixes with this RD. */ /* Display all prefixes with this RD. */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
const struct prefix_evpn *evp = const struct prefix_evpn *evp =
(const struct prefix_evpn *)bgp_node_get_prefix(rn); (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
json_object *json_prefix = NULL; json_object *json_prefix = NULL;
json_object *json_paths = NULL; json_object *json_paths = NULL;
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
@ -2614,7 +2611,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json) if (json)
json_prefix = json_object_new_object(); json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn); pi = bgp_dest_get_bgp_path_info(dest);
if (pi) { if (pi) {
/* RD header and legend - once overall. */ /* RD header and legend - once overall. */
if (rd_header && !json) { if (rd_header && !json) {
@ -2628,7 +2625,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
} }
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
route_vty_out_detail_header(vty, bgp, rn, prd, afi, route_vty_out_detail_header(vty, bgp, dest, prd, afi,
safi, json_prefix); safi, json_prefix);
prefix_cnt++; prefix_cnt++;
@ -2644,7 +2641,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json) if (json)
json_path = json_object_new_array(); json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi, route_vty_out_detail(vty, bgp, dest, pi, afi, safi,
json_path); json_path);
if (json) if (json)
@ -2699,9 +2696,9 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
json_object *json, int detail) json_object *json, int detail)
{ {
struct bgp_node *rd_rn; struct bgp_dest *rd_dest;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
int header = detail ? 0 : 1; int header = detail ? 0 : 1;
int rd_header; int rd_header;
@ -2716,20 +2713,20 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
/* EVPN routing table is a 2-level table with the first level being /* EVPN routing table is a 2-level table with the first level being
* the RD. * the RD.
*/ */
for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn; for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
rd_rn = bgp_route_next(rd_rn)) { rd_dest = bgp_route_next(rd_dest)) {
char rd_str[RD_ADDRSTRLEN]; char rd_str[RD_ADDRSTRLEN];
json_object *json_rd = NULL; /* contains routes for an RD */ json_object *json_rd = NULL; /* contains routes for an RD */
int add_rd_to_json = 0; int add_rd_to_json = 0;
uint64_t tbl_ver; uint64_t tbl_ver;
const struct prefix *rd_rnp = bgp_node_get_prefix(rd_rn); const struct prefix *rd_destp = bgp_dest_get_prefix(rd_dest);
table = bgp_node_get_bgp_table_info(rd_rn); table = bgp_dest_get_bgp_table_info(rd_dest);
if (table == NULL) if (table == NULL)
continue; continue;
tbl_ver = table->version; tbl_ver = table->version;
prefix_rd2str((struct prefix_rd *)rd_rnp, rd_str, prefix_rd2str((struct prefix_rd *)rd_destp, rd_str,
sizeof(rd_str)); sizeof(rd_str));
if (json) if (json)
@ -2738,17 +2735,18 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
rd_header = 1; rd_header = 1;
/* Display all prefixes for an RD */ /* Display all prefixes for an RD */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest;
dest = bgp_route_next(dest)) {
json_object *json_prefix = json_object *json_prefix =
NULL; /* contains prefix under a RD */ NULL; /* contains prefix under a RD */
json_object *json_paths = json_object *json_paths =
NULL; /* array of paths under a prefix*/ NULL; /* array of paths under a prefix*/
const struct prefix_evpn *evp = const struct prefix_evpn *evp =
(const struct prefix_evpn *)bgp_node_get_prefix( (const struct prefix_evpn *)bgp_dest_get_prefix(
rn); dest);
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
int add_prefix_to_json = 0; int add_prefix_to_json = 0;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str, bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str,
sizeof(prefix_str)); sizeof(prefix_str));
@ -2756,7 +2754,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
if (type && evp->prefix.route_type != type) if (type && evp->prefix.route_type != type)
continue; continue;
pi = bgp_node_get_bgp_path_info(rn); pi = bgp_dest_get_bgp_path_info(dest);
if (pi) { if (pi) {
/* Overall header/legend displayed once. */ /* Overall header/legend displayed once. */
if (header) { if (header) {
@ -2773,7 +2771,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
/* RD header - per RD. */ /* RD header - per RD. */
if (rd_header) { if (rd_header) {
bgp_evpn_show_route_rd_header( bgp_evpn_show_route_rd_header(
vty, rd_rn, json_rd, rd_str, vty, rd_dest, json_rd, rd_str,
RD_ADDRSTRLEN); RD_ADDRSTRLEN);
rd_header = 0; rd_header = 0;
} }
@ -2793,8 +2791,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
if (detail) if (detail)
route_vty_out_detail_header( route_vty_out_detail_header(
vty, bgp, rn, vty, bgp, dest,
(struct prefix_rd *)rd_rnp, AFI_L2VPN, (struct prefix_rd *)rd_destp, AFI_L2VPN,
SAFI_EVPN, json_prefix); SAFI_EVPN, json_prefix);
/* For EVPN, the prefix is displayed for each path (to /* For EVPN, the prefix is displayed for each path (to
@ -2812,7 +2810,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
if (detail) { if (detail) {
route_vty_out_detail( route_vty_out_detail(
vty, bgp, rn, pi, AFI_L2VPN, vty, bgp, dest, pi, AFI_L2VPN,
SAFI_EVPN, json_path); SAFI_EVPN, json_path);
} else } else
route_vty_out(vty, p, pi, 0, SAFI_EVPN, route_vty_out(vty, p, pi, 0, SAFI_EVPN,

View File

@ -603,11 +603,12 @@ bool bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
{ {
struct bgp_pbr_entry_main api; struct bgp_pbr_entry_main api;
int i; int i;
struct bgp_node *rn = pi->net; struct bgp_dest *dest = pi->net;
struct bgp_pbr_entry_action *api_action; struct bgp_pbr_entry_action *api_action;
memset(&api, 0, sizeof(struct bgp_pbr_entry_main)); memset(&api, 0, sizeof(struct bgp_pbr_entry_main));
if (bgp_pbr_build_and_validate_entry(bgp_node_get_prefix(rn), pi, &api) if (bgp_pbr_build_and_validate_entry(bgp_dest_get_prefix(dest), pi,
&api)
< 0) < 0)
return true; return true;
for (i = 0; i < api.action_num; i++) { for (i = 0; i < api.action_num; i++) {

View File

@ -391,7 +391,7 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
unsigned long *output_cum, unsigned long *total_cum) unsigned long *output_cum, unsigned long *total_cum)
{ {
struct bgp_path_info *pi; struct bgp_path_info *pi;
struct bgp_node *rn; struct bgp_dest *dest;
unsigned long total_count = 0; unsigned long total_count = 0;
json_object *json_paths = NULL; json_object *json_paths = NULL;
int display = NLRI_STRING_FORMAT_LARGE; int display = NLRI_STRING_FORMAT_LARGE;
@ -399,8 +399,8 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
if (type != bgp_show_type_detail) if (type != bgp_show_type_detail)
return CMD_SUCCESS; return CMD_SUCCESS;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
pi = bgp_node_get_bgp_path_info(rn); pi = bgp_dest_get_bgp_path_info(dest);
if (pi == NULL) if (pi == NULL)
continue; continue;
if (use_json) { if (use_json) {
@ -409,8 +409,8 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
} }
for (; pi; pi = pi->next) { for (; pi; pi = pi->next) {
total_count++; total_count++;
route_vty_out_flowspec(vty, bgp_node_get_prefix(rn), pi, route_vty_out_flowspec(vty, bgp_dest_get_prefix(dest),
display, json_paths); pi, display, json_paths);
} }
if (use_json) { if (use_json) {
vty_out(vty, "%s\n", vty_out(vty, "%s\n",
@ -553,19 +553,19 @@ extern int bgp_flowspec_display_match_per_ip(afi_t afi, struct bgp_table *rib,
bool use_json, bool use_json,
json_object *json_paths) json_object *json_paths)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
const struct prefix *prefix; const struct prefix *prefix;
int display = 0; int display = 0;
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(rib); dest; dest = bgp_route_next(dest)) {
prefix = bgp_node_get_prefix(rn); prefix = bgp_dest_get_prefix(dest);
if (prefix->family != AF_FLOWSPEC) if (prefix->family != AF_FLOWSPEC)
continue; continue;
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) { if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
route_vty_out_flowspec( route_vty_out_flowspec(
vty, prefix, bgp_node_get_bgp_path_info(rn), vty, prefix, bgp_dest_get_bgp_path_info(dest),
use_json ? NLRI_STRING_FORMAT_JSON use_json ? NLRI_STRING_FORMAT_JSON
: NLRI_STRING_FORMAT_LARGE, : NLRI_STRING_FORMAT_LARGE,
json_paths); json_paths);

View File

@ -45,7 +45,7 @@ extern struct zclient *zclient;
int bgp_parse_fec_update(void) int bgp_parse_fec_update(void)
{ {
struct stream *s; struct stream *s;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp *bgp; struct bgp *bgp;
struct bgp_table *table; struct bgp_table *table;
struct prefix p; struct prefix p;
@ -75,33 +75,33 @@ int bgp_parse_fec_update(void)
zlog_debug("no %u unicast table", p.family); zlog_debug("no %u unicast table", p.family);
return -1; return -1;
} }
rn = bgp_node_lookup(table, &p); dest = bgp_node_lookup(table, &p);
if (!rn) { if (!dest) {
zlog_debug("no node for the prefix"); zlog_debug("no node for the prefix");
return -1; return -1;
} }
/* treat it as implicit withdraw - the label is invalid */ /* treat it as implicit withdraw - the label is invalid */
if (label == MPLS_INVALID_LABEL) if (label == MPLS_INVALID_LABEL)
bgp_unset_valid_label(&rn->local_label); bgp_unset_valid_label(&dest->local_label);
else { else {
label_ntop(label, 1, &rn->local_label); label_ntop(label, 1, &dest->local_label);
bgp_set_valid_label(&rn->local_label); bgp_set_valid_label(&dest->local_label);
} }
SET_FLAG(rn->flags, BGP_NODE_LABEL_CHANGED); SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
bgp_process(bgp, rn, afi, safi); bgp_process(bgp, dest, afi, safi);
return 1; return 1;
} }
mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi, mpls_label_t bgp_adv_label(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *to, afi_t afi, safi_t safi) struct peer *to, afi_t afi, safi_t safi)
{ {
struct peer *from; struct peer *from;
mpls_label_t remote_label; mpls_label_t remote_label;
int reflect; int reflect;
if (!rn || !pi || !to) if (!dest || !pi || !to)
return MPLS_INVALID_LABEL; return MPLS_INVALID_LABEL;
remote_label = pi->extra ? pi->extra->label[0] : MPLS_INVALID_LABEL; remote_label = pi->extra ? pi->extra->label[0] : MPLS_INVALID_LABEL;
@ -117,7 +117,7 @@ mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi,
if (CHECK_FLAG(to->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) if (CHECK_FLAG(to->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
return remote_label; return remote_label;
return rn->local_label; return dest->local_label;
} }
/** /**
@ -131,7 +131,7 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
bool allocated) bool allocated)
{ {
struct bgp_path_info *pi; struct bgp_path_info *pi;
struct bgp_node *rn; struct bgp_dest *dest;
pi = labelid; pi = labelid;
/* Is this path still valid? */ /* Is this path still valid? */
@ -143,11 +143,11 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
return -1; return -1;
} }
rn = pi->net; dest = pi->net;
if (BGP_DEBUG(labelpool, LABELPOOL)) if (BGP_DEBUG(labelpool, LABELPOOL))
zlog_debug("%s: FEC %pRN label=%u, allocated=%d", __func__, rn, zlog_debug("%s: FEC %pRN label=%u, allocated=%d", __func__,
new_label, allocated); bgp_dest_to_rnode(dest), new_label, allocated);
if (!allocated) { if (!allocated) {
/* /*
@ -155,11 +155,11 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
*/ */
if (pi->attr->label_index == MPLS_INVALID_LABEL_INDEX if (pi->attr->label_index == MPLS_INVALID_LABEL_INDEX
&& pi->attr->label != MPLS_LABEL_NONE && pi->attr->label != MPLS_LABEL_NONE
&& CHECK_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) { && CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
bgp_unregister_for_label(rn); bgp_unregister_for_label(dest);
label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1, label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
&rn->local_label); &dest->local_label);
bgp_set_valid_label(&rn->local_label); bgp_set_valid_label(&dest->local_label);
} }
return 0; return 0;
} }
@ -173,7 +173,8 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
flog_err( flog_err(
EC_BGP_LABEL, EC_BGP_LABEL,
"%s: FEC %pRN Rejecting allocated label %u as Label Index is %u", "%s: FEC %pRN Rejecting allocated label %u as Label Index is %u",
__func__, rn, new_label, pi->attr->label_index); __func__, bgp_dest_to_rnode(dest), new_label,
pi->attr->label_index);
bgp_register_for_label(pi->net, pi); bgp_register_for_label(pi->net, pi);
@ -188,12 +189,13 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
/* Shouldn't happen: different label allocation */ /* Shouldn't happen: different label allocation */
flog_err(EC_BGP_LABEL, flog_err(EC_BGP_LABEL,
"%s: %pRN had label %u but got new assignment %u", "%s: %pRN had label %u but got new assignment %u",
__func__, rn, pi->attr->label, new_label); __func__, bgp_dest_to_rnode(dest), pi->attr->label,
new_label);
/* continue means use new one */ /* continue means use new one */
} }
label_ntop(new_label, 1, &rn->local_label); label_ntop(new_label, 1, &dest->local_label);
bgp_set_valid_label(&rn->local_label); bgp_set_valid_label(&dest->local_label);
/* /*
* Get back to registering the FEC * Get back to registering the FEC
@ -203,7 +205,7 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
return 0; return 0;
} }
void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *pi, void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
bool reg) bool reg)
{ {
bool with_label_index = false; bool with_label_index = false;
@ -215,8 +217,8 @@ void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *pi,
size_t flags_pos = 0; size_t flags_pos = 0;
char addr[PREFIX_STRLEN]; char addr[PREFIX_STRLEN];
p = bgp_node_get_prefix(rn); p = bgp_dest_get_prefix(dest);
local_label = &(rn->local_label); local_label = &(dest->local_label);
/* this prevents the loop when we're called by /* this prevents the loop when we're called by
* bgp_reg_for_label_callback() * bgp_reg_for_label_callback()
*/ */
@ -280,9 +282,9 @@ void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *pi,
flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX; flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX;
stream_putl(s, pi->attr->label_index); stream_putl(s, pi->attr->label_index);
} }
SET_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL); SET_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL);
} else } else
UNSET_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL); UNSET_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL);
/* Set length and flags */ /* Set length and flags */
stream_putw_at(s, 0, stream_get_endp(s)); stream_putw_at(s, 0, stream_get_endp(s));

View File

@ -26,17 +26,18 @@
#define BGP_WITHDRAW_LABEL 0x800000 #define BGP_WITHDRAW_LABEL 0x800000
#define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE #define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
struct bgp_node; struct bgp_dest;
struct bgp_path_info; struct bgp_path_info;
struct peer; struct peer;
extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid, extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
bool allocated); bool allocated);
extern void bgp_reg_dereg_for_label(struct bgp_node *rn, extern void bgp_reg_dereg_for_label(struct bgp_dest *dest,
struct bgp_path_info *pi, bool reg); struct bgp_path_info *pi, bool reg);
extern int bgp_parse_fec_update(void); extern int bgp_parse_fec_update(void);
extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi, extern mpls_label_t bgp_adv_label(struct bgp_dest *dest,
struct peer *to, afi_t afi, safi_t safi); struct bgp_path_info *pi, struct peer *to,
afi_t afi, safi_t safi);
extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, extern int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
struct bgp_nlri *packet); struct bgp_nlri *packet);
@ -86,15 +87,15 @@ static inline void bgp_unset_valid_label(mpls_label_t *label)
t[2] &= ~0x02; t[2] &= ~0x02;
} }
static inline void bgp_register_for_label(struct bgp_node *rn, static inline void bgp_register_for_label(struct bgp_dest *dest,
struct bgp_path_info *pi) struct bgp_path_info *pi)
{ {
bgp_reg_dereg_for_label(rn, pi, true); bgp_reg_dereg_for_label(dest, pi, true);
} }
static inline void bgp_unregister_for_label(struct bgp_node *rn) static inline void bgp_unregister_for_label(struct bgp_dest *dest)
{ {
bgp_reg_dereg_for_label(rn, NULL, false); bgp_reg_dereg_for_label(dest, NULL, false);
} }
/* Label stream to value */ /* Label stream to value */

View File

@ -137,34 +137,37 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
struct bgp_table *table, struct bgp_table *table,
struct ethaddr *macaddr) struct ethaddr *macaddr)
{ {
struct bgp_node *prn, *rn; struct bgp_dest *pdest, *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
for (prn = bgp_table_top(table); prn; prn = bgp_route_next(prn)) { for (pdest = bgp_table_top(table); pdest;
struct bgp_table *sub = prn->info; pdest = bgp_route_next(pdest)) {
const struct prefix *prn_p = bgp_node_get_prefix(prn); struct bgp_table *sub = pdest->info;
const struct prefix *pdest_p = bgp_dest_get_prefix(pdest);
if (!sub) if (!sub)
continue; continue;
for (rn = bgp_table_top(sub); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(sub); dest;
bool rn_affected; dest = bgp_route_next(dest)) {
const struct prefix *p = bgp_node_get_prefix(rn); bool dest_affected;
const struct prefix_evpn *pevpn = (const struct prefix_evpn *)p; const struct prefix *p = bgp_dest_get_prefix(dest);
struct prefix_evpn *pevpn = (struct prefix_evpn *)dest;
struct prefix_rd prd; struct prefix_rd prd;
uint32_t num_labels = 0; uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL; mpls_label_t *label_pnt = NULL;
struct bgp_route_evpn evpn; struct bgp_route_evpn evpn;
if (pevpn->family == AF_EVPN && if (pevpn->family == AF_EVPN
pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE && && pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
memcmp(&p->u.prefix_evpn.macip_addr.mac, && memcmp(&p->u.prefix_evpn.macip_addr.mac, macaddr,
macaddr, ETH_ALEN) == 0) ETH_ALEN)
rn_affected = true; == 0)
dest_affected = true;
else else
rn_affected = false; dest_affected = false;
for (pi = rn->info; pi; pi = pi->next) { for (pi = dest->info; pi; pi = pi->next) {
if (pi->peer == peer) if (pi->peer == peer)
break; break;
} }
@ -176,8 +179,8 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
* If the mac address is not the same then * If the mac address is not the same then
* we don't care and since we are looking * we don't care and since we are looking
*/ */
if ((memcmp(&pi->attr->rmac, macaddr, ETH_ALEN) != 0) && if ((memcmp(&pi->attr->rmac, macaddr, ETH_ALEN) != 0)
!rn_affected) && !dest_affected)
continue; continue;
if (pi->extra) if (pi->extra)
@ -187,7 +190,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; prd.prefixlen = 64;
memcpy(&prd.val, prn_p->u.val, 8); memcpy(&prd.val, pdest_p->u.val, 8);
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) { if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
if (bgp_debug_update(peer, p, NULL, 1)) { if (bgp_debug_update(peer, p, NULL, 1)) {
@ -216,7 +219,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
1, &evpn); 1, &evpn);
if (ret < 0) if (ret < 0)
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
} }

View File

@ -506,7 +506,7 @@ static void bgp_path_info_mpath_attr_set(struct bgp_path_info *path,
* Compare and sync up the multipath list with the mp_list generated by * Compare and sync up the multipath list with the mp_list generated by
* bgp_best_selection * bgp_best_selection
*/ */
void bgp_path_info_mpath_update(struct bgp_node *rn, void bgp_path_info_mpath_update(struct bgp_dest *dest,
struct bgp_path_info *new_best, struct bgp_path_info *new_best,
struct bgp_path_info *old_best, struct bgp_path_info *old_best,
struct list *mp_list, struct list *mp_list,
@ -530,7 +530,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
old_cum_bw = cum_bw = 0; old_cum_bw = cum_bw = 0;
prev_mpath = new_best; prev_mpath = new_best;
mp_node = listhead(mp_list); mp_node = listhead(mp_list);
debug = bgp_debug_bestpath(rn); debug = bgp_debug_bestpath(dest);
if (new_best) { if (new_best) {
mpath_count++; mpath_count++;
@ -553,7 +553,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (debug) if (debug)
zlog_debug( zlog_debug(
"%pRN: starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw u%" PRIu64, "%pRN: starting mpath update, newbest %s num candidates %d old-mpath-count %d old-cum-bw u%" PRIu64,
rn, new_best ? new_best->peer->host : "NONE", bgp_dest_to_rnode(dest),
new_best ? new_best->peer->host : "NONE",
mp_list ? listcount(mp_list) : 0, mp_list ? listcount(mp_list) : 0,
old_mpath_count, old_cum_bw); old_mpath_count, old_cum_bw);
@ -588,7 +589,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (debug) if (debug)
zlog_debug( zlog_debug(
"%pRN: comparing candidate %s with existing mpath %s", "%pRN: comparing candidate %s with existing mpath %s",
rn, bgp_dest_to_rnode(dest),
tmp_info ? tmp_info->peer->host : "NONE", tmp_info ? tmp_info->peer->host : "NONE",
cur_mpath ? cur_mpath->peer->host : "NONE"); cur_mpath ? cur_mpath->peer->host : "NONE");
@ -617,7 +618,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%pRN: %s is still multipath, cur count %d", "%pRN: %s is still multipath, cur count %d",
rn, path_buf, mpath_count); bgp_dest_to_rnode(dest),
path_buf, mpath_count);
} }
} else { } else {
mpath_changed = 1; mpath_changed = 1;
@ -626,7 +628,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d", "%pRN: remove mpath %s nexthop %s, cur count %d",
rn, path_buf, bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&cur_mpath->attr &cur_mpath->attr
->nexthop, ->nexthop,
@ -659,7 +662,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d", "%pRN: remove mpath %s nexthop %s, cur count %d",
rn, path_buf, bgp_dest_to_rnode(dest), path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&cur_mpath->attr->nexthop, &cur_mpath->attr->nexthop,
nh_buf[0], sizeof(nh_buf[0])), nh_buf[0], sizeof(nh_buf[0])),
@ -709,7 +712,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
new_mpath, path_buf); new_mpath, path_buf);
zlog_debug( zlog_debug(
"%pRN: add mpath %s nexthop %s, cur count %d", "%pRN: add mpath %s nexthop %s, cur count %d",
rn, path_buf, bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&new_mpath->attr &new_mpath->attr
->nexthop, ->nexthop,
@ -737,7 +741,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
zlog_debug( zlog_debug(
"%pRN: New mpath count (incl newbest) %d mpath-change %s" "%pRN: New mpath count (incl newbest) %d mpath-change %s"
" all_paths_lb %d cum_bw u%" PRIu64, " all_paths_lb %d cum_bw u%" PRIu64,
rn, mpath_count, bgp_dest_to_rnode(dest), mpath_count,
mpath_changed ? "YES" : "NO", mpath_changed ? "YES" : "NO",
all_paths_lb, cum_bw); all_paths_lb, cum_bw);

View File

@ -64,7 +64,7 @@ extern void bgp_mp_list_init(struct list *);
extern void bgp_mp_list_clear(struct list *); extern void bgp_mp_list_clear(struct list *);
extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo); extern void bgp_mp_list_add(struct list *mp_list, struct bgp_path_info *mpinfo);
extern void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best); extern void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best);
extern void bgp_path_info_mpath_update(struct bgp_node *rn, extern void bgp_path_info_mpath_update(struct bgp_dest *dest,
struct bgp_path_info *new_best, struct bgp_path_info *new_best,
struct bgp_path_info *old_best, struct bgp_path_info *old_best,
struct list *mp_list, struct list *mp_list,

View File

@ -462,13 +462,13 @@ static void setlabels(struct bgp_path_info *bpi,
*/ */
static struct bgp_path_info * static struct bgp_path_info *
leak_update(struct bgp *bgp, /* destination bgp instance */ leak_update(struct bgp *bgp, /* destination bgp instance */
struct bgp_node *bn, struct attr *new_attr, /* already interned */ struct bgp_dest *bn, struct attr *new_attr, /* already interned */
afi_t afi, safi_t safi, struct bgp_path_info *source_bpi, afi_t afi, safi_t safi, struct bgp_path_info *source_bpi,
mpls_label_t *label, uint32_t num_labels, void *parent, mpls_label_t *label, uint32_t num_labels, void *parent,
struct bgp *bgp_orig, struct prefix *nexthop_orig, struct bgp *bgp_orig, struct prefix *nexthop_orig,
int nexthop_self_flag, int debug) int nexthop_self_flag, int debug)
{ {
const struct prefix *p = bgp_node_get_prefix(bn); const struct prefix *p = bgp_dest_get_prefix(bn);
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_path_info *bpi_ultimate; struct bgp_path_info *bpi_ultimate;
struct bgp_path_info *new; struct bgp_path_info *new;
@ -502,7 +502,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
/* /*
* match parent * match parent
*/ */
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
if (bpi->extra && bpi->extra->parent == parent) if (bpi->extra && bpi->extra->parent == parent)
break; break;
} }
@ -574,7 +574,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
/* Process change. */ /* Process change. */
bgp_aggregate_increment(bgp, p, bpi, afi, safi); bgp_aggregate_increment(bgp, p, bpi, afi, safi);
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
if (debug) if (debug)
zlog_debug("%s: ->%s: %pRN Found route, changed attr", zlog_debug("%s: ->%s: %pRN Found route, changed attr",
@ -595,7 +595,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
setlabels(new, label, num_labels); setlabels(new, label, num_labels);
new->extra->parent = bgp_path_info_lock(parent); new->extra->parent = bgp_path_info_lock(parent);
bgp_lock_node((struct bgp_node *)((struct bgp_path_info *)parent)->net); bgp_dest_lock_node(
(struct bgp_dest *)((struct bgp_path_info *)parent)->net);
if (bgp_orig) if (bgp_orig)
new->extra->bgp_orig = bgp_lock(bgp_orig); new->extra->bgp_orig = bgp_lock(bgp_orig);
if (nexthop_orig) if (nexthop_orig)
@ -638,7 +639,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
bgp_aggregate_increment(bgp, p, new, afi, safi); bgp_aggregate_increment(bgp, p, new, afi, safi);
bgp_path_info_add(bn, new); bgp_path_info_add(bn, new);
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
if (debug) if (debug)
@ -654,14 +655,14 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */ struct bgp_path_info *path_vrf) /* route */
{ {
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
const struct prefix *p = bgp_node_get_prefix(path_vrf->net); const struct prefix *p = bgp_dest_get_prefix(path_vrf->net);
afi_t afi = family2afi(p->family); afi_t afi = family2afi(p->family);
struct attr static_attr = {0}; struct attr static_attr = {0};
struct attr *new_attr = NULL; struct attr *new_attr = NULL;
safi_t safi = SAFI_MPLS_VPN; safi_t safi = SAFI_MPLS_VPN;
mpls_label_t label_val; mpls_label_t label_val;
mpls_label_t label; mpls_label_t label;
struct bgp_node *bn; struct bgp_dest *bn;
const char *debugmsg; const char *debugmsg;
int nexthop_self_flag = 0; int nexthop_self_flag = 0;
@ -888,11 +889,11 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */ struct bgp_path_info *path_vrf) /* route */
{ {
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
const struct prefix *p = bgp_node_get_prefix(path_vrf->net); const struct prefix *p = bgp_dest_get_prefix(path_vrf->net);
afi_t afi = family2afi(p->family); afi_t afi = family2afi(p->family);
safi_t safi = SAFI_MPLS_VPN; safi_t safi = SAFI_MPLS_VPN;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_node *bn; struct bgp_dest *bn;
const char *debugmsg; const char *debugmsg;
if (debug) { if (debug) {
@ -933,7 +934,7 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
* vrf -> vpn * vrf -> vpn
* match original bpi imported from * match original bpi imported from
*/ */
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
if (bpi->extra && bpi->extra->parent == path_vrf) { if (bpi->extra && bpi->extra->parent == path_vrf) {
break; break;
} }
@ -947,7 +948,7 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vpn, bn, afi, safi); bgp_process(bgp_vpn, bn, afi, safi);
} }
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
} }
void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
@ -955,27 +956,27 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
afi_t afi) afi_t afi)
{ {
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
struct bgp_node *prn; struct bgp_dest *pdest;
safi_t safi = SAFI_MPLS_VPN; safi_t safi = SAFI_MPLS_VPN;
/* /*
* Walk vpn table, delete bpi with bgp_orig == bgp_vrf * Walk vpn table, delete bpi with bgp_orig == bgp_vrf
*/ */
for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn; for (pdest = bgp_table_top(bgp_vpn->rib[afi][safi]); pdest;
prn = bgp_route_next(prn)) { pdest = bgp_route_next(pdest)) {
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
/* This is the per-RD table of prefixes */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (!table) if (!table)
continue; continue;
for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) { for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
bpi = bgp_node_get_bgp_path_info(bn); bpi = bgp_dest_get_bgp_path_info(bn);
if (debug && bpi) { if (debug && bpi) {
zlog_debug("%s: looking at prefix %pRN", zlog_debug("%s: looking at prefix %pRN",
__func__, bn); __func__, bn);
@ -998,7 +999,7 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
__func__); __func__);
bgp_aggregate_decrement( bgp_aggregate_decrement(
bgp_vpn, bgp_vpn,
bgp_node_get_prefix(bn), bpi, bgp_dest_get_prefix(bn), bpi,
afi, safi); afi, safi);
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vpn, bn, afi, safi); bgp_process(bgp_vpn, bn, afi, safi);
@ -1012,7 +1013,7 @@ void vpn_leak_from_vrf_update_all(struct bgp *bgp_vpn, /* to */
struct bgp *bgp_vrf, /* from */ struct bgp *bgp_vrf, /* from */
afi_t afi) afi_t afi)
{ {
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
@ -1026,7 +1027,7 @@ void vpn_leak_from_vrf_update_all(struct bgp *bgp_vpn, /* to */
if (debug) if (debug)
zlog_debug("%s: node=%p", __func__, bn); zlog_debug("%s: node=%p", __func__, bn);
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (debug) if (debug)
zlog_debug( zlog_debug(
@ -1042,12 +1043,12 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
struct bgp *bgp_vpn, /* from */ struct bgp *bgp_vpn, /* from */
struct bgp_path_info *path_vpn) /* route */ struct bgp_path_info *path_vpn) /* route */
{ {
const struct prefix *p = bgp_node_get_prefix(path_vpn->net); const struct prefix *p = bgp_dest_get_prefix(path_vpn->net);
afi_t afi = family2afi(p->family); afi_t afi = family2afi(p->family);
struct attr static_attr = {0}; struct attr static_attr = {0};
struct attr *new_attr = NULL; struct attr *new_attr = NULL;
struct bgp_node *bn; struct bgp_dest *bn;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
const char *debugmsg; const char *debugmsg;
struct prefix nexthop_orig; struct prefix nexthop_orig;
@ -1214,7 +1215,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
if (bpi_ultimate->net) { if (bpi_ultimate->net) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_table(bpi_ultimate->net); table = bgp_dest_table(bpi_ultimate->net);
if (table && (table->safi == SAFI_UNICAST)) if (table && (table->safi == SAFI_UNICAST))
origin_local = 1; origin_local = 1;
} }
@ -1276,7 +1277,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
struct bgp *bgp; struct bgp *bgp;
struct listnode *mnode, *mnnode; struct listnode *mnode, *mnnode;
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
const char *debugmsg; const char *debugmsg;
@ -1305,7 +1306,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
return; return;
} }
p = bgp_node_get_prefix(path_vpn->net); p = bgp_dest_get_prefix(path_vpn->net);
afi = family2afi(p->family); afi = family2afi(p->family);
/* Loop over VRFs */ /* Loop over VRFs */
@ -1331,7 +1332,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL); bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (bpi->extra if (bpi->extra
&& (struct bgp_path_info *)bpi->extra->parent && (struct bgp_path_info *)bpi->extra->parent
@ -1348,14 +1349,14 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
} }
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
} }
} }
void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */
afi_t afi) afi_t afi)
{ {
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
@ -1368,7 +1369,7 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */
for (bn = bgp_table_top(bgp_vrf->rib[afi][safi]); bn; for (bn = bgp_table_top(bgp_vrf->rib[afi][safi]); bn;
bn = bgp_route_next(bn)) { bn = bgp_route_next(bn)) {
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (bpi->extra if (bpi->extra
&& bpi->extra->bgp_orig != bgp_vrf && bpi->extra->bgp_orig != bgp_vrf
@ -1377,7 +1378,7 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */
/* delete route */ /* delete route */
bgp_aggregate_decrement(bgp_vrf, bgp_aggregate_decrement(bgp_vrf,
bgp_node_get_prefix(bn), bgp_dest_get_prefix(bn),
bpi, afi, safi); bpi, afi, safi);
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vrf, bn, afi, safi); bgp_process(bgp_vrf, bn, afi, safi);
@ -1391,7 +1392,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
afi_t afi) afi_t afi)
{ {
struct prefix_rd prd; struct prefix_rd prd;
struct bgp_node *prn; struct bgp_dest *pdest;
safi_t safi = SAFI_MPLS_VPN; safi_t safi = SAFI_MPLS_VPN;
assert(bgp_vpn); assert(bgp_vpn);
@ -1399,11 +1400,11 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
/* /*
* Walk vpn table * Walk vpn table
*/ */
for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn; for (pdest = bgp_table_top(bgp_vpn->rib[afi][safi]); pdest;
prn = bgp_route_next(prn)) { pdest = bgp_route_next(pdest)) {
const struct prefix *p = bgp_node_get_prefix(prn); const struct prefix *p = bgp_dest_get_prefix(pdest);
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
memset(&prd, 0, sizeof(prd)); memset(&prd, 0, sizeof(prd));
@ -1412,14 +1413,14 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
memcpy(prd.val, &p->u.val, 8); memcpy(prd.val, &p->u.val, 8);
/* This is the per-RD table of prefixes */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (!table) if (!table)
continue; continue;
for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) { for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (bpi->extra if (bpi->extra

View File

@ -233,7 +233,7 @@ static inline bool is_route_injectable_into_vpn(struct bgp_path_info *pi)
{ {
struct bgp_path_info *parent_pi; struct bgp_path_info *parent_pi;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
if (pi->sub_type != BGP_ROUTE_IMPORTED || if (pi->sub_type != BGP_ROUTE_IMPORTED ||
!pi->extra || !pi->extra ||
@ -241,10 +241,10 @@ static inline bool is_route_injectable_into_vpn(struct bgp_path_info *pi)
return true; return true;
parent_pi = (struct bgp_path_info *)pi->extra->parent; parent_pi = (struct bgp_path_info *)pi->extra->parent;
rn = parent_pi->net; dest = parent_pi->net;
if (!rn) if (!dest)
return true; return true;
table = bgp_node_table(rn); table = bgp_dest_table(dest);
if (table && if (table &&
(table->afi == AFI_IP || table->afi == AFI_IP6) && (table->afi == AFI_IP || table->afi == AFI_IP6) &&
table->safi == SAFI_MPLS_VPN) table->safi == SAFI_MPLS_VPN)

View File

@ -50,7 +50,7 @@ DEFINE_MTYPE_STATIC(BGPD, MARTIAN_STRING, "BGP Martian Address Intf String");
char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size) char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size)
{ {
prefix2str(bgp_node_get_prefix(bnc->node), buf, size); prefix2str(bgp_dest_get_prefix(bnc->dest), buf, size);
return buf; return buf;
} }
@ -78,11 +78,11 @@ void bnc_free(struct bgp_nexthop_cache *bnc)
/* Reset and free all BGP nexthop cache. */ /* Reset and free all BGP nexthop cache. */
static void bgp_nexthop_cache_reset(struct bgp_table *table) static void bgp_nexthop_cache_reset(struct bgp_table *table)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
continue; continue;
@ -93,8 +93,8 @@ static void bgp_nexthop_cache_reset(struct bgp_table *table)
} }
bnc_free(bnc); bnc_free(bnc);
bgp_node_set_bgp_nexthop_info(rn, NULL); bgp_dest_set_bgp_nexthop_info(dest, NULL);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
@ -345,7 +345,7 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
{ {
struct prefix p; struct prefix p;
struct prefix *addr; struct prefix *addr;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_connected_ref *bc; struct bgp_connected_ref *bc;
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct peer *peer; struct peer *peer;
@ -361,16 +361,16 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
bgp_address_add(bgp, ifc, addr); bgp_address_add(bgp, ifc, addr);
rn = bgp_node_get(bgp->connected_table[AFI_IP], dest = bgp_node_get(bgp->connected_table[AFI_IP],
(struct prefix *)&p); (struct prefix *)&p);
bc = bgp_node_get_bgp_connected_ref_info(rn); bc = bgp_dest_get_bgp_connected_ref_info(dest);
if (bc) if (bc)
bc->refcnt++; bc->refcnt++;
else { else {
bc = XCALLOC(MTYPE_BGP_CONN, bc = XCALLOC(MTYPE_BGP_CONN,
sizeof(struct bgp_connected_ref)); sizeof(struct bgp_connected_ref));
bc->refcnt = 1; bc->refcnt = 1;
bgp_node_set_bgp_connected_ref_info(rn, bc); bgp_dest_set_bgp_connected_ref_info(dest, bc);
} }
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
@ -395,17 +395,17 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
bgp_address_add(bgp, ifc, addr); bgp_address_add(bgp, ifc, addr);
rn = bgp_node_get(bgp->connected_table[AFI_IP6], dest = bgp_node_get(bgp->connected_table[AFI_IP6],
(struct prefix *)&p); (struct prefix *)&p);
bc = bgp_node_get_bgp_connected_ref_info(rn); bc = bgp_dest_get_bgp_connected_ref_info(dest);
if (bc) if (bc)
bc->refcnt++; bc->refcnt++;
else { else {
bc = XCALLOC(MTYPE_BGP_CONN, bc = XCALLOC(MTYPE_BGP_CONN,
sizeof(struct bgp_connected_ref)); sizeof(struct bgp_connected_ref));
bc->refcnt = 1; bc->refcnt = 1;
bgp_node_set_bgp_connected_ref_info(rn, bc); bgp_dest_set_bgp_connected_ref_info(dest, bc);
} }
} }
} }
@ -414,7 +414,7 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
{ {
struct prefix p; struct prefix p;
struct prefix *addr; struct prefix *addr;
struct bgp_node *rn = NULL; struct bgp_dest *dest = NULL;
struct bgp_connected_ref *bc; struct bgp_connected_ref *bc;
addr = ifc->address; addr = ifc->address;
@ -427,7 +427,7 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
bgp_address_del(bgp, ifc, addr); bgp_address_del(bgp, ifc, addr);
rn = bgp_node_lookup(bgp->connected_table[AFI_IP], &p); dest = bgp_node_lookup(bgp->connected_table[AFI_IP], &p);
} else if (addr->family == AF_INET6) { } else if (addr->family == AF_INET6) {
if (IN6_IS_ADDR_UNSPECIFIED(&p.u.prefix6)) if (IN6_IS_ADDR_UNSPECIFIED(&p.u.prefix6))
return; return;
@ -437,46 +437,47 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
bgp_address_del(bgp, ifc, addr); bgp_address_del(bgp, ifc, addr);
rn = bgp_node_lookup(bgp->connected_table[AFI_IP6], &p); dest = bgp_node_lookup(bgp->connected_table[AFI_IP6], &p);
} }
if (!rn) if (!dest)
return; return;
bc = bgp_node_get_bgp_connected_ref_info(rn); bc = bgp_dest_get_bgp_connected_ref_info(dest);
bc->refcnt--; bc->refcnt--;
if (bc->refcnt == 0) { if (bc->refcnt == 0) {
XFREE(MTYPE_BGP_CONN, bc); XFREE(MTYPE_BGP_CONN, bc);
bgp_node_set_bgp_connected_ref_info(rn, NULL); bgp_dest_set_bgp_connected_ref_info(dest, NULL);
} }
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
static void bgp_connected_cleanup(struct route_table *table, static void bgp_connected_cleanup(struct route_table *table,
struct route_node *rn) struct route_node *rn)
{ {
struct bgp_connected_ref *bc; struct bgp_connected_ref *bc;
struct bgp_node *bn = bgp_node_from_rnode(rn); struct bgp_dest *bn = bgp_dest_from_rnode(rn);
bc = bgp_node_get_bgp_connected_ref_info(bn); bc = bgp_dest_get_bgp_connected_ref_info(bn);
if (!bc) if (!bc)
return; return;
bc->refcnt--; bc->refcnt--;
if (bc->refcnt == 0) { if (bc->refcnt == 0) {
XFREE(MTYPE_BGP_CONN, bc); XFREE(MTYPE_BGP_CONN, bc);
bgp_node_set_bgp_connected_ref_info(bn, NULL); bgp_dest_set_bgp_connected_ref_info(bn, NULL);
} }
} }
bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
uint8_t sub_type, struct attr *attr, struct bgp_node *rn) uint8_t sub_type, struct attr *attr,
struct bgp_dest *dest)
{ {
uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6; uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6;
struct bgp_addr tmp_addr = {{0}}, *addr = NULL; struct bgp_addr tmp_addr = {{0}}, *addr = NULL;
struct tip_addr tmp_tip, *tip = NULL; struct tip_addr tmp_tip, *tip = NULL;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
bool is_bgp_static_route = bool is_bgp_static_route =
((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC)) ((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC))
? true ? true
@ -547,8 +548,8 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer) bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
{ {
struct bgp_node *rn1; struct bgp_dest *dest1;
struct bgp_node *rn2; struct bgp_dest *dest2;
struct prefix p; struct prefix p;
int ret; int ret;
@ -556,32 +557,32 @@ bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = nexthop; p.u.prefix4 = nexthop;
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p); dest1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn1) if (!dest1)
return false; return false;
p.family = AF_INET; p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = peer->su.sin.sin_addr; p.u.prefix4 = peer->su.sin.sin_addr;
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p); dest2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn2) { if (!dest2) {
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
return false; return false;
} }
ret = (rn1 == rn2); ret = (dest1 == dest2);
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
return ret; return ret;
} }
bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer) bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
{ {
struct bgp_node *rn1; struct bgp_dest *dest1;
struct bgp_node *rn2; struct bgp_dest *dest2;
struct prefix p; struct prefix p;
int ret; int ret;
@ -589,24 +590,24 @@ bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
p.prefixlen = IPV6_MAX_BITLEN; p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = nexthop; p.u.prefix6 = nexthop;
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p); dest1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn1) if (!dest1)
return false; return false;
p.family = AF_INET6; p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN; p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = peer->su.sin6.sin6_addr; p.u.prefix6 = peer->su.sin6.sin6_addr;
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p); dest2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn2) { if (!dest2) {
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
return false; return false;
} }
ret = (rn1 == rn2); ret = (dest1 == dest2);
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
return ret; return ret;
} }
@ -615,7 +616,7 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude) struct peer *exclude)
{ {
struct bgp_node *rn1 = NULL, *rn2 = NULL; struct bgp_dest *dest1 = NULL, *dest2 = NULL;
struct peer_af *paf = NULL; struct peer_af *paf = NULL;
struct prefix p = {0}, np = {0}; struct prefix p = {0}, np = {0};
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
@ -628,8 +629,8 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
p.prefixlen = IPV6_MAX_BITLEN; p.prefixlen = IPV6_MAX_BITLEN;
bgp = SUBGRP_INST(subgrp); bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np); dest1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np);
if (!rn1) if (!dest1)
return false; return false;
SUBGRP_FOREACH_PEER (subgrp, paf) { SUBGRP_FOREACH_PEER (subgrp, paf) {
@ -638,18 +639,18 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
continue; continue;
p.u.prefix6 = paf->peer->su.sin6.sin6_addr; p.u.prefix6 = paf->peer->su.sin6.sin6_addr;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p); dest2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p);
if (rn1 == rn2) { if (dest1 == dest2) {
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
return true; return true;
} }
if (rn2) if (dest2)
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
} }
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
return false; return false;
} }
@ -657,7 +658,7 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct peer *exclude) struct peer *exclude)
{ {
struct bgp_node *rn1, *rn2; struct bgp_dest *dest1, *dest2;
struct peer_af *paf; struct peer_af *paf;
struct prefix p, np; struct prefix p, np;
struct bgp *bgp; struct bgp *bgp;
@ -670,8 +671,8 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
p.prefixlen = IPV4_MAX_BITLEN; p.prefixlen = IPV4_MAX_BITLEN;
bgp = SUBGRP_INST(subgrp); bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP], &np); dest1 = bgp_node_match(bgp->connected_table[AFI_IP], &np);
if (!rn1) if (!dest1)
return false; return false;
SUBGRP_FOREACH_PEER (subgrp, paf) { SUBGRP_FOREACH_PEER (subgrp, paf) {
@ -681,25 +682,25 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
p.u.prefix4 = paf->peer->su.sin.sin_addr; p.u.prefix4 = paf->peer->su.sin.sin_addr;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP], &p); dest2 = bgp_node_match(bgp->connected_table[AFI_IP], &p);
if (rn1 == rn2) { if (dest1 == dest2) {
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
return true; return true;
} }
if (rn2) if (dest2)
bgp_unlock_node(rn2); bgp_dest_unlock_node(dest2);
} }
bgp_unlock_node(rn1); bgp_dest_unlock_node(dest1);
return false; return false;
} }
static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp, static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
struct bgp_nexthop_cache *bnc) struct bgp_nexthop_cache *bnc)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *path; struct bgp_path_info *path;
int afi; int afi;
safi_t safi; safi_t safi;
@ -709,21 +710,21 @@ static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
vty_out(vty, " Paths:\n"); vty_out(vty, " Paths:\n");
LIST_FOREACH (path, &(bnc->paths), nh_thread) { LIST_FOREACH (path, &(bnc->paths), nh_thread) {
rn = path->net; dest = path->net;
assert(rn && bgp_node_table(rn)); assert(dest && bgp_dest_table(dest));
afi = family2afi(rn->p.family); afi = family2afi(bgp_dest_get_prefix(dest)->family);
table = bgp_node_table(rn); table = bgp_dest_table(dest);
safi = table->safi; safi = table->safi;
bgp_path = table->bgp; bgp_path = table->bgp;
if (rn->prn) { if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)&rn->prn->p, prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1)); buf1, sizeof(buf1));
vty_out(vty, " %d/%d %pRN RD %s %s flags 0x%x\n", vty_out(vty, " %d/%d %pRN RD %s %s flags 0x%x\n",
afi, safi, rn, buf1, bgp_path->name_pretty, path->flags); afi, safi, dest, buf1, bgp_path->name_pretty, path->flags);
} else } else
vty_out(vty, " %d/%d %pRN %s flags 0x%x\n", vty_out(vty, " %d/%d %pRN %s flags 0x%x\n",
afi, safi, rn, bgp_path->name_pretty, path->flags); afi, safi, dest, bgp_path->name_pretty, path->flags);
} }
} }
@ -772,14 +773,14 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
} }
static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp, static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
struct bgp_node *rn, struct bgp_dest *dest,
struct bgp_nexthop_cache *bnc, struct bgp_nexthop_cache *bnc,
bool specific) bool specific)
{ {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
time_t tbuf; time_t tbuf;
struct peer *peer; struct peer *peer;
const struct prefix *p = bgp_node_get_prefix(rn); const struct prefix *p = bgp_dest_get_prefix(dest);
peer = (struct peer *)bnc->nht_info; peer = (struct peer *)bnc->nht_info;
@ -815,7 +816,7 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp,
bool import_table) bool import_table)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
afi_t afi; afi_t afi;
struct bgp_table **table; struct bgp_table **table;
@ -831,12 +832,12 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp,
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
if (!table || !table[afi]) if (!table || !table[afi])
continue; continue;
for (rn = bgp_table_top(table[afi]); rn; for (dest = bgp_table_top(table[afi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
continue; continue;
bgp_show_nexthop(vty, bgp, rn, bnc, false); bgp_show_nexthop(vty, bgp, dest, bnc, false);
} }
} }
} }
@ -859,7 +860,7 @@ static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name,
if (nhopip_str) { if (nhopip_str) {
struct prefix nhop; struct prefix nhop;
struct bgp_table **table; struct bgp_table **table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
if (!str2prefix(nhopip_str, &nhop)) { if (!str2prefix(nhopip_str, &nhop)) {
@ -868,17 +869,17 @@ static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name,
} }
table = import_table ? \ table = import_table ? \
bgp->import_check_table : bgp->nexthop_cache_table; bgp->import_check_table : bgp->nexthop_cache_table;
rn = bgp_node_lookup(table[family2afi(nhop.family)], &nhop); dest = bgp_node_lookup(table[family2afi(nhop.family)], &nhop);
if (!rn) { if (!dest) {
vty_out(vty, "specified nexthop is not found\n"); vty_out(vty, "specified nexthop is not found\n");
return CMD_SUCCESS; return CMD_SUCCESS;
} }
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) { if (!bnc) {
vty_out(vty, "specified nexthop does not have entry\n"); vty_out(vty, "specified nexthop does not have entry\n");
return CMD_SUCCESS; return CMD_SUCCESS;
} }
bgp_show_nexthop(vty, bgp, rn, bnc, true); bgp_show_nexthop(vty, bgp, dest, bnc, true);
} else } else
bgp_show_nexthops(vty, bgp, import_table); bgp_show_nexthops(vty, bgp, import_table);

View File

@ -61,7 +61,7 @@ struct bgp_nexthop_cache {
#define BGP_NEXTHOP_METRIC_CHANGED (1 << 1) #define BGP_NEXTHOP_METRIC_CHANGED (1 << 1)
#define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2) #define BGP_NEXTHOP_CONNECTED_CHANGED (1 << 2)
struct bgp_node *node; struct bgp_dest *dest;
void *nht_info; /* In BGP, peer session */ void *nht_info; /* In BGP, peer session */
LIST_HEAD(path_list, bgp_path_info) paths; LIST_HEAD(path_list, bgp_path_info) paths;
unsigned int path_count; unsigned int path_count;
@ -93,7 +93,7 @@ extern bool bgp_multiaccess_check_v6(struct in6_addr nexthop,
extern int bgp_config_write_scan_time(struct vty *); extern int bgp_config_write_scan_time(struct vty *);
extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, extern bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
uint8_t sub_type, struct attr *attr, uint8_t sub_type, struct attr *attr,
struct bgp_node *rn); struct bgp_dest *dest);
extern struct bgp_nexthop_cache *bnc_new(void); extern struct bgp_nexthop_cache *bnc_new(void);
extern void bnc_free(struct bgp_nexthop_cache *bnc); extern void bnc_free(struct bgp_nexthop_cache *bnc);
extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc); extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc);

View File

@ -78,9 +78,9 @@ static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc)
} }
unregister_zebra_rnh(bnc, unregister_zebra_rnh(bnc,
CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE)); CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE));
bgp_node_set_bgp_nexthop_info(bnc->node, NULL); bgp_dest_set_bgp_nexthop_info(bnc->dest, NULL);
bgp_unlock_node(bnc->node); bgp_dest_unlock_node(bnc->dest);
bnc->node = NULL; bnc->dest = NULL;
bnc_free(bnc); bnc_free(bnc);
} }
} }
@ -100,16 +100,16 @@ void bgp_unlink_nexthop(struct bgp_path_info *path)
void bgp_unlink_nexthop_by_peer(struct peer *peer) void bgp_unlink_nexthop_by_peer(struct peer *peer)
{ {
struct prefix p; struct prefix p;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
afi_t afi = family2afi(peer->su.sa.sa_family); afi_t afi = family2afi(peer->su.sa.sa_family);
if (!sockunion2hostprefix(&peer->su, &p)) if (!sockunion2hostprefix(&peer->su, &p))
return; return;
rn = bgp_node_get(peer->bgp->nexthop_cache_table[afi], &p); dest = bgp_node_get(peer->bgp->nexthop_cache_table[afi], &p);
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
return; return;
@ -127,7 +127,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
afi_t afi, struct bgp_path_info *pi, afi_t afi, struct bgp_path_info *pi,
struct peer *peer, int connected) struct peer *peer, int connected)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
struct prefix p; struct prefix p;
int is_bgp_static_route = 0; int is_bgp_static_route = 0;
@ -163,17 +163,17 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
return 0; return 0;
if (is_bgp_static_route) if (is_bgp_static_route)
rn = bgp_node_get(bgp_nexthop->import_check_table[afi], &p); dest = bgp_node_get(bgp_nexthop->import_check_table[afi], &p);
else else
rn = bgp_node_get(bgp_nexthop->nexthop_cache_table[afi], &p); dest = bgp_node_get(bgp_nexthop->nexthop_cache_table[afi], &p);
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) { if (!bnc) {
bnc = bnc_new(); bnc = bnc_new();
bgp_node_set_bgp_nexthop_info(rn, bnc); bgp_dest_set_bgp_nexthop_info(dest, bnc);
bnc->node = rn; bnc->dest = dest;
bnc->bgp = bgp_nexthop; bnc->bgp = bgp_nexthop;
bgp_lock_node(rn); bgp_dest_lock_node(dest);
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
@ -183,9 +183,9 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
} }
} }
bnc_p = bgp_node_get_prefix(bnc->node); bnc_p = bgp_dest_get_prefix(bnc->dest);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
if (is_bgp_static_route) { if (is_bgp_static_route) {
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE); SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
@ -264,7 +264,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer) void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
struct prefix p; struct prefix p;
@ -274,9 +274,9 @@ void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
if (!sockunion2hostprefix(&peer->su, &p)) if (!sockunion2hostprefix(&peer->su, &p))
return; return;
rn = bgp_node_lookup( dest = bgp_node_lookup(
peer->bgp->nexthop_cache_table[family2afi(p.family)], &p); peer->bgp->nexthop_cache_table[family2afi(p.family)], &p);
if (!rn) { if (!dest) {
if (BGP_DEBUG(nht, NHT)) if (BGP_DEBUG(nht, NHT))
zlog_debug( zlog_debug(
"Cannot find connected NHT node for peer %s(%s)", "Cannot find connected NHT node for peer %s(%s)",
@ -284,16 +284,16 @@ void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
return; return;
} }
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) { if (!bnc) {
if (BGP_DEBUG(nht, NHT)) if (BGP_DEBUG(nht, NHT))
zlog_debug( zlog_debug(
"Cannot find connected NHT node for peer %s(%s) on route_node as expected", "Cannot find connected NHT node for peer %s(%s) on route_node as expected",
peer->host, peer->bgp->name_pretty); peer->host, peer->bgp->name_pretty);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
return; return;
} }
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
if (bnc->nht_info != peer) { if (bnc->nht_info != peer) {
if (BGP_DEBUG(nht, NHT)) if (BGP_DEBUG(nht, NHT))
@ -312,15 +312,15 @@ void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
"Freeing connected NHT node %p for peer %s(%s)", "Freeing connected NHT node %p for peer %s(%s)",
bnc, peer->host, bnc->bgp->name_pretty); bnc, peer->host, bnc->bgp->name_pretty);
unregister_zebra_rnh(bnc, 0); unregister_zebra_rnh(bnc, 0);
bgp_node_set_bgp_nexthop_info(bnc->node, NULL); bgp_dest_set_bgp_nexthop_info(bnc->dest, NULL);
bgp_unlock_node(bnc->node); bgp_dest_unlock_node(bnc->dest);
bnc_free(bnc); bnc_free(bnc);
} }
} }
void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
{ {
struct bgp_node *rn = NULL; struct bgp_dest *dest = NULL;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
struct nexthop *nexthop; struct nexthop *nexthop;
struct nexthop *oldnh; struct nexthop *oldnh;
@ -347,15 +347,15 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
} }
if (command == ZEBRA_NEXTHOP_UPDATE) if (command == ZEBRA_NEXTHOP_UPDATE)
rn = bgp_node_lookup( dest = bgp_node_lookup(
bgp->nexthop_cache_table[family2afi(nhr.prefix.family)], bgp->nexthop_cache_table[family2afi(nhr.prefix.family)],
&nhr.prefix); &nhr.prefix);
else if (command == ZEBRA_IMPORT_CHECK_UPDATE) else if (command == ZEBRA_IMPORT_CHECK_UPDATE)
rn = bgp_node_lookup( dest = bgp_node_lookup(
bgp->import_check_table[family2afi(nhr.prefix.family)], bgp->import_check_table[family2afi(nhr.prefix.family)],
&nhr.prefix); &nhr.prefix);
if (!rn) { if (!dest) {
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
prefix2str(&nhr.prefix, buf, sizeof(buf)); prefix2str(&nhr.prefix, buf, sizeof(buf));
@ -365,7 +365,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
return; return;
} }
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) { if (!bnc) {
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
@ -375,11 +375,11 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
"parse nexthop update(%s(%s)): bnc node info not found", "parse nexthop update(%s(%s)): bnc node info not found",
buf, bgp->name_pretty); buf, bgp->name_pretty);
} }
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
return; return;
} }
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
bnc->last_update = bgp_clock(); bnc->last_update = bgp_clock();
bnc->change_flags = 0; bnc->change_flags = 0;
@ -499,16 +499,16 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
void bgp_cleanup_nexthops(struct bgp *bgp) void bgp_cleanup_nexthops(struct bgp *bgp)
{ {
afi_t afi; afi_t afi;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {
if (!bgp->nexthop_cache_table[afi]) if (!bgp->nexthop_cache_table[afi])
continue; continue;
for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn; for (dest = bgp_table_top(bgp->nexthop_cache_table[afi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
continue; continue;
@ -531,8 +531,8 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
&& (pi->sub_type == BGP_ROUTE_STATIC)) && (pi->sub_type == BGP_ROUTE_STATIC))
? 1 ? 1
: 0; : 0;
struct bgp_node *net = pi->net; struct bgp_dest *net = pi->net;
const struct prefix *p_orig = bgp_node_get_prefix(net); const struct prefix *p_orig = bgp_dest_get_prefix(net);
if (p_orig->family == AF_FLOWSPEC) { if (p_orig->family == AF_FLOWSPEC) {
if (!pi->peer) if (!pi->peer)
@ -618,7 +618,7 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
"%s: We have not connected yet, cannot send nexthops", "%s: We have not connected yet, cannot send nexthops",
__func__); __func__);
} }
p = bgp_node_get_prefix(bnc->node); p = bgp_dest_get_prefix(bnc->dest);
if ((command == ZEBRA_NEXTHOP_REGISTER if ((command == ZEBRA_NEXTHOP_REGISTER
|| command == ZEBRA_IMPORT_ROUTE_REGISTER) || command == ZEBRA_IMPORT_ROUTE_REGISTER)
&& (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) && (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)
@ -699,7 +699,7 @@ static void unregister_zebra_rnh(struct bgp_nexthop_cache *bnc,
*/ */
static void evaluate_paths(struct bgp_nexthop_cache *bnc) static void evaluate_paths(struct bgp_nexthop_cache *bnc)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *path; struct bgp_path_info *path;
int afi; int afi;
struct peer *peer = (struct peer *)bnc->nht_info; struct peer *peer = (struct peer *)bnc->nht_info;
@ -724,11 +724,11 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
|| (path->sub_type == BGP_ROUTE_IMPORTED)))) || (path->sub_type == BGP_ROUTE_IMPORTED))))
continue; continue;
rn = path->net; dest = path->net;
assert(rn && bgp_node_table(rn)); assert(dest && bgp_dest_table(dest));
p = bgp_node_get_prefix(rn); p = bgp_dest_get_prefix(dest);
afi = family2afi(p->family); afi = family2afi(p->family);
table = bgp_node_table(rn); table = bgp_dest_table(dest);
safi = table->safi; safi = table->safi;
/* /*
@ -760,11 +760,11 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
} else { } else {
if (bgp_update_martian_nexthop( if (bgp_update_martian_nexthop(
bnc->bgp, afi, safi, path->type, bnc->bgp, afi, safi, path->type,
path->sub_type, path->attr, rn)) { path->sub_type, path->attr, dest)) {
if (BGP_DEBUG(nht, NHT)) if (BGP_DEBUG(nht, NHT))
zlog_debug( zlog_debug(
"%s: prefix %pRN (vrf %s), ignoring path due to martian or self-next-hop", "%s: prefix %pRN (vrf %s), ignoring path due to martian or self-next-hop",
__func__, rn, bgp_path->name); __func__, dest, bgp_path->name);
} else } else
bnc_is_valid_nexthop = bnc_is_valid_nexthop =
bgp_isvalid_nexthop(bnc) ? true : false; bgp_isvalid_nexthop(bnc) ? true : false;
@ -773,17 +773,17 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT)) {
char buf1[RD_ADDRSTRLEN]; char buf1[RD_ADDRSTRLEN];
if (rn->prn) { if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)&rn->prn->p, prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1)); buf1, sizeof(buf1));
zlog_debug( zlog_debug(
"... eval path %d/%d %pRN RD %s %s flags 0x%x", "... eval path %d/%d %pRN RD %s %s flags 0x%x",
afi, safi, rn, buf1, afi, safi, dest, buf1,
bgp_path->name_pretty, path->flags); bgp_path->name_pretty, path->flags);
} else } else
zlog_debug( zlog_debug(
"... eval path %d/%d %pRN %s flags 0x%x", "... eval path %d/%d %pRN %s flags 0x%x",
afi, safi, rn, bgp_path->name_pretty, afi, safi, dest, bgp_path->name_pretty,
path->flags); path->flags);
} }
@ -812,28 +812,28 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
*/ */
bgp_aggregate_decrement(bgp_path, p, path, afi, bgp_aggregate_decrement(bgp_path, p, path, afi,
safi); safi);
bgp_path_info_unset_flag(rn, path, bgp_path_info_unset_flag(dest, path,
BGP_PATH_VALID); BGP_PATH_VALID);
if (safi == SAFI_EVPN && if (safi == SAFI_EVPN &&
bgp_evpn_is_prefix_nht_supported(&rn->p)) bgp_evpn_is_prefix_nht_supported(bgp_dest_get_prefix(dest)))
bgp_evpn_unimport_route(bgp_path, bgp_evpn_unimport_route(bgp_path,
afi, safi, &rn->p, path); afi, safi, bgp_dest_get_prefix(dest), path);
} else { } else {
/* Path becomes valid, set flag; also for EVPN /* Path becomes valid, set flag; also for EVPN
* routes, import from VRFs if needed. * routes, import from VRFs if needed.
*/ */
bgp_path_info_set_flag(rn, path, bgp_path_info_set_flag(dest, path,
BGP_PATH_VALID); BGP_PATH_VALID);
bgp_aggregate_increment(bgp_path, p, path, afi, bgp_aggregate_increment(bgp_path, p, path, afi,
safi); safi);
if (safi == SAFI_EVPN && if (safi == SAFI_EVPN &&
bgp_evpn_is_prefix_nht_supported(&rn->p)) bgp_evpn_is_prefix_nht_supported(bgp_dest_get_prefix(dest)))
bgp_evpn_import_route(bgp_path, bgp_evpn_import_route(bgp_path,
afi, safi, &rn->p, path); afi, safi, bgp_dest_get_prefix(dest), path);
} }
} }
bgp_process(bgp_path, rn, afi, safi); bgp_process(bgp_path, dest, afi, safi);
} }
if (peer) { if (peer) {
@ -888,7 +888,7 @@ void path_nh_map(struct bgp_path_info *path, struct bgp_nexthop_cache *bnc,
*/ */
void bgp_nht_register_nexthops(struct bgp *bgp) void bgp_nht_register_nexthops(struct bgp *bgp)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
afi_t afi; afi_t afi;
@ -896,9 +896,9 @@ void bgp_nht_register_nexthops(struct bgp *bgp)
if (!bgp->nexthop_cache_table[afi]) if (!bgp->nexthop_cache_table[afi])
continue; continue;
for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn; for (dest = bgp_table_top(bgp->nexthop_cache_table[afi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
continue; continue;
@ -911,7 +911,7 @@ void bgp_nht_register_nexthops(struct bgp *bgp)
void bgp_nht_reg_enhe_cap_intfs(struct peer *peer) void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
{ {
struct bgp *bgp; struct bgp *bgp;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
struct nexthop *nhop; struct nexthop *nhop;
struct interface *ifp; struct interface *ifp;
@ -933,11 +933,11 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
if (p.family != AF_INET6) if (p.family != AF_INET6)
return; return;
rn = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p); dest = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!rn) if (!dest)
return; return;
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
return; return;
@ -960,7 +960,7 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
void bgp_nht_dereg_enhe_cap_intfs(struct peer *peer) void bgp_nht_dereg_enhe_cap_intfs(struct peer *peer)
{ {
struct bgp *bgp; struct bgp *bgp;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc; struct bgp_nexthop_cache *bnc;
struct nexthop *nhop; struct nexthop *nhop;
struct interface *ifp; struct interface *ifp;
@ -983,11 +983,11 @@ void bgp_nht_dereg_enhe_cap_intfs(struct peer *peer)
if (p.family != AF_INET6) if (p.family != AF_INET6)
return; return;
rn = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p); dest = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!rn) if (!dest)
return; return;
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) if (!bnc)
return; return;

View File

@ -289,7 +289,6 @@ extern bool bgp_pbr_match_hash_equal(const void *arg1,
void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api); void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api);
struct bgp_node;
struct bgp_path_info; struct bgp_path_info;
extern void bgp_pbr_update_entry(struct bgp *bgp, const struct prefix *p, extern void bgp_pbr_update_entry(struct bgp *bgp, const struct prefix *p,
struct bgp_path_info *new_select, afi_t afi, struct bgp_path_info *new_select, afi_t afi,

File diff suppressed because it is too large Load Diff

View File

@ -196,7 +196,7 @@ struct bgp_path_info {
LIST_ENTRY(bgp_path_info) nh_thread; LIST_ENTRY(bgp_path_info) nh_thread;
/* Back pointer to the prefix node */ /* Back pointer to the prefix node */
struct bgp_node *net; struct bgp_dest *net;
/* Back pointer to the nexthop structure */ /* Back pointer to the nexthop structure */
struct bgp_nexthop_cache *nexthop; struct bgp_nexthop_cache *nexthop;
@ -436,9 +436,9 @@ enum bgp_path_type {
BGP_PATH_SHOW_MULTIPATH BGP_PATH_SHOW_MULTIPATH
}; };
static inline void bgp_bump_version(struct bgp_node *node) static inline void bgp_bump_version(struct bgp_dest *dest)
{ {
node->version = bgp_table_next_version(bgp_node_table(node)); dest->version = bgp_table_next_version(bgp_dest_table(dest));
} }
static inline int bgp_fibupd_safi(safi_t safi) static inline int bgp_fibupd_safi(safi_t safi)
@ -455,12 +455,12 @@ static inline bool is_pi_family_matching(struct bgp_path_info *pi,
afi_t afi, safi_t safi) afi_t afi, safi_t safi)
{ {
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
rn = pi->net; dest = pi->net;
if (!rn) if (!dest)
return false; return false;
table = bgp_node_table(rn); table = bgp_dest_table(dest);
if (table && if (table &&
table->afi == afi && table->afi == afi &&
table->safi == safi) table->safi == safi)
@ -470,14 +470,14 @@ static inline bool is_pi_family_matching(struct bgp_path_info *pi,
static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi, static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi,
struct bgp_path_info_extra *dst_pie, struct bgp_path_info_extra *dst_pie,
struct bgp_node *rn, struct bgp_dest *dest,
struct bgp_path_info *src_pi, struct bgp_path_info *src_pi,
struct peer *peer, struct attr *attr) struct peer *peer, struct attr *attr)
{ {
memset(dst_pi, 0, sizeof(struct bgp_path_info)); memset(dst_pi, 0, sizeof(struct bgp_path_info));
dst_pi->peer = peer; dst_pi->peer = peer;
dst_pi->attr = attr; dst_pi->attr = attr;
dst_pi->net = rn; dst_pi->net = dest;
dst_pi->flags = src_pi->flags; dst_pi->flags = src_pi->flags;
dst_pi->type = src_pi->type; dst_pi->type = src_pi->type;
dst_pi->sub_type = src_pi->sub_type; dst_pi->sub_type = src_pi->sub_type;
@ -491,12 +491,12 @@ static inline void prep_for_rmap_apply(struct bgp_path_info *dst_pi,
/* called before bgp_process() */ /* called before bgp_process() */
DECLARE_HOOK(bgp_process, DECLARE_HOOK(bgp_process,
(struct bgp *bgp, afi_t afi, safi_t safi, (struct bgp * bgp, afi_t afi, safi_t safi, struct bgp_dest *bn,
struct bgp_node *bn, struct peer *peer, bool withdraw), struct peer *peer, bool withdraw),
(bgp, afi, safi, bn, peer, withdraw)) (bgp, afi, safi, bn, peer, withdraw))
/* Prototypes. */ /* Prototypes. */
extern void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *pi, extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *peer, afi_t afi, safi_t safi); struct peer *peer, afi_t afi, safi_t safi);
extern void bgp_process_queue_init(void); extern void bgp_process_queue_init(void);
extern void bgp_route_init(void); extern void bgp_route_init(void);
@ -514,20 +514,21 @@ extern void bgp_clear_stale_route(struct peer *, afi_t, safi_t);
extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *); extern bool bgp_outbound_policy_exists(struct peer *, struct bgp_filter *);
extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *); extern bool bgp_inbound_policy_exists(struct peer *, struct bgp_filter *);
extern struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, extern struct bgp_dest *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
safi_t safi, const struct prefix *p, safi_t safi, const struct prefix *p,
struct prefix_rd *prd); struct prefix_rd *prd);
extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path); extern struct bgp_path_info *bgp_path_info_lock(struct bgp_path_info *path);
extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path); extern struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path);
extern void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *pi); extern void bgp_path_info_add(struct bgp_dest *dest, struct bgp_path_info *pi);
extern void bgp_path_info_extra_free(struct bgp_path_info_extra **extra); extern void bgp_path_info_extra_free(struct bgp_path_info_extra **extra);
extern void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *pi); extern void bgp_path_info_reap(struct bgp_dest *dest, struct bgp_path_info *pi);
extern void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi); extern void bgp_path_info_delete(struct bgp_dest *dest,
struct bgp_path_info *pi);
extern struct bgp_path_info_extra * extern struct bgp_path_info_extra *
bgp_path_info_extra_get(struct bgp_path_info *path); bgp_path_info_extra_get(struct bgp_path_info *path);
extern void bgp_path_info_set_flag(struct bgp_node *rn, extern void bgp_path_info_set_flag(struct bgp_dest *dest,
struct bgp_path_info *path, uint32_t flag); struct bgp_path_info *path, uint32_t flag);
extern void bgp_path_info_unset_flag(struct bgp_node *rn, extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
struct bgp_path_info *path, uint32_t flag); struct bgp_path_info *path, uint32_t flag);
extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi, extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
char *buf); char *buf);
@ -577,7 +578,7 @@ extern int bgp_withdraw(struct peer *peer, const struct prefix *p,
uint32_t num_labels, struct bgp_route_evpn *evpn); uint32_t num_labels, struct bgp_route_evpn *evpn);
/* for bgp_nexthop and bgp_damp */ /* for bgp_nexthop and bgp_damp */
extern void bgp_process(struct bgp *, struct bgp_node *, afi_t, safi_t); extern void bgp_process(struct bgp *, struct bgp_dest *, afi_t, safi_t);
/* /*
* Add an end-of-initial-update marker to the process queue. This is just a * Add an end-of-initial-update marker to the process queue. This is just a
@ -613,7 +614,7 @@ extern safi_t bgp_node_safi(struct vty *);
extern struct bgp_path_info *info_make(int type, int sub_type, extern struct bgp_path_info *info_make(int type, int sub_type,
unsigned short instance, unsigned short instance,
struct peer *peer, struct attr *attr, struct peer *peer, struct attr *attr,
struct bgp_node *rn); struct bgp_dest *dest);
extern void route_vty_out(struct vty *vty, const struct prefix *p, extern void route_vty_out(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, safi_t safi, struct bgp_path_info *path, int display, safi_t safi,
@ -630,10 +631,10 @@ extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p,
extern void subgroup_process_announce_selected(struct update_subgroup *subgrp, extern void subgroup_process_announce_selected(struct update_subgroup *subgrp,
struct bgp_path_info *selected, struct bgp_path_info *selected,
struct bgp_node *rn, struct bgp_dest *dest,
uint32_t addpath_tx_id); uint32_t addpath_tx_id);
extern bool subgroup_announce_check(struct bgp_node *rn, extern bool subgroup_announce_check(struct bgp_dest *dest,
struct bgp_path_info *pi, struct bgp_path_info *pi,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
const struct prefix *p, struct attr *attr); const struct prefix *p, struct attr *attr);
@ -642,10 +643,10 @@ extern void bgp_peer_clear_node_queue_drain_immediate(struct peer *peer);
extern void bgp_process_queues_drain_immediate(void); extern void bgp_process_queues_drain_immediate(void);
/* for encap/vpn */ /* for encap/vpn */
extern struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi, extern struct bgp_dest *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
safi_t safi, const struct prefix *p, safi_t safi, const struct prefix *p,
struct prefix_rd *prd); struct prefix_rd *prd);
extern void bgp_path_info_restore(struct bgp_node *rn, extern void bgp_path_info_restore(struct bgp_dest *dest,
struct bgp_path_info *path); struct bgp_path_info *path);
extern int bgp_path_info_cmp_compatible(struct bgp *bgp, extern int bgp_path_info_cmp_compatible(struct bgp *bgp,
@ -655,23 +656,21 @@ extern int bgp_path_info_cmp_compatible(struct bgp *bgp,
enum bgp_path_selection_reason *reason); enum bgp_path_selection_reason *reason);
extern void bgp_attr_add_gshut_community(struct attr *attr); extern void bgp_attr_add_gshut_community(struct attr *attr);
extern void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn, extern void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
struct bgp_maxpaths_cfg *mpath_cfg, struct bgp_maxpaths_cfg *mpath_cfg,
struct bgp_path_info_pair *result, afi_t afi, struct bgp_path_info_pair *result, afi_t afi,
safi_t safi); safi_t safi);
extern void bgp_zebra_clear_route_change_flags(struct bgp_node *rn); extern void bgp_zebra_clear_route_change_flags(struct bgp_dest *dest);
extern bool bgp_zebra_has_route_changed(struct bgp_node *rn, extern bool bgp_zebra_has_route_changed(struct bgp_path_info *selected);
struct bgp_path_info *selected);
extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct bgp_node *rn, struct bgp_dest *dest,
struct prefix_rd *prd, afi_t afi, struct prefix_rd *prd, afi_t afi,
safi_t safi, json_object *json); safi_t safi, json_object *json);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct bgp_node *bn, struct bgp_dest *bn,
struct bgp_path_info *path, struct bgp_path_info *path, afi_t afi,
afi_t afi, safi_t safi, safi_t safi, json_object *json_paths);
json_object *json_paths);
extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd, struct bgp_table *table, struct prefix_rd *prd,
enum bgp_show_type type, void *output_arg, enum bgp_show_type type, void *output_arg,
@ -679,5 +678,5 @@ extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
extern int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi); extern int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi);
extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
uint8_t type, uint8_t stype, uint8_t type, uint8_t stype,
struct attr *attr, struct bgp_node *rn); struct attr *attr, struct bgp_dest *dest);
#endif /* _QUAGGA_BGP_ROUTE_H */ #endif /* _QUAGGA_BGP_ROUTE_H */

View File

@ -1027,11 +1027,11 @@ route_match_rd(void *rule, const struct prefix *prefix,
prd_rule = (struct prefix_rd *)rule; prd_rule = (struct prefix_rd *)rule;
path = (struct bgp_path_info *)object; path = (struct bgp_path_info *)object;
if (path->net == NULL || path->net->prn == NULL) if (path->net == NULL || path->net->pdest == NULL)
return RMAP_NOMATCH; return RMAP_NOMATCH;
prd_route = prd_route = (struct prefix_rd *)bgp_dest_get_prefix(
(struct prefix_rd *)bgp_node_get_prefix(path->net->prn); path->net->pdest);
if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0) if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
return RMAP_MATCH; return RMAP_MATCH;
} }
@ -3705,7 +3705,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
struct peer *peer; struct peer *peer;
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_static *bgp_static; struct bgp_static *bgp_static;
struct bgp_aggregate *aggregate; struct bgp_aggregate *aggregate;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -3766,7 +3766,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
/* For network route-map updates. */ /* For network route-map updates. */
for (bn = bgp_table_top(bgp->route[afi][safi]); bn; for (bn = bgp_table_top(bgp->route[afi][safi]); bn;
bn = bgp_route_next(bn)) { bn = bgp_route_next(bn)) {
bgp_static = bgp_node_get_bgp_static_info(bn); bgp_static = bgp_dest_get_bgp_static_info(bn);
if (!bgp_static) if (!bgp_static)
continue; continue;
@ -3781,7 +3781,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
if (route_update && !bgp_static->backdoor) { if (route_update && !bgp_static->backdoor) {
const struct prefix *bn_p = const struct prefix *bn_p =
bgp_node_get_prefix(bn); bgp_dest_get_prefix(bn);
if (bgp_debug_zebra(bn_p)) if (bgp_debug_zebra(bn_p))
zlog_debug( zlog_debug(
@ -3798,7 +3798,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
/* For aggregate-address route-map updates. */ /* For aggregate-address route-map updates. */
for (bn = bgp_table_top(bgp->aggregate[afi][safi]); bn; for (bn = bgp_table_top(bgp->aggregate[afi][safi]); bn;
bn = bgp_route_next(bn)) { bn = bgp_route_next(bn)) {
aggregate = bgp_node_get_bgp_aggregate_info(bn); aggregate = bgp_dest_get_bgp_aggregate_info(bn);
if (!aggregate) if (!aggregate)
continue; continue;
@ -3813,7 +3813,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
if (route_update) { if (route_update) {
const struct prefix *bn_p = const struct prefix *bn_p =
bgp_node_get_prefix(bn); bgp_dest_get_prefix(bn);
if (bgp_debug_zebra(bn_p)) if (bgp_debug_zebra(bn_p))
zlog_debug( zlog_debug(

View File

@ -127,8 +127,7 @@ static enum route_map_cmd_result_t route_match(void *rule,
route_map_object_t type, route_map_object_t type,
void *object); void *object);
static void *route_match_compile(const char *arg); static void *route_match_compile(const char *arg);
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi, static void revalidate_bgp_node(struct bgp_dest *dest, afi_t afi, safi_t safi);
safi_t safi);
static void revalidate_all_routes(void); static void revalidate_all_routes(void);
static struct rtr_mgr_config *rtr_config; static struct rtr_mgr_config *rtr_config;
@ -402,15 +401,15 @@ static int bgpd_sync_callback(struct thread *thread)
if (!peer->bgp->rib[afi][safi]) if (!peer->bgp->rib[afi][safi])
continue; continue;
struct bgp_node *match; struct bgp_dest *match;
struct bgp_node *node; struct bgp_dest *node;
match = bgp_table_subtree_lookup( match = bgp_table_subtree_lookup(
peer->bgp->rib[afi][safi], prefix); peer->bgp->rib[afi][safi], prefix);
node = match; node = match;
while (node) { while (node) {
if (bgp_node_has_bgp_path_info_data( if (bgp_dest_has_bgp_path_info_data(
node)) { node)) {
revalidate_bgp_node(node, afi, revalidate_bgp_node(node, afi,
safi); safi);
@ -427,15 +426,15 @@ static int bgpd_sync_callback(struct thread *thread)
return 0; return 0;
} }
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi, static void revalidate_bgp_node(struct bgp_dest *bgp_dest, afi_t afi,
safi_t safi) safi_t safi)
{ {
struct bgp_adj_in *ain; struct bgp_adj_in *ain;
for (ain = bgp_node->adj_in; ain; ain = ain->next) { for (ain = bgp_dest->adj_in; ain; ain = ain->next) {
int ret; int ret;
struct bgp_path_info *path = struct bgp_path_info *path =
bgp_node_get_bgp_path_info(bgp_node); bgp_dest_get_bgp_path_info(bgp_dest);
mpls_label_t *label = NULL; mpls_label_t *label = NULL;
uint32_t num_labels = 0; uint32_t num_labels = 0;
@ -443,7 +442,7 @@ static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
label = path->extra->label; label = path->extra->label;
num_labels = path->extra->num_labels; num_labels = path->extra->num_labels;
} }
ret = bgp_update(ain->peer, bgp_node_get_prefix(bgp_node), ret = bgp_update(ain->peer, bgp_dest_get_prefix(bgp_dest),
ain->addpath_rx_id, ain->attr, afi, safi, ain->addpath_rx_id, ain->attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
num_labels, 1, NULL); num_labels, 1, NULL);

View File

@ -660,7 +660,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
int offsetlen; int offsetlen;
struct bgp_path_info *path; struct bgp_path_info *path;
struct bgp_path_info *min; struct bgp_path_info *min;
struct bgp_node *rn; struct bgp_dest *dest;
union sockunion su; union sockunion su;
unsigned int len; unsigned int len;
struct in_addr paddr; struct in_addr paddr;
@ -687,12 +687,12 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
oid2in_addr(offset, IN_ADDR_SIZE, &su.sin.sin_addr); oid2in_addr(offset, IN_ADDR_SIZE, &su.sin.sin_addr);
/* Lookup node. */ /* Lookup node. */
rn = bgp_node_lookup(bgp->rib[AFI_IP][SAFI_UNICAST], dest = bgp_node_lookup(bgp->rib[AFI_IP][SAFI_UNICAST],
(struct prefix *)addr); (struct prefix *)addr);
if (rn) { if (dest) {
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
for (path = bgp_node_get_bgp_path_info(rn); path; for (path = bgp_dest_get_bgp_path_info(dest); path;
path = path->next) path = path->next)
if (sockunion_same(&path->peer->su, &su)) if (sockunion_same(&path->peer->su, &su))
return path; return path;
@ -703,7 +703,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
len = offsetlen; len = offsetlen;
if (offsetlen == 0) if (offsetlen == 0)
rn = bgp_table_top(bgp->rib[AFI_IP][SAFI_UNICAST]); dest = bgp_table_top(bgp->rib[AFI_IP][SAFI_UNICAST]);
else { else {
if (len > IN_ADDR_SIZE) if (len > IN_ADDR_SIZE)
len = IN_ADDR_SIZE; len = IN_ADDR_SIZE;
@ -718,8 +718,8 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
else else
addr->prefixlen = len * 8; addr->prefixlen = len * 8;
rn = bgp_node_get(bgp->rib[AFI_IP][SAFI_UNICAST], dest = bgp_node_get(bgp->rib[AFI_IP][SAFI_UNICAST],
(struct prefix *)addr); (struct prefix *)addr);
offset++; offset++;
offsetlen--; offsetlen--;
@ -734,13 +734,13 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
} else } else
paddr.s_addr = INADDR_ANY; paddr.s_addr = INADDR_ANY;
if (!rn) if (!dest)
return NULL; return NULL;
do { do {
min = NULL; min = NULL;
for (path = bgp_node_get_bgp_path_info(rn); path; for (path = bgp_dest_get_bgp_path_info(dest); path;
path = path->next) { path = path->next) {
if (path->peer->su.sin.sin_family == AF_INET if (path->peer->su.sin.sin_family == AF_INET
&& ntohl(paddr.s_addr) && ntohl(paddr.s_addr)
@ -762,7 +762,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
if (min) { if (min) {
const struct prefix *rn_p = const struct prefix *rn_p =
bgp_node_get_prefix(rn); bgp_dest_get_prefix(dest);
*length = *length =
v->namelen + BGP_PATHATTR_ENTRY_OFFSET; v->namelen + BGP_PATHATTR_ENTRY_OFFSET;
@ -779,13 +779,13 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
addr->prefix = rn_p->u.prefix4; addr->prefix = rn_p->u.prefix4;
addr->prefixlen = rn_p->prefixlen; addr->prefixlen = rn_p->prefixlen;
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
return min; return min;
} }
paddr.s_addr = INADDR_ANY; paddr.s_addr = INADDR_ANY;
} while ((rn = bgp_route_next(rn)) != NULL); } while ((dest = bgp_route_next(dest)) != NULL);
} }
return NULL; return NULL;
} }

View File

@ -69,7 +69,7 @@ static struct route_node *bgp_node_create(route_table_delegate_t *delegate,
node = XCALLOC(MTYPE_BGP_NODE, sizeof(struct bgp_node)); node = XCALLOC(MTYPE_BGP_NODE, sizeof(struct bgp_node));
RB_INIT(bgp_adj_out_rb, &node->adj_out); RB_INIT(bgp_adj_out_rb, &node->adj_out);
return bgp_node_to_rnode(node); return bgp_dest_to_rnode(node);
} }
/* /*
@ -80,7 +80,7 @@ static void bgp_node_destroy(route_table_delegate_t *delegate,
{ {
struct bgp_node *bgp_node; struct bgp_node *bgp_node;
struct bgp_table *rt; struct bgp_table *rt;
bgp_node = bgp_node_from_rnode(node); bgp_node = bgp_dest_from_rnode(node);
rt = table->info; rt = table->info;
if (rt->bgp) { if (rt->bgp) {
@ -140,7 +140,7 @@ void bgp_delete_listnode(struct bgp_node *node)
* route node in gr_info * route node in gr_info
*/ */
if (CHECK_FLAG(node->flags, BGP_NODE_SELECT_DEFER)) { if (CHECK_FLAG(node->flags, BGP_NODE_SELECT_DEFER)) {
table = bgp_node_table(node); table = bgp_dest_table(node);
if (table) { if (table) {
bgp = table->bgp; bgp = table->bgp;
@ -149,7 +149,7 @@ void bgp_delete_listnode(struct bgp_node *node)
} else } else
return; return;
rn = bgp_node_to_rnode(node); rn = bgp_dest_to_rnode(node);
if (bgp && rn && rn->lock == 1) { if (bgp && rn && rn->lock == 1) {
/* Delete the route from the selection pending list */ /* Delete the route from the selection pending list */
@ -167,7 +167,7 @@ void bgp_delete_listnode(struct bgp_node *node)
struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table, struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
const struct prefix *p) const struct prefix *p)
{ {
struct bgp_node *node = bgp_node_from_rnode(table->route_table->top); struct bgp_node *node = bgp_dest_from_rnode(table->route_table->top);
struct bgp_node *matched = NULL; struct bgp_node *matched = NULL;
if (node == NULL) if (node == NULL)
@ -175,7 +175,7 @@ struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
while (node) { while (node) {
const struct prefix *node_p = bgp_node_get_prefix(node); const struct prefix *node_p = bgp_dest_get_prefix(node);
if (node_p->prefixlen >= p->prefixlen) { if (node_p->prefixlen >= p->prefixlen) {
if (!prefix_match(p, node_p)) if (!prefix_match(p, node_p))
@ -193,13 +193,13 @@ struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
break; break;
} }
node = bgp_node_from_rnode(node->link[prefix_bit( node = bgp_dest_from_rnode(node->link[prefix_bit(
&p->u.prefix, node_p->prefixlen)]); &p->u.prefix, node_p->prefixlen)]);
} }
if (!matched) if (!matched)
return NULL; return NULL;
bgp_lock_node(matched); bgp_dest_lock_node(matched);
return matched; return matched;
} }

View File

@ -21,6 +21,10 @@
#ifndef _QUAGGA_BGP_TABLE_H #ifndef _QUAGGA_BGP_TABLE_H
#define _QUAGGA_BGP_TABLE_H #define _QUAGGA_BGP_TABLE_H
/* XXX BEGIN TEMPORARY COMPAT */
#define bgp_dest bgp_node
/* XXX END TEMPORARY COMPAT */
#include "mpls.h" #include "mpls.h"
#include "table.h" #include "table.h"
#include "queue.h" #include "queue.h"
@ -28,8 +32,6 @@
#include "bgpd.h" #include "bgpd.h"
#include "bgp_advertise.h" #include "bgp_advertise.h"
extern void bgp_delete_listnode(struct bgp_node *node);
struct bgp_table { struct bgp_table {
/* table belongs to this instance */ /* table belongs to this instance */
struct bgp *bgp; struct bgp *bgp;
@ -84,9 +86,9 @@ struct bgp_node {
struct bgp_adj_in *adj_in; struct bgp_adj_in *adj_in;
struct bgp_node *prn; struct bgp_dest *pdest;
STAILQ_ENTRY(bgp_node) pq; STAILQ_ENTRY(bgp_dest) pq;
uint64_t version; uint64_t version;
@ -105,6 +107,7 @@ struct bgp_node {
enum bgp_path_selection_reason reason; enum bgp_path_selection_reason reason;
}; };
extern void bgp_delete_listnode(struct bgp_dest *dest);
/* /*
* bgp_table_iter_t * bgp_table_iter_t
* *
@ -122,150 +125,161 @@ extern void bgp_table_finish(struct bgp_table **);
/* /*
* bgp_node_from_rnode * bgp_dest_from_rnode
* *
* Returns the bgp_node structure corresponding to a route_node. * Returns the bgp_dest structure corresponding to a route_node.
*/ */
static inline struct bgp_node *bgp_node_from_rnode(struct route_node *rnode) static inline struct bgp_dest *bgp_dest_from_rnode(struct route_node *rnode)
{ {
return (struct bgp_node *)rnode; return (struct bgp_dest *)rnode;
} }
/* /*
* bgp_node_to_rnode * bgp_dest_to_rnode
* *
* Returns the route_node structure corresponding to a bgp_node. * Returns the route_node structure corresponding to a bgp_dest.
*/ */
static inline struct route_node *bgp_node_to_rnode(struct bgp_node *node) static inline struct route_node *bgp_dest_to_rnode(const struct bgp_dest *dest)
{ {
return (struct route_node *)node; return (struct route_node *)dest;
} }
/* /*
* bgp_node_table * bgp_dest_table
* *
* Returns the bgp_table that the given node is in. * Returns the bgp_table that the given dest is in.
*/ */
static inline struct bgp_table *bgp_node_table(struct bgp_node *node) static inline struct bgp_table *bgp_dest_table(struct bgp_dest *dest)
{ {
return route_table_get_info(bgp_node_to_rnode(node)->table); return route_table_get_info(bgp_dest_to_rnode(dest)->table);
} }
/* /*
* bgp_node_parent_nolock * bgp_dest_parent_nolock
* *
* Gets the parent node of the given node without locking it. * Gets the parent dest of the given node without locking it.
*/ */
static inline struct bgp_node *bgp_node_parent_nolock(struct bgp_node *node) static inline struct bgp_dest *bgp_dest_parent_nolock(struct bgp_dest *dest)
{ {
return bgp_node_from_rnode(node->parent); struct route_node *rn = bgp_dest_to_rnode(dest)->parent;
return bgp_dest_from_rnode(rn);
} }
/* /*
* bgp_unlock_node * bgp_dest_unlock_node
*/ */
static inline void bgp_unlock_node(struct bgp_node *node) static inline void bgp_dest_unlock_node(struct bgp_dest *dest)
{ {
bgp_delete_listnode(node); bgp_delete_listnode(dest);
route_unlock_node(bgp_node_to_rnode(node)); route_unlock_node(bgp_dest_to_rnode(dest));
} }
/* /*
* bgp_table_top_nolock * bgp_table_top_nolock
* *
* Gets the top node in the table without locking it. * Gets the top dest in the table without locking it.
* *
* @see bgp_table_top * @see bgp_table_top
*/ */
static inline struct bgp_node * static inline struct bgp_dest *
bgp_table_top_nolock(const struct bgp_table *const table) bgp_table_top_nolock(const struct bgp_table *const table)
{ {
return bgp_node_from_rnode(table->route_table->top); return bgp_dest_from_rnode(table->route_table->top);
} }
/* /*
* bgp_table_top * bgp_table_top
*/ */
static inline struct bgp_node * static inline struct bgp_dest *
bgp_table_top(const struct bgp_table *const table) bgp_table_top(const struct bgp_table *const table)
{ {
return bgp_node_from_rnode(route_top(table->route_table)); return bgp_dest_from_rnode(route_top(table->route_table));
} }
/* /*
* bgp_route_next * bgp_route_next
*/ */
static inline struct bgp_node *bgp_route_next(struct bgp_node *node) static inline struct bgp_dest *bgp_route_next(struct bgp_dest *dest)
{ {
return bgp_node_from_rnode(route_next(bgp_node_to_rnode(node))); return bgp_dest_from_rnode(route_next(bgp_dest_to_rnode(dest)));
} }
/* /*
* bgp_route_next_until * bgp_route_next_until
*/ */
static inline struct bgp_node *bgp_route_next_until(struct bgp_node *node, static inline struct bgp_dest *bgp_route_next_until(struct bgp_dest *dest,
struct bgp_node *limit) struct bgp_dest *limit)
{ {
struct route_node *rnode; struct route_node *rnode;
rnode = route_next_until(bgp_node_to_rnode(node), rnode = route_next_until(bgp_dest_to_rnode(dest),
bgp_node_to_rnode(limit)); bgp_dest_to_rnode(limit));
return bgp_node_from_rnode(rnode);
return bgp_dest_from_rnode(rnode);
} }
/* /*
* bgp_node_get * bgp_node_get
*/ */
static inline struct bgp_node *bgp_node_get(struct bgp_table *const table, static inline struct bgp_dest *bgp_node_get(struct bgp_table *const table,
const struct prefix *p) const struct prefix *p)
{ {
return bgp_node_from_rnode(route_node_get(table->route_table, p)); return bgp_dest_from_rnode(route_node_get(table->route_table, p));
} }
/* /*
* bgp_node_lookup * bgp_node_lookup
*/ */
static inline struct bgp_node * static inline struct bgp_dest *
bgp_node_lookup(const struct bgp_table *const table, const struct prefix *p) bgp_node_lookup(const struct bgp_table *const table, const struct prefix *p)
{ {
return bgp_node_from_rnode(route_node_lookup(table->route_table, p)); struct route_node *rn = route_node_lookup(table->route_table, p);
return bgp_dest_from_rnode(rn);
} }
/* /*
* bgp_lock_node * bgp_dest_lock_node
*/ */
static inline struct bgp_node *bgp_lock_node(struct bgp_node *node) static inline struct bgp_dest *bgp_dest_lock_node(struct bgp_dest *dest)
{ {
return bgp_node_from_rnode(route_lock_node(bgp_node_to_rnode(node))); struct route_node *rn = route_lock_node(bgp_dest_to_rnode(dest));
return bgp_dest_from_rnode(rn);
} }
/* /*
* bgp_node_match * bgp_node_match
*/ */
static inline struct bgp_node *bgp_node_match(const struct bgp_table *table, static inline struct bgp_dest *bgp_node_match(const struct bgp_table *table,
const struct prefix *p) const struct prefix *p)
{ {
return bgp_node_from_rnode(route_node_match(table->route_table, p)); struct route_node *rn = route_node_match(table->route_table, p);
return bgp_dest_from_rnode(rn);
} }
/* /*
* bgp_node_match_ipv4 * bgp_node_match_ipv4
*/ */
static inline struct bgp_node * static inline struct bgp_dest *
bgp_node_match_ipv4(const struct bgp_table *table, struct in_addr *addr) bgp_node_match_ipv4(const struct bgp_table *table, struct in_addr *addr)
{ {
return bgp_node_from_rnode( struct route_node *rn = route_node_match_ipv4(table->route_table, addr);
route_node_match_ipv4(table->route_table, addr));
return bgp_dest_from_rnode(rn);
} }
/* /*
* bgp_node_match_ipv6 * bgp_node_match_ipv6
*/ */
static inline struct bgp_node * static inline struct bgp_dest *
bgp_node_match_ipv6(const struct bgp_table *table, struct in6_addr *addr) bgp_node_match_ipv6(const struct bgp_table *table, struct in6_addr *addr)
{ {
return bgp_node_from_rnode( struct route_node *rn = route_node_match_ipv6(table->route_table, addr);
route_node_match_ipv6(table->route_table, addr));
return bgp_dest_from_rnode(rn);
} }
static inline unsigned long bgp_table_count(const struct bgp_table *const table) static inline unsigned long bgp_table_count(const struct bgp_table *const table)
@ -276,10 +290,10 @@ static inline unsigned long bgp_table_count(const struct bgp_table *const table)
/* /*
* bgp_table_get_next * bgp_table_get_next
*/ */
static inline struct bgp_node *bgp_table_get_next(const struct bgp_table *table, static inline struct bgp_dest *bgp_table_get_next(const struct bgp_table *table,
const struct prefix *p) const struct prefix *p)
{ {
return bgp_node_from_rnode(route_table_get_next(table->route_table, p)); return bgp_dest_from_rnode(route_table_get_next(table->route_table, p));
} }
/* /*
@ -296,9 +310,9 @@ static inline void bgp_table_iter_init(bgp_table_iter_t *iter,
/* /*
* bgp_table_iter_next * bgp_table_iter_next
*/ */
static inline struct bgp_node *bgp_table_iter_next(bgp_table_iter_t *iter) static inline struct bgp_dest *bgp_table_iter_next(bgp_table_iter_t *iter)
{ {
return bgp_node_from_rnode(route_table_iter_next(&iter->rt_iter)); return bgp_dest_from_rnode(route_table_iter_next(&iter->rt_iter));
} }
/* /*
@ -354,104 +368,103 @@ static inline uint64_t bgp_table_version(struct bgp_table *table)
* *
* If the subtree is not present in the table, NULL is returned. * If the subtree is not present in the table, NULL is returned.
*/ */
struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table, struct bgp_dest *bgp_table_subtree_lookup(const struct bgp_table *table,
const struct prefix *p); const struct prefix *p);
static inline struct bgp_aggregate * static inline struct bgp_aggregate *
bgp_node_get_bgp_aggregate_info(struct bgp_node *node) bgp_dest_get_bgp_aggregate_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void static inline void
bgp_node_set_bgp_aggregate_info(struct bgp_node *node, bgp_dest_set_bgp_aggregate_info(struct bgp_dest *dest,
struct bgp_aggregate *aggregate) struct bgp_aggregate *aggregate)
{ {
node->info = aggregate; dest->info = aggregate;
} }
static inline struct bgp_distance * static inline struct bgp_distance *
bgp_node_get_bgp_distance_info(struct bgp_node *node) bgp_dest_get_bgp_distance_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void bgp_node_set_bgp_distance_info(struct bgp_node *node, static inline void bgp_dest_set_bgp_distance_info(struct bgp_dest *dest,
struct bgp_distance *distance) struct bgp_distance *distance)
{ {
node->info = distance; dest->info = distance;
} }
static inline struct bgp_static * static inline struct bgp_static *
bgp_node_get_bgp_static_info(struct bgp_node *node) bgp_dest_get_bgp_static_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void bgp_node_set_bgp_static_info(struct bgp_node *node, static inline void bgp_dest_set_bgp_static_info(struct bgp_dest *dest,
struct bgp_static *bgp_static) struct bgp_static *bgp_static)
{ {
node->info = bgp_static; dest->info = bgp_static;
} }
static inline struct bgp_connected_ref * static inline struct bgp_connected_ref *
bgp_node_get_bgp_connected_ref_info(struct bgp_node *node) bgp_dest_get_bgp_connected_ref_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void static inline void
bgp_node_set_bgp_connected_ref_info(struct bgp_node *node, bgp_dest_set_bgp_connected_ref_info(struct bgp_dest *dest,
struct bgp_connected_ref *bc) struct bgp_connected_ref *bc)
{ {
node->info = bc; dest->info = bc;
} }
static inline struct bgp_nexthop_cache * static inline struct bgp_nexthop_cache *
bgp_node_get_bgp_nexthop_info(struct bgp_node *node) bgp_dest_get_bgp_nexthop_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void bgp_node_set_bgp_nexthop_info(struct bgp_node *node, static inline void bgp_dest_set_bgp_nexthop_info(struct bgp_dest *dest,
struct bgp_nexthop_cache *bnc) struct bgp_nexthop_cache *bnc)
{ {
node->info = bnc; dest->info = bnc;
} }
static inline struct bgp_path_info * static inline struct bgp_path_info *
bgp_node_get_bgp_path_info(struct bgp_node *node) bgp_dest_get_bgp_path_info(struct bgp_dest *dest)
{ {
return node->info; return dest ? dest->info : NULL;
} }
static inline void bgp_node_set_bgp_path_info(struct bgp_node *node, static inline void bgp_dest_set_bgp_path_info(struct bgp_dest *dest,
struct bgp_path_info *bi) struct bgp_path_info *bi)
{ {
node->info = bi; dest->info = bi;
} }
static inline struct bgp_table * static inline struct bgp_table *
bgp_node_get_bgp_table_info(struct bgp_node *node) bgp_dest_get_bgp_table_info(struct bgp_dest *dest)
{ {
return node->info; return dest->info;
} }
static inline void bgp_node_set_bgp_table_info(struct bgp_node *node, static inline void bgp_dest_set_bgp_table_info(struct bgp_dest *dest,
struct bgp_table *table) struct bgp_table *table)
{ {
node->info = table; dest->info = table;
} }
static inline bool bgp_node_has_bgp_path_info_data(struct bgp_node *node) static inline bool bgp_dest_has_bgp_path_info_data(struct bgp_dest *dest)
{ {
return !!node->info; return !!dest->info;
} }
static inline const struct prefix *bgp_node_get_prefix(struct bgp_node *node) static inline const struct prefix *bgp_dest_get_prefix(const struct bgp_dest *dest)
{ {
return &node->p; return &dest->p;
} }
#ifdef _FRR_ATTRIBUTE_PRINTFRR #ifdef _FRR_ATTRIBUTE_PRINTFRR

View File

@ -1177,8 +1177,8 @@ static void update_subgroup_copy_adj_out(struct update_subgroup *source,
/* /*
* Copy the adj out. * Copy the adj out.
*/ */
aout_copy = aout_copy = bgp_adj_out_alloc(dest, aout->dest,
bgp_adj_out_alloc(dest, aout->rn, aout->addpath_tx_id); aout->addpath_tx_id);
aout_copy->attr = aout_copy->attr =
aout->attr ? bgp_attr_intern(aout->attr) : NULL; aout->attr ? bgp_attr_intern(aout->attr) : NULL;
} }

View File

@ -292,7 +292,7 @@ typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx);
/* really a private structure */ /* really a private structure */
struct updwalk_context { struct updwalk_context {
struct vty *vty; struct vty *vty;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
uint64_t updgrp_id; uint64_t updgrp_id;
uint64_t subgrp_id; uint64_t subgrp_id;
@ -442,22 +442,23 @@ extern void subgroup_announce_all(struct update_subgroup *subgrp);
extern void subgroup_default_originate(struct update_subgroup *subgrp, extern void subgroup_default_originate(struct update_subgroup *subgrp,
int withdraw); int withdraw);
extern void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi, extern void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_node *rn, struct bgp_path_info *pi); struct bgp_dest *dest,
struct bgp_path_info *pi);
extern void subgroup_clear_table(struct update_subgroup *subgrp); extern void subgroup_clear_table(struct update_subgroup *subgrp);
extern void update_group_announce(struct bgp *bgp); extern void update_group_announce(struct bgp *bgp);
extern void update_group_announce_rrclients(struct bgp *bgp); extern void update_group_announce_rrclients(struct bgp *bgp);
extern void peer_af_announce_route(struct peer_af *paf, int combine); extern void peer_af_announce_route(struct peer_af *paf, int combine);
extern struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp, extern struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
struct bgp_node *rn, struct bgp_dest *dest,
uint32_t addpath_tx_id); uint32_t addpath_tx_id);
extern void bgp_adj_out_remove_subgroup(struct bgp_node *rn, extern void bgp_adj_out_remove_subgroup(struct bgp_dest *dest,
struct bgp_adj_out *adj, struct bgp_adj_out *adj,
struct update_subgroup *subgrp); struct update_subgroup *subgrp);
extern void bgp_adj_out_set_subgroup(struct bgp_node *rn, extern void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
struct attr *attr, struct attr *attr,
struct bgp_path_info *path); struct bgp_path_info *path);
extern void bgp_adj_out_unset_subgroup(struct bgp_node *rn, extern void bgp_adj_out_unset_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
char withdraw, uint32_t addpath_tx_id); char withdraw, uint32_t addpath_tx_id);
void subgroup_announce_table(struct update_subgroup *subgrp, void subgroup_announce_table(struct update_subgroup *subgrp,

View File

@ -74,13 +74,13 @@ static int bgp_adj_out_compare(const struct bgp_adj_out *o1,
} }
RB_GENERATE(bgp_adj_out_rb, bgp_adj_out, adj_entry, bgp_adj_out_compare); RB_GENERATE(bgp_adj_out_rb, bgp_adj_out, adj_entry, bgp_adj_out_compare);
static inline struct bgp_adj_out *adj_lookup(struct bgp_node *rn, static inline struct bgp_adj_out *adj_lookup(struct bgp_dest *dest,
struct update_subgroup *subgrp, struct update_subgroup *subgrp,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
struct bgp_adj_out lookup; struct bgp_adj_out lookup;
if (!rn || !subgrp) if (!dest || !subgrp)
return NULL; return NULL;
/* update-groups that do not support addpath will pass 0 for /* update-groups that do not support addpath will pass 0 for
@ -88,7 +88,7 @@ static inline struct bgp_adj_out *adj_lookup(struct bgp_node *rn,
lookup.subgroup = subgrp; lookup.subgroup = subgrp;
lookup.addpath_tx_id = addpath_tx_id; lookup.addpath_tx_id = addpath_tx_id;
return RB_FIND(bgp_adj_out_rb, &rn->adj_out, &lookup); return RB_FIND(bgp_adj_out_rb, &dest->adj_out, &lookup);
} }
static void adj_free(struct bgp_adj_out *adj) static void adj_free(struct bgp_adj_out *adj)
@ -110,11 +110,11 @@ static void subgrp_withdraw_stale_addpath(struct updwalk_context *ctx,
/* Look through all of the paths we have advertised for this rn and send /* Look through all of the paths we have advertised for this rn and send
* a withdraw for the ones that are no longer present */ * a withdraw for the ones that are no longer present */
RB_FOREACH_SAFE (adj, bgp_adj_out_rb, &ctx->rn->adj_out, adj_next) { RB_FOREACH_SAFE (adj, bgp_adj_out_rb, &ctx->dest->adj_out, adj_next) {
if (adj->subgroup == subgrp) { if (adj->subgroup == subgrp) {
for (pi = bgp_node_get_bgp_path_info(ctx->rn); for (pi = bgp_dest_get_bgp_path_info(ctx->dest); pi;
pi; pi = pi->next) { pi = pi->next) {
id = bgp_addpath_id_for_peer(peer, afi, safi, id = bgp_addpath_id_for_peer(peer, afi, safi,
&pi->tx_addpath); &pi->tx_addpath);
@ -125,7 +125,7 @@ static void subgrp_withdraw_stale_addpath(struct updwalk_context *ctx,
if (!pi) { if (!pi) {
subgroup_process_announce_selected( subgroup_process_announce_selected(
subgrp, NULL, ctx->rn, subgrp, NULL, ctx->dest,
adj->addpath_tx_id); adj->addpath_tx_id);
} }
} }
@ -150,8 +150,8 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
if (BGP_DEBUG(update, UPDATE_OUT)) if (BGP_DEBUG(update, UPDATE_OUT))
zlog_debug("%s: afi=%s, safi=%s, p=%pRN", __func__, zlog_debug("%s: afi=%s, safi=%s, p=%pRN", __func__,
afi2str(afi), safi2str(safi), ctx->rn); afi2str(afi), safi2str(safi),
bgp_dest_to_rnode(ctx->dest));
UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) { UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
@ -165,14 +165,14 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
if (addpath_capable) { if (addpath_capable) {
subgrp_withdraw_stale_addpath(ctx, subgrp); subgrp_withdraw_stale_addpath(ctx, subgrp);
for (pi = bgp_node_get_bgp_path_info(ctx->rn); for (pi = bgp_dest_get_bgp_path_info(ctx->dest);
pi; pi = pi->next) { pi; pi = pi->next) {
/* Skip the bestpath for now */ /* Skip the bestpath for now */
if (pi == ctx->pi) if (pi == ctx->pi)
continue; continue;
subgroup_process_announce_selected( subgroup_process_announce_selected(
subgrp, pi, ctx->rn, subgrp, pi, ctx->dest,
bgp_addpath_id_for_peer( bgp_addpath_id_for_peer(
peer, afi, safi, peer, afi, safi,
&pi->tx_addpath)); &pi->tx_addpath));
@ -184,7 +184,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
*/ */
if (ctx->pi) if (ctx->pi)
subgroup_process_announce_selected( subgroup_process_announce_selected(
subgrp, ctx->pi, ctx->rn, subgrp, ctx->pi, ctx->dest,
bgp_addpath_id_for_peer( bgp_addpath_id_for_peer(
peer, afi, safi, peer, afi, safi,
&ctx->pi->tx_addpath)); &ctx->pi->tx_addpath));
@ -194,7 +194,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
else { else {
if (ctx->pi) { if (ctx->pi) {
subgroup_process_announce_selected( subgroup_process_announce_selected(
subgrp, ctx->pi, ctx->rn, subgrp, ctx->pi, ctx->dest,
bgp_addpath_id_for_peer( bgp_addpath_id_for_peer(
peer, afi, safi, peer, afi, safi,
&ctx->pi->tx_addpath)); &ctx->pi->tx_addpath));
@ -203,12 +203,12 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
* had advertised and * had advertised and
* send a withdraw */ * send a withdraw */
RB_FOREACH_SAFE (adj, bgp_adj_out_rb, RB_FOREACH_SAFE (adj, bgp_adj_out_rb,
&ctx->rn->adj_out, &ctx->dest->adj_out,
adj_next) { adj_next) {
if (adj->subgroup == subgrp) { if (adj->subgroup == subgrp) {
subgroup_process_announce_selected( subgroup_process_announce_selected(
subgrp, NULL, subgrp, NULL,
ctx->rn, ctx->dest,
adj->addpath_tx_id); adj->addpath_tx_id);
} }
} }
@ -226,7 +226,7 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
struct bgp_table *table; struct bgp_table *table;
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
unsigned long output_count; unsigned long output_count;
struct bgp_node *rn; struct bgp_dest *dest;
int header1 = 1; int header1 = 1;
struct bgp *bgp; struct bgp *bgp;
int header2 = 1; int header2 = 1;
@ -239,10 +239,10 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
output_count = 0; output_count = 0;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out) RB_FOREACH (adj, bgp_adj_out_rb, &dest->adj_out)
if (adj->subgroup == subgrp) { if (adj->subgroup == subgrp) {
if (header1) { if (header1) {
vty_out(vty, vty_out(vty,
@ -260,16 +260,17 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
} }
if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv
&& adj->adv->baa) { && adj->adv->baa) {
route_vty_out_tmp( route_vty_out_tmp(vty, dest_p,
vty, rn_p, adj->adv->baa->attr, adj->adv->baa->attr,
SUBGRP_SAFI(subgrp), 0, NULL); SUBGRP_SAFI(subgrp),
0, NULL);
output_count++; output_count++;
} }
if ((flags & UPDWALK_FLAGS_ADVERTISED) if ((flags & UPDWALK_FLAGS_ADVERTISED)
&& adj->attr) { && adj->attr) {
route_vty_out_tmp(vty, rn_p, adj->attr, route_vty_out_tmp(
SUBGRP_SAFI(subgrp), vty, dest_p, adj->attr,
0, NULL); SUBGRP_SAFI(subgrp), 0, NULL);
output_count++; output_count++;
} }
} }
@ -386,7 +387,7 @@ static int update_group_announce_rrc_walkcb(struct update_group *updgrp,
* primarily its association with the subgroup and the prefix. * primarily its association with the subgroup and the prefix.
*/ */
struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp, struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
struct bgp_node *rn, struct bgp_dest *dest,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
@ -395,10 +396,10 @@ struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
adj->subgroup = subgrp; adj->subgroup = subgrp;
adj->addpath_tx_id = addpath_tx_id; adj->addpath_tx_id = addpath_tx_id;
if (rn) { if (dest) {
RB_INSERT(bgp_adj_out_rb, &rn->adj_out, adj); RB_INSERT(bgp_adj_out_rb, &dest->adj_out, adj);
bgp_lock_node(rn); bgp_dest_lock_node(dest);
adj->rn = rn; adj->dest = dest;
} }
TAILQ_INSERT_TAIL(&(subgrp->adjq), adj, subgrp_adj_train); TAILQ_INSERT_TAIL(&(subgrp->adjq), adj, subgrp_adj_train);
@ -445,7 +446,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
return next; return next;
} }
void bgp_adj_out_set_subgroup(struct bgp_node *rn, void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp, struct attr *attr, struct update_subgroup *subgrp, struct attr *attr,
struct bgp_path_info *path) struct bgp_path_info *path)
{ {
@ -464,14 +465,14 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
/* Look for adjacency information. */ /* Look for adjacency information. */
adj = adj_lookup( adj = adj_lookup(
rn, subgrp, dest, subgrp,
bgp_addpath_id_for_peer(peer, afi, safi, &path->tx_addpath)); bgp_addpath_id_for_peer(peer, afi, safi, &path->tx_addpath));
if (!adj) { if (!adj) {
adj = bgp_adj_out_alloc( adj = bgp_adj_out_alloc(
subgrp, rn, subgrp, dest,
bgp_addpath_id_for_peer(peer, afi, safi, bgp_addpath_id_for_peer(peer, afi, safi,
&path->tx_addpath)); &path->tx_addpath));
if (!adj) if (!adj)
return; return;
} }
@ -481,7 +482,7 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
adj->adv = bgp_advertise_new(); adj->adv = bgp_advertise_new();
adv = adj->adv; adv = adj->adv;
adv->rn = rn; adv->dest = dest;
assert(adv->pathi == NULL); assert(adv->pathi == NULL);
/* bgp_path_info adj_out reference */ /* bgp_path_info adj_out reference */
adv->pathi = bgp_path_info_lock(path); adv->pathi = bgp_path_info_lock(path);
@ -509,14 +510,14 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
bgp_adv_fifo_add_tail(&subgrp->sync->update, adv); bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);
subgrp->version = max(subgrp->version, rn->version); subgrp->version = max(subgrp->version, dest->version);
} }
/* The only time 'withdraw' will be false is if we are sending /* The only time 'withdraw' will be false is if we are sending
* the "neighbor x.x.x.x default-originate" default and need to clear * the "neighbor x.x.x.x default-originate" default and need to clear
* bgp_adj_out for the 0.0.0.0/0 route in the BGP table. * bgp_adj_out for the 0.0.0.0/0 route in the BGP table.
*/ */
void bgp_adj_out_unset_subgroup(struct bgp_node *rn, void bgp_adj_out_unset_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp, char withdraw, struct update_subgroup *subgrp, char withdraw,
uint32_t addpath_tx_id) uint32_t addpath_tx_id)
{ {
@ -528,7 +529,7 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
return; return;
/* Lookup existing adjacency */ /* Lookup existing adjacency */
if ((adj = adj_lookup(rn, subgrp, addpath_tx_id)) != NULL) { if ((adj = adj_lookup(dest, subgrp, addpath_tx_id)) != NULL) {
/* Clean up previous advertisement. */ /* Clean up previous advertisement. */
if (adj->adv) if (adj->adv)
bgp_advertise_clean_subgroup(subgrp, adj); bgp_advertise_clean_subgroup(subgrp, adj);
@ -538,14 +539,14 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
* the default route at the peer. * the default route at the peer.
*/ */
if (CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE) if (CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)
&& is_default_prefix(&rn->p)) && is_default_prefix(bgp_dest_get_prefix(dest)))
return; return;
if (adj->attr && withdraw) { if (adj->attr && withdraw) {
/* We need advertisement structure. */ /* We need advertisement structure. */
adj->adv = bgp_advertise_new(); adj->adv = bgp_advertise_new();
adv = adj->adv; adv = adj->adv;
adv->rn = rn; adv->dest = dest;
adv->adj = adj; adv->adj = adj;
/* Note if we need to trigger a packet write */ /* Note if we need to trigger a packet write */
@ -560,19 +561,19 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
subgroup_trigger_write(subgrp); subgroup_trigger_write(subgrp);
} else { } else {
/* Remove myself from adjacency. */ /* Remove myself from adjacency. */
RB_REMOVE(bgp_adj_out_rb, &rn->adj_out, adj); RB_REMOVE(bgp_adj_out_rb, &dest->adj_out, adj);
/* Free allocated information. */ /* Free allocated information. */
adj_free(adj); adj_free(adj);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
subgrp->version = max(subgrp->version, rn->version); subgrp->version = max(subgrp->version, dest->version);
} }
void bgp_adj_out_remove_subgroup(struct bgp_node *rn, struct bgp_adj_out *adj, void bgp_adj_out_remove_subgroup(struct bgp_dest *dest, struct bgp_adj_out *adj,
struct update_subgroup *subgrp) struct update_subgroup *subgrp)
{ {
if (adj->attr) if (adj->attr)
@ -581,7 +582,7 @@ void bgp_adj_out_remove_subgroup(struct bgp_node *rn, struct bgp_adj_out *adj,
if (adj->adv) if (adj->adv)
bgp_advertise_clean_subgroup(subgrp, adj); bgp_advertise_clean_subgroup(subgrp, adj);
RB_REMOVE(bgp_adj_out_rb, &rn->adj_out, adj); RB_REMOVE(bgp_adj_out_rb, &dest->adj_out, adj);
adj_free(adj); adj_free(adj);
} }
@ -594,9 +595,9 @@ void subgroup_clear_table(struct update_subgroup *subgrp)
struct bgp_adj_out *aout, *taout; struct bgp_adj_out *aout, *taout;
SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) { SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) {
struct bgp_node *rn = aout->rn; struct bgp_dest *dest = aout->dest;
bgp_adj_out_remove_subgroup(rn, aout, subgrp); bgp_adj_out_remove_subgroup(dest, aout, subgrp);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
@ -606,7 +607,7 @@ void subgroup_clear_table(struct update_subgroup *subgrp)
void subgroup_announce_table(struct update_subgroup *subgrp, void subgroup_announce_table(struct update_subgroup *subgrp,
struct bgp_table *table) struct bgp_table *table)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *ri; struct bgp_path_info *ri;
struct attr attr; struct attr attr;
struct peer *peer; struct peer *peer;
@ -630,19 +631,19 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
PEER_FLAG_DEFAULT_ORIGINATE)) PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate(subgrp, 0); subgroup_default_originate(subgrp, 0);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
for (ri = bgp_node_get_bgp_path_info(rn); ri; ri = ri->next) for (ri = bgp_dest_get_bgp_path_info(dest); ri; ri = ri->next)
if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)
|| (addpath_capable || (addpath_capable
&& bgp_addpath_tx_path( && bgp_addpath_tx_path(
peer->addpath_type[afi][safi], peer->addpath_type[afi][safi],
ri))) { ri))) {
if (subgroup_announce_check(rn, ri, subgrp, if (subgroup_announce_check(dest, ri, subgrp,
rn_p, &attr)) dest_p, &attr))
bgp_adj_out_set_subgroup(rn, subgrp, bgp_adj_out_set_subgroup(dest, subgrp,
&attr, ri); &attr, ri);
else { else {
/* If default originate is enabled for /* If default originate is enabled for
@ -654,11 +655,11 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
if (CHECK_FLAG( if (CHECK_FLAG(
peer->af_flags[afi][safi], peer->af_flags[afi][safi],
PEER_FLAG_DEFAULT_ORIGINATE) PEER_FLAG_DEFAULT_ORIGINATE)
&& is_default_prefix(&rn->p)) && is_default_prefix(bgp_dest_get_prefix(dest)))
break; break;
bgp_adj_out_unset_subgroup( bgp_adj_out_unset_subgroup(
rn, subgrp, 1, dest, subgrp, 1,
bgp_addpath_id_for_peer( bgp_addpath_id_for_peer(
peer, afi, safi, peer, afi, safi,
&ri->tx_addpath)); &ri->tx_addpath));
@ -689,7 +690,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
*/ */
void subgroup_announce_route(struct update_subgroup *subgrp) void subgroup_announce_route(struct update_subgroup *subgrp)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_table *table; struct bgp_table *table;
struct peer *onlypeer; struct peer *onlypeer;
@ -712,9 +713,9 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
&& SUBGRP_SAFI(subgrp) != SAFI_EVPN) && SUBGRP_SAFI(subgrp) != SAFI_EVPN)
subgroup_announce_table(subgrp, NULL); subgroup_announce_table(subgrp, NULL);
else else
for (rn = bgp_table_top(update_subgroup_rib(subgrp)); rn; for (dest = bgp_table_top(update_subgroup_rib(subgrp)); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (!table) if (!table)
continue; continue;
subgroup_announce_table(subgrp, table); subgroup_announce_table(subgrp, table);
@ -729,7 +730,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
struct aspath *aspath; struct aspath *aspath;
struct prefix p; struct prefix p;
struct peer *from; struct peer *from;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
struct peer *peer; struct peer *peer;
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
@ -779,11 +780,11 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
* the default route. We announce the default * the default route. We announce the default
* route only if route-map has a match. * route only if route-map has a match.
*/ */
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
ret = route_map_apply(peer->default_rmap[afi][safi].map, ret = route_map_apply(peer->default_rmap[afi][safi].map,
bgp_node_get_prefix(rn), RMAP_BGP, bgp_dest_get_prefix(dest),
&bpi_rmap); RMAP_BGP, &bpi_rmap);
if (ret != RMAP_DENYMATCH) if (ret != RMAP_DENYMATCH)
break; break;
@ -803,7 +804,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
memset(&p, 0, sizeof(p)); memset(&p, 0, sizeof(p));
p.family = afi2family(afi); p.family = afi2family(afi);
p.prefixlen = 0; p.prefixlen = 0;
rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p, NULL); dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p, NULL);
if (withdraw) { if (withdraw) {
/* Withdraw the default route advertised using default /* Withdraw the default route advertised using default
@ -816,15 +817,17 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
/* If default route is present in the local RIB, advertise the /* If default route is present in the local RIB, advertise the
* route * route
*/ */
if (rn != NULL) { if (dest != NULL) {
for (pi = bgp_node_get_bgp_path_info(rn); pi; for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) { pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
if (subgroup_announce_check( if (subgroup_announce_check(
rn, pi, subgrp, &rn->p, dest, pi, subgrp,
bgp_dest_get_prefix(dest),
&attr)) &attr))
bgp_adj_out_set_subgroup( bgp_adj_out_set_subgroup(
rn, subgrp, &attr, pi); dest, subgrp, &attr,
pi);
} }
} }
} else { } else {
@ -838,12 +841,12 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
* clear adj_out for the 0.0.0.0/0 prefix in the BGP * clear adj_out for the 0.0.0.0/0 prefix in the BGP
* table. * table.
*/ */
if (rn != NULL) { if (dest != NULL) {
/* Remove the adjacency for the previously /* Remove the adjacency for the previously
* advertised default route * advertised default route
*/ */
adj = adj_lookup( adj = adj_lookup(
rn, subgrp, dest, subgrp,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
if (adj != NULL) { if (adj != NULL) {
/* Clean up previous advertisement. */ /* Clean up previous advertisement. */
@ -852,13 +855,13 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
subgrp, adj); subgrp, adj);
/* Remove from adjacency. */ /* Remove from adjacency. */
RB_REMOVE(bgp_adj_out_rb, &rn->adj_out, RB_REMOVE(bgp_adj_out_rb,
adj); &dest->adj_out, adj);
/* Free allocated information. */ /* Free allocated information. */
adj_free(adj); adj_free(adj);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
@ -915,11 +918,11 @@ void subgroup_announce_all(struct update_subgroup *subgrp)
* input route. * input route.
*/ */
void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi, void group_announce_route(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_node *rn, struct bgp_path_info *pi) struct bgp_dest *dest, struct bgp_path_info *pi)
{ {
struct updwalk_context ctx; struct updwalk_context ctx;
ctx.pi = pi; ctx.pi = pi;
ctx.rn = rn; ctx.dest = dest;
update_group_af_walk(bgp, afi, safi, group_announce_route_walkcb, &ctx); update_group_af_walk(bgp, afi, safi, group_announce_route_walkcb, &ctx);
} }

View File

@ -691,7 +691,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
struct stream *packet; struct stream *packet;
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
struct bgp_advertise *adv; struct bgp_advertise *adv;
struct bgp_node *rn = NULL; struct bgp_dest *dest = NULL;
struct bgp_path_info *path = NULL; struct bgp_path_info *path = NULL;
bgp_size_t total_attr_len = 0; bgp_size_t total_attr_len = 0;
unsigned long attrlen_pos = 0; unsigned long attrlen_pos = 0;
@ -732,11 +732,11 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
adv = bgp_adv_fifo_first(&subgrp->sync->update); adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) { while (adv) {
const struct prefix *rn_p; const struct prefix *dest_p;
assert(adv->rn); assert(adv->dest);
rn = adv->rn; dest = adv->dest;
rn_p = bgp_node_get_prefix(rn); dest_p = bgp_dest_get_prefix(dest);
adj = adv->adj; adj = adv->adj;
addpath_tx_id = adj->addpath_tx_id; addpath_tx_id = adj->addpath_tx_id;
path = adv->pathi; path = adv->pathi;
@ -759,8 +759,9 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s)) space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW; - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead space_needed =
+ bgp_packet_mpattr_prefix_size(afi, safi, rn_p); BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(afi, safi, dest_p);
/* When remaining space can't include NLRI and it's length. */ /* When remaining space can't include NLRI and it's length. */
if (space_remaining < space_needed) if (space_remaining < space_needed)
@ -806,7 +807,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
- BGP_MAX_PACKET_SIZE_OVERFLOW; - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size( + bgp_packet_mpattr_prefix_size(
afi, safi, rn_p); afi, safi, dest_p);
/* If the attributes alone do not leave any room for /* If the attributes alone do not leave any room for
* NLRI then * NLRI then
@ -836,16 +837,16 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if ((afi == AFI_IP && safi == SAFI_UNICAST) if ((afi == AFI_IP && safi == SAFI_UNICAST)
&& !peer_cap_enhe(peer, afi, safi)) && !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, rn_p, addpath_encode, stream_put_prefix_addpath(s, dest_p, addpath_encode,
addpath_tx_id); addpath_tx_id);
else { else {
/* Encode the prefix in MP_REACH_NLRI attribute */ /* Encode the prefix in MP_REACH_NLRI attribute */
if (rn->prn) if (dest->pdest)
prd = (struct prefix_rd *)bgp_node_get_prefix( prd = (struct prefix_rd *)bgp_dest_get_prefix(
rn->prn); dest->pdest);
if (safi == SAFI_LABELED_UNICAST) { if (safi == SAFI_LABELED_UNICAST) {
label = bgp_adv_label(rn, path, peer, afi, label = bgp_adv_label(dest, path, peer, afi,
safi); safi);
label_pnt = &label; label_pnt = &label;
num_labels = 1; num_labels = 1;
@ -859,7 +860,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
snlri, peer, afi, safi, &vecarr, snlri, peer, afi, safi, &vecarr,
adv->baa->attr); adv->baa->attr);
bgp_packet_mpattr_prefix(snlri, afi, safi, rn_p, prd, bgp_packet_mpattr_prefix(snlri, afi, safi, dest_p, prd,
label_pnt, num_labels, label_pnt, num_labels,
addpath_encode, addpath_tx_id, addpath_encode, addpath_tx_id,
adv->baa->attr); adv->baa->attr);
@ -867,7 +868,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
num_pfx++; num_pfx++;
if (bgp_debug_update(NULL, rn_p, subgrp->update_group, 0)) { if (bgp_debug_update(NULL, dest_p, subgrp->update_group, 0)) {
char pfx_buf[BGP_PRD_PATH_STRLEN]; char pfx_buf[BGP_PRD_PATH_STRLEN];
if (!send_attr_printed) { if (!send_attr_printed) {
@ -891,10 +892,10 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
send_attr_printed = 1; send_attr_printed = 1;
} }
bgp_debug_rdpfxpath2str(afi, safi, prd, rn_p, label_pnt, bgp_debug_rdpfxpath2str(afi, safi, prd, dest_p,
num_labels, addpath_encode, label_pnt, num_labels,
addpath_tx_id, pfx_buf, addpath_encode, addpath_tx_id,
sizeof(pfx_buf)); pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s", zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s",
subgrp->update_group->id, subgrp->id, subgrp->update_group->id, subgrp->id,
pfx_buf); pfx_buf);
@ -958,7 +959,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
struct bgp_adj_out *adj; struct bgp_adj_out *adj;
struct bgp_advertise *adv; struct bgp_advertise *adv;
struct peer *peer; struct peer *peer;
struct bgp_node *rn; struct bgp_dest *dest;
bgp_size_t unfeasible_len; bgp_size_t unfeasible_len;
bgp_size_t total_attr_len; bgp_size_t total_attr_len;
size_t mp_start = 0; size_t mp_start = 0;
@ -991,19 +992,19 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0; addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) { while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
const struct prefix *rn_p; const struct prefix *dest_p;
assert(adv->rn); assert(adv->dest);
adj = adv->adj; adj = adv->adj;
rn = adv->rn; dest = adv->dest;
rn_p = bgp_node_get_prefix(rn); dest_p = bgp_dest_get_prefix(dest);
addpath_tx_id = adj->addpath_tx_id; addpath_tx_id = adj->addpath_tx_id;
space_remaining = space_remaining =
STREAM_WRITEABLE(s) - BGP_MAX_PACKET_SIZE_OVERFLOW; STREAM_WRITEABLE(s) - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead space_needed =
+ BGP_TOTAL_ATTR_LEN BGP_NLRI_LENGTH + addpath_overhead + BGP_TOTAL_ATTR_LEN
+ bgp_packet_mpattr_prefix_size(afi, safi, rn_p); + bgp_packet_mpattr_prefix_size(afi, safi, dest_p);
if (space_remaining < space_needed) if (space_remaining < space_needed)
break; break;
@ -1016,12 +1017,12 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
if (afi == AFI_IP && safi == SAFI_UNICAST if (afi == AFI_IP && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi)) && !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, rn_p, addpath_encode, stream_put_prefix_addpath(s, dest_p, addpath_encode,
addpath_tx_id); addpath_tx_id);
else { else {
if (rn->prn) if (dest->pdest)
prd = (struct prefix_rd *)bgp_node_get_prefix( prd = (struct prefix_rd *)bgp_dest_get_prefix(
rn->prn); dest->pdest);
/* If first time, format the MP_UNREACH header /* If first time, format the MP_UNREACH header
*/ */
@ -1048,17 +1049,17 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
subgrp->id, pkt_afi, pkt_safi); subgrp->id, pkt_afi, pkt_safi);
} }
bgp_packet_mpunreach_prefix(s, rn_p, afi, safi, prd, bgp_packet_mpunreach_prefix(s, dest_p, afi, safi, prd,
NULL, 0, addpath_encode, NULL, 0, addpath_encode,
addpath_tx_id, NULL); addpath_tx_id, NULL);
} }
num_pfx++; num_pfx++;
if (bgp_debug_update(NULL, rn_p, subgrp->update_group, 0)) { if (bgp_debug_update(NULL, dest_p, subgrp->update_group, 0)) {
char pfx_buf[BGP_PRD_PATH_STRLEN]; char pfx_buf[BGP_PRD_PATH_STRLEN];
bgp_debug_rdpfxpath2str(afi, safi, prd, rn_p, NULL, 0, bgp_debug_rdpfxpath2str(afi, safi, prd, dest_p, NULL, 0,
addpath_encode, addpath_tx_id, addpath_encode, addpath_tx_id,
pfx_buf, sizeof(pfx_buf)); pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 zlog_debug("u%" PRIu64 ":s%" PRIu64
@ -1069,8 +1070,8 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
subgrp->scount--; subgrp->scount--;
bgp_adj_out_remove_subgroup(rn, adj, subgrp); bgp_adj_out_remove_subgroup(dest, adj, subgrp);
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
if (!stream_empty(s)) { if (!stream_empty(s)) {

View File

@ -37,8 +37,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
{ {
struct bgp *bgp; struct bgp *bgp;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_node *rm; struct bgp_dest *rm;
int rd_header; int rd_header;
int header = 1; int header = 1;
json_object *json = NULL; json_object *json = NULL;
@ -76,14 +76,14 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
json_object_string_add(json_ocode, "incomplete", "?"); json_object_string_add(json_ocode, "incomplete", "?");
} }
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0) if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0)
continue; continue;
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL) if (table == NULL)
continue; continue;
@ -109,7 +109,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
break; break;
} }
if (bgp_node_get_bgp_path_info(rm) == NULL) if (bgp_dest_get_bgp_path_info(rm) == NULL)
continue; continue;
if (!attr) if (!attr)
@ -160,7 +160,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
#endif #endif
const uint8_t *pnt; const uint8_t *pnt;
pnt = rn_p->u.val; pnt = dest_p->u.val;
/* Decode RD type. */ /* Decode RD type. */
type = decode_rd_type(pnt); type = decode_rd_type(pnt);
@ -225,7 +225,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
} }
rd_header = 0; rd_header = 0;
} }
route_vty_out_tmp(vty, bgp_node_get_prefix(rm), attr, route_vty_out_tmp(vty, bgp_dest_get_prefix(rm), attr,
safi, use_json, json_routes); safi, use_json, json_routes);
output_count++; output_count++;
} }

View File

@ -8004,8 +8004,8 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
{ {
int ret; int ret;
struct prefix match; struct prefix match;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_node *rm; struct bgp_dest *rm;
struct bgp *bgp; struct bgp *bgp;
struct bgp_table *table; struct bgp_table *table;
struct bgp_table *rib; struct bgp_table *rib;
@ -8037,37 +8037,38 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
rib = bgp->rib[afi][safi]; rib = bgp->rib[afi][safi];
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(rib); dest;
const struct prefix *rn_p = bgp_node_get_prefix(rn); dest = bgp_route_next(dest)) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0) if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0)
continue; continue;
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL) if (table == NULL)
continue; continue;
if ((rm = bgp_node_match(table, &match)) != NULL) { if ((rm = bgp_node_match(table, &match)) != NULL) {
const struct prefix *rm_p = const struct prefix *rm_p =
bgp_node_get_prefix(rm); bgp_dest_get_prefix(rm);
if (rm_p->prefixlen == match.prefixlen) { if (rm_p->prefixlen == match.prefixlen) {
SET_FLAG(rm->flags, SET_FLAG(rm->flags,
BGP_NODE_USER_CLEAR); BGP_NODE_USER_CLEAR);
bgp_process(bgp, rm, afi, safi); bgp_process(bgp, rm, afi, safi);
} }
bgp_unlock_node(rm); bgp_dest_unlock_node(rm);
} }
} }
} else { } else {
if ((rn = bgp_node_match(rib, &match)) != NULL) { if ((dest = bgp_node_match(rib, &match)) != NULL) {
const struct prefix *rn_p = bgp_node_get_prefix(rn); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (rn_p->prefixlen == match.prefixlen) { if (dest_p->prefixlen == match.prefixlen) {
SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
bgp_process(bgp, rn, afi, safi); bgp_process(bgp, dest, afi, safi);
} }
bgp_unlock_node(rn); bgp_dest_unlock_node(dest);
} }
} }
@ -8493,7 +8494,7 @@ DEFUN (show_bgp_memory,
count = mtype_stats_alloc(MTYPE_BGP_NODE); count = mtype_stats_alloc(MTYPE_BGP_NODE);
vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, vty_out(vty, "%ld RIB nodes, using %s of memory\n", count,
mtype_memstr(memstrbuf, sizeof(memstrbuf), mtype_memstr(memstrbuf, sizeof(memstrbuf),
count * sizeof(struct bgp_node))); count * sizeof(struct bgp_dest)));
count = mtype_stats_alloc(MTYPE_BGP_ROUTE); count = mtype_stats_alloc(MTYPE_BGP_ROUTE);
vty_out(vty, "%ld BGP routes, using %s of memory\n", count, vty_out(vty, "%ld BGP routes, using %s of memory\n", count,
@ -9010,7 +9011,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
json_object_int_add(json, "ribCount", ents); json_object_int_add(json, "ribCount", ents);
json_object_int_add( json_object_int_add(
json, "ribMemory", json, "ribMemory",
ents * sizeof(struct bgp_node)); ents * sizeof(struct bgp_dest));
ents = bgp->af_peer_count[afi][safi]; ents = bgp->af_peer_count[afi][safi];
json_object_int_add(json, "peerCount", ents); json_object_int_add(json, "peerCount", ents);
@ -9046,10 +9047,11 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
vty_out(vty, vty_out(vty,
"RIB entries %ld, using %s of memory\n", "RIB entries %ld, using %s of memory\n",
ents, ents,
mtype_memstr(memstrbuf, mtype_memstr(
sizeof(memstrbuf), memstrbuf, sizeof(memstrbuf),
ents * sizeof(struct ents
bgp_node))); * sizeof(struct
bgp_dest)));
/* Peer related usage */ /* Peer related usage */
ents = bgp->af_peer_count[afi][safi]; ents = bgp->af_peer_count[afi][safi];

View File

@ -1174,7 +1174,7 @@ static bool bgp_zebra_use_nhop_weighted(struct bgp *bgp, struct attr *attr,
return true; return true;
} }
void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p, void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
struct bgp_path_info *info, struct bgp *bgp, afi_t afi, struct bgp_path_info *info, struct bgp *bgp, afi_t afi,
safi_t safi) safi_t safi)
{ {
@ -1212,8 +1212,8 @@ void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p,
prefix2str(p, buf_prefix, sizeof(buf_prefix)); prefix2str(p, buf_prefix, sizeof(buf_prefix));
if (safi == SAFI_FLOWSPEC) { if (safi == SAFI_FLOWSPEC) {
bgp_pbr_update_entry(bgp, bgp_node_get_prefix(rn), bgp_pbr_update_entry(bgp, bgp_dest_get_prefix(dest), info, afi,
info, afi, safi, true); safi, true);
return; return;
} }
@ -1508,7 +1508,7 @@ void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p,
/* Announce all routes of a table to zebra */ /* Announce all routes of a table to zebra */
void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi) void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_table *table; struct bgp_table *table;
struct bgp_path_info *pi; struct bgp_path_info *pi;
@ -1522,15 +1522,16 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
if (!table) if (!table)
return; return;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) && if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
(pi->type == ZEBRA_ROUTE_BGP (pi->type == ZEBRA_ROUTE_BGP
&& (pi->sub_type == BGP_ROUTE_NORMAL && (pi->sub_type == BGP_ROUTE_NORMAL
|| pi->sub_type == BGP_ROUTE_IMPORTED))) || pi->sub_type == BGP_ROUTE_IMPORTED)))
bgp_zebra_announce(rn, bgp_node_get_prefix(rn), bgp_zebra_announce(dest,
bgp_dest_get_prefix(dest),
pi, bgp, afi, safi); pi, bgp, afi, safi);
} }
@ -1731,7 +1732,7 @@ bool bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red, bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
afi_t afi, int type, uint32_t metric) afi_t afi, int type, uint32_t metric)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *pi; struct bgp_path_info *pi;
if (red->redist_metric_flag && red->redist_metric == metric) if (red->redist_metric_flag && red->redist_metric == metric)
@ -1740,9 +1741,9 @@ bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
red->redist_metric_flag = 1; red->redist_metric_flag = 1;
red->redist_metric = metric; red->redist_metric = metric;
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) { for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE
&& pi->type == type && pi->type == type
&& pi->instance == red->instance) { && pi->instance == red->instance) {
@ -1755,9 +1756,9 @@ bool bgp_redistribute_metric_set(struct bgp *bgp, struct bgp_redist *red,
pi->attr = bgp_attr_intern(&new_attr); pi->attr = bgp_attr_intern(&new_attr);
bgp_attr_unintern(&old_attr); bgp_attr_unintern(&old_attr);
bgp_path_info_set_flag(rn, pi, bgp_path_info_set_flag(dest, pi,
BGP_PATH_ATTR_CHANGED); BGP_PATH_ATTR_CHANGED);
bgp_process(bgp, rn, afi, SAFI_UNICAST); bgp_process(bgp, dest, afi, SAFI_UNICAST);
} }
} }
} }

View File

@ -35,7 +35,7 @@ extern void bgp_zebra_destroy(void);
extern int bgp_zebra_get_table_range(uint32_t chunk_size, extern int bgp_zebra_get_table_range(uint32_t chunk_size,
uint32_t *start, uint32_t *end); uint32_t *start, uint32_t *end);
extern int bgp_if_update_all(void); extern int bgp_if_update_all(void);
extern void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p, extern void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
struct bgp_path_info *path, struct bgp *bgp, struct bgp_path_info *path, struct bgp *bgp,
afi_t afi, safi_t safi); afi_t afi, safi_t safi);
extern void bgp_zebra_announce_table(struct bgp *, afi_t, safi_t); extern void bgp_zebra_announce_table(struct bgp *, afi_t, safi_t);

View File

@ -1496,22 +1496,22 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer)
static void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, static void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi,
safi_t safi) safi_t safi)
{ {
struct bgp_node *rn, *nrn; struct bgp_dest *dest, *ndest;
struct bgp_table *table; struct bgp_table *table;
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
if (table != NULL) { if (table != NULL) {
/* Special handling for 2-level routing /* Special handling for 2-level routing
* tables. */ * tables. */
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) { || safi == SAFI_EVPN) {
for (nrn = bgp_table_top(table); for (ndest = bgp_table_top(table); ndest;
nrn; nrn = bgp_route_next(nrn)) ndest = bgp_route_next(ndest))
bgp_process(bgp, nrn, afi, safi); bgp_process(bgp, ndest, afi, safi);
} else } else
bgp_process(bgp, rn, afi, safi); bgp_process(bgp, dest, afi, safi);
} }
} }
} }
@ -3442,7 +3442,7 @@ void bgp_free(struct bgp *bgp)
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_rmap *rmap; struct bgp_rmap *rmap;
QOBJ_UNREG(bgp); QOBJ_UNREG(bgp);
@ -3459,9 +3459,9 @@ void bgp_free(struct bgp *bgp)
/* Special handling for 2-level routing tables. */ /* Special handling for 2-level routing tables. */
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) { || safi == SAFI_EVPN) {
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
table = bgp_node_get_bgp_table_info(rn); table = bgp_dest_get_bgp_table_info(dest);
bgp_table_finish(&table); bgp_table_finish(&table);
} }
} }

View File

@ -360,7 +360,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
struct rfapi_nexthop *lnh, int kill) struct rfapi_nexthop *lnh, int kill)
{ {
afi_t afi; /* of the VN address */ afi_t afi; /* of the VN address */
struct bgp_node *bn; struct bgp_dest *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN];
char buf2[RD_ADDRSTRLEN]; char buf2[RD_ADDRSTRLEN];
@ -382,9 +382,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p", "%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
__func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)), __func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)),
afi, safi, bn, (bn ? bgp_node_get_bgp_path_info(bn) : NULL)); afi, safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
for (bpi = (bn ? bgp_node_get_bgp_path_info(bn) : NULL); bpi; for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
bpi = bpi->next) { bpi = bpi->next) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -465,16 +465,16 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
__func__, safi, buf); __func__, safi, buf);
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL; struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL; struct bgp_table *table = NULL;
prn = bgp_node_get(bgp->rib[afi][safi], pdest = bgp_node_get(bgp->rib[afi][safi],
(struct prefix *)prd); (struct prefix *)prd);
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (table) if (table)
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, bpi); bgp, prd, table, p, bpi);
bgp_unlock_node(prn); bgp_dest_unlock_node(pdest);
} }
/* /*
@ -492,7 +492,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
__func__, safi, buf); __func__, safi, buf);
} }
done: done:
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
} }
struct rfapi_nexthop *rfapi_nexthop_new(struct rfapi_nexthop *copyme) struct rfapi_nexthop *rfapi_nexthop_new(struct rfapi_nexthop *copyme)
@ -573,7 +573,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
afi_t afi; /* of the VN address */ afi_t afi; /* of the VN address */
struct bgp_path_info *new; struct bgp_path_info *new;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_node *bn; struct bgp_dest *bn;
struct attr attr = {0}; struct attr attr = {0};
struct attr *new_attr; struct attr *new_attr;
@ -942,7 +942,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
* ecommunity: POINTS TO interned/refcounted dynamic 2-part AS attr * ecommunity: POINTS TO interned/refcounted dynamic 2-part AS attr
* aspath: POINTS TO interned/refcounted hashed block * aspath: POINTS TO interned/refcounted hashed block
*/ */
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
/* probably only need to check /* probably only need to check
* bpi->extra->vnc.export.rfapi_handle */ * bpi->extra->vnc.export.rfapi_handle */
if (bpi->peer == rfd->peer && bpi->type == type if (bpi->peer == rfd->peer && bpi->type == type
@ -997,7 +997,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
if (attrhash_cmp(bpi->attr, new_attr) if (attrhash_cmp(bpi->attr, new_attr)
&& !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) { && !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
bgp_attr_unintern(&new_attr); bgp_attr_unintern(&new_attr);
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
vnc_zlog_debug_any( vnc_zlog_debug_any(
"%s: Found route (safi=%d) at prefix %s, no change", "%s: Found route (safi=%d) at prefix %s, no change",
@ -1009,16 +1009,16 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
bgp_path_info_set_flag(bn, bpi, BGP_PATH_ATTR_CHANGED); bgp_path_info_set_flag(bn, bpi, BGP_PATH_ATTR_CHANGED);
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL; struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL; struct bgp_table *table = NULL;
prn = bgp_node_get(bgp->rib[afi][safi], pdest = bgp_node_get(bgp->rib[afi][safi],
(struct prefix *)prd); (struct prefix *)prd);
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (table) if (table)
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve( vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, bpi); bgp, prd, table, p, bpi);
bgp_unlock_node(prn); bgp_dest_unlock_node(pdest);
} }
/* Rewrite BGP route information. */ /* Rewrite BGP route information. */
@ -1032,22 +1032,22 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL; struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL; struct bgp_table *table = NULL;
prn = bgp_node_get(bgp->rib[afi][safi], pdest = bgp_node_get(bgp->rib[afi][safi],
(struct prefix *)prd); (struct prefix *)prd);
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (table) if (table)
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, bpi); bgp, prd, table, p, bpi);
bgp_unlock_node(prn); bgp_dest_unlock_node(pdest);
} }
/* Process change. */ /* Process change. */
bgp_aggregate_increment(bgp, p, bpi, afi, safi); bgp_aggregate_increment(bgp, p, bpi, afi, safi);
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
vnc_zlog_debug_any( vnc_zlog_debug_any(
"%s: Found route (safi=%d) at prefix %s, changed attr", "%s: Found route (safi=%d) at prefix %s, changed attr",
@ -1076,19 +1076,19 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
bgp_path_info_add(bn, new); bgp_path_info_add(bn, new);
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL; struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL; struct bgp_table *table = NULL;
prn = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd); pdest = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (table) if (table)
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve( vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, new); bgp, prd, table, p, new);
bgp_unlock_node(prn); bgp_dest_unlock_node(pdest);
encode_label(label_val, &bn->local_label); encode_label(label_val, &bn->local_label);
} }
bgp_unlock_node(bn); bgp_dest_unlock_node(bn);
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
vnc_zlog_debug_any( vnc_zlog_debug_any(
@ -3665,51 +3665,55 @@ void rfapi_init(void)
#ifdef DEBUG_RFAPI #ifdef DEBUG_RFAPI
static void rfapi_print_exported(struct bgp *bgp) static void rfapi_print_exported(struct bgp *bgp)
{ {
struct bgp_node *rdn; struct bgp_dest *destn;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
if (!bgp) if (!bgp)
return; return;
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rdn; for (destn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); destn;
rdn = bgp_route_next(rdn)) { destn = bgp_route_next(destn)) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rdn); table = bgp_dest_get_bgp_table_info(destn);
if (!table) if (!table)
continue; continue;
fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn); fprintf(stderr, "%s: vpn destn=%p\n", __func__, destn);
for (rn = bgp_table_top(table); rn; for (dest = bgp_table_top(table); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
bpi = bgp_node_get_bgp_path_info(rn); bpi = bgp_dest_get_bgp_path_info(dest);
if (!bpi) if (!bpi)
continue; continue;
fprintf(stderr, "%s: rn=%p\n", __func__, rn); fprintf(stderr, "%s: dest=%p\n", __func__, dest);
for (; bpi; bpi = bpi->next) { for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
} }
} }
} }
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); rdn; for (destn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); destn;
rdn = bgp_route_next(rdn)) { destn = bgp_route_next(destn)) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rdn); table = bgp_dest_get_bgp_table_info(destn);
if (!table) if (!table)
continue; continue;
fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn); fprintf(stderr, "%s: encap destn=%p\n", __func__, destn);
for (rn = bgp_table_top(table)); rn; for (dest = bgp_table_top(table))
rn = bgp_route_next(rn)) { ;
bpi = bgp_node_get_bgp_path_info(rn); dest;
if (!bpi) dest = bgp_route_next(dest))
continue; {
fprintf(stderr, "%s: rn=%p\n", __func__, rn); bpi = bgp_dest_get_bgp_path_info(dest);
for (; bpi; bpi = bpi->next) { if (!bpi)
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */ continue;
} fprintf(stderr, "%s: dest=%p\n", __func__, dest);
} for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2,
bpi); /* 2 => stderr */
}
}
} }
} }
#endif /* defined(DEBUG_RFAPI) */ #endif /* defined(DEBUG_RFAPI) */

View File

@ -4177,8 +4177,8 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
struct rfapi_import_table *it, struct rfapi_import_table *it,
afi_t afi, safi_t safi) afi_t afi, safi_t safi)
{ {
struct bgp_node *rn1; struct bgp_dest *dest1;
struct bgp_node *rn2; struct bgp_dest *dest2;
/* Only these SAFIs have 2-level RIBS */ /* Only these SAFIs have 2-level RIBS */
assert(safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP); assert(safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP);
@ -4188,17 +4188,18 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
* route tables attached to them, and import the routes * route tables attached to them, and import the routes
* if they have matching route targets * if they have matching route targets
*/ */
for (rn1 = bgp_table_top(bgp->rib[afi][safi]); rn1; for (dest1 = bgp_table_top(bgp->rib[afi][safi]); dest1;
rn1 = bgp_route_next(rn1)) { dest1 = bgp_route_next(dest1)) {
if (bgp_node_has_bgp_path_info_data(rn1)) { if (bgp_dest_has_bgp_path_info_data(dest1)) {
for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2; for (dest2 = bgp_table_top(
rn2 = bgp_route_next(rn2)) { bgp_dest_get_bgp_table_info(dest1));
dest2; dest2 = bgp_route_next(dest2)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
for (bpi = bgp_node_get_bgp_path_info(rn2); for (bpi = bgp_dest_get_bgp_path_info(dest2);
bpi; bpi = bpi->next) { bpi; bpi = bpi->next) {
uint32_t label = 0; uint32_t label = 0;
@ -4213,11 +4214,12 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
safi))( safi))(
it, /* which import table */ it, /* which import table */
FIF_ACTION_UPDATE, bpi->peer, FIF_ACTION_UPDATE, bpi->peer,
NULL, bgp_node_get_prefix(rn2), NULL,
bgp_dest_get_prefix(dest2),
NULL, afi, NULL, afi,
(struct prefix_rd *) (struct prefix_rd *)
bgp_node_get_prefix( bgp_dest_get_prefix(
rn1), dest1),
bpi->attr, bpi->type, bpi->attr, bpi->type,
bpi->sub_type, &label); bpi->sub_type, &label);
} }

View File

@ -1535,7 +1535,7 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd,
safi_t safi, struct prefix *p) safi_t safi, struct prefix *p)
{ {
afi_t afi; /* of the VN address */ afi_t afi; /* of the VN address */
struct bgp_node *bn; struct bgp_dest *bd;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
uint8_t type = ZEBRA_ROUTE_BGP; uint8_t type = ZEBRA_ROUTE_BGP;
struct bgp *bgp; struct bgp *bgp;
@ -1562,11 +1562,11 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd,
} else { } else {
prd = &rfd->rd; prd = &rfd->rd;
} }
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd); bd = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
vty_out(vty, " bn=%p%s", bn, HVTYNL); vty_out(vty, " bd=%p%s", bd, HVTYNL);
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bd); bpi; bpi = bpi->next) {
if (bpi->peer == rfd->peer && bpi->type == type if (bpi->peer == rfd->peer && bpi->type == type
&& bpi->sub_type == BGP_ROUTE_RFP && bpi->extra && bpi->sub_type == BGP_ROUTE_RFP && bpi->extra
&& bpi->extra->vnc.export.rfapi_handle == (void *)rfd) { && bpi->extra->vnc.export.rfapi_handle == (void *)rfd) {

View File

@ -179,7 +179,7 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
struct peer *peer = bpi->peer; struct peer *peer = bpi->peer;
const struct prefix *prefix = agg_node_get_prefix(rn); const struct prefix *prefix = agg_node_get_prefix(rn);
afi_t afi = family2afi(prefix->family); afi_t afi = family2afi(prefix->family);
struct bgp_node *urn; struct bgp_dest *udest;
struct bgp_path_info *ubpi; struct bgp_path_info *ubpi;
struct attr hattr; struct attr hattr;
struct attr *iattr; struct attr *iattr;
@ -254,9 +254,10 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
* Is this route already represented in the unicast RIB? * Is this route already represented in the unicast RIB?
* (look up prefix; compare route type, sub_type, peer, nexthop) * (look up prefix; compare route type, sub_type, peer, nexthop)
*/ */
urn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, udest = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST,
prefix, NULL); prefix, NULL);
for (ubpi = bgp_node_get_bgp_path_info(urn); ubpi; ubpi = ubpi->next) { for (ubpi = bgp_dest_get_bgp_path_info(udest); ubpi;
ubpi = ubpi->next) {
struct prefix unicast_nexthop; struct prefix unicast_nexthop;
if (CHECK_FLAG(ubpi->flags, BGP_PATH_REMOVED)) if (CHECK_FLAG(ubpi->flags, BGP_PATH_REMOVED))
@ -456,7 +457,7 @@ static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi)
static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi) static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi);
@ -472,14 +473,14 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
* Go through the entire BGP unicast table and remove routes that * Go through the entire BGP unicast table and remove routes that
* originated from us * originated from us
*/ */
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
struct bgp_path_info *ri; struct bgp_path_info *ri;
struct bgp_path_info *next; struct bgp_path_info *next;
for (ri = bgp_node_get_bgp_path_info(rn), next = NULL; for (ri = bgp_dest_get_bgp_path_info(dest), next = NULL; ri;
ri; ri = next) { ri = next) {
next = ri->next; next = ri->next;
@ -487,7 +488,7 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
&& ri->sub_type == BGP_ROUTE_REDISTRIBUTE) { && ri->sub_type == BGP_ROUTE_REDISTRIBUTE) {
bgp_withdraw( bgp_withdraw(
ri->peer, bgp_node_get_prefix(rn), ri->peer, bgp_dest_get_prefix(dest),
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* ignored */ NULL, /* ignored */
AFI_IP, SAFI_UNICAST, AFI_IP, SAFI_UNICAST,
@ -1805,7 +1806,7 @@ void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi,
void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi) void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
{ {
struct prefix_rd prd; struct prefix_rd prd;
struct bgp_node *prn; struct bgp_dest *pdest;
struct rfapi_cfg *hc; struct rfapi_cfg *hc;
vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi);
@ -1835,45 +1836,46 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
vnc_zlog_debug_verbose("%s: starting RD loop", __func__); vnc_zlog_debug_verbose("%s: starting RD loop", __func__);
/* Loop over all the RDs */ /* Loop over all the RDs */
for (prn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); prn; for (pdest = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); pdest;
prn = bgp_route_next(prn)) { pdest = bgp_route_next(pdest)) {
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *rn; struct bgp_dest *dest;
struct bgp_path_info *ri; struct bgp_path_info *ri;
const struct prefix *prn_p = bgp_node_get_prefix(prn); const struct prefix *pdest_p = bgp_dest_get_prefix(pdest);
memset(&prd, 0, sizeof(prd)); memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; prd.prefixlen = 64;
memcpy(prd.val, prn_p->u.val, 8); memcpy(prd.val, pdest_p->u.val, 8);
/* This is the per-RD table of prefixes */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (!table) if (!table)
continue; continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest;
const struct prefix *rn_p; dest = bgp_route_next(dest)) {
const struct prefix *dest_p;
/* /*
* skip prefix list check if no routes here * skip prefix list check if no routes here
*/ */
if (!bgp_node_has_bgp_path_info_data(rn)) if (!bgp_dest_has_bgp_path_info_data(dest))
continue; continue;
vnc_zlog_debug_verbose("%s: checking prefix %pRN", vnc_zlog_debug_verbose("%s: checking prefix %pRN",
__func__, rn); __func__, dest);
rn_p = bgp_node_get_prefix(rn); dest_p = bgp_dest_get_prefix(dest);
/* /*
* prefix list check * prefix list check
*/ */
if (hc->plist_export_bgp[afi]) { if (hc->plist_export_bgp[afi]) {
if (prefix_list_apply(hc->plist_export_bgp[afi], if (prefix_list_apply(hc->plist_export_bgp[afi],
rn_p) dest_p)
== PREFIX_DENY) { == PREFIX_DENY) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -1883,8 +1885,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
} }
} }
for (ri = bgp_node_get_bgp_path_info(rn); for (ri = bgp_dest_get_bgp_path_info(dest); ri;
ri; ri = ri->next) { ri = ri->next) {
vnc_zlog_debug_verbose("%s: ri->sub_type: %d", vnc_zlog_debug_verbose("%s: ri->sub_type: %d",
__func__, ri->sub_type); __func__, ri->sub_type);
@ -1918,7 +1920,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
info.attr = &hattr; info.attr = &hattr;
ret = route_map_apply( ret = route_map_apply(
hc->routemap_export_bgp, hc->routemap_export_bgp,
rn_p, RMAP_BGP, &info); dest_p, RMAP_BGP,
&info);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr); bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -1937,7 +1940,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
* this route * this route
*/ */
eti = vnc_eti_get( eti = vnc_eti_get(
bgp, EXPORT_TYPE_BGP, rn_p, bgp, EXPORT_TYPE_BGP, dest_p,
ri->peer, ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE); BGP_ROUTE_REDISTRIBUTE);
@ -1958,19 +1961,19 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
"%s: calling bgp_update", "%s: calling bgp_update",
__func__); __func__);
bgp_update(ri->peer, rn_p, /* prefix */ bgp_update(
0, /* addpath_id */ ri->peer, dest_p, /* prefix */
iattr, /* bgp_update copies 0, /* addpath_id */
it */ iattr, /* bgp_update copies
AFI_IP, SAFI_UNICAST, it */
ZEBRA_ROUTE_VNC_DIRECT_RH, AFI_IP, SAFI_UNICAST,
BGP_ROUTE_REDISTRIBUTE, NULL, ZEBRA_ROUTE_VNC_DIRECT_RH,
/* RD not used for unicast */ BGP_ROUTE_REDISTRIBUTE, NULL,
NULL, /* RD not used for unicast */
/* tag not used for unicast, NULL,
or EVPN */ /* tag not used for unicast,
0, 0, or EVPN */
NULL); /* EVPN not used */ 0, 0, NULL); /* EVPN not used */
bgp_attr_unintern(&iattr); bgp_attr_unintern(&iattr);
} }
@ -1981,7 +1984,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi) void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi);
@ -1997,13 +2000,14 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
* Go through the entire BGP unicast table and remove routes that * Go through the entire BGP unicast table and remove routes that
* originated from us * originated from us
*/ */
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
struct bgp_path_info *ri; struct bgp_path_info *ri;
struct bgp_path_info *next; struct bgp_path_info *next;
for (ri = bgp_node_get_bgp_path_info(rn), next = NULL; ri; ri = next) { for (ri = bgp_dest_get_bgp_path_info(dest), next = NULL; ri;
ri = next) {
next = ri->next; next = ri->next;
@ -2016,7 +2020,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
* Delete routes immediately (no timer) * Delete routes immediately (no timer)
*/ */
eti = vnc_eti_checktimer( eti = vnc_eti_checktimer(
bgp, EXPORT_TYPE_BGP, rn_p, ri->peer, bgp, EXPORT_TYPE_BGP, dest_p, ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE); BGP_ROUTE_REDISTRIBUTE);
if (eti) { if (eti) {
@ -2025,9 +2029,9 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
vnc_eti_delete(eti); vnc_eti_delete(eti);
} }
bgp_withdraw(ri->peer, rn_p, /* prefix */ bgp_withdraw(ri->peer, dest_p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* ignored */ NULL, /* ignored */
AFI_IP, SAFI_UNICAST, AFI_IP, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT_RH, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE, BGP_ROUTE_REDISTRIBUTE,

View File

@ -523,7 +523,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
uint32_t *med, /* NULL = no med */ uint32_t *med, /* NULL = no med */
struct prefix *ubpi_nexthop) /* unicast nexthop */ struct prefix *ubpi_nexthop) /* unicast nexthop */
{ {
struct bgp_node *bn; struct bgp_dest *bd;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
if (!table_rd) if (!table_rd)
@ -538,8 +538,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
} }
/* exact match */ /* exact match */
bn = bgp_node_lookup(table_rd, ubpi_nexthop); bd = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bn) { if (!bd) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: no match in RD's table for ubpi_nexthop", "%s: no match in RD's table for ubpi_nexthop",
__func__); __func__);
@ -547,14 +547,14 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
} }
/* Iterate over bgp_info items at this node */ /* Iterate over bgp_info items at this node */
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bd); bpi; bpi = bpi->next) {
vnc_import_bgp_add_route_mode_resolve_nve_one_bi( vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
bgp, afi, bpi, /* VPN bpi */ bgp, afi, bpi, /* VPN bpi */
prd, prefix, local_pref, med, ecom); prd, prefix, local_pref, med, ecom);
} }
bgp_unlock_node(bn); bgp_dest_unlock_node(bd);
} }
static void vnc_import_bgp_add_route_mode_resolve_nve( static void vnc_import_bgp_add_route_mode_resolve_nve(
@ -570,7 +570,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
uint32_t *med = NULL; uint32_t *med = NULL;
struct prefix_bag *pb; struct prefix_bag *pb;
struct bgp_node *bnp; /* prd table node */ struct bgp_dest *bdp; /* prd table node */
/*debugging */ /*debugging */
if (VNC_DEBUG(VERBOSE)) { if (VNC_DEBUG(VERBOSE)) {
@ -668,18 +668,18 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
* (exact match, /32). If an exact match is found, call add_vnc_route. * (exact match, /32). If an exact match is found, call add_vnc_route.
*/ */
for (bnp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bnp; for (bdp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bdp;
bnp = bgp_route_next(bnp)) { bdp = bgp_route_next(bdp)) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(bnp); table = bgp_dest_get_bgp_table_info(bdp);
if (!table) if (!table)
continue; continue;
vnc_import_bgp_add_route_mode_resolve_nve_one_rd( vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
(struct prefix_rd *)bgp_node_get_prefix(bnp), table, (struct prefix_rd *)bgp_dest_get_prefix(bdp), table,
afi, bgp, prefix, ecom, &local_pref, med, afi, bgp, prefix, ecom, &local_pref, med,
&pfx_unicast_nexthop); &pfx_unicast_nexthop);
} }
@ -1282,7 +1282,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
const struct prefix *prefix, /* unicast prefix */ const struct prefix *prefix, /* unicast prefix */
const struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */ const struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */
{ {
struct bgp_node *bn; struct bgp_dest *bd;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
if (!table_rd) if (!table_rd)
@ -1297,8 +1297,8 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
/* exact match */ /* exact match */
bn = bgp_node_lookup(table_rd, ubpi_nexthop); bd = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bn) { if (!bd) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: no match in RD's table for ubpi_nexthop", "%s: no match in RD's table for ubpi_nexthop",
__func__); __func__);
@ -1306,7 +1306,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
} }
/* Iterate over bgp_info items at this node */ /* Iterate over bgp_info items at this node */
for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) { for (bpi = bgp_dest_get_bgp_path_info(bd); bpi; bpi = bpi->next) {
vnc_import_bgp_del_route_mode_resolve_nve_one_bi( vnc_import_bgp_del_route_mode_resolve_nve_one_bi(
bgp, afi, bpi, /* VPN bpi */ bgp, afi, bpi, /* VPN bpi */
@ -1314,7 +1314,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
prefix); /* unicast route prefix */ prefix); /* unicast route prefix */
} }
bgp_unlock_node(bn); bgp_dest_unlock_node(bd);
} }
static void static void
@ -1331,7 +1331,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
void *cursor; void *cursor;
struct skiplist *sl = bgp->rfapi->resolve_nve_nexthop; struct skiplist *sl = bgp->rfapi->resolve_nve_nexthop;
int rc; int rc;
struct bgp_node *bnp; /* prd table node */ struct bgp_dest *bdp; /* prd table node */
if (!sl) { if (!sl) {
vnc_zlog_debug_verbose("%s: no RHN entries, skipping", vnc_zlog_debug_verbose("%s: no RHN entries, skipping",
@ -1372,18 +1372,18 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
* (exact match, /32). If an exact match is found, call add_vnc_route. * (exact match, /32). If an exact match is found, call add_vnc_route.
*/ */
for (bnp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bnp; for (bdp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bdp;
bnp = bgp_route_next(bnp)) { bdp = bgp_route_next(bdp)) {
struct bgp_table *table; struct bgp_table *table;
table = bgp_node_get_bgp_table_info(bnp); table = bgp_dest_get_bgp_table_info(bdp);
if (!table) if (!table)
continue; continue;
vnc_import_bgp_del_route_mode_resolve_nve_one_rd( vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
(struct prefix_rd *)bgp_node_get_prefix(bnp), table, (struct prefix_rd *)bgp_dest_get_prefix(bdp), table,
afi, bgp, prefix, &pfx_unicast_nexthop); afi, bgp, prefix, &pfx_unicast_nexthop);
} }
@ -2737,7 +2737,7 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi)
/* iterate over bgp unicast v4 and v6 routes, call /* iterate over bgp unicast v4 and v6 routes, call
* vnc_import_bgp_add_route */ * vnc_import_bgp_add_route */
struct bgp_node *rn; struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi); vnc_zlog_debug_verbose("%s: entry, afi=%d", __func__, afi);
@ -2749,18 +2749,18 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi)
} }
bgp->rfapi_cfg->redist[afi][ZEBRA_ROUTE_BGP_DIRECT] = 1; bgp->rfapi_cfg->redist[afi][ZEBRA_ROUTE_BGP_DIRECT] = 1;
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
for (bpi = bgp_node_get_bgp_path_info(rn); bpi; for (bpi = bgp_dest_get_bgp_path_info(dest); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_add_route(bgp, bgp_node_get_prefix(rn), vnc_import_bgp_add_route(bgp, bgp_dest_get_prefix(dest),
bpi); bpi);
} }
} }
@ -2772,7 +2772,7 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi)
void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi) void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi)
{ {
struct bgp *bgp_exterior; struct bgp *bgp_exterior;
struct bgp_node *rn; struct bgp_dest *dest;
bgp_exterior = bgp->rfapi_cfg->redist_bgp_exterior_view; bgp_exterior = bgp->rfapi_cfg->redist_bgp_exterior_view;
@ -2791,19 +2791,19 @@ void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi)
return; return;
} }
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
for (bpi = bgp_node_get_bgp_path_info(rn); bpi; for (bpi = bgp_dest_get_bgp_path_info(dest); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_exterior_add_route( vnc_import_bgp_exterior_add_route(
bgp_exterior, bgp_node_get_prefix(rn), bpi); bgp_exterior, bgp_dest_get_prefix(dest), bpi);
} }
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -2818,7 +2818,7 @@ void vnc_import_bgp_exterior_redist_enable_it(
struct bgp *bgp, afi_t afi, struct rfapi_import_table *it_only) struct bgp *bgp, afi_t afi, struct rfapi_import_table *it_only)
{ {
struct bgp *bgp_exterior; struct bgp *bgp_exterior;
struct bgp_node *rn; struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry", __func__); vnc_zlog_debug_verbose("%s: entry", __func__);
@ -2837,19 +2837,19 @@ void vnc_import_bgp_exterior_redist_enable_it(
return; return;
} }
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn; for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); dest;
rn = bgp_route_next(rn)) { dest = bgp_route_next(dest)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
for (bpi = bgp_node_get_bgp_path_info(rn); bpi; for (bpi = bgp_dest_get_bgp_path_info(dest); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_exterior_add_route_it( vnc_import_bgp_exterior_add_route_it(
bgp_exterior, bgp_node_get_prefix(rn), bpi, bgp_exterior, bgp_dest_get_prefix(dest), bpi,
it_only); it_only);
} }
} }
@ -2862,8 +2862,8 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
* iterate over vpn routes, find routes of type ZEBRA_ROUTE_BGP_DIRECT, * iterate over vpn routes, find routes of type ZEBRA_ROUTE_BGP_DIRECT,
* delete (call timer expire immediately) * delete (call timer expire immediately)
*/ */
struct bgp_node *rn1; struct bgp_dest *dest1;
struct bgp_node *rn2; struct bgp_dest *dest2;
vnc_zlog_debug_verbose("%s: entry", __func__); vnc_zlog_debug_verbose("%s: entry", __func__);
@ -2878,21 +2878,22 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
* Two-level table for SAFI_MPLS_VPN * Two-level table for SAFI_MPLS_VPN
* Be careful when changing the things we iterate over * Be careful when changing the things we iterate over
*/ */
for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1; for (dest1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); dest1;
rn1 = bgp_route_next(rn1)) { dest1 = bgp_route_next(dest1)) {
const struct prefix *rn1_p; const struct prefix *dest1_p;
if (!bgp_node_has_bgp_path_info_data(rn1)) if (!bgp_dest_has_bgp_path_info_data(dest1))
continue; continue;
rn1_p = bgp_node_get_prefix(rn1); dest1_p = bgp_dest_get_prefix(dest1);
for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2; for (dest2 = bgp_table_top(bgp_dest_get_bgp_table_info(dest1));
rn2 = bgp_route_next(rn2)) { dest2; dest2 = bgp_route_next(dest2)) {
const struct prefix *rn2_p = bgp_node_get_prefix(rn2); const struct prefix *dest2_p =
bgp_dest_get_prefix(dest2);
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_path_info *nextbpi; struct bgp_path_info *nextbpi;
for (bpi = bgp_node_get_bgp_path_info(rn2); bpi; for (bpi = bgp_dest_get_bgp_path_info(dest2); bpi;
bpi = nextbpi) { bpi = nextbpi) {
nextbpi = bpi->next; nextbpi = bpi->next;
@ -2917,8 +2918,8 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
rfd); rfd);
del_vnc_route(rfd, bpi->peer, bgp, del_vnc_route(rfd, bpi->peer, bgp,
SAFI_MPLS_VPN, rn2_p, SAFI_MPLS_VPN, dest2_p,
(struct prefix_rd *)rn1_p, (struct prefix_rd *)dest1_p,
bpi->type, bpi->sub_type, NULL, bpi->type, bpi->sub_type, NULL,
1); /* kill */ 1); /* kill */
@ -2966,20 +2967,20 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi)
{ {
struct bgp_node *rn; struct bgp_dest *dest;
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]);
rn; rn = bgp_route_next(rn)) { dest; dest = bgp_route_next(dest)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
for (bpi = bgp_node_get_bgp_path_info(rn); bpi; for (bpi = bgp_dest_get_bgp_path_info(dest); bpi;
bpi = bpi->next) { bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_exterior_del_route( vnc_import_bgp_exterior_del_route(
bgp_exterior, bgp_node_get_prefix(rn), bgp_exterior, bgp_dest_get_prefix(dest),
bpi); bpi);
} }
} }

View File

@ -286,8 +286,8 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
{ {
struct prefix_rd prd; struct prefix_rd prd;
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *prn; struct bgp_dest *pdest;
struct bgp_node *rn; struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry", __func__); vnc_zlog_debug_verbose("%s: entry", __func__);
@ -302,25 +302,26 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
/* /*
* Loop over all the RDs * Loop over all the RDs
*/ */
for (prn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); prn; for (pdest = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); pdest;
prn = bgp_route_next(prn)) { pdest = bgp_route_next(pdest)) {
const struct prefix *prn_p = bgp_node_get_prefix(prn); const struct prefix *pdest_p = bgp_dest_get_prefix(pdest);
memset(&prd, 0, sizeof(prd)); memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; prd.prefixlen = 64;
memcpy(prd.val, prn_p->u.val, 8); memcpy(prd.val, pdest_p->u.val, 8);
/* This is the per-RD table of prefixes */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); table = bgp_dest_get_bgp_table_info(pdest);
if (!table) if (!table)
continue; continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (dest = bgp_table_top(table); dest;
dest = bgp_route_next(dest)) {
struct bgp_path_info *ri; struct bgp_path_info *ri;
for (ri = bgp_node_get_bgp_path_info(rn); ri; for (ri = bgp_dest_get_bgp_path_info(dest); ri;
ri = ri->next) { ri = ri->next) {
if (ri->type if (ri->type
== type) { /* has matching redist type */ == type) { /* has matching redist type */
@ -331,7 +332,7 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
del_vnc_route( del_vnc_route(
&vncHD1VR, /* use dummy ptr as cookie */ &vncHD1VR, /* use dummy ptr as cookie */
vncHD1VR.peer, bgp, SAFI_MPLS_VPN, vncHD1VR.peer, bgp, SAFI_MPLS_VPN,
bgp_node_get_prefix(rn), &prd, type, bgp_dest_get_prefix(dest), &prd, type,
BGP_ROUTE_REDISTRIBUTE, NULL, 0); BGP_ROUTE_REDISTRIBUTE, NULL, 0);
} }
} }

View File

@ -53,15 +53,15 @@ static void add_node(struct bgp_table *table, const char *prefix_str)
{ {
struct prefix_ipv4 p; struct prefix_ipv4 p;
struct test_node_t *node; struct test_node_t *node;
struct bgp_node *rn; struct bgp_dest *dest;
assert(prefix_str); assert(prefix_str);
if (str2prefix_ipv4(prefix_str, &p) <= 0) if (str2prefix_ipv4(prefix_str, &p) <= 0)
assert(0); assert(0);
rn = bgp_node_get(table, (struct prefix *)&p); dest = bgp_node_get(table, (struct prefix *)&p);
if (rn->info) { if (dest->info) {
assert(0); assert(0);
return; return;
} }
@ -70,7 +70,7 @@ static void add_node(struct bgp_table *table, const char *prefix_str)
assert(node); assert(node);
node->prefix_str = strdup(prefix_str); node->prefix_str = strdup(prefix_str);
assert(node->prefix_str); assert(node->prefix_str);
rn->info = node; dest->info = node;
} }
static bool prefix_in_array(const struct prefix *p, struct prefix *prefix_array, static bool prefix_in_array(const struct prefix *p, struct prefix *prefix_array,
@ -83,7 +83,7 @@ static bool prefix_in_array(const struct prefix *p, struct prefix *prefix_array,
return false; return false;
} }
static void check_lookup_result(struct bgp_node *match, va_list arglist) static void check_lookup_result(struct bgp_dest *match, va_list arglist)
{ {
char *prefix_str; char *prefix_str;
struct prefix *prefixes = NULL; struct prefix *prefixes = NULL;
@ -102,16 +102,16 @@ static void check_lookup_result(struct bgp_node *match, va_list arglist)
if (!match) if (!match)
return; return;
struct bgp_node *node = match; struct bgp_dest *dest = match;
while ((node = bgp_route_next_until(node, match))) { while ((dest = bgp_route_next_until(dest, match))) {
const struct prefix *node_p = bgp_node_get_prefix(node); const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (bgp_node_has_bgp_path_info_data(node) if (bgp_dest_has_bgp_path_info_data(dest)
&& !prefix_in_array(node_p, prefixes, prefix_count)) { && !prefix_in_array(dest_p, prefixes, prefix_count)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
prefix2str(node_p, buf, PREFIX2STR_BUFFER); prefix2str(dest_p, buf, PREFIX2STR_BUFFER);
printf("prefix %s was not expected!\n", buf); printf("prefix %s was not expected!\n", buf);
assert(0); assert(0);
} }
@ -128,9 +128,9 @@ static void do_test(struct bgp_table *table, const char *prefix, ...)
printf("\nDoing lookup for %s\n", prefix); printf("\nDoing lookup for %s\n", prefix);
if (str2prefix(prefix, &p) <= 0) if (str2prefix(prefix, &p) <= 0)
assert(0); assert(0);
struct bgp_node *node = bgp_table_subtree_lookup(table, &p); struct bgp_dest *dest = bgp_table_subtree_lookup(table, &p);
check_lookup_result(node, arglist); check_lookup_result(dest, arglist);
va_end(arglist); va_end(arglist);

View File

@ -313,7 +313,7 @@ static int setup_bgp_path_info_mpath_update(testcase_t *t)
return -1; return -1;
str2prefix("42.1.1.0/24", &test_rn.p); str2prefix("42.1.1.0/24", &test_rn.p);
rt_node = bgp_node_to_rnode(&test_rn); rt_node = bgp_dest_to_rnode(&test_rn);
memcpy((struct route_table *)&rt_node->table, &rt->route_table, memcpy((struct route_table *)&rt_node->table, &rt->route_table,
sizeof(struct route_table *)); sizeof(struct route_table *));
setup_bgp_mp_list(t); setup_bgp_mp_list(t);