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,
enum bgp_addpath_strat addpath_type,
struct bgp_node *rn)
struct bgp_dest *dest)
{
struct bgp_path_info *pi;
idalloc_drain_pool(
bgp->tx_addpath.id_allocators[afi][safi][addpath_type],
&(rn->tx_addpath.free_ids[addpath_type]));
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
&(dest->tx_addpath.free_ids[addpath_type]));
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (pi->tx_addpath.addpath_tx_id[addpath_type]
!= IDALLOC_INVALID) {
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,
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;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
if (safi == SAFI_MPLS_VPN) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rn);
table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
for (nrn = bgp_table_top(table); nrn;
nrn = bgp_route_next(nrn))
for (ndest = bgp_table_top(table); ndest;
ndest = bgp_route_next(ndest))
bgp_addpath_flush_type_rn(bgp, afi, safi,
addpath_type, nrn);
addpath_type, ndest);
} else {
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,
enum bgp_addpath_strat addpath_type)
{
struct bgp_node *rn, *nrn;
struct bgp_dest *dest, *ndest;
char buf[200];
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];
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
struct bgp_path_info *bi;
if (safi == SAFI_MPLS_VPN) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rn);
table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
for (nrn = bgp_table_top(table); nrn;
nrn = bgp_route_next(nrn))
for (bi = bgp_node_get_bgp_path_info(nrn); bi;
for (ndest = bgp_table_top(table); ndest;
ndest = bgp_route_next(ndest))
for (bi = bgp_dest_get_bgp_path_info(ndest); bi;
bi = bi->next)
bgp_addpath_populate_path(allocator, bi,
addpath_type);
} else {
for (bi = bgp_node_get_bgp_path_info(rn); bi;
for (bi = bgp_dest_get_bgp_path_info(dest); bi;
bi = bi->next)
bgp_addpath_populate_path(allocator, bi,
addpath_type);
@ -426,7 +426,7 @@ 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
* 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)
{
int i;
@ -442,7 +442,7 @@ void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi,
continue;
/* 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
&& !bgp_addpath_tx_path(i, pi)) {
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) */
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
&& bgp_addpath_tx_path(i, pi)) {
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,
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);
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)
{
struct bgp_adj_out *adj;
@ -153,7 +153,7 @@ bool bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
safi_t safi;
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)
if (paf->peer == peer) {
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)
{
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->attr != 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->uptime = bgp_clock();
adj->addpath_rx_id = addpath_id;
BGP_ADJ_IN_ADD(rn, adj);
bgp_lock_node(rn);
BGP_ADJ_IN_ADD(dest, adj);
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_ADJ_IN_DEL(rn, bai);
BGP_ADJ_IN_DEL(dest, bai);
peer_unlock(bai->peer); /* adj_in peer reference */
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)
{
struct bgp_adj_in *adj;
struct bgp_adj_in *adj_next;
adj = rn->adj_in;
adj = dest->adj_in;
if (!adj)
return false;
@ -224,8 +224,8 @@ bool bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
adj_next = adj->next;
if (adj->peer == peer && adj->addpath_rx_id == addpath_id) {
bgp_adj_in_remove(rn, adj);
bgp_unlock_node(rn);
bgp_adj_in_remove(dest, adj);
bgp_dest_unlock_node(dest);
}
adj = adj_next;

View File

@ -48,7 +48,7 @@ struct bgp_advertise {
struct bgp_advertise *prev;
/* Prefix information. */
struct bgp_node *rn;
struct bgp_dest *dest;
/* Reference pointer. */
struct bgp_adj_out *adj;
@ -74,7 +74,7 @@ struct bgp_adj_out {
TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
/* Prefix information. */
struct bgp_node *rn;
struct bgp_dest *dest;
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)
/* Prototypes. */
extern bool bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
extern bool bgp_adj_out_lookup(struct peer *, struct bgp_dest *, uint32_t);
extern void bgp_adj_in_set(struct bgp_dest *, struct peer *, struct attr *,
uint32_t);
extern bool bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
extern bool bgp_adj_in_unset(struct bgp_dest *, struct peer *, uint32_t);
extern void bgp_adj_in_remove(struct bgp_dest *, struct bgp_adj_in *);
extern void bgp_sync_init(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_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi = NULL, *bpiter;
struct bgp_adj_in *adjin = NULL, *adjiter;
@ -943,7 +943,7 @@ afibreak:
return true;
}
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) {
@ -991,7 +991,7 @@ afibreak:
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)
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 peer *peer;
struct bgp_node *bn;
struct bgp_dest *bn;
bool written = false;
bqe = bmp_pull(bmp);
@ -1129,8 +1129,8 @@ static void bmp_wrerr(struct bmp *bmp, struct pullwr *pullwr, bool eof)
bmp_free(bmp);
}
static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
afi_t afi, safi_t safi, struct bgp_node *bn, struct peer *peer)
static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp, afi_t afi,
safi_t safi, struct bgp_dest *bn, struct peer *peer)
{
struct bmp *bmp;
struct bmp_queue_entry *bqe, bqeref;
@ -1141,7 +1141,7 @@ static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
return;
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.afi = afi;
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,
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_targets *bt;

View File

@ -148,17 +148,18 @@ static int bgp_reuse_timer(struct thread *t)
/* if (figure-of-merit < reuse). */
if (bdi->penalty < bdc->reuse_limit) {
/* Reuse the route. */
bgp_path_info_unset_flag(bdi->rn, bdi->path,
bgp_path_info_unset_flag(bdi->dest, bdi->path,
BGP_PATH_DAMPED);
bdi->suppress_time = 0;
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_aggregate_increment(
bgp, bgp_node_get_prefix(bdi->rn),
bgp, bgp_dest_get_prefix(bdi->dest),
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)
@ -175,7 +176,7 @@ static int bgp_reuse_timer(struct thread *t)
}
/* 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)
{
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,
sizeof(struct bgp_damp_info));
bdi->path = path;
bdi->rn = rn;
bdi->dest = dest;
bdi->penalty =
(attr_change ? DEFAULT_PENALTY / 2 : DEFAULT_PENALTY);
bdi->flap = 1;
@ -226,13 +227,13 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_node *rn,
bdi->flap++;
}
assert((rn == bdi->rn) && (path == bdi->path));
assert((dest == bdi->dest) && (path == bdi->path));
bdi->lastrecord = BGP_RECORD_WITHDRAW;
bdi->t_updated = t_now;
/* 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. */
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
insert into reuse_list. */
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;
BGP_DAMP_LIST_DEL(bdc, bdi);
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;
}
int bgp_damp_update(struct bgp_path_info *path, struct bgp_node *rn, afi_t afi,
safi_t safi)
int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest,
afi_t afi, safi_t safi)
{
time_t t_now;
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;
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->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;
else if (CHECK_FLAG(bdi->path->flags, BGP_PATH_DAMPED)
&& (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_DAMP_LIST_ADD(bdc, bdi);
bdi->suppress_time = 0;
@ -312,11 +313,11 @@ void bgp_damp_info_free(struct bgp_damp_info *bdi, int withdraw, afi_t afi,
else
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);
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);
}

View File

@ -21,6 +21,8 @@
#ifndef _QUAGGA_BGP_DAMP_H
#define _QUAGGA_BGP_DAMP_H
#include "bgpd/bgp_table.h"
/* Structure maintained on a per-route basis. */
struct bgp_damp_info {
/* Doubly linked list. This information must be linked to
@ -47,7 +49,7 @@ struct bgp_damp_info {
struct bgp_path_info *path;
/* Back reference to bgp_node. */
struct bgp_node *rn;
struct bgp_dest *dest;
/* Current index in the reuse_list. */
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,
unsigned int, time_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);
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);
extern void bgp_damp_info_free(struct bgp_damp_info *path, int withdraw,
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;
}
bool bgp_debug_bestpath(struct bgp_node *rn)
bool bgp_debug_bestpath(struct bgp_dest *dest)
{
if (BGP_DEBUG(bestpath, BESTPATH)) {
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))
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 bool bgp_debug_update(struct peer *peer, const struct prefix *p,
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 const char *

View File

@ -302,13 +302,13 @@ static void bgp_dump_routes_index_table(struct bgp *bgp)
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 stream *obuf;
size_t sizep;
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;
stream_reset(obuf);
@ -391,7 +391,7 @@ static unsigned int bgp_dump_routes_func(int afi, int first_run,
unsigned int seq)
{
struct bgp_path_info *path;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp *bgp;
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. */
table = bgp->rib[afi][SAFI_UNICAST];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
path = bgp_node_get_bgp_path_info(rn);
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
path = bgp_dest_get_bgp_path_info(dest);
while (path) {
path = bgp_dump_route_node_record(afi, rn, path, seq);
path = bgp_dump_route_node_record(afi, dest, path, 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_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
/* If not imported (or doesn't have a parent), bail. */
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 */
rn = parent_ri->net;
if (!rn)
dest = parent_ri->net;
if (!dest)
return 0;
table = bgp_node_table(rn);
table = bgp_dest_table(dest);
if (table &&
table->afi == AFI_L2VPN &&
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_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
if (pi->sub_type != BGP_ROUTE_IMPORTED ||
!pi->extra ||
@ -128,10 +128,10 @@ static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
return true;
parent_pi = (struct bgp_path_info *)pi->extra->parent;
rn = parent_pi->net;
if (!rn)
dest = parent_pi->net;
if (!dest)
return true;
table = bgp_node_table(rn);
table = bgp_dest_table(dest);
if (table &&
table->afi == AFI_L2VPN &&
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,
struct bgp_node *rd_rn,
json_object *json,
char *rd_str, int len)
struct bgp_dest *rd_dest,
json_object *json, char *rd_str,
int len)
{
uint16_t type;
struct rd_as rd_as;
struct rd_ip rd_ip;
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;
@ -634,7 +634,7 @@ static void show_esi_routes(struct bgp *bgp,
json_object *json)
{
int header = 1;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
uint32_t prefix_cnt, path_cnt;
uint64_t tbl_ver;
@ -642,13 +642,13 @@ static void show_esi_routes(struct bgp *bgp,
prefix_cnt = path_cnt = 0;
tbl_ver = es->route_table->version;
for (rn = bgp_table_top(es->route_table); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(es->route_table); dest;
dest = bgp_route_next(dest)) {
int add_prefix_to_json = 0;
char prefix_str[BUFSIZ];
json_object *json_paths = 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,
sizeof(prefix_str));
@ -656,7 +656,7 @@ static void show_esi_routes(struct bgp *bgp,
if (json)
json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn);
pi = bgp_dest_get_bgp_path_info(dest);
if (pi) {
/* Overall header/legend displayed once. */
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,
json_object *json, int detail)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_table *table;
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;
tbl_ver = table->version;
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 *)bgp_node_get_prefix(rn);
(const struct prefix_evpn *)bgp_dest_get_prefix(dest);
int add_prefix_to_json = 0;
char prefix_str[BUFSIZ];
json_object *json_paths = 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,
sizeof(prefix_str));
bgp_evpn_route2str(
(struct prefix_evpn *)bgp_dest_get_prefix(dest),
prefix_str, sizeof(prefix_str));
if (type && evp->prefix.route_type != type)
continue;
@ -754,7 +754,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
if (json)
json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn);
pi = bgp_dest_get_bgp_path_info(dest);
if (pi) {
/* Overall header/legend displayed once. */
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();
if (detail)
route_vty_out_detail(vty, bgp, rn, pi,
route_vty_out_detail(vty, bgp, dest, pi,
AFI_L2VPN, SAFI_EVPN,
json_path);
else
@ -1167,8 +1167,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
afi_t afi = AFI_L2VPN;
struct bgp *bgp;
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_node *rm;
struct bgp_dest *dest;
struct bgp_dest *rm;
struct bgp_path_info *pi;
int rd_header;
int header = 1;
@ -1196,16 +1196,16 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (use_json)
json = json_object_new_object();
for (rn = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][SAFI_EVPN]); dest;
dest = bgp_route_next(dest)) {
uint64_t tbl_ver;
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)
continue;
table = bgp_node_get_bgp_table_info(rn);
table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
@ -1213,7 +1213,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
tbl_ver = table->version;
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)
continue;
@ -1294,8 +1294,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (use_json)
json_nroute =
json_object_new_object();
bgp_evpn_show_route_rd_header(vty, rn,
json_nroute, rd_str,
bgp_evpn_show_route_rd_header(
vty, dest, json_nroute, rd_str,
RD_ADDRSTRLEN);
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)
route_vty_out_tag(
vty, bgp_node_get_prefix(rm),
vty, bgp_dest_get_prefix(rm),
pi, no_display, SAFI_EVPN,
json_array);
else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay(
vty, bgp_node_get_prefix(rm),
vty, bgp_dest_get_prefix(rm),
pi, no_display, json_array);
else
route_vty_out(vty,
bgp_node_get_prefix(rm),
bgp_dest_get_prefix(rm),
pi, no_display, SAFI_EVPN,
json_array);
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) {
const struct prefix *p =
bgp_node_get_prefix(rm);
bgp_dest_get_prefix(rm);
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 prefix_evpn p;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
uint32_t path_cnt = 0;
afi_t afi;
@ -2342,8 +2342,8 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
/* See if route exists. */
build_evpn_type3_prefix(&p, orig_ip);
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json)
vty_out(vty, "%% Network not in table\n");
return;
@ -2353,17 +2353,16 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
json_paths = json_object_new_array();
/* 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. */
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;
if (json)
json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi,
json_path);
route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
if (json)
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 prefix_evpn p;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
uint32_t path_cnt = 0;
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. */
build_evpn_type2_prefix(&p, mac, ip);
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json)
vty_out(vty, "%% Network not in table\n");
return;
@ -2423,17 +2422,16 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
json_paths = json_object_new_array();
/* 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. */
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;
if (json)
json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi,
json_path);
route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
if (json)
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 prefix_evpn p;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
afi_t afi;
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. */
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);
if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
if (!json)
vty_out(vty, "%% Network not in table\n");
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));
/* 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)
json_paths = json_object_new_array();
/* 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;
if (json)
json_path = json_object_new_array();
route_vty_out_detail(vty, bgp, rn, pi, afi, safi,
json_path);
route_vty_out_detail(vty, bgp, dest, pi, afi, safi, json_path);
if (json)
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,
json_object *json)
{
struct bgp_node *rd_rn;
struct bgp_dest *rd_dest;
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
int rd_header = 1;
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));
rd_rn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd);
if (!rd_rn)
rd_dest = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)prd);
if (!rd_dest)
return;
table = bgp_node_get_bgp_table_info(rd_rn);
table = bgp_dest_get_bgp_table_info(rd_dest);
if (table == NULL)
return;
@ -2597,9 +2594,9 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
}
/* 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 *)bgp_node_get_prefix(rn);
(const struct prefix_evpn *)bgp_dest_get_prefix(dest);
json_object *json_prefix = NULL;
json_object *json_paths = NULL;
char prefix_str[BUFSIZ];
@ -2614,7 +2611,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json)
json_prefix = json_object_new_object();
pi = bgp_node_get_bgp_path_info(rn);
pi = bgp_dest_get_bgp_path_info(dest);
if (pi) {
/* RD header and legend - once overall. */
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. */
route_vty_out_detail_header(vty, bgp, rn, prd, afi,
route_vty_out_detail_header(vty, bgp, dest, prd, afi,
safi, json_prefix);
prefix_cnt++;
@ -2644,7 +2641,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json)
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);
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,
json_object *json, int detail)
{
struct bgp_node *rd_rn;
struct bgp_dest *rd_dest;
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
int header = detail ? 0 : 1;
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
* the RD.
*/
for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
rd_rn = bgp_route_next(rd_rn)) {
for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
rd_dest = bgp_route_next(rd_dest)) {
char rd_str[RD_ADDRSTRLEN];
json_object *json_rd = NULL; /* contains routes for an RD */
int add_rd_to_json = 0;
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)
continue;
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));
if (json)
@ -2738,17 +2735,18 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
rd_header = 1;
/* 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 =
NULL; /* contains prefix under a RD */
json_object *json_paths =
NULL; /* array of paths under a prefix*/
const struct prefix_evpn *evp =
(const struct prefix_evpn *)bgp_node_get_prefix(
rn);
(const struct prefix_evpn *)bgp_dest_get_prefix(
dest);
char prefix_str[BUFSIZ];
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,
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)
continue;
pi = bgp_node_get_bgp_path_info(rn);
pi = bgp_dest_get_bgp_path_info(dest);
if (pi) {
/* Overall header/legend displayed once. */
if (header) {
@ -2773,7 +2771,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
/* RD header - per RD. */
if (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_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. */
if (detail)
route_vty_out_detail_header(
vty, bgp, rn,
(struct prefix_rd *)rd_rnp, AFI_L2VPN,
vty, bgp, dest,
(struct prefix_rd *)rd_destp, AFI_L2VPN,
SAFI_EVPN, json_prefix);
/* 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) {
route_vty_out_detail(
vty, bgp, rn, pi, AFI_L2VPN,
vty, bgp, dest, pi, AFI_L2VPN,
SAFI_EVPN, json_path);
} else
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;
int i;
struct bgp_node *rn = pi->net;
struct bgp_dest *dest = pi->net;
struct bgp_pbr_entry_action *api_action;
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)
return true;
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)
{
struct bgp_path_info *pi;
struct bgp_node *rn;
struct bgp_dest *dest;
unsigned long total_count = 0;
json_object *json_paths = NULL;
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)
return CMD_SUCCESS;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
pi = bgp_node_get_bgp_path_info(rn);
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
pi = bgp_dest_get_bgp_path_info(dest);
if (pi == NULL)
continue;
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) {
total_count++;
route_vty_out_flowspec(vty, bgp_node_get_prefix(rn), pi,
display, json_paths);
route_vty_out_flowspec(vty, bgp_dest_get_prefix(dest),
pi, display, json_paths);
}
if (use_json) {
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,
json_object *json_paths)
{
struct bgp_node *rn;
struct bgp_dest *dest;
const struct prefix *prefix;
int display = 0;
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
prefix = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(rib); dest; dest = bgp_route_next(dest)) {
prefix = bgp_dest_get_prefix(dest);
if (prefix->family != AF_FLOWSPEC)
continue;
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
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
: NLRI_STRING_FORMAT_LARGE,
json_paths);

View File

@ -45,7 +45,7 @@ extern struct zclient *zclient;
int bgp_parse_fec_update(void)
{
struct stream *s;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp *bgp;
struct bgp_table *table;
struct prefix p;
@ -75,33 +75,33 @@ int bgp_parse_fec_update(void)
zlog_debug("no %u unicast table", p.family);
return -1;
}
rn = bgp_node_lookup(table, &p);
if (!rn) {
dest = bgp_node_lookup(table, &p);
if (!dest) {
zlog_debug("no node for the prefix");
return -1;
}
/* treat it as implicit withdraw - the label is invalid */
if (label == MPLS_INVALID_LABEL)
bgp_unset_valid_label(&rn->local_label);
bgp_unset_valid_label(&dest->local_label);
else {
label_ntop(label, 1, &rn->local_label);
bgp_set_valid_label(&rn->local_label);
label_ntop(label, 1, &dest->local_label);
bgp_set_valid_label(&dest->local_label);
}
SET_FLAG(rn->flags, BGP_NODE_LABEL_CHANGED);
bgp_unlock_node(rn);
bgp_process(bgp, rn, afi, safi);
SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
bgp_dest_unlock_node(dest);
bgp_process(bgp, dest, afi, safi);
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 *from;
mpls_label_t remote_label;
int reflect;
if (!rn || !pi || !to)
if (!dest || !pi || !to)
return 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))
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)
{
struct bgp_path_info *pi;
struct bgp_node *rn;
struct bgp_dest *dest;
pi = labelid;
/* Is this path still valid? */
@ -143,11 +143,11 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
return -1;
}
rn = pi->net;
dest = pi->net;
if (BGP_DEBUG(labelpool, LABELPOOL))
zlog_debug("%s: FEC %pRN label=%u, allocated=%d", __func__, rn,
new_label, allocated);
zlog_debug("%s: FEC %pRN label=%u, allocated=%d", __func__,
bgp_dest_to_rnode(dest), new_label, 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
&& pi->attr->label != MPLS_LABEL_NONE
&& CHECK_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
bgp_unregister_for_label(rn);
&& CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
bgp_unregister_for_label(dest);
label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
&rn->local_label);
bgp_set_valid_label(&rn->local_label);
&dest->local_label);
bgp_set_valid_label(&dest->local_label);
}
return 0;
}
@ -173,7 +173,8 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
flog_err(
EC_BGP_LABEL,
"%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);
@ -188,12 +189,13 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
/* Shouldn't happen: different label allocation */
flog_err(EC_BGP_LABEL,
"%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 */
}
label_ntop(new_label, 1, &rn->local_label);
bgp_set_valid_label(&rn->local_label);
label_ntop(new_label, 1, &dest->local_label);
bgp_set_valid_label(&dest->local_label);
/*
* 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;
}
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 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;
char addr[PREFIX_STRLEN];
p = bgp_node_get_prefix(rn);
local_label = &(rn->local_label);
p = bgp_dest_get_prefix(dest);
local_label = &(dest->local_label);
/* this prevents the loop when we're called by
* 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;
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
UNSET_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL);
UNSET_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL);
/* Set length and flags */
stream_putw_at(s, 0, stream_get_endp(s));

View File

@ -26,17 +26,18 @@
#define BGP_WITHDRAW_LABEL 0x800000
#define BGP_PREVENT_VRF_2_VRF_LEAK 0xFFFFFFFE
struct bgp_node;
struct bgp_dest;
struct bgp_path_info;
struct peer;
extern int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
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);
extern int bgp_parse_fec_update(void);
extern mpls_label_t bgp_adv_label(struct bgp_node *rn, struct bgp_path_info *pi,
struct peer *to, afi_t afi, safi_t safi);
extern mpls_label_t bgp_adv_label(struct bgp_dest *dest,
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,
struct bgp_nlri *packet);
@ -86,15 +87,15 @@ static inline void bgp_unset_valid_label(mpls_label_t *label)
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)
{
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 */

View File

@ -137,34 +137,37 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
struct bgp_table *table,
struct ethaddr *macaddr)
{
struct bgp_node *prn, *rn;
struct bgp_dest *pdest, *dest;
struct bgp_path_info *pi;
for (prn = bgp_table_top(table); prn; prn = bgp_route_next(prn)) {
struct bgp_table *sub = prn->info;
const struct prefix *prn_p = bgp_node_get_prefix(prn);
for (pdest = bgp_table_top(table); pdest;
pdest = bgp_route_next(pdest)) {
struct bgp_table *sub = pdest->info;
const struct prefix *pdest_p = bgp_dest_get_prefix(pdest);
if (!sub)
continue;
for (rn = bgp_table_top(sub); rn; rn = bgp_route_next(rn)) {
bool rn_affected;
const struct prefix *p = bgp_node_get_prefix(rn);
const struct prefix_evpn *pevpn = (const struct prefix_evpn *)p;
for (dest = bgp_table_top(sub); dest;
dest = bgp_route_next(dest)) {
bool dest_affected;
const struct prefix *p = bgp_dest_get_prefix(dest);
struct prefix_evpn *pevpn = (struct prefix_evpn *)dest;
struct prefix_rd prd;
uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL;
struct bgp_route_evpn evpn;
if (pevpn->family == AF_EVPN &&
pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE &&
memcmp(&p->u.prefix_evpn.macip_addr.mac,
macaddr, ETH_ALEN) == 0)
rn_affected = true;
if (pevpn->family == AF_EVPN
&& pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
&& memcmp(&p->u.prefix_evpn.macip_addr.mac, macaddr,
ETH_ALEN)
== 0)
dest_affected = true;
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)
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
* we don't care and since we are looking
*/
if ((memcmp(&pi->attr->rmac, macaddr, ETH_ALEN) != 0) &&
!rn_affected)
if ((memcmp(&pi->attr->rmac, macaddr, ETH_ALEN) != 0)
&& !dest_affected)
continue;
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.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 (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);
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
* 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 *old_best,
struct list *mp_list,
@ -530,7 +530,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
old_cum_bw = cum_bw = 0;
prev_mpath = new_best;
mp_node = listhead(mp_list);
debug = bgp_debug_bestpath(rn);
debug = bgp_debug_bestpath(dest);
if (new_best) {
mpath_count++;
@ -553,7 +553,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (debug)
zlog_debug(
"%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,
old_mpath_count, old_cum_bw);
@ -588,7 +589,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (debug)
zlog_debug(
"%pRN: comparing candidate %s with existing mpath %s",
rn,
bgp_dest_to_rnode(dest),
tmp_info ? tmp_info->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);
zlog_debug(
"%pRN: %s is still multipath, cur count %d",
rn, path_buf, mpath_count);
bgp_dest_to_rnode(dest),
path_buf, mpath_count);
}
} else {
mpath_changed = 1;
@ -626,7 +628,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
cur_mpath, path_buf);
zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d",
rn, path_buf,
bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr
->nexthop,
@ -659,7 +662,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
cur_mpath, path_buf);
zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d",
rn, path_buf,
bgp_dest_to_rnode(dest), path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr->nexthop,
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);
zlog_debug(
"%pRN: add mpath %s nexthop %s, cur count %d",
rn, path_buf,
bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET,
&new_mpath->attr
->nexthop,
@ -737,7 +741,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
zlog_debug(
"%pRN: New mpath count (incl newbest) %d mpath-change %s"
" all_paths_lb %d cum_bw u%" PRIu64,
rn, mpath_count,
bgp_dest_to_rnode(dest), mpath_count,
mpath_changed ? "YES" : "NO",
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_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_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 *old_best,
struct list *mp_list,

View File

@ -462,13 +462,13 @@ static void setlabels(struct bgp_path_info *bpi,
*/
static struct bgp_path_info *
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,
mpls_label_t *label, uint32_t num_labels, void *parent,
struct bgp *bgp_orig, struct prefix *nexthop_orig,
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_ultimate;
struct bgp_path_info *new;
@ -502,7 +502,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
/*
* 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)
break;
}
@ -574,7 +574,7 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
/* Process change. */
bgp_aggregate_increment(bgp, p, bpi, afi, safi);
bgp_process(bgp, bn, afi, safi);
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
if (debug)
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);
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)
new->extra->bgp_orig = bgp_lock(bgp_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_path_info_add(bn, new);
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
bgp_process(bgp, bn, afi, safi);
if (debug)
@ -654,14 +655,14 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */
{
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);
struct attr static_attr = {0};
struct attr *new_attr = NULL;
safi_t safi = SAFI_MPLS_VPN;
mpls_label_t label_val;
mpls_label_t label;
struct bgp_node *bn;
struct bgp_dest *bn;
const char *debugmsg;
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 */
{
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);
safi_t safi = SAFI_MPLS_VPN;
struct bgp_path_info *bpi;
struct bgp_node *bn;
struct bgp_dest *bn;
const char *debugmsg;
if (debug) {
@ -933,7 +934,7 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
* vrf -> vpn
* 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) {
break;
}
@ -947,7 +948,7 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
bgp_path_info_delete(bn, bpi);
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 */
@ -955,27 +956,27 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
afi_t afi)
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
struct bgp_node *prn;
struct bgp_dest *pdest;
safi_t safi = SAFI_MPLS_VPN;
/*
* Walk vpn table, delete bpi with bgp_orig == bgp_vrf
*/
for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn;
prn = bgp_route_next(prn)) {
for (pdest = bgp_table_top(bgp_vpn->rib[afi][safi]); pdest;
pdest = bgp_route_next(pdest)) {
struct bgp_table *table;
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
/* 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)
continue;
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) {
zlog_debug("%s: looking at prefix %pRN",
__func__, bn);
@ -998,7 +999,7 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
__func__);
bgp_aggregate_decrement(
bgp_vpn,
bgp_node_get_prefix(bn), bpi,
bgp_dest_get_prefix(bn), bpi,
afi, safi);
bgp_path_info_delete(bn, bpi);
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 */
afi_t afi)
{
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
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)
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) {
if (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_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);
struct attr static_attr = {0};
struct attr *new_attr = NULL;
struct bgp_node *bn;
struct bgp_dest *bn;
safi_t safi = SAFI_UNICAST;
const char *debugmsg;
struct prefix nexthop_orig;
@ -1214,7 +1215,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
if (bpi_ultimate->net) {
struct bgp_table *table;
table = bgp_node_table(bpi_ultimate->net);
table = bgp_dest_table(bpi_ultimate->net);
if (table && (table->safi == SAFI_UNICAST))
origin_local = 1;
}
@ -1276,7 +1277,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
safi_t safi = SAFI_UNICAST;
struct bgp *bgp;
struct listnode *mnode, *mnnode;
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
const char *debugmsg;
@ -1305,7 +1306,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
return;
}
p = bgp_node_get_prefix(path_vpn->net);
p = bgp_dest_get_prefix(path_vpn->net);
afi = family2afi(p->family);
/* 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);
for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
for (bpi = bgp_dest_get_bgp_path_info(bn); bpi;
bpi = bpi->next) {
if (bpi->extra
&& (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_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 */
afi_t afi)
{
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
safi_t safi = SAFI_UNICAST;
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;
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) {
if (bpi->extra
&& bpi->extra->bgp_orig != bgp_vrf
@ -1377,7 +1378,7 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */
/* delete route */
bgp_aggregate_decrement(bgp_vrf,
bgp_node_get_prefix(bn),
bgp_dest_get_prefix(bn),
bpi, afi, safi);
bgp_path_info_delete(bn, bpi);
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)
{
struct prefix_rd prd;
struct bgp_node *prn;
struct bgp_dest *pdest;
safi_t safi = SAFI_MPLS_VPN;
assert(bgp_vpn);
@ -1399,11 +1400,11 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
/*
* Walk vpn table
*/
for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn;
prn = bgp_route_next(prn)) {
const struct prefix *p = bgp_node_get_prefix(prn);
for (pdest = bgp_table_top(bgp_vpn->rib[afi][safi]); pdest;
pdest = bgp_route_next(pdest)) {
const struct prefix *p = bgp_dest_get_prefix(pdest);
struct bgp_table *table;
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
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);
/* 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)
continue;
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) {
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_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
if (pi->sub_type != BGP_ROUTE_IMPORTED ||
!pi->extra ||
@ -241,10 +241,10 @@ static inline bool is_route_injectable_into_vpn(struct bgp_path_info *pi)
return true;
parent_pi = (struct bgp_path_info *)pi->extra->parent;
rn = parent_pi->net;
if (!rn)
dest = parent_pi->net;
if (!dest)
return true;
table = bgp_node_table(rn);
table = bgp_dest_table(dest);
if (table &&
(table->afi == AFI_IP || table->afi == AFI_IP6) &&
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)
{
prefix2str(bgp_node_get_prefix(bnc->node), buf, size);
prefix2str(bgp_dest_get_prefix(bnc->dest), buf, size);
return buf;
}
@ -78,11 +78,11 @@ void bnc_free(struct bgp_nexthop_cache *bnc)
/* Reset and free all BGP nexthop cache. */
static void bgp_nexthop_cache_reset(struct bgp_table *table)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
bnc = bgp_node_get_bgp_nexthop_info(rn);
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
continue;
@ -93,8 +93,8 @@ static void bgp_nexthop_cache_reset(struct bgp_table *table)
}
bnc_free(bnc);
bgp_node_set_bgp_nexthop_info(rn, NULL);
bgp_unlock_node(rn);
bgp_dest_set_bgp_nexthop_info(dest, NULL);
bgp_dest_unlock_node(dest);
}
}
@ -345,7 +345,7 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
{
struct prefix p;
struct prefix *addr;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_connected_ref *bc;
struct listnode *node, *nnode;
struct peer *peer;
@ -361,16 +361,16 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
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);
bc = bgp_node_get_bgp_connected_ref_info(rn);
bc = bgp_dest_get_bgp_connected_ref_info(dest);
if (bc)
bc->refcnt++;
else {
bc = XCALLOC(MTYPE_BGP_CONN,
sizeof(struct bgp_connected_ref));
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)) {
@ -395,17 +395,17 @@ void bgp_connected_add(struct bgp *bgp, struct connected *ifc)
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);
bc = bgp_node_get_bgp_connected_ref_info(rn);
bc = bgp_dest_get_bgp_connected_ref_info(dest);
if (bc)
bc->refcnt++;
else {
bc = XCALLOC(MTYPE_BGP_CONN,
sizeof(struct bgp_connected_ref));
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 *addr;
struct bgp_node *rn = NULL;
struct bgp_dest *dest = NULL;
struct bgp_connected_ref *bc;
addr = ifc->address;
@ -427,7 +427,7 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
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) {
if (IN6_IS_ADDR_UNSPECIFIED(&p.u.prefix6))
return;
@ -437,46 +437,47 @@ void bgp_connected_delete(struct bgp *bgp, struct connected *ifc)
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;
bc = bgp_node_get_bgp_connected_ref_info(rn);
bc = bgp_dest_get_bgp_connected_ref_info(dest);
bc->refcnt--;
if (bc->refcnt == 0) {
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_unlock_node(rn);
bgp_dest_unlock_node(dest);
bgp_dest_unlock_node(dest);
}
static void bgp_connected_cleanup(struct route_table *table,
struct route_node *rn)
{
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)
return;
bc->refcnt--;
if (bc->refcnt == 0) {
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,
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;
struct bgp_addr tmp_addr = {{0}}, *addr = 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 =
((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC))
? 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)
{
struct bgp_node *rn1;
struct bgp_node *rn2;
struct bgp_dest *dest1;
struct bgp_dest *dest2;
struct prefix p;
int ret;
@ -556,32 +557,32 @@ bool bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = nexthop;
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn1)
dest1 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!dest1)
return false;
p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = peer->su.sin.sin_addr;
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!rn2) {
bgp_unlock_node(rn1);
dest2 = bgp_node_match(peer->bgp->connected_table[AFI_IP], &p);
if (!dest2) {
bgp_dest_unlock_node(dest1);
return false;
}
ret = (rn1 == rn2);
ret = (dest1 == dest2);
bgp_unlock_node(rn1);
bgp_unlock_node(rn2);
bgp_dest_unlock_node(dest1);
bgp_dest_unlock_node(dest2);
return ret;
}
bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
{
struct bgp_node *rn1;
struct bgp_node *rn2;
struct bgp_dest *dest1;
struct bgp_dest *dest2;
struct prefix p;
int ret;
@ -589,24 +590,24 @@ bool bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = nexthop;
rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn1)
dest1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!dest1)
return false;
p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = peer->su.sin6.sin6_addr;
rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!rn2) {
bgp_unlock_node(rn1);
dest2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
if (!dest2) {
bgp_dest_unlock_node(dest1);
return false;
}
ret = (rn1 == rn2);
ret = (dest1 == dest2);
bgp_unlock_node(rn1);
bgp_unlock_node(rn2);
bgp_dest_unlock_node(dest1);
bgp_dest_unlock_node(dest2);
return ret;
}
@ -615,7 +616,7 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
struct update_subgroup *subgrp,
struct peer *exclude)
{
struct bgp_node *rn1 = NULL, *rn2 = NULL;
struct bgp_dest *dest1 = NULL, *dest2 = NULL;
struct peer_af *paf = NULL;
struct prefix p = {0}, np = {0};
struct bgp *bgp = NULL;
@ -628,8 +629,8 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
p.prefixlen = IPV6_MAX_BITLEN;
bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np);
if (!rn1)
dest1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np);
if (!dest1)
return false;
SUBGRP_FOREACH_PEER (subgrp, paf) {
@ -638,18 +639,18 @@ bool bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
continue;
p.u.prefix6 = paf->peer->su.sin6.sin6_addr;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p);
if (rn1 == rn2) {
bgp_unlock_node(rn1);
bgp_unlock_node(rn2);
dest2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p);
if (dest1 == dest2) {
bgp_dest_unlock_node(dest1);
bgp_dest_unlock_node(dest2);
return true;
}
if (rn2)
bgp_unlock_node(rn2);
if (dest2)
bgp_dest_unlock_node(dest2);
}
bgp_unlock_node(rn1);
bgp_dest_unlock_node(dest1);
return false;
}
@ -657,7 +658,7 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
struct update_subgroup *subgrp,
struct peer *exclude)
{
struct bgp_node *rn1, *rn2;
struct bgp_dest *dest1, *dest2;
struct peer_af *paf;
struct prefix p, np;
struct bgp *bgp;
@ -670,8 +671,8 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
p.prefixlen = IPV4_MAX_BITLEN;
bgp = SUBGRP_INST(subgrp);
rn1 = bgp_node_match(bgp->connected_table[AFI_IP], &np);
if (!rn1)
dest1 = bgp_node_match(bgp->connected_table[AFI_IP], &np);
if (!dest1)
return false;
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;
rn2 = bgp_node_match(bgp->connected_table[AFI_IP], &p);
if (rn1 == rn2) {
bgp_unlock_node(rn1);
bgp_unlock_node(rn2);
dest2 = bgp_node_match(bgp->connected_table[AFI_IP], &p);
if (dest1 == dest2) {
bgp_dest_unlock_node(dest1);
bgp_dest_unlock_node(dest2);
return true;
}
if (rn2)
bgp_unlock_node(rn2);
if (dest2)
bgp_dest_unlock_node(dest2);
}
bgp_unlock_node(rn1);
bgp_dest_unlock_node(dest1);
return false;
}
static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
struct bgp_nexthop_cache *bnc)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *path;
int afi;
safi_t safi;
@ -709,21 +710,21 @@ static void bgp_show_nexthop_paths(struct vty *vty, struct bgp *bgp,
vty_out(vty, " Paths:\n");
LIST_FOREACH (path, &(bnc->paths), nh_thread) {
rn = path->net;
assert(rn && bgp_node_table(rn));
afi = family2afi(rn->p.family);
table = bgp_node_table(rn);
dest = path->net;
assert(dest && bgp_dest_table(dest));
afi = family2afi(bgp_dest_get_prefix(dest)->family);
table = bgp_dest_table(dest);
safi = table->safi;
bgp_path = table->bgp;
if (rn->prn) {
prefix_rd2str((struct prefix_rd *)&rn->prn->p,
if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1));
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
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,
struct bgp_node *rn,
struct bgp_dest *dest,
struct bgp_nexthop_cache *bnc,
bool specific)
{
char buf[PREFIX2STR_BUFFER];
time_t tbuf;
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;
@ -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,
bool import_table)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
afi_t afi;
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++) {
if (!table || !table[afi])
continue;
for (rn = bgp_table_top(table[afi]); rn;
rn = bgp_route_next(rn)) {
bnc = bgp_node_get_bgp_nexthop_info(rn);
for (dest = bgp_table_top(table[afi]); dest;
dest = bgp_route_next(dest)) {
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
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) {
struct prefix nhop;
struct bgp_table **table;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
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 ? \
bgp->import_check_table : bgp->nexthop_cache_table;
rn = bgp_node_lookup(table[family2afi(nhop.family)], &nhop);
if (!rn) {
dest = bgp_node_lookup(table[family2afi(nhop.family)], &nhop);
if (!dest) {
vty_out(vty, "specified nexthop is not found\n");
return CMD_SUCCESS;
}
bnc = bgp_node_get_bgp_nexthop_info(rn);
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) {
vty_out(vty, "specified nexthop does not have entry\n");
return CMD_SUCCESS;
}
bgp_show_nexthop(vty, bgp, rn, bnc, true);
bgp_show_nexthop(vty, bgp, dest, bnc, true);
} else
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_CONNECTED_CHANGED (1 << 2)
struct bgp_node *node;
struct bgp_dest *dest;
void *nht_info; /* In BGP, peer session */
LIST_HEAD(path_list, bgp_path_info) paths;
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 bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
uint8_t sub_type, struct attr *attr,
struct bgp_node *rn);
struct bgp_dest *dest);
extern struct bgp_nexthop_cache *bnc_new(void);
extern void bnc_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,
CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE));
bgp_node_set_bgp_nexthop_info(bnc->node, NULL);
bgp_unlock_node(bnc->node);
bnc->node = NULL;
bgp_dest_set_bgp_nexthop_info(bnc->dest, NULL);
bgp_dest_unlock_node(bnc->dest);
bnc->dest = NULL;
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)
{
struct prefix p;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
afi_t afi = family2afi(peer->su.sa.sa_family);
if (!sockunion2hostprefix(&peer->su, &p))
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)
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,
struct peer *peer, int connected)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
struct prefix p;
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;
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
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) {
bnc = bnc_new();
bgp_node_set_bgp_nexthop_info(rn, bnc);
bnc->node = rn;
bgp_dest_set_bgp_nexthop_info(dest, bnc);
bnc->dest = dest;
bnc->bgp = bgp_nexthop;
bgp_lock_node(rn);
bgp_dest_lock_node(dest);
if (BGP_DEBUG(nht, NHT)) {
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) {
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)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
struct prefix p;
@ -274,9 +274,9 @@ void bgp_delete_connected_nexthop(afi_t afi, struct peer *peer)
if (!sockunion2hostprefix(&peer->su, &p))
return;
rn = bgp_node_lookup(
dest = bgp_node_lookup(
peer->bgp->nexthop_cache_table[family2afi(p.family)], &p);
if (!rn) {
if (!dest) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
"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;
}
bnc = bgp_node_get_bgp_nexthop_info(rn);
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
"Cannot find connected NHT node for peer %s(%s) on route_node as expected",
peer->host, peer->bgp->name_pretty);
bgp_unlock_node(rn);
bgp_dest_unlock_node(dest);
return;
}
bgp_unlock_node(rn);
bgp_dest_unlock_node(dest);
if (bnc->nht_info != peer) {
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)",
bnc, peer->host, bnc->bgp->name_pretty);
unregister_zebra_rnh(bnc, 0);
bgp_node_set_bgp_nexthop_info(bnc->node, NULL);
bgp_unlock_node(bnc->node);
bgp_dest_set_bgp_nexthop_info(bnc->dest, NULL);
bgp_dest_unlock_node(bnc->dest);
bnc_free(bnc);
}
}
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 nexthop *nexthop;
struct nexthop *oldnh;
@ -347,15 +347,15 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
}
if (command == ZEBRA_NEXTHOP_UPDATE)
rn = bgp_node_lookup(
dest = bgp_node_lookup(
bgp->nexthop_cache_table[family2afi(nhr.prefix.family)],
&nhr.prefix);
else if (command == ZEBRA_IMPORT_CHECK_UPDATE)
rn = bgp_node_lookup(
dest = bgp_node_lookup(
bgp->import_check_table[family2afi(nhr.prefix.family)],
&nhr.prefix);
if (!rn) {
if (!dest) {
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
prefix2str(&nhr.prefix, buf, sizeof(buf));
@ -365,7 +365,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
return;
}
bnc = bgp_node_get_bgp_nexthop_info(rn);
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc) {
if (BGP_DEBUG(nht, NHT)) {
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",
buf, bgp->name_pretty);
}
bgp_unlock_node(rn);
bgp_dest_unlock_node(dest);
return;
}
bgp_unlock_node(rn);
bgp_dest_unlock_node(dest);
bnc->last_update = bgp_clock();
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)
{
afi_t afi;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
if (!bgp->nexthop_cache_table[afi])
continue;
for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn;
rn = bgp_route_next(rn)) {
bnc = bgp_node_get_bgp_nexthop_info(rn);
for (dest = bgp_table_top(bgp->nexthop_cache_table[afi]); dest;
dest = bgp_route_next(dest)) {
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
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))
? 1
: 0;
struct bgp_node *net = pi->net;
const struct prefix *p_orig = bgp_node_get_prefix(net);
struct bgp_dest *net = pi->net;
const struct prefix *p_orig = bgp_dest_get_prefix(net);
if (p_orig->family == AF_FLOWSPEC) {
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",
__func__);
}
p = bgp_node_get_prefix(bnc->node);
p = bgp_dest_get_prefix(bnc->dest);
if ((command == ZEBRA_NEXTHOP_REGISTER
|| command == ZEBRA_IMPORT_ROUTE_REGISTER)
&& (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)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *path;
int afi;
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))))
continue;
rn = path->net;
assert(rn && bgp_node_table(rn));
p = bgp_node_get_prefix(rn);
dest = path->net;
assert(dest && bgp_dest_table(dest));
p = bgp_dest_get_prefix(dest);
afi = family2afi(p->family);
table = bgp_node_table(rn);
table = bgp_dest_table(dest);
safi = table->safi;
/*
@ -760,11 +760,11 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
} else {
if (bgp_update_martian_nexthop(
bnc->bgp, afi, safi, path->type,
path->sub_type, path->attr, rn)) {
path->sub_type, path->attr, dest)) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
"%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
bnc_is_valid_nexthop =
bgp_isvalid_nexthop(bnc) ? true : false;
@ -773,17 +773,17 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
if (BGP_DEBUG(nht, NHT)) {
char buf1[RD_ADDRSTRLEN];
if (rn->prn) {
prefix_rd2str((struct prefix_rd *)&rn->prn->p,
if (dest->pdest) {
prefix_rd2str((struct prefix_rd *)bgp_dest_get_prefix(dest->pdest),
buf1, sizeof(buf1));
zlog_debug(
"... 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);
} else
zlog_debug(
"... 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);
}
@ -812,28 +812,28 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
*/
bgp_aggregate_decrement(bgp_path, p, path, afi,
safi);
bgp_path_info_unset_flag(rn, path,
bgp_path_info_unset_flag(dest, path,
BGP_PATH_VALID);
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,
afi, safi, &rn->p, path);
afi, safi, bgp_dest_get_prefix(dest), path);
} else {
/* Path becomes valid, set flag; also for EVPN
* routes, import from VRFs if needed.
*/
bgp_path_info_set_flag(rn, path,
bgp_path_info_set_flag(dest, path,
BGP_PATH_VALID);
bgp_aggregate_increment(bgp_path, p, path, afi,
safi);
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,
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) {
@ -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)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
afi_t afi;
@ -896,9 +896,9 @@ void bgp_nht_register_nexthops(struct bgp *bgp)
if (!bgp->nexthop_cache_table[afi])
continue;
for (rn = bgp_table_top(bgp->nexthop_cache_table[afi]); rn;
rn = bgp_route_next(rn)) {
bnc = bgp_node_get_bgp_nexthop_info(rn);
for (dest = bgp_table_top(bgp->nexthop_cache_table[afi]); dest;
dest = bgp_route_next(dest)) {
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
continue;
@ -911,7 +911,7 @@ void bgp_nht_register_nexthops(struct bgp *bgp)
void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
{
struct bgp *bgp;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
struct nexthop *nhop;
struct interface *ifp;
@ -933,11 +933,11 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
if (p.family != AF_INET6)
return;
rn = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!rn)
dest = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!dest)
return;
bnc = bgp_node_get_bgp_nexthop_info(rn);
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
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)
{
struct bgp *bgp;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
struct nexthop *nhop;
struct interface *ifp;
@ -983,11 +983,11 @@ void bgp_nht_dereg_enhe_cap_intfs(struct peer *peer)
if (p.family != AF_INET6)
return;
rn = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!rn)
dest = bgp_node_lookup(bgp->nexthop_cache_table[AFI_IP6], &p);
if (!dest)
return;
bnc = bgp_node_get_bgp_nexthop_info(rn);
bnc = bgp_dest_get_bgp_nexthop_info(dest);
if (!bnc)
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);
struct bgp_node;
struct bgp_path_info;
extern void bgp_pbr_update_entry(struct bgp *bgp, const struct prefix *p,
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;
/* Back pointer to the prefix node */
struct bgp_node *net;
struct bgp_dest *net;
/* Back pointer to the nexthop structure */
struct bgp_nexthop_cache *nexthop;
@ -436,9 +436,9 @@ enum bgp_path_type {
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)
@ -455,12 +455,12 @@ static inline bool is_pi_family_matching(struct bgp_path_info *pi,
afi_t afi, safi_t safi)
{
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
rn = pi->net;
if (!rn)
dest = pi->net;
if (!dest)
return false;
table = bgp_node_table(rn);
table = bgp_dest_table(dest);
if (table &&
table->afi == afi &&
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,
struct bgp_path_info_extra *dst_pie,
struct bgp_node *rn,
struct bgp_dest *dest,
struct bgp_path_info *src_pi,
struct peer *peer, struct attr *attr)
{
memset(dst_pi, 0, sizeof(struct bgp_path_info));
dst_pi->peer = peer;
dst_pi->attr = attr;
dst_pi->net = rn;
dst_pi->net = dest;
dst_pi->flags = src_pi->flags;
dst_pi->type = src_pi->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() */
DECLARE_HOOK(bgp_process,
(struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_node *bn, struct peer *peer, bool withdraw),
(struct bgp * bgp, afi_t afi, safi_t safi, struct bgp_dest *bn,
struct peer *peer, bool withdraw),
(bgp, afi, safi, bn, peer, withdraw))
/* 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);
extern void bgp_process_queue_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_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,
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_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_reap(struct bgp_node *rn, 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_reap(struct bgp_dest *dest, 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 *
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);
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);
extern void bgp_path_info_path_with_addpath_rx_str(struct bgp_path_info *pi,
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);
/* 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
@ -613,7 +614,7 @@ extern safi_t bgp_node_safi(struct vty *);
extern struct bgp_path_info *info_make(int type, int sub_type,
unsigned short instance,
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,
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,
struct bgp_path_info *selected,
struct bgp_node *rn,
struct bgp_dest *dest,
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 update_subgroup *subgrp,
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);
/* 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,
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);
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);
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_path_info_pair *result, afi_t afi,
safi_t safi);
extern void bgp_zebra_clear_route_change_flags(struct bgp_node *rn);
extern bool bgp_zebra_has_route_changed(struct bgp_node *rn,
struct bgp_path_info *selected);
extern void bgp_zebra_clear_route_change_flags(struct bgp_dest *dest);
extern bool bgp_zebra_has_route_changed(struct bgp_path_info *selected);
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,
safi_t safi, json_object *json);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct bgp_node *bn,
struct bgp_path_info *path,
afi_t afi, safi_t safi,
json_object *json_paths);
struct bgp_dest *bn,
struct bgp_path_info *path, afi_t afi,
safi_t safi, json_object *json_paths);
extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd,
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 bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
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 */

View File

@ -1027,11 +1027,11 @@ route_match_rd(void *rule, const struct prefix *prefix,
prd_rule = (struct prefix_rd *)rule;
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;
prd_route =
(struct prefix_rd *)bgp_node_get_prefix(path->net->prn);
prd_route = (struct prefix_rd *)bgp_dest_get_prefix(
path->net->pdest);
if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
return RMAP_MATCH;
}
@ -3705,7 +3705,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
afi_t afi;
safi_t safi;
struct peer *peer;
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_static *bgp_static;
struct bgp_aggregate *aggregate;
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 (bn = bgp_table_top(bgp->route[afi][safi]); 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)
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) {
const struct prefix *bn_p =
bgp_node_get_prefix(bn);
bgp_dest_get_prefix(bn);
if (bgp_debug_zebra(bn_p))
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 (bn = bgp_table_top(bgp->aggregate[afi][safi]); bn;
bn = bgp_route_next(bn)) {
aggregate = bgp_node_get_bgp_aggregate_info(bn);
aggregate = bgp_dest_get_bgp_aggregate_info(bn);
if (!aggregate)
continue;
@ -3813,7 +3813,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
if (route_update) {
const struct prefix *bn_p =
bgp_node_get_prefix(bn);
bgp_dest_get_prefix(bn);
if (bgp_debug_zebra(bn_p))
zlog_debug(

View File

@ -127,8 +127,7 @@ static enum route_map_cmd_result_t route_match(void *rule,
route_map_object_t type,
void *object);
static void *route_match_compile(const char *arg);
static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
safi_t safi);
static void revalidate_bgp_node(struct bgp_dest *dest, afi_t afi, safi_t safi);
static void revalidate_all_routes(void);
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])
continue;
struct bgp_node *match;
struct bgp_node *node;
struct bgp_dest *match;
struct bgp_dest *node;
match = bgp_table_subtree_lookup(
peer->bgp->rib[afi][safi], prefix);
node = match;
while (node) {
if (bgp_node_has_bgp_path_info_data(
if (bgp_dest_has_bgp_path_info_data(
node)) {
revalidate_bgp_node(node, afi,
safi);
@ -427,15 +426,15 @@ static int bgpd_sync_callback(struct thread *thread)
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)
{
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;
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;
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;
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,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
num_labels, 1, NULL);

View File

@ -660,7 +660,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
int offsetlen;
struct bgp_path_info *path;
struct bgp_path_info *min;
struct bgp_node *rn;
struct bgp_dest *dest;
union sockunion su;
unsigned int len;
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);
/* 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);
if (rn) {
bgp_unlock_node(rn);
if (dest) {
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)
if (sockunion_same(&path->peer->su, &su))
return path;
@ -703,7 +703,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
len = offsetlen;
if (offsetlen == 0)
rn = bgp_table_top(bgp->rib[AFI_IP][SAFI_UNICAST]);
dest = bgp_table_top(bgp->rib[AFI_IP][SAFI_UNICAST]);
else {
if (len > IN_ADDR_SIZE)
len = IN_ADDR_SIZE;
@ -718,7 +718,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
else
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);
offset++;
@ -734,13 +734,13 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
} else
paddr.s_addr = INADDR_ANY;
if (!rn)
if (!dest)
return NULL;
do {
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) {
if (path->peer->su.sin.sin_family == AF_INET
&& ntohl(paddr.s_addr)
@ -762,7 +762,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
if (min) {
const struct prefix *rn_p =
bgp_node_get_prefix(rn);
bgp_dest_get_prefix(dest);
*length =
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->prefixlen = rn_p->prefixlen;
bgp_unlock_node(rn);
bgp_dest_unlock_node(dest);
return min;
}
paddr.s_addr = INADDR_ANY;
} while ((rn = bgp_route_next(rn)) != NULL);
} while ((dest = bgp_route_next(dest)) != 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));
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_table *rt;
bgp_node = bgp_node_from_rnode(node);
bgp_node = bgp_dest_from_rnode(node);
rt = table->info;
if (rt->bgp) {
@ -140,7 +140,7 @@ void bgp_delete_listnode(struct bgp_node *node)
* route node in gr_info
*/
if (CHECK_FLAG(node->flags, BGP_NODE_SELECT_DEFER)) {
table = bgp_node_table(node);
table = bgp_dest_table(node);
if (table) {
bgp = table->bgp;
@ -149,7 +149,7 @@ void bgp_delete_listnode(struct bgp_node *node)
} else
return;
rn = bgp_node_to_rnode(node);
rn = bgp_dest_to_rnode(node);
if (bgp && rn && rn->lock == 1) {
/* 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,
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;
if (node == NULL)
@ -175,7 +175,7 @@ struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
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 (!prefix_match(p, node_p))
@ -193,13 +193,13 @@ struct bgp_node *bgp_table_subtree_lookup(const struct bgp_table *table,
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)]);
}
if (!matched)
return NULL;
bgp_lock_node(matched);
bgp_dest_lock_node(matched);
return matched;
}

View File

@ -21,6 +21,10 @@
#ifndef _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 "table.h"
#include "queue.h"
@ -28,8 +32,6 @@
#include "bgpd.h"
#include "bgp_advertise.h"
extern void bgp_delete_listnode(struct bgp_node *node);
struct bgp_table {
/* table belongs to this instance */
struct bgp *bgp;
@ -84,9 +86,9 @@ struct bgp_node {
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;
@ -105,6 +107,7 @@ struct bgp_node {
enum bgp_path_selection_reason reason;
};
extern void bgp_delete_listnode(struct bgp_dest *dest);
/*
* 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);
route_unlock_node(bgp_node_to_rnode(node));
bgp_delete_listnode(dest);
route_unlock_node(bgp_dest_to_rnode(dest));
}
/*
* 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
*/
static inline struct bgp_node *
static inline struct bgp_dest *
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
*/
static inline struct bgp_node *
static inline struct bgp_dest *
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
*/
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
*/
static inline struct bgp_node *bgp_route_next_until(struct bgp_node *node,
struct bgp_node *limit)
static inline struct bgp_dest *bgp_route_next_until(struct bgp_dest *dest,
struct bgp_dest *limit)
{
struct route_node *rnode;
rnode = route_next_until(bgp_node_to_rnode(node),
bgp_node_to_rnode(limit));
return bgp_node_from_rnode(rnode);
rnode = route_next_until(bgp_dest_to_rnode(dest),
bgp_dest_to_rnode(limit));
return bgp_dest_from_rnode(rnode);
}
/*
* 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)
{
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
*/
static inline struct bgp_node *
static inline struct bgp_dest *
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
*/
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)
{
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
*/
static inline struct bgp_node *
static inline struct bgp_dest *
bgp_node_match_ipv4(const struct bgp_table *table, struct in_addr *addr)
{
return bgp_node_from_rnode(
route_node_match_ipv4(table->route_table, addr));
struct route_node *rn = route_node_match_ipv4(table->route_table, addr);
return bgp_dest_from_rnode(rn);
}
/*
* 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)
{
return bgp_node_from_rnode(
route_node_match_ipv6(table->route_table, addr));
struct route_node *rn = 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)
@ -276,10 +290,10 @@ static inline unsigned long bgp_table_count(const struct bgp_table *const table)
/*
* 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)
{
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
*/
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.
*/
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);
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
bgp_node_set_bgp_aggregate_info(struct bgp_node *node,
bgp_dest_set_bgp_aggregate_info(struct bgp_dest *dest,
struct bgp_aggregate *aggregate)
{
node->info = aggregate;
dest->info = aggregate;
}
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)
{
node->info = distance;
dest->info = distance;
}
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)
{
node->info = bgp_static;
dest->info = bgp_static;
}
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
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)
{
node->info = bc;
dest->info = bc;
}
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)
{
node->info = bnc;
dest->info = bnc;
}
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)
{
node->info = bi;
dest->info = bi;
}
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)
{
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

View File

@ -1177,8 +1177,8 @@ static void update_subgroup_copy_adj_out(struct update_subgroup *source,
/*
* Copy the adj out.
*/
aout_copy =
bgp_adj_out_alloc(dest, aout->rn, aout->addpath_tx_id);
aout_copy = bgp_adj_out_alloc(dest, aout->dest,
aout->addpath_tx_id);
aout_copy->attr =
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 */
struct updwalk_context {
struct vty *vty;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
uint64_t updgrp_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,
int withdraw);
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 update_group_announce(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 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);
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 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 attr *attr,
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,
char withdraw, uint32_t addpath_tx_id);
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);
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,
uint32_t addpath_tx_id)
{
struct bgp_adj_out lookup;
if (!rn || !subgrp)
if (!dest || !subgrp)
return NULL;
/* 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.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)
@ -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
* 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) {
for (pi = bgp_node_get_bgp_path_info(ctx->rn);
pi; pi = pi->next) {
for (pi = bgp_dest_get_bgp_path_info(ctx->dest); pi;
pi = pi->next) {
id = bgp_addpath_id_for_peer(peer, afi, safi,
&pi->tx_addpath);
@ -125,7 +125,7 @@ static void subgrp_withdraw_stale_addpath(struct updwalk_context *ctx,
if (!pi) {
subgroup_process_announce_selected(
subgrp, NULL, ctx->rn,
subgrp, NULL, ctx->dest,
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))
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) {
@ -165,14 +165,14 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
if (addpath_capable) {
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) {
/* Skip the bestpath for now */
if (pi == ctx->pi)
continue;
subgroup_process_announce_selected(
subgrp, pi, ctx->rn,
subgrp, pi, ctx->dest,
bgp_addpath_id_for_peer(
peer, afi, safi,
&pi->tx_addpath));
@ -184,7 +184,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
*/
if (ctx->pi)
subgroup_process_announce_selected(
subgrp, ctx->pi, ctx->rn,
subgrp, ctx->pi, ctx->dest,
bgp_addpath_id_for_peer(
peer, afi, safi,
&ctx->pi->tx_addpath));
@ -194,7 +194,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
else {
if (ctx->pi) {
subgroup_process_announce_selected(
subgrp, ctx->pi, ctx->rn,
subgrp, ctx->pi, ctx->dest,
bgp_addpath_id_for_peer(
peer, afi, safi,
&ctx->pi->tx_addpath));
@ -203,12 +203,12 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
* had advertised and
* send a withdraw */
RB_FOREACH_SAFE (adj, bgp_adj_out_rb,
&ctx->rn->adj_out,
&ctx->dest->adj_out,
adj_next) {
if (adj->subgroup == subgrp) {
subgroup_process_announce_selected(
subgrp, NULL,
ctx->rn,
ctx->dest,
adj->addpath_tx_id);
}
}
@ -226,7 +226,7 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
struct bgp_table *table;
struct bgp_adj_out *adj;
unsigned long output_count;
struct bgp_node *rn;
struct bgp_dest *dest;
int header1 = 1;
struct bgp *bgp;
int header2 = 1;
@ -239,10 +239,10 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
output_count = 0;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
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 (header1) {
vty_out(vty,
@ -260,16 +260,17 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
}
if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv
&& adj->adv->baa) {
route_vty_out_tmp(
vty, rn_p, adj->adv->baa->attr,
SUBGRP_SAFI(subgrp), 0, NULL);
route_vty_out_tmp(vty, dest_p,
adj->adv->baa->attr,
SUBGRP_SAFI(subgrp),
0, NULL);
output_count++;
}
if ((flags & UPDWALK_FLAGS_ADVERTISED)
&& adj->attr) {
route_vty_out_tmp(vty, rn_p, adj->attr,
SUBGRP_SAFI(subgrp),
0, NULL);
route_vty_out_tmp(
vty, dest_p, adj->attr,
SUBGRP_SAFI(subgrp), 0, NULL);
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.
*/
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)
{
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->addpath_tx_id = addpath_tx_id;
if (rn) {
RB_INSERT(bgp_adj_out_rb, &rn->adj_out, adj);
bgp_lock_node(rn);
adj->rn = rn;
if (dest) {
RB_INSERT(bgp_adj_out_rb, &dest->adj_out, adj);
bgp_dest_lock_node(dest);
adj->dest = dest;
}
TAILQ_INSERT_TAIL(&(subgrp->adjq), adj, subgrp_adj_train);
@ -445,7 +446,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
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 bgp_path_info *path)
{
@ -464,12 +465,12 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
/* Look for adjacency information. */
adj = adj_lookup(
rn, subgrp,
dest, subgrp,
bgp_addpath_id_for_peer(peer, afi, safi, &path->tx_addpath));
if (!adj) {
adj = bgp_adj_out_alloc(
subgrp, rn,
subgrp, dest,
bgp_addpath_id_for_peer(peer, afi, safi,
&path->tx_addpath));
if (!adj)
@ -481,7 +482,7 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
adj->adv = bgp_advertise_new();
adv = adj->adv;
adv->rn = rn;
adv->dest = dest;
assert(adv->pathi == NULL);
/* bgp_path_info adj_out reference */
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);
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 "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.
*/
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,
uint32_t addpath_tx_id)
{
@ -528,7 +529,7 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
return;
/* 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. */
if (adj->adv)
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.
*/
if (CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)
&& is_default_prefix(&rn->p))
&& is_default_prefix(bgp_dest_get_prefix(dest)))
return;
if (adj->attr && withdraw) {
/* We need advertisement structure. */
adj->adv = bgp_advertise_new();
adv = adj->adv;
adv->rn = rn;
adv->dest = dest;
adv->adj = adj;
/* 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);
} else {
/* 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. */
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)
{
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)
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);
}
@ -594,9 +595,9 @@ void subgroup_clear_table(struct update_subgroup *subgrp)
struct bgp_adj_out *aout, *taout;
SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) {
struct bgp_node *rn = aout->rn;
bgp_adj_out_remove_subgroup(rn, aout, subgrp);
bgp_unlock_node(rn);
struct bgp_dest *dest = aout->dest;
bgp_adj_out_remove_subgroup(dest, aout, subgrp);
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,
struct bgp_table *table)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *ri;
struct attr attr;
struct peer *peer;
@ -630,19 +631,19 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate(subgrp, 0);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
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)
|| (addpath_capable
&& bgp_addpath_tx_path(
peer->addpath_type[afi][safi],
ri))) {
if (subgroup_announce_check(rn, ri, subgrp,
rn_p, &attr))
bgp_adj_out_set_subgroup(rn, subgrp,
if (subgroup_announce_check(dest, ri, subgrp,
dest_p, &attr))
bgp_adj_out_set_subgroup(dest, subgrp,
&attr, ri);
else {
/* If default originate is enabled for
@ -654,11 +655,11 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
if (CHECK_FLAG(
peer->af_flags[afi][safi],
PEER_FLAG_DEFAULT_ORIGINATE)
&& is_default_prefix(&rn->p))
&& is_default_prefix(bgp_dest_get_prefix(dest)))
break;
bgp_adj_out_unset_subgroup(
rn, subgrp, 1,
dest, subgrp, 1,
bgp_addpath_id_for_peer(
peer, afi, safi,
&ri->tx_addpath));
@ -689,7 +690,7 @@ void subgroup_announce_table(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 peer *onlypeer;
@ -712,9 +713,9 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
&& SUBGRP_SAFI(subgrp) != SAFI_EVPN)
subgroup_announce_table(subgrp, NULL);
else
for (rn = bgp_table_top(update_subgroup_rib(subgrp)); rn;
rn = bgp_route_next(rn)) {
table = bgp_node_get_bgp_table_info(rn);
for (dest = bgp_table_top(update_subgroup_rib(subgrp)); dest;
dest = bgp_route_next(dest)) {
table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
subgroup_announce_table(subgrp, table);
@ -729,7 +730,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
struct aspath *aspath;
struct prefix p;
struct peer *from;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
struct peer *peer;
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
* route only if route-map has a match.
*/
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
ret = route_map_apply(peer->default_rmap[afi][safi].map,
bgp_node_get_prefix(rn), RMAP_BGP,
&bpi_rmap);
bgp_dest_get_prefix(dest),
RMAP_BGP, &bpi_rmap);
if (ret != RMAP_DENYMATCH)
break;
@ -803,7 +804,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
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) {
/* 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
* route
*/
if (rn != NULL) {
for (pi = bgp_node_get_bgp_path_info(rn); pi;
if (dest != NULL) {
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
if (subgroup_announce_check(
rn, pi, subgrp, &rn->p,
dest, pi, subgrp,
bgp_dest_get_prefix(dest),
&attr))
bgp_adj_out_set_subgroup(
rn, subgrp, &attr, pi);
dest, subgrp, &attr,
pi);
}
}
} 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
* table.
*/
if (rn != NULL) {
if (dest != NULL) {
/* Remove the adjacency for the previously
* advertised default route
*/
adj = adj_lookup(
rn, subgrp,
dest, subgrp,
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
if (adj != NULL) {
/* Clean up previous advertisement. */
@ -852,13 +855,13 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
subgrp, adj);
/* Remove 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. */
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.
*/
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;
ctx.pi = pi;
ctx.rn = rn;
ctx.dest = dest;
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 bgp_adj_out *adj;
struct bgp_advertise *adv;
struct bgp_node *rn = NULL;
struct bgp_dest *dest = NULL;
struct bgp_path_info *path = NULL;
bgp_size_t total_attr_len = 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);
while (adv) {
const struct prefix *rn_p;
const struct prefix *dest_p;
assert(adv->rn);
rn = adv->rn;
rn_p = bgp_node_get_prefix(rn);
assert(adv->dest);
dest = adv->dest;
dest_p = bgp_dest_get_prefix(dest);
adj = adv->adj;
addpath_tx_id = adj->addpath_tx_id;
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))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(afi, safi, rn_p);
space_needed =
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. */
if (space_remaining < space_needed)
@ -806,7 +807,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
- BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(
afi, safi, rn_p);
afi, safi, dest_p);
/* If the attributes alone do not leave any room for
* NLRI then
@ -836,16 +837,16 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if ((afi == AFI_IP && safi == SAFI_UNICAST)
&& !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);
else {
/* Encode the prefix in MP_REACH_NLRI attribute */
if (rn->prn)
prd = (struct prefix_rd *)bgp_node_get_prefix(
rn->prn);
if (dest->pdest)
prd = (struct prefix_rd *)bgp_dest_get_prefix(
dest->pdest);
if (safi == SAFI_LABELED_UNICAST) {
label = bgp_adv_label(rn, path, peer, afi,
label = bgp_adv_label(dest, path, peer, afi,
safi);
label_pnt = &label;
num_labels = 1;
@ -859,7 +860,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
snlri, peer, afi, safi, &vecarr,
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,
addpath_encode, addpath_tx_id,
adv->baa->attr);
@ -867,7 +868,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
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];
if (!send_attr_printed) {
@ -891,10 +892,10 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
send_attr_printed = 1;
}
bgp_debug_rdpfxpath2str(afi, safi, prd, rn_p, label_pnt,
num_labels, addpath_encode,
addpath_tx_id, pfx_buf,
sizeof(pfx_buf));
bgp_debug_rdpfxpath2str(afi, safi, prd, dest_p,
label_pnt, num_labels,
addpath_encode, addpath_tx_id,
pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s",
subgrp->update_group->id, subgrp->id,
pfx_buf);
@ -958,7 +959,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
struct bgp_adj_out *adj;
struct bgp_advertise *adv;
struct peer *peer;
struct bgp_node *rn;
struct bgp_dest *dest;
bgp_size_t unfeasible_len;
bgp_size_t total_attr_len;
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;
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;
rn = adv->rn;
rn_p = bgp_node_get_prefix(rn);
dest = adv->dest;
dest_p = bgp_dest_get_prefix(dest);
addpath_tx_id = adj->addpath_tx_id;
space_remaining =
STREAM_WRITEABLE(s) - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ BGP_TOTAL_ATTR_LEN
+ bgp_packet_mpattr_prefix_size(afi, safi, rn_p);
space_needed =
BGP_NLRI_LENGTH + addpath_overhead + BGP_TOTAL_ATTR_LEN
+ bgp_packet_mpattr_prefix_size(afi, safi, dest_p);
if (space_remaining < space_needed)
break;
@ -1016,12 +1017,12 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
if (afi == AFI_IP && safi == SAFI_UNICAST
&& !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);
else {
if (rn->prn)
prd = (struct prefix_rd *)bgp_node_get_prefix(
rn->prn);
if (dest->pdest)
prd = (struct prefix_rd *)bgp_dest_get_prefix(
dest->pdest);
/* 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);
}
bgp_packet_mpunreach_prefix(s, rn_p, afi, safi, prd,
bgp_packet_mpunreach_prefix(s, dest_p, afi, safi, prd,
NULL, 0, addpath_encode,
addpath_tx_id, NULL);
}
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];
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,
pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64
@ -1069,8 +1070,8 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
subgrp->scount--;
bgp_adj_out_remove_subgroup(rn, adj, subgrp);
bgp_unlock_node(rn);
bgp_adj_out_remove_subgroup(dest, adj, subgrp);
bgp_dest_unlock_node(dest);
}
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_table *table;
struct bgp_node *rn;
struct bgp_node *rm;
struct bgp_dest *dest;
struct bgp_dest *rm;
int rd_header;
int header = 1;
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", "?");
}
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
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;
table = bgp_node_get_bgp_table_info(rn);
table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL)
continue;
@ -109,7 +109,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
break;
}
if (bgp_node_get_bgp_path_info(rm) == NULL)
if (bgp_dest_get_bgp_path_info(rm) == NULL)
continue;
if (!attr)
@ -160,7 +160,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
#endif
const uint8_t *pnt;
pnt = rn_p->u.val;
pnt = dest_p->u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
@ -225,7 +225,7 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
}
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);
output_count++;
}

View File

@ -8004,8 +8004,8 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
{
int ret;
struct prefix match;
struct bgp_node *rn;
struct bgp_node *rm;
struct bgp_dest *dest;
struct bgp_dest *rm;
struct bgp *bgp;
struct bgp_table *table;
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];
if (safi == SAFI_MPLS_VPN) {
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(rib); dest;
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;
table = bgp_node_get_bgp_table_info(rn);
table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL)
continue;
if ((rm = bgp_node_match(table, &match)) != NULL) {
const struct prefix *rm_p =
bgp_node_get_prefix(rm);
bgp_dest_get_prefix(rm);
if (rm_p->prefixlen == match.prefixlen) {
SET_FLAG(rm->flags,
BGP_NODE_USER_CLEAR);
bgp_process(bgp, rm, afi, safi);
}
bgp_unlock_node(rm);
bgp_dest_unlock_node(rm);
}
}
} else {
if ((rn = bgp_node_match(rib, &match)) != NULL) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
if ((dest = bgp_node_match(rib, &match)) != NULL) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (rn_p->prefixlen == match.prefixlen) {
SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
bgp_process(bgp, rn, afi, safi);
if (dest_p->prefixlen == match.prefixlen) {
SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
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);
vty_out(vty, "%ld RIB nodes, using %s of memory\n", count,
mtype_memstr(memstrbuf, sizeof(memstrbuf),
count * sizeof(struct bgp_node)));
count * sizeof(struct bgp_dest)));
count = mtype_stats_alloc(MTYPE_BGP_ROUTE);
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, "ribMemory",
ents * sizeof(struct bgp_node));
ents * sizeof(struct bgp_dest));
ents = bgp->af_peer_count[afi][safi];
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,
"RIB entries %ld, using %s of memory\n",
ents,
mtype_memstr(memstrbuf,
sizeof(memstrbuf),
ents * sizeof(struct
bgp_node)));
mtype_memstr(
memstrbuf, sizeof(memstrbuf),
ents
* sizeof(struct
bgp_dest)));
/* Peer related usage */
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;
}
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,
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));
if (safi == SAFI_FLOWSPEC) {
bgp_pbr_update_entry(bgp, bgp_node_get_prefix(rn),
info, afi, safi, true);
bgp_pbr_update_entry(bgp, bgp_dest_get_prefix(dest), info, afi,
safi, true);
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 */
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_path_info *pi;
@ -1522,15 +1522,16 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
if (!table)
return;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
(pi->type == ZEBRA_ROUTE_BGP
&& (pi->sub_type == BGP_ROUTE_NORMAL
|| 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);
}
@ -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,
afi_t afi, int type, uint32_t metric)
{
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_path_info *pi;
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 = metric;
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE
&& pi->type == type
&& 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);
bgp_attr_unintern(&old_attr);
bgp_path_info_set_flag(rn, pi,
bgp_path_info_set_flag(dest, pi,
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,
uint32_t *start, uint32_t *end);
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,
afi_t afi, safi_t safi);
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,
safi_t safi)
{
struct bgp_node *rn, *nrn;
struct bgp_dest *dest, *ndest;
struct bgp_table *table;
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
table = bgp_node_get_bgp_table_info(rn);
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
table = bgp_dest_get_bgp_table_info(dest);
if (table != NULL) {
/* Special handling for 2-level routing
* tables. */
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
for (nrn = bgp_table_top(table);
nrn; nrn = bgp_route_next(nrn))
bgp_process(bgp, nrn, afi, safi);
for (ndest = bgp_table_top(table); ndest;
ndest = bgp_route_next(ndest))
bgp_process(bgp, ndest, afi, safi);
} 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;
safi_t safi;
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
struct bgp_rmap *rmap;
QOBJ_UNREG(bgp);
@ -3459,9 +3459,9 @@ void bgp_free(struct bgp *bgp)
/* Special handling for 2-level routing tables. */
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) {
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
table = bgp_node_get_bgp_table_info(rn);
for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
dest = bgp_route_next(dest)) {
table = bgp_dest_get_bgp_table_info(dest);
bgp_table_finish(&table);
}
}

View File

@ -360,7 +360,7 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
struct rfapi_nexthop *lnh, int kill)
{
afi_t afi; /* of the VN address */
struct bgp_node *bn;
struct bgp_dest *bn;
struct bgp_path_info *bpi;
char buf[PREFIX_STRLEN];
char buf2[RD_ADDRSTRLEN];
@ -382,9 +382,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
vnc_zlog_debug_verbose(
"%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)),
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) {
vnc_zlog_debug_verbose(
@ -465,16 +465,16 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
__func__, safi, buf);
if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL;
struct bgp_dest *pdest = 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);
table = bgp_node_get_bgp_table_info(prn);
table = bgp_dest_get_bgp_table_info(pdest);
if (table)
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
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);
}
done:
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
}
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 */
struct bgp_path_info *new;
struct bgp_path_info *bpi;
struct bgp_node *bn;
struct bgp_dest *bn;
struct attr attr = {0};
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
* 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
* bpi->extra->vnc.export.rfapi_handle */
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)
&& !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
bgp_attr_unintern(&new_attr);
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
vnc_zlog_debug_any(
"%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);
if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL;
struct bgp_dest *pdest = 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);
table = bgp_node_get_bgp_table_info(prn);
table = bgp_dest_get_bgp_table_info(pdest);
if (table)
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, bpi);
bgp_unlock_node(prn);
bgp_dest_unlock_node(pdest);
}
/* 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) {
struct bgp_node *prn = NULL;
struct bgp_dest *pdest = 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);
table = bgp_node_get_bgp_table_info(prn);
table = bgp_dest_get_bgp_table_info(pdest);
if (table)
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, bpi);
bgp_unlock_node(prn);
bgp_dest_unlock_node(pdest);
}
/* Process change. */
bgp_aggregate_increment(bgp, p, bpi, afi, safi);
bgp_process(bgp, bn, afi, safi);
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
vnc_zlog_debug_any(
"%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);
if (safi == SAFI_MPLS_VPN) {
struct bgp_node *prn = NULL;
struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL;
prn = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
table = bgp_node_get_bgp_table_info(prn);
pdest = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
table = bgp_dest_get_bgp_table_info(pdest);
if (table)
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, new);
bgp_unlock_node(prn);
bgp_dest_unlock_node(pdest);
encode_label(label_val, &bn->local_label);
}
bgp_unlock_node(bn);
bgp_dest_unlock_node(bn);
bgp_process(bgp, bn, afi, safi);
vnc_zlog_debug_any(
@ -3665,49 +3665,53 @@ void rfapi_init(void)
#ifdef DEBUG_RFAPI
static void rfapi_print_exported(struct bgp *bgp)
{
struct bgp_node *rdn;
struct bgp_node *rn;
struct bgp_dest *destn;
struct bgp_dest *dest;
struct bgp_path_info *bpi;
if (!bgp)
return;
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rdn;
rdn = bgp_route_next(rdn)) {
for (destn = bgp_table_top(bgp->rib[AFI_IP][SAFI_MPLS_VPN]); destn;
destn = bgp_route_next(destn)) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rdn);
table = bgp_dest_get_bgp_table_info(destn);
if (!table)
continue;
fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn);
for (rn = bgp_table_top(table); rn;
rn = bgp_route_next(rn)) {
bpi = bgp_node_get_bgp_path_info(rn);
fprintf(stderr, "%s: vpn destn=%p\n", __func__, destn);
for (dest = bgp_table_top(table); dest;
dest = bgp_route_next(dest)) {
bpi = bgp_dest_get_bgp_path_info(dest);
if (!bpi)
continue;
fprintf(stderr, "%s: rn=%p\n", __func__, rn);
fprintf(stderr, "%s: dest=%p\n", __func__, dest);
for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
}
}
}
for (rdn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); rdn;
rdn = bgp_route_next(rdn)) {
for (destn = bgp_table_top(bgp->rib[AFI_IP][SAFI_ENCAP]); destn;
destn = bgp_route_next(destn)) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(rdn);
table = bgp_dest_get_bgp_table_info(destn);
if (!table)
continue;
fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn);
for (rn = bgp_table_top(table)); rn;
rn = bgp_route_next(rn)) {
bpi = bgp_node_get_bgp_path_info(rn);
fprintf(stderr, "%s: encap destn=%p\n", __func__, destn);
for (dest = bgp_table_top(table))
;
dest;
dest = bgp_route_next(dest))
{
bpi = bgp_dest_get_bgp_path_info(dest);
if (!bpi)
continue;
fprintf(stderr, "%s: rn=%p\n", __func__, rn);
fprintf(stderr, "%s: dest=%p\n", __func__, dest);
for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
rfapiPrintBi((void *)2,
bpi); /* 2 => stderr */
}
}
}

View File

@ -4177,8 +4177,8 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
struct rfapi_import_table *it,
afi_t afi, safi_t safi)
{
struct bgp_node *rn1;
struct bgp_node *rn2;
struct bgp_dest *dest1;
struct bgp_dest *dest2;
/* Only these SAFIs have 2-level RIBS */
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
* if they have matching route targets
*/
for (rn1 = bgp_table_top(bgp->rib[afi][safi]); rn1;
rn1 = bgp_route_next(rn1)) {
for (dest1 = bgp_table_top(bgp->rib[afi][safi]); dest1;
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;
rn2 = bgp_route_next(rn2)) {
for (dest2 = bgp_table_top(
bgp_dest_get_bgp_table_info(dest1));
dest2; dest2 = bgp_route_next(dest2)) {
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) {
uint32_t label = 0;
@ -4213,11 +4214,12 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
safi))(
it, /* which import table */
FIF_ACTION_UPDATE, bpi->peer,
NULL, bgp_node_get_prefix(rn2),
NULL,
bgp_dest_get_prefix(dest2),
NULL, afi,
(struct prefix_rd *)
bgp_node_get_prefix(
rn1),
bgp_dest_get_prefix(
dest1),
bpi->attr, bpi->type,
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)
{
afi_t afi; /* of the VN address */
struct bgp_node *bn;
struct bgp_dest *bd;
struct bgp_path_info *bpi;
uint8_t type = ZEBRA_ROUTE_BGP;
struct bgp *bgp;
@ -1562,11 +1562,11 @@ void rfapiPrintAdvertisedInfo(struct vty *vty, struct rfapi_descriptor *rfd,
} else {
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
&& bpi->sub_type == BGP_ROUTE_RFP && bpi->extra
&& 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;
const struct prefix *prefix = agg_node_get_prefix(rn);
afi_t afi = family2afi(prefix->family);
struct bgp_node *urn;
struct bgp_dest *udest;
struct bgp_path_info *ubpi;
struct attr hattr;
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?
* (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);
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;
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)
{
struct bgp_node *rn;
struct bgp_dest *dest;
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
* originated from us
*/
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
struct bgp_path_info *ri;
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;
@ -487,7 +488,7 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
&& ri->sub_type == BGP_ROUTE_REDISTRIBUTE) {
bgp_withdraw(
ri->peer, bgp_node_get_prefix(rn),
ri->peer, bgp_dest_get_prefix(dest),
0, /* addpath_id */
NULL, /* ignored */
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)
{
struct prefix_rd prd;
struct bgp_node *prn;
struct bgp_dest *pdest;
struct rfapi_cfg *hc;
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__);
/* Loop over all the RDs */
for (prn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); prn;
prn = bgp_route_next(prn)) {
for (pdest = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); pdest;
pdest = bgp_route_next(pdest)) {
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_dest *dest;
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));
prd.family = AF_UNSPEC;
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 */
table = bgp_node_get_bgp_table_info(prn);
table = bgp_dest_get_bgp_table_info(pdest);
if (!table)
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
const struct prefix *rn_p;
for (dest = bgp_table_top(table); dest;
dest = bgp_route_next(dest)) {
const struct prefix *dest_p;
/*
* 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;
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
*/
if (hc->plist_export_bgp[afi]) {
if (prefix_list_apply(hc->plist_export_bgp[afi],
rn_p)
dest_p)
== PREFIX_DENY) {
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);
ri; ri = ri->next) {
for (ri = bgp_dest_get_bgp_path_info(dest); ri;
ri = ri->next) {
vnc_zlog_debug_verbose("%s: ri->sub_type: %d",
__func__, ri->sub_type);
@ -1918,7 +1920,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
info.attr = &hattr;
ret = route_map_apply(
hc->routemap_export_bgp,
rn_p, RMAP_BGP, &info);
dest_p, RMAP_BGP,
&info);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(
@ -1937,7 +1940,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
* this route
*/
eti = vnc_eti_get(
bgp, EXPORT_TYPE_BGP, rn_p,
bgp, EXPORT_TYPE_BGP, dest_p,
ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
@ -1958,7 +1961,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
"%s: calling bgp_update",
__func__);
bgp_update(ri->peer, rn_p, /* prefix */
bgp_update(
ri->peer, dest_p, /* prefix */
0, /* addpath_id */
iattr, /* bgp_update copies
it */
@ -1969,8 +1973,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
NULL,
/* tag not used for unicast,
or EVPN */
0, 0,
NULL); /* EVPN not used */
0, 0, NULL); /* EVPN not used */
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)
{
struct bgp_node *rn;
struct bgp_dest *dest;
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
* originated from us
*/
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
const struct prefix *rn_p = bgp_node_get_prefix(rn);
for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
struct bgp_path_info *ri;
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;
@ -2016,7 +2020,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
* Delete routes immediately (no timer)
*/
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,
BGP_ROUTE_REDISTRIBUTE);
if (eti) {
@ -2025,7 +2029,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
vnc_eti_delete(eti);
}
bgp_withdraw(ri->peer, rn_p, /* prefix */
bgp_withdraw(ri->peer, dest_p, /* prefix */
0, /* addpath_id */
NULL, /* ignored */
AFI_IP, SAFI_UNICAST,

View File

@ -523,7 +523,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
uint32_t *med, /* NULL = no med */
struct prefix *ubpi_nexthop) /* unicast nexthop */
{
struct bgp_node *bn;
struct bgp_dest *bd;
struct bgp_path_info *bpi;
if (!table_rd)
@ -538,8 +538,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
}
/* exact match */
bn = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bn) {
bd = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bd) {
vnc_zlog_debug_verbose(
"%s: no match in RD's table for ubpi_nexthop",
__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 */
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(
bgp, afi, bpi, /* VPN bpi */
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(
@ -570,7 +570,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
uint32_t *med = NULL;
struct prefix_bag *pb;
struct bgp_node *bnp; /* prd table node */
struct bgp_dest *bdp; /* prd table node */
/*debugging */
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.
*/
for (bnp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bnp;
bnp = bgp_route_next(bnp)) {
for (bdp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bdp;
bdp = bgp_route_next(bdp)) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(bnp);
table = bgp_dest_get_bgp_table_info(bdp);
if (!table)
continue;
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,
&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 *ubpi_nexthop) /* unicast bpi's nexthop */
{
struct bgp_node *bn;
struct bgp_dest *bd;
struct bgp_path_info *bpi;
if (!table_rd)
@ -1297,8 +1297,8 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
/* exact match */
bn = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bn) {
bd = bgp_node_lookup(table_rd, ubpi_nexthop);
if (!bd) {
vnc_zlog_debug_verbose(
"%s: no match in RD's table for ubpi_nexthop",
__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 */
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(
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 */
}
bgp_unlock_node(bn);
bgp_dest_unlock_node(bd);
}
static void
@ -1331,7 +1331,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
void *cursor;
struct skiplist *sl = bgp->rfapi->resolve_nve_nexthop;
int rc;
struct bgp_node *bnp; /* prd table node */
struct bgp_dest *bdp; /* prd table node */
if (!sl) {
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.
*/
for (bnp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bnp;
bnp = bgp_route_next(bnp)) {
for (bdp = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); bdp;
bdp = bgp_route_next(bdp)) {
struct bgp_table *table;
table = bgp_node_get_bgp_table_info(bnp);
table = bgp_dest_get_bgp_table_info(bdp);
if (!table)
continue;
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);
}
@ -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
* vnc_import_bgp_add_route */
struct bgp_node *rn;
struct bgp_dest *dest;
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;
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
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) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
vnc_import_bgp_add_route(bgp, bgp_node_get_prefix(rn),
vnc_import_bgp_add_route(bgp, bgp_dest_get_prefix(dest),
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)
{
struct bgp *bgp_exterior;
struct bgp_node *rn;
struct bgp_dest *dest;
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;
}
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
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) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
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(
@ -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_exterior;
struct bgp_node *rn;
struct bgp_dest *dest;
vnc_zlog_debug_verbose("%s: entry", __func__);
@ -2837,19 +2837,19 @@ void vnc_import_bgp_exterior_redist_enable_it(
return;
}
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]); dest;
dest = bgp_route_next(dest)) {
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) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
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);
}
}
@ -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,
* delete (call timer expire immediately)
*/
struct bgp_node *rn1;
struct bgp_node *rn2;
struct bgp_dest *dest1;
struct bgp_dest *dest2;
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
* Be careful when changing the things we iterate over
*/
for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
rn1 = bgp_route_next(rn1)) {
const struct prefix *rn1_p;
for (dest1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); dest1;
dest1 = bgp_route_next(dest1)) {
const struct prefix *dest1_p;
if (!bgp_node_has_bgp_path_info_data(rn1))
if (!bgp_dest_has_bgp_path_info_data(dest1))
continue;
rn1_p = bgp_node_get_prefix(rn1);
for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2;
rn2 = bgp_route_next(rn2)) {
const struct prefix *rn2_p = bgp_node_get_prefix(rn2);
dest1_p = bgp_dest_get_prefix(dest1);
for (dest2 = bgp_table_top(bgp_dest_get_bgp_table_info(dest1));
dest2; dest2 = bgp_route_next(dest2)) {
const struct prefix *dest2_p =
bgp_dest_get_prefix(dest2);
struct bgp_path_info *bpi;
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) {
nextbpi = bpi->next;
@ -2917,8 +2918,8 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
rfd);
del_vnc_route(rfd, bpi->peer, bgp,
SAFI_MPLS_VPN, rn2_p,
(struct prefix_rd *)rn1_p,
SAFI_MPLS_VPN, dest2_p,
(struct prefix_rd *)dest1_p,
bpi->type, bpi->sub_type, NULL,
1); /* kill */
@ -2966,20 +2967,20 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi)
{
struct bgp_node *rn;
for (rn = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]);
rn; rn = bgp_route_next(rn)) {
struct bgp_dest *dest;
for (dest = bgp_table_top(bgp_exterior->rib[afi][SAFI_UNICAST]);
dest; dest = bgp_route_next(dest)) {
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) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
vnc_import_bgp_exterior_del_route(
bgp_exterior, bgp_node_get_prefix(rn),
bgp_exterior, bgp_dest_get_prefix(dest),
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 bgp_table *table;
struct bgp_node *prn;
struct bgp_node *rn;
struct bgp_dest *pdest;
struct bgp_dest *dest;
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
*/
for (prn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); prn;
prn = bgp_route_next(prn)) {
const struct prefix *prn_p = bgp_node_get_prefix(prn);
for (pdest = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); pdest;
pdest = bgp_route_next(pdest)) {
const struct prefix *pdest_p = bgp_dest_get_prefix(pdest);
memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC;
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 */
table = bgp_node_get_bgp_table_info(prn);
table = bgp_dest_get_bgp_table_info(pdest);
if (!table)
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;
for (ri = bgp_node_get_bgp_path_info(rn); ri;
for (ri = bgp_dest_get_bgp_path_info(dest); ri;
ri = ri->next) {
if (ri->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(
&vncHD1VR, /* use dummy ptr as cookie */
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);
}
}

View File

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

View File

@ -313,7 +313,7 @@ static int setup_bgp_path_info_mpath_update(testcase_t *t)
return -1;
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,
sizeof(struct route_table *));
setup_bgp_mp_list(t);