summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_addpath.c46
-rw-r--r--bgpd/bgp_addpath.h2
-rw-r--r--bgpd/bgp_advertise.c24
-rw-r--r--bgpd/bgp_advertise.h12
-rw-r--r--bgpd/bgp_bmp.c16
-rw-r--r--bgpd/bgp_damp.c31
-rw-r--r--bgpd/bgp_damp.h8
-rw-r--r--bgpd/bgp_debug.c4
-rw-r--r--bgpd/bgp_debug.h2
-rw-r--r--bgpd/bgp_dump.c12
-rw-r--r--bgpd/bgp_evpn.c705
-rw-r--r--bgpd/bgp_evpn.h16
-rw-r--r--bgpd/bgp_evpn_vty.c156
-rw-r--r--bgpd/bgp_flowspec_util.c5
-rw-r--r--bgpd/bgp_flowspec_vty.c18
-rw-r--r--bgpd/bgp_label.c60
-rw-r--r--bgpd/bgp_label.h17
-rw-r--r--bgpd/bgp_mac.c41
-rw-r--r--bgpd/bgp_mpath.c22
-rw-r--r--bgpd/bgp_mpath.h2
-rw-r--r--bgpd/bgp_mplsvpn.c77
-rw-r--r--bgpd/bgp_mplsvpn.h8
-rw-r--r--bgpd/bgp_nexthop.c179
-rw-r--r--bgpd/bgp_nexthop.h4
-rw-r--r--bgpd/bgp_nht.c134
-rw-r--r--bgpd/bgp_pbr.h1
-rw-r--r--bgpd/bgp_route.c1456
-rw-r--r--bgpd/bgp_route.h69
-rw-r--r--bgpd/bgp_routemap.c16
-rw-r--r--bgpd/bgp_rpki.c17
-rw-r--r--bgpd/bgp_snmp.c28
-rw-r--r--bgpd/bgp_table.c16
-rw-r--r--bgpd/bgp_table.h193
-rw-r--r--bgpd/bgp_updgrp.c4
-rw-r--r--bgpd/bgp_updgrp.h13
-rw-r--r--bgpd/bgp_updgrp_adv.c159
-rw-r--r--bgpd/bgp_updgrp_packet.c73
-rw-r--r--bgpd/bgp_vpn.c20
-rw-r--r--bgpd/bgp_vty.c42
-rw-r--r--bgpd/bgp_zebra.c27
-rw-r--r--bgpd/bgp_zebra.h2
-rw-r--r--bgpd/bgpd.c24
-rw-r--r--bgpd/rfapi/rfapi.c108
-rw-r--r--bgpd/rfapi/rfapi_import.c24
-rw-r--r--bgpd/rfapi/rfapi_vty.c8
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c102
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c107
-rw-r--r--bgpd/rfapi/vnc_zebra.c21
-rw-r--r--tests/bgpd/test_bgp_table.c26
-rw-r--r--tests/bgpd/test_mpath.c2
50 files changed, 2118 insertions, 2041 deletions
diff --git a/bgpd/bgp_addpath.c b/bgpd/bgp_addpath.c
index 75fdb0bb44..d07d41bef8 100644
--- a/bgpd/bgp_addpath.c
+++ b/bgpd/bgp_addpath.c
@@ -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,8 +426,8 @@ void bgp_addpath_set_peer_type(struct peer *peer, afi_t afi, safi_t safi,
* best-per-as updates from needing to do a separate withdraw and update just to
* swap out which path is sent.
*/
-void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi,
- safi_t safi)
+void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_dest *bn, afi_t afi,
+ safi_t safi)
{
int i;
struct bgp_path_info *pi;
@@ -442,7 +442,7 @@ void bgp_addpath_update_ids(struct bgp *bgp, struct bgp_node *bn, afi_t afi,
continue;
/* 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] =
diff --git a/bgpd/bgp_addpath.h b/bgpd/bgp_addpath.h
index f61d68e18f..0350ee8a76 100644
--- a/bgpd/bgp_addpath.h
+++ b/bgpd/bgp_addpath.h
@@ -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);
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index 9ee6a24bc5..1ebe4e5b53 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -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;
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h
index 6223dc94a3..f2cf78efde 100644
--- a/bgpd/bgp_advertise.h
+++ b/bgpd/bgp_advertise.h
@@ -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 *);
diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c
index fb4c50e3ef..c3fc230512 100644
--- a/bgpd/bgp_bmp.c
+++ b/bgpd/bgp_bmp.c
@@ -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;
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 538610f6d7..97d625493f 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -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);
}
diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h
index 3dd860a29d..4ab38326e2 100644
--- a/bgpd/bgp_damp.h
+++ b/bgpd/bgp_damp.h
@@ -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);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 396b7ba702..2ca9e5ee13 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -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;
}
diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h
index 7352b7917a..69f25566a9 100644
--- a/bgpd/bgp_debug.h
+++ b/bgpd/bgp_debug.h
@@ -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 *
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index c87849ad71..abd349a188 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -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++;
}
}
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 29cc9ac1eb..92cfdb7e19 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -64,7 +64,7 @@ DEFINE_QOBJ_TYPE(evpnes)
* Static function declarations
*/
static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
- struct bgp_node *rn,
+ struct bgp_dest *dest,
struct bgp_path_info **pi);
static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn);
@@ -990,10 +990,10 @@ static int evpn_zebra_uninstall(struct bgp *bgp, struct bgpevpn *vpn,
* from peers.
*/
static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
- struct bgp_node *rn,
+ struct bgp_dest *dest,
struct bgp_path_info *old_local)
{
- struct bgp_node *global_rn;
+ struct bgp_dest *global_dest;
struct bgp_path_info *pi;
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -1002,22 +1002,22 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
* this table is a 2-level tree (RD-level + Prefix-level) similar to
* L3VPN routes.
*/
- global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
- bgp_node_get_prefix(rn), &vpn->prd);
- if (global_rn) {
+ global_dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
+ bgp_dest_get_prefix(dest), &vpn->prd);
+ if (global_dest) {
/* Delete route entry in the global EVPN table. */
- delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, global_dest, &pi);
/* Schedule for processing - withdraws to peers happen from
* this table.
*/
if (pi)
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/* Delete route entry in the VNI route table, caller to remove. */
- bgp_path_info_delete(rn, old_local);
+ bgp_path_info_delete(dest, old_local);
}
static struct in_addr *es_vtep_new(struct in_addr vtep)
@@ -1097,9 +1097,8 @@ static int evpn_es_uninstall_vtep(struct bgp *bgp,
/*
* Calculate the best path for a ES(type-4) route.
*/
-static int evpn_es_route_select_install(struct bgp *bgp,
- struct evpnes *es,
- struct bgp_node *rn)
+static int evpn_es_route_select_install(struct bgp *bgp, struct evpnes *es,
+ struct bgp_dest *dest)
{
int ret = 0;
afi_t afi = AFI_L2VPN;
@@ -1109,8 +1108,8 @@ static int evpn_es_route_select_install(struct bgp *bgp,
struct bgp_path_info_pair old_and_new;
/* Compute the best path. */
- bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi],
- &old_and_new, afi, safi);
+ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new,
+ afi, safi);
old_select = old_and_new.old;
new_select = old_and_new.new;
@@ -1121,58 +1120,63 @@ static int evpn_es_route_select_install(struct bgp *bgp,
if (old_select && old_select == new_select
&& old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED
- && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
+ && !CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR)
&& !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
&& !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
- if (bgp_zebra_has_route_changed(rn, old_select)) {
- ret = evpn_es_install_vtep(bgp, es,
- (const struct prefix_evpn *)bgp_node_get_prefix(rn),
- old_select->attr->nexthop);
+ if (bgp_zebra_has_route_changed(old_select)) {
+ ret = evpn_es_install_vtep(
+ bgp, es,
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest),
+ old_select->attr->nexthop);
}
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG);
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
return ret;
}
/* If the user did a "clear" this flag will be set */
- UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
+ UNSET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
/*
* bestpath has changed; update relevant fields and install or uninstall
* into the zebra RIB.
*/
if (old_select || new_select)
- bgp_bump_version(rn);
+ bgp_bump_version(dest);
if (old_select)
- bgp_path_info_unset_flag(rn, old_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, old_select, BGP_PATH_SELECTED);
if (new_select) {
- bgp_path_info_set_flag(rn, new_select, BGP_PATH_SELECTED);
- bgp_path_info_unset_flag(rn, new_select, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, new_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, new_select,
+ BGP_PATH_ATTR_CHANGED);
UNSET_FLAG(new_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(new_select->flags, BGP_PATH_LINK_BW_CHG);
}
if (new_select && new_select->type == ZEBRA_ROUTE_BGP
&& new_select->sub_type == BGP_ROUTE_IMPORTED) {
- ret = evpn_es_install_vtep(bgp, es,
- (const struct prefix_evpn *)bgp_node_get_prefix(rn),
- new_select->attr->nexthop);
+ ret = evpn_es_install_vtep(
+ bgp, es,
+ (const struct prefix_evpn *)bgp_dest_get_prefix(dest),
+ new_select->attr->nexthop);
} else {
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED)
ret = evpn_es_uninstall_vtep(
- bgp, es, (struct prefix_evpn *)bgp_node_get_prefix(rn),
+ bgp, es,
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest),
old_select->attr->nexthop);
}
/* Clear any route change flags. */
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
/* Reap old select bgp_path_info, if it has been removed */
if (old_select && CHECK_FLAG(old_select->flags, BGP_PATH_REMOVED))
- bgp_path_info_reap(rn, old_select);
+ bgp_path_info_reap(dest, old_select);
return ret;
}
@@ -1182,7 +1186,7 @@ static int evpn_es_route_select_install(struct bgp *bgp,
* if appropriate.
*/
static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
- struct bgp_node *rn)
+ struct bgp_dest *dest)
{
struct bgp_path_info *old_select, *new_select;
struct bgp_path_info_pair old_and_new;
@@ -1191,7 +1195,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
int ret = 0;
/* Compute the best path. */
- bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new,
+ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new,
afi, safi);
old_select = old_and_new.old;
new_select = old_and_new.new;
@@ -1203,33 +1207,36 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
if (old_select && old_select == new_select
&& old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED
- && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
+ && !CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR)
&& !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
&& !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
- if (bgp_zebra_has_route_changed(rn, old_select))
+ if (bgp_zebra_has_route_changed(old_select))
ret = evpn_zebra_install(
- bgp, vpn, (const struct prefix_evpn *)bgp_node_get_prefix(rn),
+ bgp, vpn,
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest),
old_select);
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG);
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
return ret;
}
/* If the user did a "clear" this flag will be set */
- UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
+ UNSET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
/* bestpath has changed; update relevant fields and install or uninstall
* into the zebra RIB.
*/
if (old_select || new_select)
- bgp_bump_version(rn);
+ bgp_bump_version(dest);
if (old_select)
- bgp_path_info_unset_flag(rn, old_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, old_select, BGP_PATH_SELECTED);
if (new_select) {
- bgp_path_info_set_flag(rn, new_select, BGP_PATH_SELECTED);
- bgp_path_info_unset_flag(rn, new_select, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, new_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, new_select,
+ BGP_PATH_ATTR_CHANGED);
UNSET_FLAG(new_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(new_select->flags, BGP_PATH_LINK_BW_CHG);
}
@@ -1237,7 +1244,8 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
if (new_select && new_select->type == ZEBRA_ROUTE_BGP
&& new_select->sub_type == BGP_ROUTE_IMPORTED) {
ret = evpn_zebra_install(
- bgp, vpn, (struct prefix_evpn *)bgp_node_get_prefix(rn),
+ bgp, vpn,
+ (struct prefix_evpn *)bgp_dest_get_prefix(dest),
new_select);
/* If an old best existed and it was a "local" route, the only
@@ -1250,23 +1258,23 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
if (old_select && old_select->peer == bgp->peer_self
&& old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_STATIC)
- evpn_delete_old_local_route(bgp, vpn, rn, old_select);
+ evpn_delete_old_local_route(bgp, vpn, dest, old_select);
} else {
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED)
ret = evpn_zebra_uninstall(
bgp, vpn,
- (const struct prefix_evpn *)bgp_node_get_prefix(
- rn),
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest),
old_select->attr->nexthop);
}
/* Clear any route change flags. */
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
/* Reap old select bgp_path_info, if it has been removed */
if (old_select && CHECK_FLAG(old_select->flags, BGP_PATH_REMOVED))
- bgp_path_info_reap(rn, old_select);
+ bgp_path_info_reap(dest, old_select);
return ret;
}
@@ -1274,13 +1282,13 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
/*
* Return true if the local ri for this rn is of type gateway mac
*/
-static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn)
+static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_dest *dest)
{
struct bgp_path_info *tmp_pi = NULL;
struct bgp_path_info *local_pi = NULL;
local_pi = NULL;
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1298,13 +1306,13 @@ static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn)
/*
* Return true if the local ri for this rn has sticky set
*/
-static int evpn_route_is_sticky(struct bgp *bgp, struct bgp_node *rn)
+static int evpn_route_is_sticky(struct bgp *bgp, struct bgp_dest *dest)
{
struct bgp_path_info *tmp_pi;
struct bgp_path_info *local_pi;
local_pi = NULL;
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1325,8 +1333,9 @@ static int evpn_route_is_sticky(struct bgp *bgp, struct bgp_node *rn)
*/
static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es,
afi_t afi, safi_t safi,
- struct bgp_node *rn, struct attr *attr,
- int add, struct bgp_path_info **ri,
+ struct bgp_dest *dest,
+ struct attr *attr, int add,
+ struct bgp_path_info **ri,
int *route_changed)
{
char buf[ESI_STR_LEN];
@@ -1339,10 +1348,10 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es,
*ri = NULL;
*route_changed = 1;
- evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
+ evp = (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
/* locate the local and remote entries if any */
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1379,11 +1388,11 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es,
/* Create new route with its attribute. */
tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
- bgp->peer_self, attr_new, rn);
+ bgp->peer_self, attr_new, dest);
SET_FLAG(tmp_pi->flags, BGP_PATH_VALID);
/* add the newly created path to the route-node */
- bgp_path_info_add(rn, tmp_pi);
+ bgp_path_info_add(dest, tmp_pi);
} else {
tmp_pi = local_pi;
if (attrhash_cmp(tmp_pi->attr, attr)
@@ -1393,12 +1402,12 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es,
/* The attribute has changed.
* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(attr);
- bgp_path_info_set_flag(rn, tmp_pi,
+ bgp_path_info_set_flag(dest, tmp_pi,
BGP_PATH_ATTR_CHANGED);
/* Restore route, if needed. */
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, tmp_pi);
+ bgp_path_info_restore(dest, tmp_pi);
/* Unintern existing, set to new. */
bgp_attr_unintern(&tmp_pi->attr);
@@ -1425,7 +1434,7 @@ static int update_evpn_type4_route(struct bgp *bgp,
safi_t safi = SAFI_EVPN;
struct attr attr;
struct attr *attr_new = NULL;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
memset(&attr, 0, sizeof(struct attr));
@@ -1441,10 +1450,10 @@ static int update_evpn_type4_route(struct bgp *bgp,
/* First, create (or fetch) route node within the ESI. */
/* NOTE: There is no RD here. */
- rn = bgp_node_get(es->route_table, (struct prefix *)p);
+ dest = bgp_node_get(es->route_table, (struct prefix *)p);
/* Create or update route entry. */
- ret = update_evpn_type4_route_entry(bgp, es, afi, safi, rn, &attr, 1,
+ ret = update_evpn_type4_route_entry(bgp, es, afi, safi, dest, &attr, 1,
&pi, &route_changed);
if (ret != 0) {
flog_err(EC_BGP_ES_INVALID,
@@ -1461,8 +1470,8 @@ static int update_evpn_type4_route(struct bgp *bgp,
* this is just to set the flags correctly
* as local route in the ES always wins.
*/
- evpn_es_route_select_install(bgp, es, rn);
- bgp_unlock_node(rn);
+ evpn_es_route_select_install(bgp, es, dest);
+ bgp_dest_unlock_node(dest);
/* If this is a new route or some attribute has changed, export the
* route to the global table. The route will be advertised to peers
@@ -1472,14 +1481,15 @@ static int update_evpn_type4_route(struct bgp *bgp,
if (route_changed) {
struct bgp_path_info *global_pi;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)p, &es->prd);
- update_evpn_type4_route_entry(bgp, es, afi, safi, rn, attr_new,
- 1, &global_pi, &route_changed);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)p, &es->prd);
+ update_evpn_type4_route_entry(bgp, es, afi, safi, dest,
+ attr_new, 1, &global_pi,
+ &route_changed);
/* Schedule for processing and unlock node. */
- bgp_process(bgp, rn, afi, safi);
- bgp_unlock_node(rn);
+ bgp_process(bgp, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
}
/* Unintern temporary. */
@@ -1489,7 +1499,7 @@ static int update_evpn_type4_route(struct bgp *bgp,
static int update_evpn_type5_route_entry(struct bgp *bgp_evpn,
struct bgp *bgp_vrf, afi_t afi,
- safi_t safi, struct bgp_node *rn,
+ safi_t safi, struct bgp_dest *dest,
struct attr *attr, int *route_changed)
{
struct attr *attr_new = NULL;
@@ -1500,7 +1510,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn,
*route_changed = 0;
/* locate the local route entry if any */
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp_evpn->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1522,7 +1532,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn,
/* create the route info from attribute */
pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
- bgp_evpn->peer_self, attr_new, rn);
+ bgp_evpn->peer_self, attr_new, dest);
SET_FLAG(pi->flags, BGP_PATH_VALID);
/* Type-5 routes advertise the L3-VNI */
@@ -1532,7 +1542,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn,
pi->extra->num_labels = 1;
/* add the route entry to route node*/
- bgp_path_info_add(rn, pi);
+ bgp_path_info_add(dest, pi);
} else {
tmp_pi = local_pi;
@@ -1544,12 +1554,12 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn,
/* The attribute has changed. */
/* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(attr);
- bgp_path_info_set_flag(rn, tmp_pi,
+ bgp_path_info_set_flag(dest, tmp_pi,
BGP_PATH_ATTR_CHANGED);
/* Restore route, if needed. */
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, tmp_pi);
+ bgp_path_info_restore(dest, tmp_pi);
/* Unintern existing, set to new. */
bgp_attr_unintern(&tmp_pi->attr);
@@ -1567,7 +1577,7 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
struct attr attr;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp *bgp_evpn = NULL;
int route_changed = 0;
@@ -1630,18 +1640,18 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
build_evpn_type5_route_extcomm(bgp_vrf, &attr);
/* get the route node in global table */
- rn = bgp_afi_node_get(bgp_evpn->rib[afi][safi], afi, safi,
- (struct prefix *)evp, &bgp_vrf->vrf_prd);
- assert(rn);
+ dest = bgp_afi_node_get(bgp_evpn->rib[afi][safi], afi, safi,
+ (struct prefix *)evp, &bgp_vrf->vrf_prd);
+ assert(dest);
/* create or update the route entry within the route node */
- update_evpn_type5_route_entry(bgp_evpn, bgp_vrf, afi, safi, rn, &attr,
+ update_evpn_type5_route_entry(bgp_evpn, bgp_vrf, afi, safi, dest, &attr,
&route_changed);
/* schedule for processing and unlock node */
if (route_changed) {
- bgp_process(bgp_evpn, rn, afi, safi);
- bgp_unlock_node(rn);
+ bgp_process(bgp_evpn, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
}
/* uninten temporary */
@@ -1655,10 +1665,10 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
* or the global route table.
*/
static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
- afi_t afi, safi_t safi, struct bgp_node *rn,
- struct attr *attr, int add,
- struct bgp_path_info **pi, uint8_t flags,
- uint32_t seq)
+ afi_t afi, safi_t safi,
+ struct bgp_dest *dest, struct attr *attr,
+ int add, struct bgp_path_info **pi,
+ uint8_t flags, uint32_t seq)
{
struct bgp_path_info *tmp_pi;
struct bgp_path_info *local_pi;
@@ -1670,12 +1680,12 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
const struct prefix_evpn *evp;
*pi = NULL;
- evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
+ evp = (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
memset(&label, 0, sizeof(label));
/* See if this is an update of an existing route, or a new add. */
local_pi = NULL;
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1705,7 +1715,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
/* Create new route with its attribute. */
tmp_pi = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0,
- bgp->peer_self, attr_new, rn);
+ bgp->peer_self, attr_new, dest);
SET_FLAG(tmp_pi->flags, BGP_PATH_VALID);
bgp_path_info_extra_get(tmp_pi);
@@ -1732,7 +1742,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
/* Mark route as self type-2 route */
if (flags && CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_SVI_IP))
tmp_pi->extra->af_flags = BGP_EVPN_MACIP_TYPE_SVI_IP;
- bgp_path_info_add(rn, tmp_pi);
+ bgp_path_info_add(dest, tmp_pi);
} else {
tmp_pi = local_pi;
if (attrhash_cmp(tmp_pi->attr, attr)
@@ -1761,7 +1771,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
/* The attribute has changed. */
/* Add (or update) attribute to hash. */
attr_new = bgp_attr_intern(attr);
- bgp_path_info_set_flag(rn, tmp_pi,
+ bgp_path_info_set_flag(dest, tmp_pi,
BGP_PATH_ATTR_CHANGED);
/* Extract MAC mobility sequence number, if any. */
@@ -1771,7 +1781,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
/* Restore route, if needed. */
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, tmp_pi);
+ bgp_path_info_restore(dest, tmp_pi);
/* Unintern existing, set to new. */
bgp_attr_unintern(&tmp_pi->attr);
@@ -1786,13 +1796,14 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
}
static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
- struct bgpevpn *vpn, struct bgp_node *rn)
+ struct bgpevpn *vpn,
+ struct bgp_dest *dest)
{
struct bgp_path_info *tmp_ri;
struct bgp_path_info *curr_select = NULL;
- for (tmp_ri = bgp_node_get_bgp_path_info(rn);
- tmp_ri; tmp_ri = tmp_ri->next) {
+ for (tmp_ri = bgp_dest_get_bgp_path_info(dest); tmp_ri;
+ tmp_ri = tmp_ri->next) {
if (CHECK_FLAG(tmp_ri->flags, BGP_PATH_SELECTED)) {
curr_select = tmp_ri;
break;
@@ -1801,9 +1812,10 @@ static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
if (curr_select && curr_select->type == ZEBRA_ROUTE_BGP
&& curr_select->sub_type == BGP_ROUTE_IMPORTED)
- evpn_zebra_install(bgp, vpn,
- (const struct prefix_evpn *)bgp_node_get_prefix(rn),
- curr_select);
+ evpn_zebra_install(
+ bgp, vpn,
+ (const struct prefix_evpn *)bgp_dest_get_prefix(dest),
+ curr_select);
}
/*
@@ -1822,18 +1834,19 @@ static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
*/
static void evpn_cleanup_local_non_best_route(struct bgp *bgp,
struct bgpevpn *vpn,
- struct bgp_node *rn,
+ struct bgp_dest *dest,
struct bgp_path_info *local_pi)
{
/* local path was not picked as the winner; kick it out */
if (bgp_debug_zebra(NULL))
- zlog_debug("evicting local evpn prefix %pRN as remote won", rn);
+ zlog_debug("evicting local evpn prefix %pRN as remote won",
+ dest);
- evpn_delete_old_local_route(bgp, vpn, rn, local_pi);
- bgp_path_info_reap(rn, local_pi);
+ evpn_delete_old_local_route(bgp, vpn, dest, local_pi);
+ bgp_path_info_reap(dest, local_pi);
/* tell zebra to re-add the best remote path */
- evpn_zebra_reinstall_best_route(bgp, vpn, rn);
+ evpn_zebra_reinstall_best_route(bgp, vpn, dest);
}
/*
@@ -1844,7 +1857,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
struct prefix_evpn *p, uint8_t flags,
uint32_t seq)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct attr attr;
struct attr *attr_new;
int add_l3_ecomm = 0;
@@ -1913,10 +1926,10 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
/* First, create (or fetch) route node within the VNI. */
/* NOTE: There is no RD here. */
- rn = bgp_node_get(vpn->route_table, (struct prefix *)p);
+ dest = bgp_node_get(vpn->route_table, (struct prefix *)p);
/* Create or update route entry. */
- route_change = update_evpn_route_entry(bgp, vpn, afi, safi, rn, &attr,
+ route_change = update_evpn_route_entry(bgp, vpn, afi, safi, dest, &attr,
1, &pi, flags, seq);
assert(pi);
attr_new = pi->attr;
@@ -1932,7 +1945,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
* route would win, and we should evict the defunct local route
* and (re)install the remote route into zebra.
*/
- evpn_route_select_install(bgp, vpn, rn);
+ evpn_route_select_install(bgp, vpn, dest);
/*
* If the new local route was not selected evict it and tell zebra
* to re-add the best remote dest. BGP doesn't retain non-best local
@@ -1940,11 +1953,11 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
*/
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
route_change = 0;
- evpn_cleanup_local_non_best_route(bgp, vpn, rn, pi);
+ evpn_cleanup_local_non_best_route(bgp, vpn, dest, pi);
}
bgp_path_info_unlock(pi);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
/* If this is a new route or some attribute has changed, export the
* route to the global table. The route will be advertised to peers
@@ -1954,14 +1967,14 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
if (route_change) {
struct bgp_path_info *global_pi;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)p, &vpn->prd);
- update_evpn_route_entry(bgp, vpn, afi, safi, rn, attr_new, 1,
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)p, &vpn->prd);
+ update_evpn_route_entry(bgp, vpn, afi, safi, dest, attr_new, 1,
&global_pi, flags, seq);
/* Schedule for processing and unlock node. */
- bgp_process(bgp, rn, afi, safi);
- bgp_unlock_node(rn);
+ bgp_process(bgp, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
}
/* Unintern temporary. */
@@ -1975,7 +1988,7 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
* The entry can be in ESI/VNI table or the global table.
*/
static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
- struct bgp_node *rn,
+ struct bgp_dest *dest,
struct bgp_path_info **pi)
{
struct bgp_path_info *tmp_pi;
@@ -1983,7 +1996,7 @@ static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
*pi = NULL;
/* Now, find matching route. */
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next)
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -1994,7 +2007,7 @@ static void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
/* Mark route for delete. */
if (tmp_pi)
- bgp_path_info_delete(rn, tmp_pi);
+ bgp_path_info_delete(dest, tmp_pi);
}
@@ -2007,43 +2020,43 @@ static int delete_evpn_type4_route(struct bgp *bgp,
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
struct bgp_path_info *pi;
- struct bgp_node *rn = NULL; /* rn in esi table */
- struct bgp_node *global_rn = NULL; /* rn in global table */
+ struct bgp_dest *dest = NULL; /* dest in esi table */
+ struct bgp_dest *global_dest = NULL; /* dest in global table */
/* First, locate the route node within the ESI.
* If it doesn't exist, ther is nothing to do.
* Note: there is no RD here.
*/
- rn = bgp_node_lookup(es->route_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(es->route_table, (struct prefix *)p);
+ if (!dest)
return 0;
/* Next, locate route node in the global EVPN routing table.
* Note that this table is a 2-level tree (RD-level + Prefix-level)
*/
- global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)p, &es->prd);
- if (global_rn) {
+ global_dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)p, &es->prd);
+ if (global_dest) {
/* Delete route entry in the global EVPN table. */
- delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, global_dest, &pi);
/* Schedule for processing - withdraws to peers happen from
* this table.
*/
if (pi)
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/*
* Delete route entry in the ESI route table.
* This can just be removed.
*/
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, dest, &pi);
if (pi)
- bgp_path_info_reap(rn, pi);
- bgp_unlock_node(rn);
+ bgp_path_info_reap(dest, pi);
+ bgp_dest_unlock_node(dest);
return 0;
}
@@ -2052,7 +2065,7 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)
{
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
struct bgp *bgp_evpn = NULL; /* evpn bgp instance */
@@ -2061,15 +2074,15 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)
return 0;
/* locate the global route entry for this type-5 prefix */
- rn = bgp_afi_node_lookup(bgp_evpn->rib[afi][safi], afi, safi,
- (struct prefix *)evp, &bgp_vrf->vrf_prd);
- if (!rn)
+ dest = bgp_afi_node_lookup(bgp_evpn->rib[afi][safi], afi, safi,
+ (struct prefix *)evp, &bgp_vrf->vrf_prd);
+ if (!dest)
return 0;
- delete_evpn_route_entry(bgp_evpn, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp_evpn, afi, safi, dest, &pi);
if (pi)
- bgp_process(bgp_evpn, rn, afi, safi);
- bgp_unlock_node(rn);
+ bgp_process(bgp_evpn, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
return 0;
}
@@ -2080,7 +2093,7 @@ static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)
static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
struct prefix_evpn *p)
{
- struct bgp_node *rn, *global_rn;
+ struct bgp_dest *dest, *global_dest;
struct bgp_path_info *pi;
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -2090,36 +2103,36 @@ static int delete_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
* is nothing further to do.
*/
/* NOTE: There is no RD here. */
- rn = bgp_node_lookup(vpn->route_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(vpn->route_table, (struct prefix *)p);
+ if (!dest)
return 0;
/* Next, locate route node in the global EVPN routing table. Note that
* this table is a 2-level tree (RD-level + Prefix-level) similar to
* L3VPN routes.
*/
- global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)p, &vpn->prd);
- if (global_rn) {
+ global_dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)p, &vpn->prd);
+ if (global_dest) {
/* Delete route entry in the global EVPN table. */
- delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, global_dest, &pi);
/* Schedule for processing - withdraws to peers happen from
* this table.
*/
if (pi)
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/* Delete route entry in the VNI route table. This can just be removed.
*/
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, dest, &pi);
if (pi) {
- bgp_path_info_reap(rn, pi);
- evpn_route_select_install(bgp, vpn, rn);
+ bgp_path_info_reap(dest, pi);
+ evpn_route_select_install(bgp, vpn, dest);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
@@ -2132,7 +2145,7 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi, *tmp_pi;
struct attr attr;
struct attr *attr_new;
@@ -2145,17 +2158,18 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
/* Walk this VNI's route table and update local type-2 routes. For any
* routes updated, update corresponding entry in the global table too.
*/
- for (rn = bgp_table_top(vpn->route_table); rn;
- rn = bgp_route_next(rn)) {
- const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
- struct bgp_node *rd_rn;
+ for (dest = bgp_table_top(vpn->route_table); dest;
+ dest = bgp_route_next(dest)) {
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
+ struct bgp_dest *rd_dest;
struct bgp_path_info *global_pi;
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
/* Identify local route. */
- for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ for (tmp_pi = bgp_dest_get_bgp_path_info(dest); tmp_pi;
tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
@@ -2178,9 +2192,9 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
bgp_evpn_get_rmac_nexthop(vpn, evp, &attr,
tmp_pi->extra->af_flags);
- if (evpn_route_is_sticky(bgp, rn))
+ if (evpn_route_is_sticky(bgp, dest))
attr.sticky = 1;
- else if (evpn_route_is_def_gw(bgp, rn)) {
+ else if (evpn_route_is_def_gw(bgp, dest)) {
attr.default_gw = 1;
if (is_evpn_prefix_ipaddr_v6(evp))
attr.router_flag = 1;
@@ -2215,8 +2229,8 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
seq = mac_mobility_seqnum(tmp_pi->attr);
/* Update the route entry. */
- update_evpn_route_entry(bgp, vpn, afi, safi, rn, &attr, 0, &pi,
- 0, seq);
+ update_evpn_route_entry(bgp, vpn, afi, safi, dest, &attr, 0,
+ &pi, 0, seq);
/* lock ri to prevent freeing in evpn_route_select_install */
bgp_path_info_lock(pi);
@@ -2230,9 +2244,9 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
* advertised to peers; otherwise, ensure it is evicted and
* (re)install the remote route into zebra.
*/
- evpn_route_select_install(bgp, vpn, rn);
+ evpn_route_select_install(bgp, vpn, dest);
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
- evpn_cleanup_local_non_best_route(bgp, vpn, rn, pi);
+ evpn_cleanup_local_non_best_route(bgp, vpn, dest, pi);
/* unlock pi */
bgp_path_info_unlock(pi);
} else {
@@ -2241,21 +2255,21 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
bgp_path_info_unlock(pi);
/* Update route in global routing table. */
- rd_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)evp, &vpn->prd);
- assert(rd_rn);
- update_evpn_route_entry(bgp, vpn, afi, safi, rd_rn,
+ rd_dest = bgp_afi_node_get(bgp->rib[afi][safi], afi,
+ safi, (struct prefix *)evp,
+ &vpn->prd);
+ assert(rd_dest);
+ update_evpn_route_entry(bgp, vpn, afi, safi, rd_dest,
attr_new, 0, &global_pi, 0,
mac_mobility_seqnum(attr_new));
/* Schedule for processing and unlock node. */
- bgp_process(bgp, rd_rn, afi, safi);
- bgp_unlock_node(rd_rn);
+ bgp_process(bgp, rd_dest, afi, safi);
+ bgp_dest_unlock_node(rd_dest);
}
/* Unintern temporary. */
aspath_unintern(&attr.aspath);
-
}
return 0;
@@ -2269,31 +2283,35 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rdrn, *rn;
+ struct bgp_dest *rddest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
afi = AFI_L2VPN;
safi = SAFI_EVPN;
- rdrn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd);
- if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
- table = bgp_node_get_bgp_table_info(rdrn);
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
+ rddest = bgp_node_lookup(bgp->rib[afi][safi],
+ (struct prefix *)&vpn->prd);
+ if (rddest && bgp_dest_has_bgp_path_info_data(rddest)) {
+ table = bgp_dest_get_bgp_table_info(rddest);
+ for (dest = bgp_table_top(table); dest;
+ dest = bgp_route_next(dest)) {
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest);
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, dest, &pi);
if (pi)
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
}
}
/* Unlock RD node. */
- if (rdrn)
- bgp_unlock_node(rdrn);
+ if (rddest)
+ bgp_dest_unlock_node(rddest);
return 0;
}
@@ -2306,7 +2324,7 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
afi = AFI_L2VPN;
@@ -2319,18 +2337,19 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
delete_global_type2_routes(bgp, vpn);
/* Next, walk this VNI's route table and delete local type-2 routes. */
- for (rn = bgp_table_top(vpn->route_table); rn;
- rn = bgp_route_next(rn)) {
- const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
+ for (dest = bgp_table_top(vpn->route_table); dest;
+ dest = bgp_route_next(dest)) {
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
- delete_evpn_route_entry(bgp, afi, safi, rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, dest, &pi);
/* Route entry in local table gets deleted immediately. */
if (pi)
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_reap(dest, pi);
}
return 0;
@@ -2341,16 +2360,16 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
*/
static int delete_all_es_routes(struct bgp *bgp, struct evpnes *es)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi, *nextpi;
/* Walk this ES's route table and delete all routes. */
- for (rn = bgp_table_top(es->route_table); rn;
- rn = bgp_route_next(rn)) {
- for (pi = bgp_node_get_bgp_path_info(rn);
+ for (dest = bgp_table_top(es->route_table); dest;
+ dest = bgp_route_next(dest)) {
+ for (pi = bgp_dest_get_bgp_path_info(dest);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
- bgp_path_info_delete(rn, pi);
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_delete(dest, pi);
+ bgp_path_info_reap(dest, pi);
}
}
@@ -2362,16 +2381,16 @@ static int delete_all_es_routes(struct bgp *bgp, struct evpnes *es)
*/
static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi, *nextpi;
/* Walk this VNI's route table and delete all routes. */
- for (rn = bgp_table_top(vpn->route_table); rn;
- rn = bgp_route_next(rn)) {
- for (pi = bgp_node_get_bgp_path_info(rn);
+ for (dest = bgp_table_top(vpn->route_table); dest;
+ dest = bgp_route_next(dest)) {
+ for (pi = bgp_dest_get_bgp_path_info(dest);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
- bgp_path_info_delete(rn, pi);
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_delete(dest, pi);
+ bgp_path_info_reap(dest, pi);
}
}
@@ -2530,7 +2549,7 @@ static int handle_tunnel_ip_change(struct bgp *bgp, struct bgpevpn *vpn,
static struct bgp_path_info *
bgp_create_evpn_bgp_path_info(struct bgp_path_info *parent_pi,
- struct bgp_node *rn, struct attr *attr)
+ struct bgp_dest *dest, struct attr *attr)
{
struct attr *attr_new;
struct bgp_path_info *pi;
@@ -2540,17 +2559,17 @@ bgp_create_evpn_bgp_path_info(struct bgp_path_info *parent_pi,
/* Create new route with its attribute. */
pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0, parent_pi->peer,
- attr_new, rn);
+ attr_new, dest);
SET_FLAG(pi->flags, BGP_PATH_VALID);
bgp_path_info_extra_get(pi);
pi->extra->parent = bgp_path_info_lock(parent_pi);
- bgp_lock_node((struct bgp_node *)parent_pi->net);
+ bgp_dest_lock_node((struct bgp_dest *)parent_pi->net);
if (parent_pi->extra) {
memcpy(&pi->extra->label, &parent_pi->extra->label,
sizeof(pi->extra->label));
pi->extra->num_labels = parent_pi->extra->num_labels;
}
- bgp_path_info_add(rn, pi);
+ bgp_path_info_add(dest, pi);
return pi;
}
@@ -2561,17 +2580,17 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
struct bgp_path_info *parent_pi)
{
int ret = 0;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi = NULL;
struct attr *attr_new = NULL;
/* Create (or fetch) route within the VNI.
* NOTE: There is no RD here.
*/
- rn = bgp_node_get(es->route_table, (struct prefix *)p);
+ dest = bgp_node_get(es->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
@@ -2582,16 +2601,16 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
/* Create new route with its attribute. */
pi = info_make(parent_pi->type, BGP_ROUTE_IMPORTED, 0,
- parent_pi->peer, attr_new, rn);
+ parent_pi->peer, attr_new, dest);
SET_FLAG(pi->flags, BGP_PATH_VALID);
bgp_path_info_extra_get(pi);
pi->extra->parent = bgp_path_info_lock(parent_pi);
- bgp_lock_node((struct bgp_node *)parent_pi->net);
- bgp_path_info_add(rn, pi);
+ bgp_dest_lock_node((struct bgp_dest *)parent_pi->net);
+ bgp_path_info_add(dest, pi);
} else {
if (attrhash_cmp(pi->attr, parent_pi->attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
/* The attribute has changed. */
@@ -2600,7 +2619,7 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
/* Restore route, if needed. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
/* Mark if nexthop has changed. */
if (!IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop))
@@ -2613,7 +2632,7 @@ static int install_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
}
/* Perform route selection and update zebra, if required. */
- ret = evpn_es_route_select_install(bgp, es, rn);
+ ret = evpn_es_route_select_install(bgp, es, dest);
return ret;
}
@@ -2624,7 +2643,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
const struct prefix_evpn *evp,
struct bgp_path_info *parent_pi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct attr attr;
struct attr *attr_new;
@@ -2652,11 +2671,11 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
if (is_evpn_prefix_ipaddr_v4(evp)) {
afi = AFI_IP;
safi = SAFI_UNICAST;
- rn = bgp_node_get(bgp_vrf->rib[afi][safi], pp);
+ dest = bgp_node_get(bgp_vrf->rib[afi][safi], pp);
} else if (is_evpn_prefix_ipaddr_v6(evp)) {
afi = AFI_IP6;
safi = SAFI_UNICAST;
- rn = bgp_node_get(bgp_vrf->rib[afi][safi], pp);
+ dest = bgp_node_get(bgp_vrf->rib[afi][safi], pp);
} else
return 0;
@@ -2673,18 +2692,18 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
/* Check if route entry is already present. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
if (!pi) {
- pi = bgp_create_evpn_bgp_path_info(parent_pi, rn, &attr);
+ pi = bgp_create_evpn_bgp_path_info(parent_pi, dest, &attr);
new_pi = true;
} else {
if (attrhash_cmp(pi->attr, &attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
/* The attribute has changed. */
@@ -2693,7 +2712,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
/* Restore route, if needed. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
/* Mark if nexthop has changed. */
if ((afi == AFI_IP
@@ -2703,31 +2722,32 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
&attr_new->mp_nexthop_global)))
SET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED);
- bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_ATTR_CHANGED);
/* Unintern existing, set to new. */
bgp_attr_unintern(&pi->attr);
pi->attr = attr_new;
pi->uptime = bgp_clock();
}
/* as it is an importation, change nexthop */
- bgp_path_info_set_flag(rn, pi, BGP_PATH_ANNC_NH_SELF);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_ANNC_NH_SELF);
- bgp_aggregate_increment(bgp_vrf, bgp_node_get_prefix(rn), pi, afi,
+ bgp_aggregate_increment(bgp_vrf, bgp_dest_get_prefix(dest), pi, afi,
safi);
/* Perform route selection and update zebra, if required. */
- bgp_process(bgp_vrf, rn, afi, safi);
+ bgp_process(bgp_vrf, dest, afi, safi);
/* Process for route leaking. */
vpn_leak_from_vrf_update(bgp_get_default(), bgp_vrf, pi);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
if (bgp_debug_zebra(NULL))
zlog_debug(
- "... %s pi rn %p (l %d) pi %p (l %d, f 0x%x)",
+ "... %s pi dest %p (l %d) pi %p (l %d, f 0x%x)",
new_pi ? "new" : "update",
- rn, rn->lock, pi, pi->lock, pi->flags);
+ dest, bgp_dest_to_rnode(dest)->lock,
+ pi, pi->lock, pi->flags);
return ret;
}
@@ -2739,29 +2759,29 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
const struct prefix_evpn *p,
struct bgp_path_info *parent_pi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct attr *attr_new;
int ret;
/* Create (or fetch) route within the VNI. */
/* NOTE: There is no RD here. */
- rn = bgp_node_get(vpn->route_table, (struct prefix *)p);
+ dest = bgp_node_get(vpn->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
if (!pi) {
/* Create an info */
- (void)bgp_create_evpn_bgp_path_info(parent_pi, rn,
+ (void)bgp_create_evpn_bgp_path_info(parent_pi, dest,
parent_pi->attr);
} else {
if (attrhash_cmp(pi->attr, parent_pi->attr)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
/* The attribute has changed. */
@@ -2770,7 +2790,7 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
/* Restore route, if needed. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
/* Mark if nexthop has changed. */
if (!IPV4_ADDR_SAME(&pi->attr->nexthop, &attr_new->nexthop))
@@ -2783,9 +2803,9 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
}
/* Perform route selection and update zebra, if required. */
- ret = evpn_route_select_install(bgp, vpn, rn);
+ ret = evpn_route_select_install(bgp, vpn, dest);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -2796,7 +2816,7 @@ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
struct bgp_path_info *parent_pi)
{
int ret;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
if (!es->route_table)
@@ -2805,12 +2825,12 @@ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
/* Locate route within the ESI.
* NOTE: There is no RD here.
*/
- rn = bgp_node_lookup(es->route_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(es->route_table, (struct prefix *)p);
+ if (!dest)
return 0;
/* Find matching route entry. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
@@ -2819,13 +2839,13 @@ static int uninstall_evpn_route_entry_in_es(struct bgp *bgp, struct evpnes *es,
return 0;
/* Mark entry for deletion */
- bgp_path_info_delete(rn, pi);
+ bgp_path_info_delete(dest, pi);
/* Perform route selection and update zebra, if required. */
- ret = evpn_es_route_select_install(bgp, es, rn);
+ ret = evpn_es_route_select_install(bgp, es, dest);
/* Unlock route node. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -2838,7 +2858,7 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
const struct prefix_evpn *evp,
struct bgp_path_info *parent_pi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
int ret = 0;
struct prefix p;
@@ -2863,18 +2883,18 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
if (is_evpn_prefix_ipaddr_v4(evp)) {
afi = AFI_IP;
safi = SAFI_UNICAST;
- rn = bgp_node_lookup(bgp_vrf->rib[afi][safi], pp);
+ dest = bgp_node_lookup(bgp_vrf->rib[afi][safi], pp);
} else {
afi = AFI_IP6;
safi = SAFI_UNICAST;
- rn = bgp_node_lookup(bgp_vrf->rib[afi][safi], pp);
+ dest = bgp_node_lookup(bgp_vrf->rib[afi][safi], pp);
}
- if (!rn)
+ if (!dest)
return 0;
/* Find matching route entry. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
@@ -2884,23 +2904,24 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
if (bgp_debug_zebra(NULL))
zlog_debug(
- "... delete rn %p (l %d) pi %p (l %d, f 0x%x)",
- rn, rn->lock, pi, pi->lock, pi->flags);
+ "... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
+ dest, bgp_dest_to_rnode(dest)->lock,
+ pi, pi->lock, pi->flags);
/* Process for route leaking. */
vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp_vrf, pi);
- bgp_aggregate_decrement(bgp_vrf, bgp_node_get_prefix(rn), pi, afi,
+ bgp_aggregate_decrement(bgp_vrf, bgp_dest_get_prefix(dest), pi, afi,
safi);
/* Mark entry for deletion */
- bgp_path_info_delete(rn, pi);
+ bgp_path_info_delete(dest, pi);
/* Perform route selection and update zebra, if required. */
- bgp_process(bgp_vrf, rn, afi, safi);
+ bgp_process(bgp_vrf, dest, afi, safi);
/* Unlock route node. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -2913,18 +2934,18 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
const struct prefix_evpn *p,
struct bgp_path_info *parent_pi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
int ret;
/* Locate route within the VNI. */
/* NOTE: There is no RD here. */
- rn = bgp_node_lookup(vpn->route_table, (struct prefix *)p);
- if (!rn)
+ dest = bgp_node_lookup(vpn->route_table, (struct prefix *)p);
+ if (!dest)
return 0;
/* Find matching route entry. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
@@ -2933,13 +2954,13 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
return 0;
/* Mark entry for deletion */
- bgp_path_info_delete(rn, pi);
+ bgp_path_info_delete(dest, pi);
/* Perform route selection and update zebra, if required. */
- ret = evpn_route_select_install(bgp, vpn, rn);
+ ret = evpn_route_select_install(bgp, vpn, dest);
/* Unlock route node. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return ret;
}
@@ -3103,7 +3124,7 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
safi_t safi;
char buf[PREFIX_STRLEN];
char buf1[ESI_STR_LEN];
- struct bgp_node *rd_rn, *rn;
+ struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -3115,18 +3136,19 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
* imported into this VRF. Note that we need to loop through all global
* routes to determine which route matches the import rt on vrf
*/
- for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
- rd_rn = bgp_route_next(rd_rn)) {
- table = bgp_node_get_bgp_table_info(rd_rn);
+ for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
+ rd_dest = bgp_route_next(rd_dest)) {
+ table = bgp_dest_get_bgp_table_info(rd_dest);
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)) {
const struct prefix_evpn *evp =
- (const struct prefix_evpn *)bgp_node_get_prefix(
- rn);
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest);
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
/*
* Consider "valid" remote routes applicable for
@@ -3207,7 +3229,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rd_rn, *rn;
+ struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
int ret;
@@ -3224,14 +3246,17 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
* imported into this VRF. Note that we need to loop through all global
* routes to determine which route matches the import rt on vrf
*/
- for (rd_rn = bgp_table_top(bgp_evpn->rib[afi][safi]); rd_rn;
- rd_rn = bgp_route_next(rd_rn)) {
- table = bgp_node_get_bgp_table_info(rd_rn);
+ for (rd_dest = bgp_table_top(bgp_evpn->rib[afi][safi]); rd_dest;
+ rd_dest = bgp_route_next(rd_dest)) {
+ table = bgp_dest_get_bgp_table_info(rd_dest);
if (!table)
continue;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
+ for (dest = bgp_table_top(table); dest;
+ dest = bgp_route_next(dest)) {
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest);
/* if not mac-ip route skip this route */
if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
@@ -3244,7 +3269,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
|| is_evpn_prefix_ipaddr_v6(evp)))
continue;
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VRF.
@@ -3297,7 +3322,7 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
{
afi_t afi;
safi_t safi;
- struct bgp_node *rd_rn, *rn;
+ struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
int ret;
@@ -3312,21 +3337,22 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
* RD.
*/
/* EVPN routes are a 2-level table. */
- for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
- rd_rn = bgp_route_next(rd_rn)) {
- table = bgp_node_get_bgp_table_info(rd_rn);
+ for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
+ rd_dest = bgp_route_next(rd_dest)) {
+ table = bgp_dest_get_bgp_table_info(rd_dest);
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)) {
const struct prefix_evpn *evp =
- (const struct prefix_evpn *)bgp_node_get_prefix(
- rn);
+ (const struct prefix_evpn *)bgp_dest_get_prefix(
+ dest);
if (evp->prefix.route_type != rtype)
continue;
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VNI. */
@@ -3751,7 +3777,7 @@ static void withdraw_router_id_vrf(struct bgp *bgp_vrf)
static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
struct prefix_evpn p;
- struct bgp_node *rn, *global_rn;
+ struct bgp_dest *dest, *global_dest;
struct bgp_path_info *pi, *global_pi;
struct attr *attr;
afi_t afi = AFI_L2VPN;
@@ -3766,10 +3792,10 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
if (bgp_evpn_vni_flood_mode_get(bgp, vpn)
== VXLAN_FLOOD_HEAD_END_REPL) {
build_evpn_type3_prefix(&p, vpn->originator_ip);
- rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
- if (!rn) /* unexpected */
+ dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
+ if (!dest) /* unexpected */
return 0;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self &&
pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
@@ -3778,29 +3804,29 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
return 0;
attr = pi->attr;
- global_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)&p, &vpn->prd);
- update_evpn_route_entry(bgp, vpn, afi, safi, global_rn, attr,
+ global_dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)&p, &vpn->prd);
+ update_evpn_route_entry(bgp, vpn, afi, safi, global_dest, attr,
1, &pi, 0, mac_mobility_seqnum(attr));
/* Schedule for processing and unlock node. */
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
/* Now, walk this VNI's route table and use the route and its attribute
* to create and schedule route in global table.
*/
- for (rn = bgp_table_top(vpn->route_table); rn;
- rn = bgp_route_next(rn)) {
+ for (dest = bgp_table_top(vpn->route_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);
/* Identify MAC-IP local routes. */
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self
&& pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
@@ -3812,16 +3838,16 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
* attribute.
*/
attr = pi->attr;
- global_rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)evp, &vpn->prd);
- assert(global_rn);
- update_evpn_route_entry(bgp, vpn, afi, safi, global_rn, attr, 1,
- &global_pi, 0,
+ global_dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)evp, &vpn->prd);
+ assert(global_dest);
+ update_evpn_route_entry(bgp, vpn, afi, safi, global_dest, attr,
+ 1, &global_pi, 0,
mac_mobility_seqnum(attr));
/* Schedule for processing and unlock node. */
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
return 0;
@@ -3835,7 +3861,7 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
{
int ret;
struct prefix_evpn p;
- struct bgp_node *global_rn;
+ struct bgp_dest *global_dest;
struct bgp_path_info *pi;
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -3849,18 +3875,18 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
/* Remove type-3 route for this VNI from global table. */
build_evpn_type3_prefix(&p, vpn->originator_ip);
- global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)&p, &vpn->prd);
- if (global_rn) {
+ global_dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)&p, &vpn->prd);
+ if (global_dest) {
/* Delete route entry in the global EVPN table. */
- delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
+ delete_evpn_route_entry(bgp, afi, safi, global_dest, &pi);
/* Schedule for processing - withdraws to peers happen from
* this table.
*/
if (pi)
- bgp_process(bgp, global_rn, afi, safi);
- bgp_unlock_node(global_rn);
+ bgp_process(bgp, global_dest, afi, safi);
+ bgp_dest_unlock_node(global_dest);
}
return 0;
@@ -4508,20 +4534,20 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, const struct prefix *p,
void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)
{
struct bgp_table *table = NULL;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi;
table = bgp_vrf->rib[afi][safi];
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
/* Only care about "selected" routes. Also ensure that
* these are routes that are injectable into EVPN.
*/
/* TODO: Support for AddPath for EVPN. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& is_route_injectable_into_evpn(pi)) {
bgp_evpn_withdraw_type5_route(
- bgp_vrf, bgp_node_get_prefix(rn), afi,
+ bgp_vrf, bgp_dest_get_prefix(dest), afi,
safi);
break;
}
@@ -4581,17 +4607,17 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
safi_t safi)
{
struct bgp_table *table = NULL;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_path_info *pi;
table = bgp_vrf->rib[afi][safi];
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
/* Need to identify the "selected" route entry to use its
* attribute. Also, ensure that the route is injectable
* into EVPN.
* TODO: Support for AddPath for EVPN.
*/
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& is_route_injectable_into_evpn(pi)) {
@@ -4605,16 +4631,16 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
tmp_attr = *pi->attr;
/* Fill temp path_info */
- prep_for_rmap_apply(
- &tmp_pi, &tmp_pie, rn, pi,
- pi->peer, &tmp_attr);
+ prep_for_rmap_apply(&tmp_pi, &tmp_pie,
+ dest, pi, pi->peer,
+ &tmp_attr);
RESET_FLAG(tmp_attr.rmap_change_flags);
ret = route_map_apply(
bgp_vrf->adv_cmd_rmap[afi][safi]
.map,
- bgp_node_get_prefix(rn),
+ bgp_dest_get_prefix(dest),
RMAP_BGP, &tmp_pi);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&tmp_attr);
@@ -4622,12 +4648,12 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
}
bgp_evpn_advertise_type5_route(
bgp_vrf,
- bgp_node_get_prefix(rn),
+ bgp_dest_get_prefix(dest),
&tmp_attr, afi, safi);
} else
bgp_evpn_advertise_type5_route(
bgp_vrf,
- bgp_node_get_prefix(rn),
+ bgp_dest_get_prefix(dest),
pi->attr, afi, safi);
break;
}
@@ -5596,7 +5622,7 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rd_rn, *rn;
+ struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -5609,15 +5635,16 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
* remote routes applicable for this VNI could have any RD.
*/
/* EVPN routes are a 2-level table. */
- for (rd_rn = bgp_table_top(bgp->rib[afi][safi]); rd_rn;
- rd_rn = bgp_route_next(rd_rn)) {
- table = bgp_node_get_bgp_table_info(rd_rn);
+ for (rd_dest = bgp_table_top(bgp->rib[afi][safi]); rd_dest;
+ rd_dest = bgp_route_next(rd_dest)) {
+ table = bgp_dest_get_bgp_table_info(rd_dest);
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)) {
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
/* Consider "valid" remote routes applicable for
@@ -5625,11 +5652,11 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
if (!(pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_NORMAL))
continue;
- if (bgp_nexthop_self(bgp, afi,
- pi->type, pi->sub_type,
- pi->attr, rn)) {
+ if (bgp_nexthop_self(bgp, afi, pi->type,
+ pi->sub_type, pi->attr,
+ dest)) {
const struct prefix *p =
- bgp_node_get_prefix(rn);
+ bgp_dest_get_prefix(dest);
if (bgp_debug_update(pi->peer, p, NULL,
1)) {
@@ -5640,13 +5667,13 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
zlog_debug(
"%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop",
- bgp->vrf_id, rn,
+ bgp->vrf_id, dest,
attr_str);
}
bgp_evpn_unimport_route(bgp, afi, safi,
p, pi);
- bgp_rib_remove(rn, pi, pi->peer, afi,
+ bgp_rib_remove(dest, pi, pi->peer, afi,
safi);
}
}
@@ -5664,7 +5691,7 @@ int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
{
struct bgpevpn *vpn;
struct prefix_evpn p;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
/* Lookup VNI hash - should exist. */
vpn = bgp_evpn_lookup_vni(bgp, vni);
@@ -5681,9 +5708,9 @@ int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
delete_evpn_route(bgp, vpn, &p);
} else {
/* Re-instate the current remote best path if any */
- rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
- if (rn)
- evpn_zebra_reinstall_best_route(bgp, vpn, rn);
+ dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
+ if (dest)
+ evpn_zebra_reinstall_best_route(bgp, vpn, dest);
}
return 0;
diff --git a/bgpd/bgp_evpn.h b/bgpd/bgp_evpn.h
index a48a707b94..267c87ee54 100644
--- a/bgpd/bgp_evpn.h
+++ b/bgpd/bgp_evpn.h
@@ -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)
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index eac1af2ea9..d2257b0126 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -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,
- (struct prefix *)&p, prd);
- if (!rn || !bgp_node_has_bgp_path_info_data(rn)) {
+ dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
+ (struct prefix *)&p, prd);
+ 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,
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c
index 9d824a8641..764d2f87ae 100644
--- a/bgpd/bgp_flowspec_util.c
+++ b/bgpd/bgp_flowspec_util.c
@@ -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++) {
diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c
index c852e18c46..64a6c2ea8f 100644
--- a/bgpd/bgp_flowspec_vty.c
+++ b/bgpd/bgp_flowspec_vty.c
@@ -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);
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index ec44037bf7..4121a8e4b7 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -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));
diff --git a/bgpd/bgp_label.h b/bgpd/bgp_label.h
index 523671468b..d227cf7241 100644
--- a/bgpd/bgp_label.h
+++ b/bgpd/bgp_label.h
@@ -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 */
diff --git a/bgpd/bgp_mac.c b/bgpd/bgp_mac.c
index af20e5fdd7..265b4568e5 100644
--- a/bgpd/bgp_mac.c
+++ b/bgpd/bgp_mac.c
@@ -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);
}
}
}
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index f66f56cb49..5dd1cf6de8 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -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);
diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h
index 34f94b256b..a07e48159e 100644
--- a/bgpd/bgp_mpath.h
+++ b/bgpd/bgp_mpath.h
@@ -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,
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 3b82c60ae9..86b1b3e3ac 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -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
diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h
index 3234f7fc9d..ccd0d96169 100644
--- a/bgpd/bgp_mplsvpn.h
+++ b/bgpd/bgp_mplsvpn.h
@@ -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)
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index ff238d71b1..5cc0d60529 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -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],
- (struct prefix *)&p);
- bc = bgp_node_get_bgp_connected_ref_info(rn);
+ dest = bgp_node_get(bgp->connected_table[AFI_IP],
+ (struct prefix *)&p);
+ 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],
- (struct prefix *)&p);
+ 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);
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index 461e772119..416ab2a739 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -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);
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 0c2195527b..aefcaeff3a 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -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;
diff --git a/bgpd/bgp_pbr.h b/bgpd/bgp_pbr.h
index 47d5e21692..043853a157 100644
--- a/bgpd/bgp_pbr.h
+++ b/bgpd/bgp_pbr.h
@@ -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,
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 94a305760a..76586c943a 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -110,68 +110,68 @@ static const struct message bgp_pmsi_tnltype_str[] = {
#define VRFID_NONE_STR "-"
DEFINE_HOOK(bgp_process,
- (struct bgp *bgp, afi_t afi, safi_t safi,
- struct bgp_node *bn, struct peer *peer, bool withdraw),
- (bgp, afi, safi, bn, peer, 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))
-struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
+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)
{
- struct bgp_node *rn;
- struct bgp_node *prn = NULL;
+ struct bgp_dest *dest;
+ struct bgp_dest *pdest = NULL;
assert(table);
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- prn = bgp_node_get(table, (struct prefix *)prd);
+ pdest = bgp_node_get(table, (struct prefix *)prd);
- if (!bgp_node_has_bgp_path_info_data(prn))
- bgp_node_set_bgp_table_info(
- prn, bgp_table_init(table->bgp, afi, safi));
+ if (!bgp_dest_has_bgp_path_info_data(pdest))
+ bgp_dest_set_bgp_table_info(
+ pdest, bgp_table_init(table->bgp, afi, safi));
else
- bgp_unlock_node(prn);
- table = bgp_node_get_bgp_table_info(prn);
+ bgp_dest_unlock_node(pdest);
+ table = bgp_dest_get_bgp_table_info(pdest);
}
- rn = bgp_node_get(table, p);
+ dest = bgp_node_get(table, p);
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN))
- rn->prn = prn;
+ dest->pdest = pdest;
- return rn;
+ return dest;
}
-struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi,
+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)
{
- struct bgp_node *rn;
- struct bgp_node *prn = NULL;
+ struct bgp_dest *dest;
+ struct bgp_dest *pdest = NULL;
if (!table)
return NULL;
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- prn = bgp_node_lookup(table, (struct prefix *)prd);
- if (!prn)
+ pdest = bgp_node_lookup(table, (struct prefix *)prd);
+ if (!pdest)
return NULL;
- if (!bgp_node_has_bgp_path_info_data(prn)) {
- bgp_unlock_node(prn);
+ if (!bgp_dest_has_bgp_path_info_data(pdest)) {
+ bgp_dest_unlock_node(pdest);
return NULL;
}
- table = bgp_node_get_bgp_table_info(prn);
+ table = bgp_dest_get_bgp_table_info(pdest);
}
- rn = bgp_node_lookup(table, p);
+ dest = bgp_node_lookup(table, p);
- return rn;
+ return dest;
}
/* Allocate bgp_path_info_extra */
@@ -216,7 +216,7 @@ void bgp_path_info_extra_free(struct bgp_path_info_extra **extra)
bpi = bgp_path_info_lock(bpi);
refcount = bpi->net->lock - 1;
- bgp_unlock_node((struct bgp_node *)bpi->net);
+ bgp_dest_unlock_node((struct bgp_dest *)bpi->net);
if (!refcount)
bpi->net = NULL;
bgp_path_info_unlock(bpi);
@@ -294,7 +294,7 @@ struct bgp_path_info *bgp_path_info_unlock(struct bgp_path_info *path)
}
/* This function sets flag BGP_NODE_SELECT_DEFER based on condition */
-static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
+static int bgp_dest_set_defer_flag(struct bgp_dest *dest, bool delete)
{
struct peer *peer;
struct bgp_path_info *old_pi, *nextpi;
@@ -307,26 +307,26 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
/* If the flag BGP_NODE_SELECT_DEFER is set and new path is added
* then the route selection is deferred
*/
- if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER) && (!delete))
+ if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER) && (!delete))
return 0;
- if (CHECK_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED)) {
+ if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED)) {
if (BGP_DEBUG(update, UPDATE_OUT))
zlog_debug(
"Route %pRN is in workqueue and being processed, not deferred.",
- rn);
+ bgp_dest_to_rnode(dest));
return 0;
}
- table = bgp_node_table(rn);
+ table = bgp_dest_table(dest);
if (table) {
bgp = table->bgp;
afi = table->afi;
safi = table->safi;
}
- for (old_pi = bgp_node_get_bgp_path_info(rn);
+ for (old_pi = bgp_dest_get_bgp_path_info(dest);
(old_pi != NULL) && (nextpi = old_pi->next, 1); old_pi = nextpi) {
if (CHECK_FLAG(old_pi->flags, BGP_PATH_SELECTED))
continue;
@@ -358,56 +358,57 @@ static int bgp_node_set_defer_flag(struct bgp_node *rn, bool delete)
*/
if (set_flag && table) {
if (bgp && (bgp->gr_info[afi][safi].t_select_deferral)) {
- SET_FLAG(rn->flags, BGP_NODE_SELECT_DEFER);
- if (rn->rt_node == NULL)
- rn->rt_node = listnode_add(
- bgp->gr_info[afi][safi].route_list, rn);
+ SET_FLAG(dest->flags, BGP_NODE_SELECT_DEFER);
+ if (dest->rt_node == NULL)
+ dest->rt_node = listnode_add(
+ bgp->gr_info[afi][safi].route_list,
+ dest);
if (BGP_DEBUG(update, UPDATE_OUT))
- zlog_debug("DEFER route %pRN, rn %p, node %p",
- rn, rn, rn->rt_node);
+ zlog_debug("DEFER route %pRN, dest %p, node %p",
+ dest, dest, dest->rt_node);
return 0;
}
}
return -1;
}
-void bgp_path_info_add(struct bgp_node *rn, struct bgp_path_info *pi)
+void bgp_path_info_add(struct bgp_dest *dest, struct bgp_path_info *pi)
{
struct bgp_path_info *top;
- top = bgp_node_get_bgp_path_info(rn);
+ top = bgp_dest_get_bgp_path_info(dest);
pi->next = top;
pi->prev = NULL;
if (top)
top->prev = pi;
- bgp_node_set_bgp_path_info(rn, pi);
+ bgp_dest_set_bgp_path_info(dest, pi);
bgp_path_info_lock(pi);
- bgp_lock_node(rn);
+ bgp_dest_lock_node(dest);
peer_lock(pi->peer); /* bgp_path_info peer reference */
- bgp_node_set_defer_flag(rn, false);
+ bgp_dest_set_defer_flag(dest, false);
}
/* Do the actual removal of info from RIB, for use by bgp_process
completion callback *only* */
-void bgp_path_info_reap(struct bgp_node *rn, struct bgp_path_info *pi)
+void bgp_path_info_reap(struct bgp_dest *dest, struct bgp_path_info *pi)
{
if (pi->next)
pi->next->prev = pi->prev;
if (pi->prev)
pi->prev->next = pi->next;
else
- bgp_node_set_bgp_path_info(rn, pi->next);
+ bgp_dest_set_bgp_path_info(dest, pi->next);
bgp_path_info_mpath_dequeue(pi);
bgp_path_info_unlock(pi);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
-void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi)
+void bgp_path_info_delete(struct bgp_dest *dest, struct bgp_path_info *pi)
{
- bgp_path_info_set_flag(rn, pi, BGP_PATH_REMOVED);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_REMOVED);
/* set of previous already took care of pcount */
UNSET_FLAG(pi->flags, BGP_PATH_VALID);
}
@@ -415,22 +416,22 @@ void bgp_path_info_delete(struct bgp_node *rn, struct bgp_path_info *pi)
/* undo the effects of a previous call to bgp_path_info_delete; typically
called when a route is deleted and then quickly re-added before the
deletion has been processed */
-void bgp_path_info_restore(struct bgp_node *rn, struct bgp_path_info *pi)
+void bgp_path_info_restore(struct bgp_dest *dest, struct bgp_path_info *pi)
{
- bgp_path_info_unset_flag(rn, pi, BGP_PATH_REMOVED);
+ bgp_path_info_unset_flag(dest, pi, BGP_PATH_REMOVED);
/* unset of previous already took care of pcount */
SET_FLAG(pi->flags, BGP_PATH_VALID);
}
/* Adjust pcount as required */
-static void bgp_pcount_adjust(struct bgp_node *rn, struct bgp_path_info *pi)
+static void bgp_pcount_adjust(struct bgp_dest *dest, struct bgp_path_info *pi)
{
struct bgp_table *table;
- assert(rn && bgp_node_table(rn));
+ assert(dest && bgp_dest_table(dest));
assert(pi && pi->peer && pi->peer->bgp);
- table = bgp_node_table(rn);
+ table = bgp_dest_table(dest);
if (pi->peer == pi->peer->bgp->peer_self)
return;
@@ -462,7 +463,7 @@ static int bgp_label_index_differs(struct bgp_path_info *pi1,
/* Set/unset bgp_path_info flags, adjusting any other state as needed.
* This is here primarily to keep prefix-count in check.
*/
-void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *pi,
+void bgp_path_info_set_flag(struct bgp_dest *dest, struct bgp_path_info *pi,
uint32_t flag)
{
SET_FLAG(pi->flags, flag);
@@ -473,10 +474,10 @@ void bgp_path_info_set_flag(struct bgp_node *rn, struct bgp_path_info *pi,
BGP_PATH_VALID | BGP_PATH_HISTORY | BGP_PATH_REMOVED))
return;
- bgp_pcount_adjust(rn, pi);
+ bgp_pcount_adjust(dest, pi);
}
-void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *pi,
+void bgp_path_info_unset_flag(struct bgp_dest *dest, struct bgp_path_info *pi,
uint32_t flag)
{
UNSET_FLAG(pi->flags, flag);
@@ -487,7 +488,7 @@ void bgp_path_info_unset_flag(struct bgp_node *rn, struct bgp_path_info *pi,
BGP_PATH_VALID | BGP_PATH_HISTORY | BGP_PATH_REMOVED))
return;
- bgp_pcount_adjust(rn, pi);
+ bgp_pcount_adjust(dest, pi);
}
/* Get MED value. If MED value is missing and "bgp bestpath
@@ -591,10 +592,9 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
*/
if (newattr->sticky != existattr->sticky) {
if (!debug) {
- prefix2str(bgp_node_get_prefix(new->net),
- pfx_buf,
- sizeof(*pfx_buf)
- * PREFIX2STR_BUFFER);
+ prefix2str(
+ bgp_dest_get_prefix(new->net), pfx_buf,
+ sizeof(*pfx_buf) * PREFIX2STR_BUFFER);
bgp_path_info_path_with_addpath_rx_str(new,
new_buf);
bgp_path_info_path_with_addpath_rx_str(
@@ -1324,7 +1324,7 @@ static bool bgp_cluster_filter(struct peer *peer, struct attr *attr)
static int bgp_input_modifier(struct peer *peer, const struct prefix *p,
struct attr *attr, afi_t afi, safi_t safi,
const char *rmap_name, mpls_label_t *label,
- uint32_t num_labels, struct bgp_node *rn)
+ uint32_t num_labels, struct bgp_dest *dest)
{
struct bgp_filter *filter;
struct bgp_path_info rmap_path = { 0 };
@@ -1359,7 +1359,7 @@ static int bgp_input_modifier(struct peer *peer, const struct prefix *p,
rmap_path.peer = peer;
rmap_path.attr = attr;
rmap_path.extra = &extra;
- rmap_path.net = rn;
+ rmap_path.net = dest;
extra.num_labels = num_labels;
if (label && num_labels && num_labels <= BGP_MAX_LABELS)
@@ -1543,7 +1543,7 @@ static void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr)
memset(&attr->mp_nexthop_global_in, 0, BGP_ATTR_NHLEN_IPV4);
}
-bool subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
+bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
struct update_subgroup *subgrp,
const struct prefix *p, struct attr *attr)
{
@@ -1641,7 +1641,7 @@ bool subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
/* If it's labeled safi, make sure the route has a valid label. */
if (safi == SAFI_LABELED_UNICAST) {
- mpls_label_t label = bgp_adv_label(rn, pi, peer, afi, safi);
+ mpls_label_t label = bgp_adv_label(dest, pi, peer, afi, safi);
if (!bgp_is_valid_label(&label)) {
if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
zlog_debug("u%" PRIu64 ":s%" PRIu64
@@ -1878,8 +1878,8 @@ bool subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
struct attr dummy_attr = {0};
/* Fill temp path_info */
- prep_for_rmap_apply(&rmap_path, &dummy_rmap_path_extra,
- rn, pi, peer, attr);
+ prep_for_rmap_apply(&rmap_path, &dummy_rmap_path_extra, dest,
+ pi, peer, attr);
/* don't confuse inbound and outbound setting */
RESET_FLAG(attr->rmap_change_flags);
@@ -2098,7 +2098,7 @@ static int bgp_route_select_timer_expire(struct thread *thread)
return bgp_best_path_select_defer(bgp, afi, safi);
}
-void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
+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)
@@ -2118,23 +2118,23 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
do_mpath =
(mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1);
- debug = bgp_debug_bestpath(rn);
+ debug = bgp_debug_bestpath(dest);
if (debug)
- prefix2str(bgp_node_get_prefix(rn), pfx_buf, sizeof(pfx_buf));
+ prefix2str(bgp_dest_get_prefix(dest), pfx_buf, sizeof(pfx_buf));
- rn->reason = bgp_path_selection_none;
+ dest->reason = bgp_path_selection_none;
/* bgp deterministic-med */
new_select = NULL;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) {
/* Clear BGP_PATH_DMED_SELECTED for all paths */
- for (pi1 = bgp_node_get_bgp_path_info(rn); pi1;
+ for (pi1 = bgp_dest_get_bgp_path_info(dest); pi1;
pi1 = pi1->next)
- bgp_path_info_unset_flag(rn, pi1,
+ bgp_path_info_unset_flag(dest, pi1,
BGP_PATH_DMED_SELECTED);
- for (pi1 = bgp_node_get_bgp_path_info(rn); pi1;
+ for (pi1 = bgp_dest_get_bgp_path_info(dest); pi1;
pi1 = pi1->next) {
if (CHECK_FLAG(pi1->flags, BGP_PATH_DMED_CHECK))
continue;
@@ -2171,20 +2171,20 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
bgp, pi2, new_select,
&paths_eq, mpath_cfg, debug,
pfx_buf, afi, safi,
- &rn->reason)) {
+ &dest->reason)) {
bgp_path_info_unset_flag(
- rn, new_select,
+ dest, new_select,
BGP_PATH_DMED_SELECTED);
new_select = pi2;
}
bgp_path_info_set_flag(
- rn, pi2, BGP_PATH_DMED_CHECK);
+ dest, pi2, BGP_PATH_DMED_CHECK);
}
}
- bgp_path_info_set_flag(rn, new_select,
+ bgp_path_info_set_flag(dest, new_select,
BGP_PATH_DMED_CHECK);
- bgp_path_info_set_flag(rn, new_select,
+ bgp_path_info_set_flag(dest, new_select,
BGP_PATH_DMED_SELECTED);
if (debug) {
@@ -2201,7 +2201,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
/* Check old selected route and new selected route. */
old_select = NULL;
new_select = NULL;
- for (pi = bgp_node_get_bgp_path_info(rn);
+ for (pi = bgp_dest_get_bgp_path_info(dest);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
enum bgp_path_selection_reason reason;
@@ -2214,7 +2214,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
*/
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)
&& (pi != old_select))
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_reap(dest, pi);
if (debug)
zlog_debug("%s: pi %p in holddown", __func__,
@@ -2237,20 +2237,21 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)
&& (!CHECK_FLAG(pi->flags, BGP_PATH_DMED_SELECTED))) {
- bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK);
+ bgp_path_info_unset_flag(dest, pi, BGP_PATH_DMED_CHECK);
if (debug)
zlog_debug("%s: pi %p dmed", __func__, pi);
continue;
}
- bgp_path_info_unset_flag(rn, pi, BGP_PATH_DMED_CHECK);
+ bgp_path_info_unset_flag(dest, pi, BGP_PATH_DMED_CHECK);
- reason = rn->reason;
+ reason = dest->reason;
if (bgp_path_info_cmp(bgp, pi, new_select, &paths_eq, mpath_cfg,
- debug, pfx_buf, afi, safi, &rn->reason)) {
+ debug, pfx_buf, afi, safi,
+ &dest->reason)) {
if (new_select == NULL &&
reason != bgp_path_selection_none)
- rn->reason = reason;
+ dest->reason = reason;
new_select = pi;
}
}
@@ -2272,7 +2273,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
}
if (do_mpath && new_select) {
- for (pi = bgp_node_get_bgp_path_info(rn);
+ for (pi = bgp_dest_get_bgp_path_info(dest);
(pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
if (debug)
@@ -2307,7 +2308,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
bgp_path_info_cmp(bgp, pi, new_select, &paths_eq,
mpath_cfg, debug, pfx_buf, afi, safi,
- &rn->reason);
+ &dest->reason);
if (paths_eq) {
if (debug)
@@ -2319,12 +2320,12 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
}
}
- bgp_path_info_mpath_update(rn, new_select, old_select, &mp_list,
+ bgp_path_info_mpath_update(dest, new_select, old_select, &mp_list,
mpath_cfg);
bgp_path_info_mpath_aggregate_update(new_select, old_select);
bgp_mp_list_clear(&mp_list);
- bgp_addpath_update_ids(bgp, rn, afi, safi);
+ bgp_addpath_update_ids(bgp, dest, afi, safi);
result->old = old_select;
result->new = new_select;
@@ -2338,7 +2339,7 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_node *rn,
*/
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)
{
const struct prefix *p;
@@ -2347,7 +2348,7 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
afi_t afi;
safi_t safi;
- p = bgp_node_get_prefix(rn);
+ p = bgp_dest_get_prefix(dest);
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
@@ -2371,16 +2372,16 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
/* Announcement to the subgroup. If the route is filtered withdraw it.
*/
if (selected) {
- if (subgroup_announce_check(rn, selected, subgrp, p, &attr))
- bgp_adj_out_set_subgroup(rn, subgrp, &attr, selected);
+ if (subgroup_announce_check(dest, selected, subgrp, p, &attr))
+ bgp_adj_out_set_subgroup(dest, subgrp, &attr, selected);
else
- bgp_adj_out_unset_subgroup(rn, subgrp, 1,
+ bgp_adj_out_unset_subgroup(dest, subgrp, 1,
addpath_tx_id);
}
/* If selected is NULL we must withdraw the path using addpath_tx_id */
else {
- bgp_adj_out_unset_subgroup(rn, subgrp, 1, addpath_tx_id);
+ bgp_adj_out_unset_subgroup(dest, subgrp, 1, addpath_tx_id);
}
}
@@ -2388,11 +2389,11 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
* Clear IGP changed flag and attribute changed flag for a route (all paths).
* This is called at the end of route processing.
*/
-void bgp_zebra_clear_route_change_flags(struct bgp_node *rn)
+void bgp_zebra_clear_route_change_flags(struct bgp_dest *dest)
{
struct bgp_path_info *pi;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
UNSET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED);
@@ -2405,8 +2406,7 @@ void bgp_zebra_clear_route_change_flags(struct bgp_node *rn)
* if the route selection returns the same best route as earlier - to
* determine if we need to update zebra or not.
*/
-bool bgp_zebra_has_route_changed(struct bgp_node *rn,
- struct bgp_path_info *selected)
+bool bgp_zebra_has_route_changed(struct bgp_path_info *selected)
{
struct bgp_path_info *mpinfo;
@@ -2437,18 +2437,18 @@ bool bgp_zebra_has_route_changed(struct bgp_node *rn,
struct bgp_process_queue {
struct bgp *bgp;
- STAILQ_HEAD(, bgp_node) pqueue;
+ STAILQ_HEAD(, bgp_dest) pqueue;
#define BGP_PROCESS_QUEUE_EOIU_MARKER (1 << 0)
unsigned int flags;
unsigned int queued;
};
static void bgp_process_evpn_route_injection(struct bgp *bgp, afi_t afi,
- safi_t safi, struct bgp_node *rn,
+ safi_t safi, struct bgp_dest *dest,
struct bgp_path_info *new_select,
struct bgp_path_info *old_select)
{
- const struct prefix *p = bgp_node_get_prefix(rn);
+ const struct prefix *p = bgp_dest_get_prefix(dest);
if ((afi != AFI_IP && afi != AFI_IP6) || (safi != SAFI_UNICAST))
return;
@@ -2466,7 +2466,7 @@ static void bgp_process_evpn_route_injection(struct bgp *bgp, afi_t afi,
dummy_attr = *new_select->attr;
/* Fill temp path_info */
- prep_for_rmap_apply(&rmap_path, &rmap_path_extra, rn,
+ prep_for_rmap_apply(&rmap_path, &rmap_path_extra, dest,
new_select, new_select->peer,
&dummy_attr);
@@ -2510,7 +2510,7 @@ static void bgp_process_evpn_route_injection(struct bgp *bgp, afi_t afi,
* We have no eligible route that we can announce or the rn
* is being removed.
*/
-static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
+static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
afi_t afi, safi_t safi)
{
struct bgp_path_info *new_select;
@@ -2519,16 +2519,16 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
int debug = 0;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
- if (rn)
- debug = bgp_debug_bestpath(rn);
+ if (dest)
+ debug = bgp_debug_bestpath(dest);
if (debug)
zlog_debug(
"%s: bgp delete in progress, ignoring event, p=%pRN",
- __func__, rn);
+ __func__, dest);
return;
}
/* Is it end of initial update? (after startup) */
- if (!rn) {
+ if (!dest) {
quagga_timestamp(3, bgp->update_delay_zebra_resume_time,
sizeof(bgp->update_delay_zebra_resume_time));
@@ -2543,24 +2543,24 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
return;
}
- const struct prefix *p = bgp_node_get_prefix(rn);
+ const struct prefix *p = bgp_dest_get_prefix(dest);
- debug = bgp_debug_bestpath(rn);
+ debug = bgp_debug_bestpath(dest);
if (debug)
- zlog_debug("%s: p=%pRN afi=%s, safi=%s start", __func__, rn,
+ zlog_debug("%s: p=%pRN afi=%s, safi=%s start", __func__, dest,
afi2str(afi), safi2str(safi));
/* The best path calculation for the route is deferred if
* BGP_NODE_SELECT_DEFER is set
*/
- if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
+ if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER)) {
if (BGP_DEBUG(update, UPDATE_OUT))
- zlog_debug("SELECT_DEFER flag set for route %p", rn);
+ zlog_debug("SELECT_DEFER falg set for route %p", dest);
return;
}
/* Best path selection. */
- bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new,
+ bgp_best_selection(bgp, dest, &bgp->maxpaths[afi][safi], &old_and_new,
afi, safi);
old_select = old_and_new.old;
new_select = old_and_new.new;
@@ -2577,7 +2577,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
if (!old_select
|| bgp_label_index_differs(new_select, old_select)
|| new_select->sub_type != old_select->sub_type
- || !bgp_is_valid_label(&rn->local_label)) {
+ || !bgp_is_valid_label(&dest->local_label)) {
/* Enforced penultimate hop popping:
* implicit-null for local routes, aggregate
* and redistributed routes
@@ -2588,37 +2588,38 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
|| new_select->sub_type
== BGP_ROUTE_REDISTRIBUTE) {
if (CHECK_FLAG(
- rn->flags,
+ dest->flags,
BGP_NODE_REGISTERED_FOR_LABEL))
- bgp_unregister_for_label(rn);
+ 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);
} else
- bgp_register_for_label(rn, new_select);
+ bgp_register_for_label(dest,
+ new_select);
}
- } else if (CHECK_FLAG(rn->flags,
+ } else if (CHECK_FLAG(dest->flags,
BGP_NODE_REGISTERED_FOR_LABEL)) {
- bgp_unregister_for_label(rn);
+ bgp_unregister_for_label(dest);
}
- } else if (CHECK_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
- bgp_unregister_for_label(rn);
+ } else if (CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)) {
+ bgp_unregister_for_label(dest);
}
if (debug)
zlog_debug(
"%s: p=%pRN afi=%s, safi=%s, old_select=%p, new_select=%p",
- __func__, rn, afi2str(afi), safi2str(safi),
+ __func__, dest, afi2str(afi), safi2str(safi),
old_select, new_select);
/* If best route remains the same and this is not due to user-initiated
* clear, see exactly what needs to be done.
*/
if (old_select && old_select == new_select
- && !CHECK_FLAG(rn->flags, BGP_NODE_USER_CLEAR)
+ && !CHECK_FLAG(dest->flags, BGP_NODE_USER_CLEAR)
&& !CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
&& !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
- if (bgp_zebra_has_route_changed(rn, old_select)) {
+ if (bgp_zebra_has_route_changed(old_select)) {
#ifdef ENABLE_BGP_VNC
vnc_import_bgp_add_route(bgp, p, old_select);
vnc_import_bgp_exterior_add_route(bgp, p, old_select);
@@ -2631,7 +2632,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
|| new_select->sub_type
== BGP_ROUTE_IMPORTED))
- bgp_zebra_announce(rn, p, old_select,
+ bgp_zebra_announce(dest, p, old_select,
bgp, afi, safi);
}
}
@@ -2640,40 +2641,40 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
* route. */
if (CHECK_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED)
|| CHECK_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG)
- || CHECK_FLAG(rn->flags, BGP_NODE_LABEL_CHANGED)) {
- group_announce_route(bgp, afi, safi, rn, new_select);
+ || CHECK_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED)) {
+ group_announce_route(bgp, afi, safi, dest, new_select);
/* unicast routes must also be annouced to
* labeled-unicast update-groups */
if (safi == SAFI_UNICAST)
group_announce_route(bgp, afi,
- SAFI_LABELED_UNICAST, rn,
+ SAFI_LABELED_UNICAST, dest,
new_select);
UNSET_FLAG(old_select->flags, BGP_PATH_ATTR_CHANGED);
- UNSET_FLAG(rn->flags, BGP_NODE_LABEL_CHANGED);
+ UNSET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
}
/* advertise/withdraw type-5 routes */
if (CHECK_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG)
|| CHECK_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG))
bgp_process_evpn_route_injection(
- bgp, afi, safi, rn, old_select, old_select);
+ bgp, afi, safi, dest, old_select, old_select);
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(old_select->flags, BGP_PATH_LINK_BW_CHG);
- bgp_zebra_clear_route_change_flags(rn);
- UNSET_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED);
+ bgp_zebra_clear_route_change_flags(dest);
+ UNSET_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED);
return;
}
/* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set
*/
- UNSET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
+ UNSET_FLAG(dest->flags, BGP_NODE_USER_CLEAR);
/* bestpath has changed; bump version */
if (old_select || new_select) {
- bgp_bump_version(rn);
+ bgp_bump_version(dest);
if (!bgp->t_rmap_def_originate_eval) {
bgp_lock(bgp);
@@ -2686,12 +2687,13 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
}
if (old_select)
- bgp_path_info_unset_flag(rn, old_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, old_select, BGP_PATH_SELECTED);
if (new_select) {
if (debug)
zlog_debug("%s: setting SELECTED flag", __func__);
- bgp_path_info_set_flag(rn, new_select, BGP_PATH_SELECTED);
- bgp_path_info_unset_flag(rn, new_select, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, new_select, BGP_PATH_SELECTED);
+ bgp_path_info_unset_flag(dest, new_select,
+ BGP_PATH_ATTR_CHANGED);
UNSET_FLAG(new_select->flags, BGP_PATH_MULTIPATH_CHG);
UNSET_FLAG(new_select->flags, BGP_PATH_LINK_BW_CHG);
}
@@ -2713,12 +2715,12 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
}
#endif
- group_announce_route(bgp, afi, safi, rn, new_select);
+ group_announce_route(bgp, afi, safi, dest, new_select);
/* unicast routes must also be annouced to labeled-unicast update-groups
*/
if (safi == SAFI_UNICAST)
- group_announce_route(bgp, afi, SAFI_LABELED_UNICAST, rn,
+ group_announce_route(bgp, afi, SAFI_LABELED_UNICAST, dest,
new_select);
/* FIB update. */
@@ -2737,7 +2739,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
is_route_parent_evpn(old_select))
bgp_zebra_withdraw(p, old_select, bgp, safi);
- bgp_zebra_announce(rn, p, new_select, bgp, afi, safi);
+ bgp_zebra_announce(dest, p, new_select, bgp, afi, safi);
} else {
/* Withdraw the route from the kernel. */
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
@@ -2749,24 +2751,24 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
}
}
- bgp_process_evpn_route_injection(bgp, afi, safi, rn, new_select,
+ bgp_process_evpn_route_injection(bgp, afi, safi, dest, new_select,
old_select);
/* Clear any route change flags. */
- bgp_zebra_clear_route_change_flags(rn);
+ bgp_zebra_clear_route_change_flags(dest);
/* Reap old select bgp_path_info, if it has been removed */
if (old_select && CHECK_FLAG(old_select->flags, BGP_PATH_REMOVED))
- bgp_path_info_reap(rn, old_select);
+ bgp_path_info_reap(dest, old_select);
- UNSET_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED);
+ UNSET_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED);
return;
}
/* Process the routes with the flag BGP_NODE_SELECT_DEFER set */
int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
int cnt = 0;
struct afi_safi_info *thread_info;
struct listnode *node = NULL, *nnode = NULL;
@@ -2783,14 +2785,14 @@ int bgp_best_path_select_defer(struct bgp *bgp, afi_t afi, safi_t safi)
/* Process the route list */
node = listhead(bgp->gr_info[afi][safi].route_list);
while (node) {
- rn = listgetdata(node);
+ dest = listgetdata(node);
nnode = node->next;
list_delete_node(bgp->gr_info[afi][safi].route_list, node);
- rn->rt_node = NULL;
+ dest->rt_node = NULL;
- if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
- UNSET_FLAG(rn->flags, BGP_NODE_SELECT_DEFER);
- bgp_process_main_one(bgp, rn, afi, safi);
+ if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER)) {
+ UNSET_FLAG(dest->flags, BGP_NODE_SELECT_DEFER);
+ bgp_process_main_one(bgp, dest, afi, safi);
cnt++;
if (cnt >= BGP_MAX_BEST_ROUTE_SELECT)
break;
@@ -2827,7 +2829,7 @@ static wq_item_status bgp_process_wq(struct work_queue *wq, void *data)
struct bgp_process_queue *pqnode = data;
struct bgp *bgp = pqnode->bgp;
struct bgp_table *table;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
/* eoiu marker */
if (CHECK_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER)) {
@@ -2838,14 +2840,14 @@ static wq_item_status bgp_process_wq(struct work_queue *wq, void *data)
}
while (!STAILQ_EMPTY(&pqnode->pqueue)) {
- rn = STAILQ_FIRST(&pqnode->pqueue);
+ dest = STAILQ_FIRST(&pqnode->pqueue);
STAILQ_REMOVE_HEAD(&pqnode->pqueue, pq);
- STAILQ_NEXT(rn, pq) = NULL; /* complete unlink */
- table = bgp_node_table(rn);
- /* note, new RNs may be added as part of processing */
- bgp_process_main_one(bgp, rn, table->afi, table->safi);
+ STAILQ_NEXT(dest, pq) = NULL; /* complete unlink */
+ table = bgp_dest_table(dest);
+ /* note, new DESTs may be added as part of processing */
+ bgp_process_main_one(bgp, dest, table->afi, table->safi);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
bgp_table_unlock(table);
}
@@ -2889,7 +2891,7 @@ static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
return pqnode;
}
-void bgp_process(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
+void bgp_process(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, safi_t safi)
{
#define ARBITRARY_PROCESS_QLEN 10000
struct work_queue *wq = bm->process_main_queue;
@@ -2897,16 +2899,16 @@ void bgp_process(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
int pqnode_reuse = 0;
/* already scheduled for processing? */
- if (CHECK_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED))
+ if (CHECK_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED))
return;
/* If the flag BGP_NODE_SELECT_DEFER is set, do not add route to
* the workqueue
*/
- if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
+ if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER)) {
if (BGP_DEBUG(update, UPDATE_OUT))
zlog_debug("BGP_NODE_SELECT_DEFER set for route %p",
- rn);
+ dest);
return;
}
@@ -2929,14 +2931,14 @@ void bgp_process(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
} else
pqnode = bgp_processq_alloc(bgp);
/* all unlocked in bgp_process_wq */
- bgp_table_lock(bgp_node_table(rn));
+ bgp_table_lock(bgp_dest_table(dest));
- SET_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED);
- bgp_lock_node(rn);
+ SET_FLAG(dest->flags, BGP_NODE_PROCESS_SCHEDULED);
+ bgp_dest_lock_node(dest);
/* can't be enqueued twice */
- assert(STAILQ_NEXT(rn, pq) == NULL);
- STAILQ_INSERT_TAIL(&pqnode->pqueue, rn, pq);
+ assert(STAILQ_NEXT(dest, pq) == NULL);
+ STAILQ_INSERT_TAIL(&pqnode->pqueue, dest, pq);
pqnode->queued++;
if (!pqnode_reuse)
@@ -3069,57 +3071,57 @@ bool bgp_maximum_prefix_overflow(struct peer *peer, afi_t afi, safi_t safi,
/* Unconditionally remove the route from the RIB, without taking
* damping into consideration (eg, because the session went down)
*/
-void bgp_rib_remove(struct bgp_node *rn, struct bgp_path_info *pi,
+void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp *bgp = NULL;
bool delete_route = false;
- bgp_aggregate_decrement(peer->bgp, bgp_node_get_prefix(rn),
- pi, afi, safi);
+ bgp_aggregate_decrement(peer->bgp, bgp_dest_get_prefix(dest), pi, afi,
+ safi);
if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
- bgp_path_info_delete(rn, pi); /* keep historical info */
+ bgp_path_info_delete(dest, pi); /* keep historical info */
/* If the selected path is removed, reset BGP_NODE_SELECT_DEFER
* flag
*/
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
delete_route = true;
- else if (bgp_node_set_defer_flag(rn, true) < 0)
+ else if (bgp_dest_set_defer_flag(dest, true) < 0)
delete_route = true;
if (delete_route) {
- if (CHECK_FLAG(rn->flags, BGP_NODE_SELECT_DEFER)) {
- UNSET_FLAG(rn->flags, BGP_NODE_SELECT_DEFER);
+ if (CHECK_FLAG(dest->flags, BGP_NODE_SELECT_DEFER)) {
+ UNSET_FLAG(dest->flags, BGP_NODE_SELECT_DEFER);
bgp = pi->peer->bgp;
- if ((rn->rt_node)
+ if ((dest->rt_node)
&& (bgp->gr_info[afi][safi].route_list)) {
list_delete_node(bgp->gr_info[afi][safi]
.route_list,
- rn->rt_node);
- rn->rt_node = NULL;
+ dest->rt_node);
+ dest->rt_node = NULL;
}
}
}
}
- hook_call(bgp_process, peer->bgp, afi, safi, rn, peer, true);
- bgp_process(peer->bgp, rn, afi, safi);
+ hook_call(bgp_process, peer->bgp, afi, safi, dest, peer, true);
+ bgp_process(peer->bgp, dest, afi, safi);
}
-static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi,
+static void bgp_rib_withdraw(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *peer, afi_t afi, safi_t safi,
struct prefix_rd *prd)
{
- const struct prefix *p = bgp_node_get_prefix(rn);
+ const struct prefix *p = bgp_dest_get_prefix(dest);
/* apply dampening, if result is suppressed, we'll be retaining
* the bgp_path_info in the RIB for historical reference.
*/
if (CHECK_FLAG(peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP)
- if ((bgp_damp_withdraw(pi, rn, afi, safi, 0))
+ if ((bgp_damp_withdraw(pi, dest, afi, safi, 0))
== BGP_DAMP_SUPPRESSED) {
bgp_aggregate_decrement(peer->bgp, p, pi, afi,
safi);
@@ -3128,18 +3130,18 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi,
#ifdef ENABLE_BGP_VNC
if (safi == SAFI_MPLS_VPN) {
- struct bgp_node *prn = NULL;
+ struct bgp_dest *pdest = NULL;
struct bgp_table *table = NULL;
- prn = bgp_node_get(peer->bgp->rib[afi][safi],
- (struct prefix *)prd);
- if (bgp_node_has_bgp_path_info_data(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ pdest = bgp_node_get(peer->bgp->rib[afi][safi],
+ (struct prefix *)prd);
+ if (bgp_dest_has_bgp_path_info_data(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
peer->bgp, prd, table, p, pi);
}
- bgp_unlock_node(prn);
+ bgp_dest_unlock_node(pdest);
}
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
@@ -3154,12 +3156,12 @@ static void bgp_rib_withdraw(struct bgp_node *rn, struct bgp_path_info *pi,
if (safi == SAFI_EVPN)
bgp_evpn_unimport_route(peer->bgp, afi, safi, p, pi);
- bgp_rib_remove(rn, pi, peer, afi, safi);
+ bgp_rib_remove(dest, pi, peer, afi, safi);
}
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)
{
struct bgp_path_info *new;
@@ -3171,7 +3173,7 @@ struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance,
new->peer = peer;
new->attr = attr;
new->uptime = bgp_clock();
- new->net = rn;
+ new->net = dest;
return new;
}
@@ -3236,7 +3238,7 @@ static bool overlay_index_equal(afi_t afi, struct bgp_path_info *path,
/* Check if received nexthop is valid or not. */
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 bgp_dest *dest)
{
bool ret = false;
bool is_bgp_static_route =
@@ -3252,7 +3254,7 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if ((attr->nexthop.s_addr == INADDR_ANY && !is_bgp_static_route)
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
- || bgp_nexthop_self(bgp, afi, type, stype, attr, rn))
+ || bgp_nexthop_self(bgp, afi, type, stype, attr, dest))
return true;
}
@@ -3274,7 +3276,7 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
|| IPV4_CLASS_DE(
ntohl(attr->mp_nexthop_global_in.s_addr))
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
- rn));
+ dest));
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
@@ -3286,14 +3288,14 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
|| IN6_IS_ADDR_MULTICAST(
&attr->mp_nexthop_global)
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
- rn));
+ dest));
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
ret = (IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)
|| IN6_IS_ADDR_MULTICAST(
&attr->mp_nexthop_global)
|| bgp_nexthop_self(bgp, afi, type, stype, attr,
- rn));
+ dest));
break;
default:
@@ -3313,7 +3315,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
{
int ret;
int aspath_loop_count = 0;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp *bgp;
struct attr new_attr;
struct attr *attr_new;
@@ -3339,7 +3341,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
new_attr.label = MPLS_INVALID_LABEL;
bgp = peer->bgp;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
/* TODO: Check to see if we can get rid of "is_valid_label" */
if (afi == AFI_L2VPN && safi == SAFI_EVPN)
has_valid_label = (num_labels > 0) ? 1 : 0;
@@ -3351,10 +3353,10 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (!soft_reconfig
&& CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
&& peer != bgp->peer_self)
- bgp_adj_in_set(rn, peer, attr, addpath_id);
+ bgp_adj_in_set(dest, peer, attr, addpath_id);
/* Check previously received route. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == peer && pi->type == type
&& pi->sub_type == sub_type
&& pi->addpath_rx_id == addpath_id)
@@ -3371,7 +3373,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (aspath_loop_check(attr->aspath, peer->change_local_as)
> aspath_loop_count) {
peer->stat_pfx_aspath_loop++;
- reason = "as-path contains our own AS;";
+ reason = "as-path contains our own AS A;";
goto filtered;
}
}
@@ -3456,8 +3458,9 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
* commands, so we need bgp_attr_flush in the error paths, until we
* intern
* the attr (which takes over the memory references) */
- if (bgp_input_modifier(peer, p, &new_attr, afi, safi, NULL,
- label, num_labels, rn) == RMAP_DENY) {
+ if (bgp_input_modifier(peer, p, &new_attr, afi, safi, NULL, label,
+ num_labels, dest)
+ == RMAP_DENY) {
peer->stat_pfx_filter++;
reason = "route-map;";
bgp_attr_flush(&new_attr);
@@ -3493,8 +3496,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* next hop check. */
if (!CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)
- && bgp_update_martian_nexthop(bgp, afi, safi, pi_type,
- pi_sub_type, &new_attr, rn)) {
+ && bgp_update_martian_nexthop(bgp, afi, safi, pi_type, pi_sub_type,
+ &new_attr, dest)) {
peer->stat_pfx_nh_invalid++;
reason = "martian or self next-hop;";
bgp_attr_flush(&new_attr);
@@ -3514,7 +3517,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
pi->uptime = bgp_clock();
same_attr = attrhash_cmp(pi->attr, attr_new);
- hook_call(bgp_process, bgp, afi, safi, rn, peer, true);
+ hook_call(bgp_process, bgp, afi, safi, dest, peer, true);
/* Same attribute comes in. */
if (!CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)
@@ -3540,11 +3543,11 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
pfx_buf);
}
- if (bgp_damp_update(pi, rn, afi, safi)
+ if (bgp_damp_update(pi, dest, afi, safi)
!= BGP_DAMP_SUPPRESSED) {
bgp_aggregate_increment(bgp, p, pi, afi,
safi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
}
} else /* Duplicate - odd */
{
@@ -3570,13 +3573,13 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* graceful restart STALE flag unset. */
if (CHECK_FLAG(pi->flags, BGP_PATH_STALE)) {
bgp_path_info_unset_flag(
- rn, pi, BGP_PATH_STALE);
- bgp_node_set_defer_flag(rn, false);
- bgp_process(bgp, rn, afi, safi);
+ dest, pi, BGP_PATH_STALE);
+ bgp_dest_set_defer_flag(dest, false);
+ bgp_process(bgp, dest, afi, safi);
}
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
bgp_attr_unintern(&attr_new);
return 0;
@@ -3594,7 +3597,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
peer->host, pfx_buf);
}
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
}
/* Received Logging. */
@@ -3608,12 +3611,12 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* graceful restart STALE flag unset. */
if (CHECK_FLAG(pi->flags, BGP_PATH_STALE)) {
- bgp_path_info_unset_flag(rn, pi, BGP_PATH_STALE);
- bgp_node_set_defer_flag(rn, false);
+ bgp_path_info_unset_flag(dest, pi, BGP_PATH_STALE);
+ bgp_dest_set_defer_flag(dest, false);
}
/* The attribute is changed. */
- bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_ATTR_CHANGED);
/* implicit withdraw, decrement aggregate and pcount here.
* only if update is accepted, they'll increment below.
@@ -3627,22 +3630,22 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
dampening
information. */
if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY))
- bgp_damp_withdraw(pi, rn, afi, safi, 1);
+ bgp_damp_withdraw(pi, dest, afi, safi, 1);
}
#ifdef ENABLE_BGP_VNC
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);
- if (bgp_node_has_bgp_path_info_data(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ pdest = bgp_node_get(bgp->rib[afi][safi],
+ (struct prefix *)prd);
+ if (bgp_dest_has_bgp_path_info_data(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, pi);
}
- bgp_unlock_node(prn);
+ bgp_dest_unlock_node(pdest);
}
if ((afi == AFI_IP || afi == AFI_IP6)
&& (safi == SAFI_UNICAST)) {
@@ -3752,9 +3755,9 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
&& peer->sort == BGP_PEER_EBGP) {
/* Now we do normal update dampening. */
- ret = bgp_damp_update(pi, rn, afi, safi);
+ ret = bgp_damp_update(pi, dest, afi, safi);
if (ret == BGP_DAMP_SUPPRESSED) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
}
@@ -3785,7 +3788,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (bgp_find_or_add_nexthop(bgp, bgp_nexthop, nh_afi,
pi, NULL, connected)
|| CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
- bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, pi,
+ BGP_PATH_VALID);
else {
if (BGP_DEBUG(nht, NHT)) {
char buf1[INET6_ADDRSTRLEN];
@@ -3796,26 +3800,26 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
zlog_debug("%s(%s): NH unresolved",
__func__, buf1);
}
- bgp_path_info_unset_flag(rn, pi,
+ bgp_path_info_unset_flag(dest, pi,
BGP_PATH_VALID);
}
} else
- bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_VALID);
#ifdef ENABLE_BGP_VNC
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);
- if (bgp_node_has_bgp_path_info_data(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ pdest = bgp_node_get(bgp->rib[afi][safi],
+ (struct prefix *)prd);
+ if (bgp_dest_has_bgp_path_info_data(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, pi);
}
- bgp_unlock_node(prn);
+ bgp_dest_unlock_node(pdest);
}
#endif
@@ -3838,8 +3842,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* Process change. */
bgp_aggregate_increment(bgp, p, pi, afi, safi);
- bgp_process(bgp, rn, afi, safi);
- bgp_unlock_node(rn);
+ bgp_process(bgp, dest, afi, safi);
+ bgp_dest_unlock_node(dest);
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF
@@ -3884,7 +3888,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
}
/* Make new BGP info. */
- new = info_make(type, sub_type, 0, peer, attr_new, rn);
+ new = info_make(type, sub_type, 0, peer, attr_new, dest);
/* Update MPLS label */
if (has_valid_label) {
@@ -3935,7 +3939,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (bgp_find_or_add_nexthop(bgp, bgp, nh_afi, new, NULL,
connected)
|| CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD))
- bgp_path_info_set_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, new, BGP_PATH_VALID);
else {
if (BGP_DEBUG(nht, NHT)) {
char buf1[INET6_ADDRSTRLEN];
@@ -3945,10 +3949,10 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
zlog_debug("%s(%s): NH unresolved", __func__,
buf1);
}
- bgp_path_info_unset_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_unset_flag(dest, new, BGP_PATH_VALID);
}
} else
- bgp_path_info_set_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, new, BGP_PATH_VALID);
/* Addpath ID */
new->addpath_rx_id = addpath_id;
@@ -3957,24 +3961,24 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp_aggregate_increment(bgp, p, new, afi, safi);
/* Register new BGP information. */
- bgp_path_info_add(rn, new);
+ bgp_path_info_add(dest, new);
/* route_node_get lock */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
#ifdef ENABLE_BGP_VNC
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);
- if (bgp_node_has_bgp_path_info_data(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ pdest = bgp_node_get(bgp->rib[afi][safi], (struct prefix *)prd);
+ if (bgp_dest_has_bgp_path_info_data(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
bgp, prd, table, p, new);
}
- bgp_unlock_node(prn);
+ bgp_dest_unlock_node(pdest);
}
#endif
@@ -3987,10 +3991,10 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
if (safi == SAFI_EVPN && CHECK_FLAG(new->flags, BGP_PATH_VALID))
bgp_evpn_import_route(bgp, afi, safi, p, new);
- hook_call(bgp_process, bgp, afi, safi, rn, peer, false);
+ hook_call(bgp_process, bgp, afi, safi, dest, peer, false);
/* Process change. */
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF
@@ -4020,7 +4024,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* This BGP update is filtered. Log the reason then update BGP
entry. */
filtered:
- hook_call(bgp_process, bgp, afi, safi, rn, peer, true);
+ hook_call(bgp_process, bgp, afi, safi, dest, peer, true);
if (bgp_debug_update(peer, p, NULL, 1)) {
if (!peer->rcvd_attr_printed) {
@@ -4054,10 +4058,10 @@ filtered:
vpn_leak_to_vrf_withdraw(bgp, pi);
}
- bgp_rib_remove(rn, pi, peer, afi, safi);
+ bgp_rib_remove(dest, pi, peer, afi, safi);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
#ifdef ENABLE_BGP_VNC
/*
@@ -4081,7 +4085,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
{
struct bgp *bgp;
char pfx_buf[BGP_PRD_PATH_STRLEN];
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
#ifdef ENABLE_BGP_VNC
@@ -4094,7 +4098,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp = peer->bgp;
/* Lookup node. */
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
/* If peer is soft reconfiguration enabled. Record input packet for
* further calculation.
@@ -4109,7 +4113,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
*/
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
&& peer != bgp->peer_self)
- if (!bgp_adj_in_unset(rn, peer, addpath_id)) {
+ if (!bgp_adj_in_unset(dest, peer, addpath_id)) {
peer->stat_pfx_dup_withdraw++;
if (bgp_debug_update(peer, p, NULL, 1)) {
@@ -4121,12 +4125,12 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
"%s withdrawing route %s not in adj-in",
peer->host, pfx_buf);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
/* Lookup withdrawn route. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == peer && pi->type == type
&& pi->sub_type == sub_type
&& pi->addpath_rx_id == addpath_id)
@@ -4143,7 +4147,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* Withdraw specified route from routing table. */
if (pi && !CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
- bgp_rib_withdraw(rn, pi, peer, afi, safi, prd);
+ bgp_rib_withdraw(dest, pi, peer, afi, safi, prd);
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF
|| bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) {
@@ -4162,7 +4166,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
}
/* Unlock bgp_node_get() lock. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
@@ -4269,14 +4273,14 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
struct prefix_rd *prd)
{
int ret;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_adj_in *ain;
if (!table)
table = peer->bgp->rib[afi][safi];
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
- for (ain = rn->adj_in; ain; ain = ain->next) {
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
+ for (ain = dest->adj_in; ain; ain = ain->next) {
if (ain->peer != peer)
continue;
@@ -4285,7 +4289,7 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
mpls_label_t *label_pnt = NULL;
struct bgp_route_evpn evpn;
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next)
if (pi->peer == peer)
break;
@@ -4300,14 +4304,14 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
else
memset(&evpn, 0, sizeof(evpn));
- ret = bgp_update(peer, bgp_node_get_prefix(rn),
- ain->addpath_rx_id, ain->attr,
- afi, safi, ZEBRA_ROUTE_BGP,
+ ret = bgp_update(peer, bgp_dest_get_prefix(dest),
+ ain->addpath_rx_id, ain->attr, afi,
+ safi, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, prd, label_pnt,
num_labels, 1, &evpn);
if (ret < 0) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return;
}
}
@@ -4315,7 +4319,7 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_table *table;
if (peer->status != Established)
@@ -4325,14 +4329,14 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
&& (safi != SAFI_EVPN))
bgp_soft_reconfig_table(peer, afi, safi, NULL, NULL);
else
- for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- table = bgp_node_get_bgp_table_info(rn);
+ for (dest = bgp_table_top(peer->bgp->rib[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ table = bgp_dest_get_bgp_table_info(dest);
if (table == NULL)
continue;
- const struct prefix *p = bgp_node_get_prefix(rn);
+ const struct prefix *p = bgp_dest_get_prefix(dest);
struct prefix_rd prd;
prd.family = AF_UNSPEC;
@@ -4345,26 +4349,26 @@ void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
struct bgp_clear_node_queue {
- struct bgp_node *rn;
+ struct bgp_dest *dest;
};
static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
{
struct bgp_clear_node_queue *cnq = data;
- struct bgp_node *rn = cnq->rn;
+ struct bgp_dest *dest = cnq->dest;
struct peer *peer = wq->spec.data;
struct bgp_path_info *pi;
struct bgp *bgp;
- afi_t afi = bgp_node_table(rn)->afi;
- safi_t safi = bgp_node_table(rn)->safi;
+ afi_t afi = bgp_dest_table(dest)->afi;
+ safi_t safi = bgp_dest_table(dest)->safi;
- assert(rn && peer);
+ assert(dest && peer);
bgp = peer->bgp;
/* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath.
*/
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (pi->peer != peer)
continue;
@@ -4373,14 +4377,14 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
&& peer->nsf[afi][safi]
&& !CHECK_FLAG(pi->flags, BGP_PATH_STALE)
&& !CHECK_FLAG(pi->flags, BGP_PATH_UNUSEABLE))
- bgp_path_info_set_flag(rn, pi, BGP_PATH_STALE);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_STALE);
else {
/* If this is an EVPN route, process for
* un-import. */
if (safi == SAFI_EVPN)
- bgp_evpn_unimport_route(bgp, afi, safi,
- bgp_node_get_prefix(rn),
- pi);
+ bgp_evpn_unimport_route(
+ bgp, afi, safi,
+ bgp_dest_get_prefix(dest), pi);
/* Handle withdraw for VRF route-leaking and L3VPN */
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF ||
@@ -4393,7 +4397,7 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
vpn_leak_to_vrf_withdraw(bgp, pi);
}
- bgp_rib_remove(rn, pi, peer, afi, safi);
+ bgp_rib_remove(dest, pi, peer, afi, safi);
}
}
return WQ_SUCCESS;
@@ -4402,10 +4406,10 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
static void bgp_clear_node_queue_del(struct work_queue *wq, void *data)
{
struct bgp_clear_node_queue *cnq = data;
- struct bgp_node *rn = cnq->rn;
- struct bgp_table *table = bgp_node_table(rn);
+ struct bgp_dest *dest = cnq->dest;
+ struct bgp_table *table = bgp_dest_table(dest);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
bgp_table_unlock(table);
XFREE(MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
}
@@ -4442,7 +4446,7 @@ static void bgp_clear_node_queue_init(struct peer *peer)
static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_table *table)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
int force = bm->process_main_queue ? 0 : 1;
if (!table)
@@ -4452,7 +4456,7 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
if (!table)
return;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
struct bgp_path_info *pi, *next;
struct bgp_adj_in *ain;
struct bgp_adj_in *ain_next;
@@ -4492,35 +4496,35 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
* a peer
* if that peer is using AddPath.
*/
- ain = rn->adj_in;
+ ain = dest->adj_in;
while (ain) {
ain_next = ain->next;
if (ain->peer == peer) {
- bgp_adj_in_remove(rn, ain);
- bgp_unlock_node(rn);
+ bgp_adj_in_remove(dest, ain);
+ bgp_dest_unlock_node(dest);
}
ain = ain_next;
}
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = next) {
next = pi->next;
if (pi->peer != peer)
continue;
if (force)
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_reap(dest, pi);
else {
struct bgp_clear_node_queue *cnq;
/* both unlocked in bgp_clear_node_queue_del */
- bgp_table_lock(bgp_node_table(rn));
- bgp_lock_node(rn);
+ bgp_table_lock(bgp_dest_table(dest));
+ bgp_dest_lock_node(dest);
cnq = XCALLOC(
MTYPE_BGP_CLEAR_NODE_QUEUE,
sizeof(struct bgp_clear_node_queue));
- cnq->rn = rn;
+ cnq->dest = dest;
work_queue_add(peer->clear_node_queue, cnq);
break;
}
@@ -4531,7 +4535,7 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
void bgp_clear_route(struct peer *peer, afi_t afi, safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_table *table;
if (peer->clear_node_queue == NULL)
@@ -4560,9 +4564,9 @@ void bgp_clear_route(struct peer *peer, afi_t afi, safi_t safi)
if (safi != SAFI_MPLS_VPN && safi != SAFI_ENCAP && safi != SAFI_EVPN)
bgp_clear_route_table(peer, afi, safi, NULL);
else
- for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- table = bgp_node_get_bgp_table_info(rn);
+ for (dest = bgp_table_top(peer->bgp->rib[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
@@ -4590,7 +4594,7 @@ void bgp_clear_route_all(struct peer *peer)
void bgp_clear_adj_in(struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp_table *table;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_adj_in *ain;
struct bgp_adj_in *ain_next;
@@ -4599,15 +4603,15 @@ void bgp_clear_adj_in(struct peer *peer, afi_t afi, safi_t safi)
/* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath.
*/
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- ain = rn->adj_in;
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
+ ain = dest->adj_in;
while (ain) {
ain_next = ain->next;
if (ain->peer == peer) {
- bgp_adj_in_remove(rn, ain);
- bgp_unlock_node(rn);
+ bgp_adj_in_remove(dest, ain);
+ bgp_dest_unlock_node(dest);
}
ain = ain_next;
@@ -4617,23 +4621,23 @@ void bgp_clear_adj_in(struct peer *peer, afi_t afi, safi_t safi)
void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_table *table;
if (safi == SAFI_MPLS_VPN) {
- for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- struct bgp_node *rm;
+ for (dest = bgp_table_top(peer->bgp->rib[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ struct bgp_dest *rm;
/* look for neighbor in tables */
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm))
- for (pi = bgp_node_get_bgp_path_info(rm); pi;
+ for (pi = bgp_dest_get_bgp_path_info(rm); pi;
pi = pi->next) {
if (pi->peer != peer)
continue;
@@ -4646,15 +4650,15 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
}
}
} else {
- for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
- rn = bgp_route_next(rn))
- for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ for (dest = bgp_table_top(peer->bgp->rib[afi][safi]); dest;
+ dest = bgp_route_next(dest))
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
if (pi->peer != peer)
continue;
if (!CHECK_FLAG(pi->flags, BGP_PATH_STALE))
break;
- bgp_rib_remove(rn, pi, peer, afi, safi);
+ bgp_rib_remove(dest, pi, peer, afi, safi);
break;
}
}
@@ -4689,13 +4693,13 @@ bool bgp_inbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info *next;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = next) {
- const struct prefix *p = bgp_node_get_prefix(rn);
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = next) {
+ const struct prefix *p = bgp_dest_get_prefix(dest);
next = pi->next;
@@ -4714,7 +4718,7 @@ static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
bgp_zebra_withdraw(p, pi, bgp, safi);
}
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_reap(dest, pi);
}
}
@@ -4722,7 +4726,7 @@ static void bgp_cleanup_table(struct bgp *bgp, struct bgp_table *table,
void bgp_cleanup_routes(struct bgp *bgp)
{
afi_t afi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_table *table;
for (afi = AFI_IP; afi < AFI_MAX; ++afi) {
@@ -4736,37 +4740,37 @@ void bgp_cleanup_routes(struct bgp *bgp)
if (afi != AFI_L2VPN) {
safi_t safi;
safi = SAFI_MPLS_VPN;
- 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) {
bgp_cleanup_table(bgp, table, safi);
bgp_table_finish(&table);
- bgp_node_set_bgp_table_info(rn, NULL);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_table_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
}
}
safi = SAFI_ENCAP;
- 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) {
bgp_cleanup_table(bgp, table, safi);
bgp_table_finish(&table);
- bgp_node_set_bgp_table_info(rn, NULL);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_table_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
}
}
}
}
- for (rn = bgp_table_top(bgp->rib[AFI_L2VPN][SAFI_EVPN]); rn;
- rn = bgp_route_next(rn)) {
- table = bgp_node_get_bgp_table_info(rn);
+ for (dest = bgp_table_top(bgp->rib[AFI_L2VPN][SAFI_EVPN]); dest;
+ dest = bgp_route_next(dest)) {
+ table = bgp_dest_get_bgp_table_info(dest);
if (table != NULL) {
bgp_cleanup_table(bgp, table, SAFI_EVPN);
bgp_table_finish(&table);
- bgp_node_set_bgp_table_info(rn, NULL);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_table_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
}
}
}
@@ -4964,7 +4968,7 @@ static void bgp_static_free(struct bgp_static *bgp_static)
void bgp_static_update(struct bgp *bgp, const struct prefix *p,
struct bgp_static *bgp_static, afi_t afi, safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_path_info *new;
struct bgp_path_info rmap_path;
@@ -4977,7 +4981,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
assert(bgp_static);
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
bgp_attr_default_set(&attr, BGP_ORIGIN_IGP);
@@ -5031,7 +5035,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
attr_new = bgp_attr_intern(&attr);
}
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
@@ -5040,17 +5044,17 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
if (attrhash_cmp(pi->attr, attr_new)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)
&& !CHECK_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
bgp_attr_unintern(&attr_new);
aspath_unintern(&attr.aspath);
return;
} else {
/* The attribute is changed. */
- bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_ATTR_CHANGED);
/* Rewrite BGP route information. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
else
bgp_aggregate_decrement(bgp, p, pi, afi, safi);
#ifdef ENABLE_BGP_VNC
@@ -5095,7 +5099,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
if (bgp_find_or_add_nexthop(bgp, bgp_nexthop,
afi, pi, NULL, 0))
- bgp_path_info_set_flag(rn, pi,
+ bgp_path_info_set_flag(dest, pi,
BGP_PATH_VALID);
else {
if (BGP_DEBUG(nht, NHT)) {
@@ -5108,7 +5112,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
__func__, buf1);
}
bgp_path_info_unset_flag(
- rn, pi, BGP_PATH_VALID);
+ dest, pi, BGP_PATH_VALID);
}
} else {
/* Delete the NHT structure if any, if we're
@@ -5119,11 +5123,12 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
* process interaction
*/
bgp_unlink_nexthop(pi);
- bgp_path_info_set_flag(rn, pi, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, pi,
+ BGP_PATH_VALID);
}
/* Process change. */
bgp_aggregate_increment(bgp, p, pi, afi, safi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF
@@ -5133,7 +5138,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
pi);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
aspath_unintern(&attr.aspath);
return;
}
@@ -5141,12 +5146,12 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
/* Make new BGP info. */
new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self,
- attr_new, rn);
+ attr_new, dest);
/* Nexthop reachability check. */
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)
&& (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST)) {
if (bgp_find_or_add_nexthop(bgp, bgp, afi, new, NULL, 0))
- bgp_path_info_set_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, new, BGP_PATH_VALID);
else {
if (BGP_DEBUG(nht, NHT)) {
char buf1[INET6_ADDRSTRLEN];
@@ -5156,7 +5161,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
"%s(%s): Route not in table, not advertising",
__func__, buf1);
}
- bgp_path_info_unset_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_unset_flag(dest, new, BGP_PATH_VALID);
}
} else {
/* Delete the NHT structure if any, if we're toggling between
@@ -5165,20 +5170,20 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
*/
bgp_unlink_nexthop(new);
- bgp_path_info_set_flag(rn, new, BGP_PATH_VALID);
+ bgp_path_info_set_flag(dest, new, BGP_PATH_VALID);
}
/* Aggregate address increment. */
bgp_aggregate_increment(bgp, p, new, afi, safi);
/* Register new BGP information. */
- bgp_path_info_add(rn, new);
+ bgp_path_info_add(dest, new);
/* route_node_get lock */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
/* Process change. */
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
if (SAFI_UNICAST == safi
&& (bgp->inst_type == BGP_INSTANCE_TYPE_VRF
@@ -5193,13 +5198,13 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p,
void bgp_static_withdraw(struct bgp *bgp, const struct prefix *p, afi_t afi,
safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
/* Check selected route and self inserted route. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
@@ -5213,12 +5218,12 @@ void bgp_static_withdraw(struct bgp *bgp, const struct prefix *p, afi_t afi,
}
bgp_aggregate_decrement(bgp, p, pi, afi, safi);
bgp_unlink_nexthop(pi);
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, safi);
}
/* Unlock bgp_node_lookup. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
/*
@@ -5228,13 +5233,13 @@ static void bgp_static_withdraw_safi(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi,
struct prefix_rd *prd)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
/* Check selected route and self inserted route. */
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
@@ -5251,19 +5256,19 @@ static void bgp_static_withdraw_safi(struct bgp *bgp, const struct prefix *p,
vpn_leak_to_vrf_withdraw(bgp, pi);
}
bgp_aggregate_decrement(bgp, p, pi, afi, safi);
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, safi);
}
/* Unlock bgp_node_lookup. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
struct bgp_static *bgp_static, afi_t afi,
safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *new;
struct attr *attr_new;
struct attr attr = {0};
@@ -5278,8 +5283,8 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
if (bgp_static->label != MPLS_INVALID_LABEL)
num_labels = 1;
- rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p,
- &bgp_static->prd);
+ dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p,
+ &bgp_static->prd);
bgp_attr_default_set(&attr, BGP_ORIGIN_IGP);
@@ -5344,7 +5349,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
attr_new = bgp_attr_intern(&attr);
}
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
@@ -5354,17 +5359,17 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
if (attrhash_cmp(pi->attr, attr_new)
&& overlay_index_equal(afi, pi, bgp_static->eth_s_id, &add)
&& !CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
bgp_attr_unintern(&attr_new);
aspath_unintern(&attr.aspath);
return;
} else {
/* The attribute is changed. */
- bgp_path_info_set_flag(rn, pi, BGP_PATH_ATTR_CHANGED);
+ bgp_path_info_set_flag(dest, pi, BGP_PATH_ATTR_CHANGED);
/* Rewrite BGP route information. */
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED))
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
else
bgp_aggregate_decrement(bgp, p, pi, afi, safi);
bgp_attr_unintern(&pi->attr);
@@ -5377,7 +5382,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
/* Process change. */
bgp_aggregate_increment(bgp, p, pi, afi, safi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
if (SAFI_MPLS_VPN == safi
&& bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
@@ -5388,7 +5393,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
pi->attr, afi, safi, pi->type,
pi->sub_type, &label);
#endif
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
aspath_unintern(&attr.aspath);
return;
}
@@ -5397,7 +5402,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
/* Make new BGP info. */
new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self,
- attr_new, rn);
+ attr_new, dest);
SET_FLAG(new->flags, BGP_PATH_VALID);
new->extra = bgp_path_info_extra_new();
if (num_labels) {
@@ -5412,12 +5417,12 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p,
bgp_aggregate_increment(bgp, p, new, afi, safi);
/* Register new BGP information. */
- bgp_path_info_add(rn, new);
+ bgp_path_info_add(dest, new);
/* route_node_get lock */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
/* Process change. */
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
if (SAFI_MPLS_VPN == safi
&& bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
@@ -5442,7 +5447,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
int ret;
struct prefix p;
struct bgp_static *bgp_static;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
uint8_t need_update = 0;
/* Convert IP prefix string to struct prefix. */
@@ -5461,14 +5466,14 @@ static int bgp_static_set(struct vty *vty, const char *negate,
if (negate) {
/* Set BGP static route configuration. */
- rn = bgp_node_lookup(bgp->route[afi][safi], &p);
+ dest = bgp_node_lookup(bgp->route[afi][safi], &p);
- if (!rn) {
+ if (!dest) {
vty_out(vty, "%% Can't find static route specified\n");
return CMD_WARNING_CONFIG_FAILED;
}
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
if ((label_index != BGP_INVALID_LABEL_INDEX)
&& (label_index != bgp_static->label_index)) {
@@ -5490,15 +5495,14 @@ static int bgp_static_set(struct vty *vty, const char *negate,
/* Clear configuration. */
bgp_static_free(bgp_static);
- bgp_node_set_bgp_static_info(rn, NULL);
- bgp_unlock_node(rn);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_static_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
+ bgp_dest_unlock_node(dest);
} else {
/* Set BGP static route configuration. */
- rn = bgp_node_get(bgp->route[afi][safi], &p);
-
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ dest = bgp_node_get(bgp->route[afi][safi], &p);
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
if (bgp_static) {
/* Configuration change. */
/* Label index cannot be changed. */
@@ -5533,7 +5537,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
bgp_static->rmap.map = NULL;
bgp_static->valid = 0;
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
} else {
/* New configuration. */
bgp_static = bgp_static_new();
@@ -5555,7 +5559,7 @@ static int bgp_static_set(struct vty *vty, const char *negate,
route_map_counter_increment(
bgp_static->rmap.map);
}
- bgp_node_set_bgp_static_info(rn, bgp_static);
+ bgp_dest_set_bgp_static_info(dest, bgp_static);
}
bgp_static->valid = 1;
@@ -5573,35 +5577,34 @@ void bgp_static_add(struct bgp *bgp)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
- struct bgp_node *rm;
+ struct bgp_dest *dest;
+ struct bgp_dest *rm;
struct bgp_table *table;
struct bgp_static *bgp_static;
FOREACH_AFI_SAFI (afi, safi)
- for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- if (!bgp_node_has_bgp_path_info_data(rn))
+ for (dest = bgp_table_top(bgp->route[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ if (!bgp_dest_has_bgp_path_info_data(dest))
continue;
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
bgp_static =
- bgp_node_get_bgp_static_info(
+ bgp_dest_get_bgp_static_info(
rm);
- bgp_static_update_safi(bgp,
- bgp_node_get_prefix(rm),
- bgp_static, afi,
- safi);
+ bgp_static_update_safi(
+ bgp, bgp_dest_get_prefix(rm),
+ bgp_static, afi, safi);
}
} else {
bgp_static_update(
- bgp, bgp_node_get_prefix(rn),
- bgp_node_get_bgp_static_info(rn), afi,
+ bgp, bgp_dest_get_prefix(dest),
+ bgp_dest_get_bgp_static_info(dest), afi,
safi);
}
}
@@ -5613,47 +5616,48 @@ void bgp_static_delete(struct bgp *bgp)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
- struct bgp_node *rm;
+ struct bgp_dest *dest;
+ struct bgp_dest *rm;
struct bgp_table *table;
struct bgp_static *bgp_static;
FOREACH_AFI_SAFI (afi, safi)
- for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- if (!bgp_node_has_bgp_path_info_data(rn))
+ for (dest = bgp_table_top(bgp->route[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ if (!bgp_dest_has_bgp_path_info_data(dest))
continue;
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
bgp_static =
- bgp_node_get_bgp_static_info(
+ bgp_dest_get_bgp_static_info(
rm);
if (!bgp_static)
continue;
bgp_static_withdraw_safi(
- bgp, bgp_node_get_prefix(rm),
+ bgp, bgp_dest_get_prefix(rm),
AFI_IP, safi,
(struct prefix_rd *)
- bgp_node_get_prefix(
- rn));
+ bgp_dest_get_prefix(
+ dest));
bgp_static_free(bgp_static);
- bgp_node_set_bgp_static_info(rn, NULL);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_static_info(dest,
+ NULL);
+ bgp_dest_unlock_node(dest);
}
} else {
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
bgp_static_withdraw(bgp,
- bgp_node_get_prefix(rn),
+ bgp_dest_get_prefix(dest),
afi, safi);
bgp_static_free(bgp_static);
- bgp_node_set_bgp_static_info(rn, NULL);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_static_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
}
}
}
@@ -5662,38 +5666,37 @@ void bgp_static_redo_import_check(struct bgp *bgp)
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
- struct bgp_node *rm;
+ struct bgp_dest *dest;
+ struct bgp_dest *rm;
struct bgp_table *table;
struct bgp_static *bgp_static;
/* Use this flag to force reprocessing of the route */
SET_FLAG(bgp->flags, BGP_FLAG_FORCE_STATIC_PROCESS);
FOREACH_AFI_SAFI (afi, safi) {
- for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- if (!bgp_node_has_bgp_path_info_data(rn))
+ for (dest = bgp_table_top(bgp->route[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ if (!bgp_dest_has_bgp_path_info_data(dest))
continue;
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
bgp_static =
- bgp_node_get_bgp_static_info(
+ bgp_dest_get_bgp_static_info(
rm);
- bgp_static_update_safi(bgp,
- bgp_node_get_prefix(rm),
- bgp_static, afi,
- safi);
+ bgp_static_update_safi(
+ bgp, bgp_dest_get_prefix(rm),
+ bgp_static, afi, safi);
}
} else {
- bgp_static = bgp_node_get_bgp_static_info(rn);
- bgp_static_update(bgp, bgp_node_get_prefix(rn),
- bgp_static, afi,
- safi);
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
+ bgp_static_update(bgp,
+ bgp_dest_get_prefix(dest),
+ bgp_static, afi, safi);
}
}
}
@@ -5704,7 +5707,7 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,
safi_t safi)
{
struct bgp_table *table;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
/* Do not install the aggregate route if BGP is in the
@@ -5715,20 +5718,20 @@ static void bgp_purge_af_static_redist_routes(struct bgp *bgp, afi_t afi,
return;
table = bgp->rib[afi][safi];
- 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 (pi->peer == bgp->peer_self
&& ((pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
|| (pi->type != ZEBRA_ROUTE_BGP
&& pi->sub_type
== BGP_ROUTE_REDISTRIBUTE))) {
- bgp_aggregate_decrement(bgp,
- bgp_node_get_prefix(rn),
- pi, afi, safi);
+ bgp_aggregate_decrement(
+ bgp, bgp_dest_get_prefix(dest), pi, afi,
+ safi);
bgp_unlink_nexthop(pi);
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, safi);
}
}
}
@@ -5762,8 +5765,8 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
int ret;
struct prefix p;
struct prefix_rd prd;
- struct bgp_node *prn;
- struct bgp_node *rn;
+ struct bgp_dest *pdest;
+ struct bgp_dest *dest;
struct bgp_table *table;
struct bgp_static *bgp_static;
mpls_label_t label = MPLS_INVALID_LABEL;
@@ -5823,17 +5826,17 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
}
}
}
- prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
- if (!bgp_node_has_bgp_path_info_data(prn))
- bgp_node_set_bgp_table_info(prn,
+ pdest = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
+ if (!bgp_dest_has_bgp_path_info_data(pdest))
+ bgp_dest_set_bgp_table_info(pdest,
bgp_table_init(bgp, afi, safi));
- table = bgp_node_get_bgp_table_info(prn);
+ table = bgp_dest_get_bgp_table_info(pdest);
- rn = bgp_node_get(table, &p);
+ dest = bgp_node_get(table, &p);
- if (bgp_node_has_bgp_path_info_data(rn)) {
+ if (bgp_dest_has_bgp_path_info_data(dest)) {
vty_out(vty, "%% Same network configuration exists\n");
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
} else {
/* New configuration. */
bgp_static = bgp_static_new();
@@ -5870,7 +5873,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
if (gwip)
prefix_copy(&bgp_static->gatewayIp, &gw_ip);
}
- bgp_node_set_bgp_static_info(rn, bgp_static);
+ bgp_dest_set_bgp_static_info(dest, bgp_static);
bgp_static->valid = 1;
bgp_static_update_safi(bgp, &p, bgp_static, afi, safi);
@@ -5889,8 +5892,8 @@ int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty,
int ret;
struct prefix p;
struct prefix_rd prd;
- struct bgp_node *prn;
- struct bgp_node *rn;
+ struct bgp_dest *pdest;
+ struct bgp_dest *dest;
struct bgp_table *table;
struct bgp_static *bgp_static;
mpls_label_t label = MPLS_INVALID_LABEL;
@@ -5920,24 +5923,24 @@ int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty,
encode_label(label_val, &label);
}
- prn = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
- if (!bgp_node_has_bgp_path_info_data(prn))
- bgp_node_set_bgp_table_info(prn,
+ pdest = bgp_node_get(bgp->route[afi][safi], (struct prefix *)&prd);
+ if (!bgp_dest_has_bgp_path_info_data(pdest))
+ bgp_dest_set_bgp_table_info(pdest,
bgp_table_init(bgp, afi, safi));
else
- bgp_unlock_node(prn);
- table = bgp_node_get_bgp_table_info(prn);
+ bgp_dest_unlock_node(pdest);
+ table = bgp_dest_get_bgp_table_info(pdest);
- rn = bgp_node_lookup(table, &p);
+ dest = bgp_node_lookup(table, &p);
- if (rn) {
+ if (dest) {
bgp_static_withdraw_safi(bgp, &p, afi, safi, &prd);
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
bgp_static_free(bgp_static);
- bgp_node_set_bgp_static_info(rn, NULL);
- bgp_unlock_node(rn);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_static_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
+ bgp_dest_unlock_node(dest);
} else
vty_out(vty, "%% Can't find the route\n");
@@ -6124,16 +6127,16 @@ static void bgp_aggregate_install(
struct ecommunity *ecommunity, struct lcommunity *lcommunity,
uint8_t atomic_aggregate, struct bgp_aggregate *aggregate)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_table *table;
struct bgp_path_info *pi, *orig, *new;
struct attr *attr;
table = bgp->rib[afi][safi];
- rn = bgp_node_get(table, p);
+ dest = bgp_node_get(table, p);
- for (orig = pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (orig = pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_AGGREGATE)
break;
@@ -6145,7 +6148,7 @@ static void bgp_aggregate_install(
*/
if (bgp_aggregate_info_same(orig, origin, aspath, community,
ecommunity, lcommunity)) {
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
if (aspath)
aspath_free(aspath);
@@ -6163,7 +6166,7 @@ static void bgp_aggregate_install(
* Mark the old as unusable
*/
if (pi)
- bgp_path_info_delete(rn, pi);
+ bgp_path_info_delete(dest, pi);
attr = bgp_attr_aggregate_intern(
bgp, origin, aspath, community, ecommunity, lcommunity,
@@ -6175,12 +6178,12 @@ static void bgp_aggregate_install(
}
new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_AGGREGATE, 0,
- bgp->peer_self, attr, rn);
+ bgp->peer_self, attr, dest);
SET_FLAG(new->flags, BGP_PATH_VALID);
- bgp_path_info_add(rn, new);
- bgp_process(bgp, rn, afi, safi);
+ bgp_path_info_add(dest, new);
+ bgp_process(bgp, dest, afi, safi);
} else {
for (pi = orig; pi; pi = pi->next)
if (pi->peer == bgp->peer_self
@@ -6190,12 +6193,12 @@ static void bgp_aggregate_install(
/* Withdraw static BGP route from routing table. */
if (pi) {
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, safi);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, safi);
}
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
/* Update an aggregate as routes are added/removed from the BGP table */
@@ -6203,8 +6206,8 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
safi_t safi, struct bgp_aggregate *aggregate)
{
struct bgp_table *table;
- struct bgp_node *top;
- struct bgp_node *rn;
+ struct bgp_dest *top;
+ struct bgp_dest *dest;
uint8_t origin;
struct aspath *aspath = NULL;
struct community *community = NULL;
@@ -6234,16 +6237,16 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
table = bgp->rib[afi][safi];
top = bgp_node_get(table, p);
- for (rn = bgp_node_get(table, p); rn;
- rn = bgp_route_next_until(rn, top)) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = bgp_node_get(table, p); dest;
+ dest = bgp_route_next_until(dest, top)) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- if (rn_p->prefixlen <= p->prefixlen)
+ if (dest_p->prefixlen <= p->prefixlen)
continue;
match = 0;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
@@ -6260,7 +6263,7 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
*/
if (aggregate->summary_only) {
(bgp_path_info_extra_get(pi))->suppress++;
- bgp_path_info_set_flag(rn, pi,
+ bgp_path_info_set_flag(dest, pi,
BGP_PATH_ATTR_CHANGED);
match++;
}
@@ -6324,7 +6327,7 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
pi->attr->lcommunity);
}
if (match)
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
}
if (aggregate->as_set) {
bgp_compute_aggregate_aspath_val(aggregate);
@@ -6334,7 +6337,7 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
}
- bgp_unlock_node(top);
+ bgp_dest_unlock_node(top);
if (aggregate->incomplete_origin_count > 0)
@@ -6376,8 +6379,8 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
safi_t safi, struct bgp_aggregate *aggregate)
{
struct bgp_table *table;
- struct bgp_node *top;
- struct bgp_node *rn;
+ struct bgp_dest *top;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
unsigned long match;
@@ -6385,15 +6388,15 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
/* If routes exists below this node, generate aggregate routes. */
top = bgp_node_get(table, p);
- for (rn = bgp_node_get(table, p); rn;
- rn = bgp_route_next_until(rn, top)) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = bgp_node_get(table, p); dest;
+ dest = bgp_route_next_until(dest, top)) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- if (rn_p->prefixlen <= p->prefixlen)
+ if (dest_p->prefixlen <= p->prefixlen)
continue;
match = 0;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
@@ -6405,7 +6408,8 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (pi->extra->suppress == 0) {
bgp_path_info_set_flag(
- rn, pi, BGP_PATH_ATTR_CHANGED);
+ dest, pi,
+ BGP_PATH_ATTR_CHANGED);
match++;
}
}
@@ -6444,12 +6448,11 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
aggregate,
pi->attr->lcommunity);
}
-
}
/* If this node was suppressed, process the change. */
if (match)
- bgp_process(bgp, rn, afi, safi);
+ bgp_process(bgp, dest, afi, safi);
}
if (aggregate->as_set) {
aspath_free(aggregate->aspath);
@@ -6462,7 +6465,7 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
lcommunity_free(&aggregate->lcommunity);
}
- bgp_unlock_node(top);
+ bgp_dest_unlock_node(top);
}
static void bgp_add_route_to_aggregate(struct bgp *bgp,
@@ -6679,8 +6682,8 @@ static void bgp_remove_route_from_aggregate(struct bgp *bgp, afi_t afi,
void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
struct bgp_path_info *pi, afi_t afi, safi_t safi)
{
- struct bgp_node *child;
- struct bgp_node *rn;
+ struct bgp_dest *child;
+ struct bgp_dest *dest;
struct bgp_aggregate *aggregate;
struct bgp_table *table;
@@ -6699,23 +6702,23 @@ void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
child = bgp_node_get(table, p);
/* Aggregate address configuration check. */
- for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = child; dest; dest = bgp_dest_parent_nolock(dest)) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- aggregate = bgp_node_get_bgp_aggregate_info(rn);
- if (aggregate != NULL && rn_p->prefixlen < p->prefixlen) {
- bgp_add_route_to_aggregate(bgp, rn_p, pi, afi, safi,
+ aggregate = bgp_dest_get_bgp_aggregate_info(dest);
+ if (aggregate != NULL && dest_p->prefixlen < p->prefixlen) {
+ bgp_add_route_to_aggregate(bgp, dest_p, pi, afi, safi,
aggregate);
}
}
- bgp_unlock_node(child);
+ bgp_dest_unlock_node(child);
}
void bgp_aggregate_decrement(struct bgp *bgp, const struct prefix *p,
struct bgp_path_info *del, afi_t afi, safi_t safi)
{
- struct bgp_node *child;
- struct bgp_node *rn;
+ struct bgp_dest *child;
+ struct bgp_dest *dest;
struct bgp_aggregate *aggregate;
struct bgp_table *table;
@@ -6731,16 +6734,16 @@ void bgp_aggregate_decrement(struct bgp *bgp, const struct prefix *p,
child = bgp_node_get(table, p);
/* Aggregate address configuration check. */
- for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = child; dest; dest = bgp_dest_parent_nolock(dest)) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- aggregate = bgp_node_get_bgp_aggregate_info(rn);
- if (aggregate != NULL && rn_p->prefixlen < p->prefixlen) {
+ aggregate = bgp_dest_get_bgp_aggregate_info(dest);
+ if (aggregate != NULL && dest_p->prefixlen < p->prefixlen) {
bgp_remove_route_from_aggregate(bgp, afi, safi, del,
- aggregate, rn_p);
+ aggregate, dest_p);
}
}
- bgp_unlock_node(child);
+ bgp_dest_unlock_node(child);
}
/* Aggregate route attribute. */
@@ -6767,7 +6770,7 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_aggregate *aggregate;
/* Convert string to prefix structure. */
@@ -6779,20 +6782,20 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
apply_mask(&p);
/* Old configuration check. */
- rn = bgp_node_lookup(bgp->aggregate[afi][safi], &p);
- if (!rn) {
+ dest = bgp_node_lookup(bgp->aggregate[afi][safi], &p);
+ if (!dest) {
vty_out(vty,
"%% There is no aggregate-address configuration.\n");
return CMD_WARNING_CONFIG_FAILED;
}
- aggregate = bgp_node_get_bgp_aggregate_info(rn);
+ aggregate = bgp_dest_get_bgp_aggregate_info(dest);
bgp_aggregate_delete(bgp, &p, afi, safi, aggregate);
bgp_aggregate_install(bgp, afi, safi, &p, 0, NULL, NULL,
NULL, NULL, 0, aggregate);
/* Unlock aggregate address configuration. */
- bgp_node_set_bgp_aggregate_info(rn, NULL);
+ bgp_dest_set_bgp_aggregate_info(dest, NULL);
if (aggregate->community)
community_free(&aggregate->community);
@@ -6847,8 +6850,8 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
}
bgp_aggregate_free(aggregate);
- bgp_unlock_node(rn);
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
+ bgp_dest_unlock_node(dest);
return CMD_SUCCESS;
}
@@ -6861,7 +6864,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
struct prefix p;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_aggregate *aggregate;
uint8_t as_set_new = as_set;
@@ -6881,8 +6884,8 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
}
/* Old configuration check. */
- rn = bgp_node_get(bgp->aggregate[afi][safi], &p);
- aggregate = bgp_node_get_bgp_aggregate_info(rn);
+ dest = bgp_node_get(bgp->aggregate[afi][safi], &p);
+ aggregate = bgp_dest_get_bgp_aggregate_info(dest);
if (aggregate) {
vty_out(vty, "There is already same aggregate network.\n");
@@ -6890,7 +6893,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
ret = bgp_aggregate_unset(vty, prefix_str, afi, safi);
if (ret) {
vty_out(vty, "Error deleting aggregate.\n");
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -6935,7 +6938,7 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
aggregate->rmap.map = route_map_lookup_by_name(rmap);
route_map_counter_increment(aggregate->rmap.map);
}
- bgp_node_set_bgp_aggregate_info(rn, aggregate);
+ bgp_dest_set_bgp_aggregate_info(dest, aggregate);
/* Aggregate address insert into BGP routing table. */
bgp_aggregate_route(bgp, &p, afi, safi, aggregate);
@@ -7185,7 +7188,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
struct bgp_path_info *new;
struct bgp_path_info *bpi;
struct bgp_path_info rmap_path;
- struct bgp_node *bn;
+ struct bgp_dest *bn;
struct attr attr;
struct attr *new_attr;
afi_t afi;
@@ -7275,8 +7278,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
new_attr = bgp_attr_intern(&attr_new);
- 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->peer == bgp->peer_self
&& bpi->sub_type == BGP_ROUTE_REDISTRIBUTE)
break;
@@ -7288,7 +7290,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
&& !CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)) {
bgp_attr_unintern(&new_attr);
aspath_unintern(&attr.aspath);
- bgp_unlock_node(bn);
+ bgp_dest_unlock_node(bn);
return;
} else {
/* The attribute is changed. */
@@ -7309,7 +7311,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
bgp_aggregate_increment(bgp, p, bpi, afi,
SAFI_UNICAST);
bgp_process(bgp, bn, afi, SAFI_UNICAST);
- bgp_unlock_node(bn);
+ bgp_dest_unlock_node(bn);
aspath_unintern(&attr.aspath);
if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
@@ -7329,7 +7331,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p,
bgp_aggregate_increment(bgp, p, new, afi, SAFI_UNICAST);
bgp_path_info_add(bn, new);
- bgp_unlock_node(bn);
+ bgp_dest_unlock_node(bn);
bgp_process(bgp, bn, afi, SAFI_UNICAST);
if ((bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
@@ -7347,7 +7349,7 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type,
unsigned short instance)
{
afi_t afi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_redist *red;
@@ -7355,10 +7357,10 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type,
red = bgp_redist_lookup(bgp, afi, type, instance);
if (red) {
- rn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi,
- SAFI_UNICAST, p, NULL);
+ dest = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi,
+ SAFI_UNICAST, p, NULL);
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == type)
break;
@@ -7370,10 +7372,10 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type,
bgp, pi);
}
bgp_aggregate_decrement(bgp, p, pi, afi, SAFI_UNICAST);
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, SAFI_UNICAST);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, SAFI_UNICAST);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
}
@@ -7381,14 +7383,14 @@ void bgp_redistribute_delete(struct bgp *bgp, struct prefix *p, uint8_t type,
void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type,
unsigned short instance)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_table *table;
table = bgp->rib[afi][SAFI_UNICAST];
- 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 (pi->peer == bgp->peer_self && pi->type == type
&& pi->instance == instance)
break;
@@ -7400,10 +7402,10 @@ void bgp_redistribute_withdraw(struct bgp *bgp, afi_t afi, int type,
vpn_leak_from_vrf_withdraw(bgp_get_default(),
bgp, pi);
}
- bgp_aggregate_decrement(bgp, bgp_node_get_prefix(rn),
+ bgp_aggregate_decrement(bgp, bgp_dest_get_prefix(dest),
pi, afi, SAFI_UNICAST);
- bgp_path_info_delete(rn, pi);
- bgp_process(bgp, rn, afi, SAFI_UNICAST);
+ bgp_path_info_delete(dest, pi);
+ bgp_process(bgp, dest, afi, SAFI_UNICAST);
}
}
}
@@ -8623,9 +8625,9 @@ static const char *bgp_path_selection_reason2str(
return "Invalid (internal error)";
}
-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)
+void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
+ struct bgp_path_info *path, afi_t afi, safi_t safi,
+ json_object *json_paths)
{
char buf[INET6_ADDRSTRLEN];
char buf1[BUFSIZ];
@@ -8678,7 +8680,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (!json_paths) {
bgp_evpn_route2str(
(struct prefix_evpn *)
- bgp_node_get_prefix(bn),
+ bgp_dest_get_prefix(bn),
buf2, sizeof(buf2));
vty_out(vty, " Route %s", buf2);
if (tag_buf[0] != '\0')
@@ -8693,19 +8695,21 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (path->extra && path->extra->parent && !json_paths) {
struct bgp_path_info *parent_ri;
- struct bgp_node *rn, *prn;
+ struct bgp_dest *dest, *pdest;
parent_ri = (struct bgp_path_info *)path->extra->parent;
- rn = parent_ri->net;
- if (rn && rn->prn) {
- prn = rn->prn;
- prefix_rd2str((struct prefix_rd *)
- bgp_node_get_prefix(prn),
- buf1, sizeof(buf1));
+ dest = parent_ri->net;
+ if (dest && dest->pdest) {
+ pdest = dest->pdest;
+ prefix_rd2str(
+ (struct prefix_rd *)bgp_dest_get_prefix(
+ pdest),
+ buf1, sizeof(buf1));
if (is_pi_family_evpn(parent_ri)) {
bgp_evpn_route2str(
(struct prefix_evpn *)
- bgp_node_get_prefix(rn),
+ bgp_dest_get_prefix(
+ dest),
buf2, sizeof(buf2));
vty_out(vty, " Imported from %s:%s, VNI %s\n", buf1, buf2, tag_buf);
} else
@@ -8807,7 +8811,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
/* Line2 display Next-hop, Neighbor, Router-id */
/* Display the nexthop */
- const struct prefix *bn_p = bgp_node_get_prefix(bn);
+ const struct prefix *bn_p = bgp_dest_get_prefix(bn);
if ((bn_p->family == AF_INET || bn_p->family == AF_ETHERNET
|| bn_p->family == AF_EVPN)
@@ -9538,7 +9542,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
unsigned long *json_header_depth)
{
struct bgp_path_info *pi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
int header = 1;
int display;
unsigned long output_count = 0;
@@ -9574,10 +9578,10 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
}
/* Start processing of routes. */
- 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);
- pi = bgp_node_get_bgp_path_info(rn);
+ pi = bgp_dest_get_bgp_path_info(dest);
if (pi == NULL)
continue;
@@ -9606,7 +9610,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
if (type == bgp_show_type_prefix_list) {
struct prefix_list *plist = output_arg;
- if (prefix_list_apply(plist, rn_p)
+ if (prefix_list_apply(plist, dest_p)
!= PREFIX_PERMIT)
continue;
}
@@ -9628,7 +9632,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
path.peer = pi->peer;
path.attr = &dummy_attr;
- ret = route_map_apply(rmap, rn_p, RMAP_BGP,
+ ret = route_map_apply(rmap, dest_p, RMAP_BGP,
&path);
if (ret == RMAP_DENYMATCH)
continue;
@@ -9646,20 +9650,20 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
if (type == bgp_show_type_cidr_only) {
uint32_t destination;
- destination = ntohl(rn_p->u.prefix4.s_addr);
+ destination = ntohl(dest_p->u.prefix4.s_addr);
if (IN_CLASSC(destination)
- && rn_p->prefixlen == 24)
+ && dest_p->prefixlen == 24)
continue;
if (IN_CLASSB(destination)
- && rn_p->prefixlen == 16)
+ && dest_p->prefixlen == 16)
continue;
if (IN_CLASSA(destination)
- && rn_p->prefixlen == 8)
+ && dest_p->prefixlen == 8)
continue;
}
if (type == bgp_show_type_prefix_longer) {
p = output_arg;
- if (!prefix_match(p, rn_p))
+ if (!prefix_match(p, dest_p))
continue;
}
if (type == bgp_show_type_community_all) {
@@ -9772,16 +9776,16 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
}
if (type == bgp_show_type_dampend_paths
|| type == bgp_show_type_damp_neighbor)
- damp_route_vty_out(vty, rn_p, pi, display,
+ damp_route_vty_out(vty, dest_p, pi, display,
AFI_IP, safi, use_json,
json_paths);
else if (type == bgp_show_type_flap_statistics
|| type == bgp_show_type_flap_neighbor)
- flap_route_vty_out(vty, rn_p, pi, display,
+ flap_route_vty_out(vty, dest_p, pi, display,
AFI_IP, safi, use_json,
json_paths);
else
- route_vty_out(vty, rn_p, pi, display, safi,
+ route_vty_out(vty, dest_p, pi, display, safi,
json_paths);
display++;
}
@@ -9792,24 +9796,24 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
continue;
/* encode prefix */
- if (rn_p->family == AF_FLOWSPEC) {
+ if (dest_p->family == AF_FLOWSPEC) {
char retstr[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
bgp_fs_nlri_get_string(
(unsigned char *)
- rn_p->u.prefix_flowspec.ptr,
- rn_p->u.prefix_flowspec.prefixlen,
+ dest_p->u.prefix_flowspec.ptr,
+ dest_p->u.prefix_flowspec.prefixlen,
retstr, NLRI_STRING_FORMAT_MIN, NULL);
if (first)
vty_out(vty, "\"%s/%d\": ", retstr,
- rn_p->u.prefix_flowspec
+ dest_p->u.prefix_flowspec
.prefixlen);
else
vty_out(vty, ",\"%s/%d\": ", retstr,
- rn_p->u.prefix_flowspec
+ dest_p->u.prefix_flowspec
.prefixlen);
} else {
- prefix2str(rn_p, buf2, sizeof(buf2));
+ prefix2str(dest_p, buf2, sizeof(buf2));
if (first)
vty_out(vty, "\"%s\": ", buf2);
else
@@ -9865,7 +9869,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd_match,
enum bgp_show_type type, void *output_arg, bool use_json)
{
- struct bgp_node *rn, *next;
+ struct bgp_dest *dest, *next;
unsigned long output_cum = 0;
unsigned long total_cum = 0;
unsigned long json_header_depth = 0;
@@ -9874,19 +9878,19 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
show_msg = (!use_json && type == bgp_show_type_normal);
- for (rn = bgp_table_top(table); rn; rn = next) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ for (dest = bgp_table_top(table); dest; dest = next) {
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
- next = bgp_route_next(rn);
- if (prd_match && memcmp(rn_p->u.val, prd_match->val, 8) != 0)
+ next = bgp_route_next(dest);
+ if (prd_match && memcmp(dest_p->u.val, prd_match->val, 8) != 0)
continue;
- itable = bgp_node_get_bgp_table_info(rn);
+ itable = bgp_dest_get_bgp_table_info(dest);
if (itable != NULL) {
struct prefix_rd prd;
char rd[RD_ADDRSTRLEN];
- memcpy(&prd, rn_p, sizeof(struct prefix_rd));
+ memcpy(&prd, dest_p, sizeof(struct prefix_rd));
prefix_rd2str(&prd, rd, sizeof(rd));
bgp_show_table(vty, bgp, safi, itable, type, output_arg,
use_json, rd, next == NULL, &output_cum,
@@ -9985,7 +9989,7 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
/* Header of detailed BGP route information */
void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
- struct bgp_node *rn, struct prefix_rd *prd,
+ struct bgp_dest *dest, struct prefix_rd *prd,
afi_t afi, safi_t safi, json_object *json)
{
struct bgp_path_info *pi;
@@ -10017,11 +10021,11 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
mpls_label_t label = 0;
json_object *json_adv_to = NULL;
- p = bgp_node_get_prefix(rn);
- has_valid_label = bgp_is_valid_label(&rn->local_label);
+ p = bgp_dest_get_prefix(dest);
+ has_valid_label = bgp_is_valid_label(&dest->local_label);
if (has_valid_label)
- label = label_pton(&rn->local_label);
+ label = label_pton(&dest->local_label);
if (safi == SAFI_EVPN) {
@@ -10065,7 +10069,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
if (bgp_labeled_safi(safi) && safi != SAFI_EVPN)
vty_out(vty, "not allocated\n");
- 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) {
count++;
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
best = count;
@@ -10171,7 +10175,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
* though then we must display Advertised to on a path-by-path basis. */
if (!bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
- if (bgp_adj_out_lookup(peer, rn, 0)) {
+ if (bgp_adj_out_lookup(peer, dest, 0)) {
if (json && !json_adv_to)
json_adv_to = json_object_new_object();
@@ -10196,10 +10200,10 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
}
static void bgp_show_path_info(struct prefix_rd *pfx_rd,
- struct bgp_node *bgp_node, struct vty *vty,
- struct bgp *bgp, afi_t afi,
- safi_t safi, json_object *json,
- enum bgp_path_type pathtype, int *display)
+ struct bgp_dest *bgp_node, struct vty *vty,
+ struct bgp *bgp, afi_t afi, safi_t safi,
+ json_object *json, enum bgp_path_type pathtype,
+ int *display)
{
struct bgp_path_info *pi;
int header = 1;
@@ -10207,8 +10211,7 @@ static void bgp_show_path_info(struct prefix_rd *pfx_rd,
json_object *json_header = NULL;
json_object *json_paths = NULL;
- for (pi = bgp_node_get_bgp_path_info(bgp_node); pi;
- pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(bgp_node); pi; pi = pi->next) {
if (json && !json_paths) {
/* Instantiate json_paths only if path is valid */
@@ -10257,8 +10260,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
int ret;
int display = 0;
struct prefix match;
- struct bgp_node *rn;
- struct bgp_node *rm;
+ struct bgp_dest *dest;
+ struct bgp_dest *rm;
struct bgp_table *table;
json_object *json = NULL;
json_object *json_paths = NULL;
@@ -10276,41 +10279,43 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
json = json_object_new_object();
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) {
- 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)
continue;
if ((rm = bgp_node_match(table, &match)) == NULL)
continue;
- const struct prefix *rm_p = bgp_node_get_prefix(rm);
+ const struct prefix *rm_p = bgp_dest_get_prefix(rm);
if (prefix_check
&& rm_p->prefixlen != match.prefixlen) {
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
continue;
}
- bgp_show_path_info((struct prefix_rd *)rn_p, rm, vty,
+ bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty,
bgp, afi, safi, json, pathtype,
&display);
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
}
} else if (safi == SAFI_EVPN) {
- struct bgp_node *longest_pfx;
+ struct bgp_dest *longest_pfx;
bool is_exact_pfxlen_match = false;
- 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)
continue;
@@ -10325,7 +10330,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
const struct prefix *rm_p =
- bgp_node_get_prefix(rm);
+ bgp_dest_get_prefix(rm);
/*
* Get prefixlen of the ip-prefix within type5
* evpn route
@@ -10338,7 +10343,7 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
rm_p);
if (type5_pfxlen == match.prefixlen) {
is_exact_pfxlen_match = true;
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
break;
}
}
@@ -10351,13 +10356,13 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
continue;
rm = longest_pfx;
- bgp_lock_node(rm);
+ bgp_dest_lock_node(rm);
- bgp_show_path_info((struct prefix_rd *)rn_p, rm, vty,
+ bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty,
bgp, afi, safi, json, pathtype,
&display);
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
}
} else if (safi == SAFI_FLOWSPEC) {
if (use_json)
@@ -10371,16 +10376,16 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
if (use_json && display)
json_object_object_add(json, "paths", json_paths);
} 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 (!prefix_check
- || rn_p->prefixlen == match.prefixlen) {
- bgp_show_path_info(NULL, rn, vty, bgp, afi,
- safi, json,
- pathtype, &display);
+ || dest_p->prefixlen == match.prefixlen) {
+ bgp_show_path_info(NULL, dest, vty, bgp, afi,
+ safi, json, pathtype,
+ &display);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
}
@@ -11220,20 +11225,20 @@ ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
}
#endif
-static void bgp_table_stats_rn(struct bgp_node *rn, struct bgp_node *top,
+static void bgp_table_stats_rn(struct bgp_dest *dest, struct bgp_dest *top,
struct bgp_table_stats *ts, unsigned int space)
{
- struct bgp_node *prn = bgp_node_parent_nolock(rn);
+ struct bgp_dest *pdest = bgp_dest_parent_nolock(dest);
struct bgp_path_info *pi;
const struct prefix *rn_p;
- if (rn == top)
+ if (dest == top)
return;
- if (!bgp_node_has_bgp_path_info_data(rn))
+ if (!bgp_dest_has_bgp_path_info_data(dest))
return;
- rn_p = bgp_node_get_prefix(rn);
+ rn_p = bgp_dest_get_prefix(dest);
ts->counts[BGP_STATS_PREFIXES]++;
ts->counts[BGP_STATS_TOTPLEN] += rn_p->prefixlen;
@@ -11245,19 +11250,19 @@ static void bgp_table_stats_rn(struct bgp_node *rn, struct bgp_node *top,
#endif
/* check if the prefix is included by any other announcements */
- while (prn && !bgp_node_has_bgp_path_info_data(prn))
- prn = bgp_node_parent_nolock(prn);
+ while (pdest && !bgp_dest_has_bgp_path_info_data(pdest))
+ pdest = bgp_dest_parent_nolock(pdest);
- if (prn == NULL || prn == top) {
+ if (pdest == NULL || pdest == top) {
ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
/* announced address space */
if (space)
ts->total_space += pow(2.0, space - rn_p->prefixlen);
- } else if (bgp_node_has_bgp_path_info_data(prn))
+ } else if (bgp_dest_has_bgp_path_info_data(pdest))
ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
- 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) {
ts->counts[BGP_STATS_RIB]++;
if (CHECK_FLAG(pi->attr->flag,
@@ -11298,8 +11303,8 @@ static void bgp_table_stats_rn(struct bgp_node *rn, struct bgp_node *top,
static int bgp_table_stats_walker(struct thread *t)
{
- struct bgp_node *rn, *nrn;
- struct bgp_node *top;
+ struct bgp_dest *dest, *ndest;
+ struct bgp_dest *top;
struct bgp_table_stats *ts = THREAD_ARG(t);
unsigned int space = 0;
@@ -11319,22 +11324,22 @@ static int bgp_table_stats_walker(struct thread *t)
ts->counts[BGP_STATS_MAXBITLEN] = space;
- for (rn = top; rn; rn = bgp_route_next(rn)) {
+ for (dest = top; dest; dest = bgp_route_next(dest)) {
if (ts->table->safi == SAFI_MPLS_VPN
|| ts->table->safi == SAFI_ENCAP
|| ts->table->safi == SAFI_EVPN) {
struct bgp_table *table;
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(dest);
if (!table)
continue;
top = bgp_table_top(table);
- for (nrn = bgp_table_top(table); nrn;
- nrn = bgp_route_next(nrn))
- bgp_table_stats_rn(nrn, top, ts, space);
+ for (ndest = bgp_table_top(table); ndest;
+ ndest = bgp_route_next(ndest))
+ bgp_table_stats_rn(ndest, top, ts, space);
} else {
- bgp_table_stats_rn(rn, top, ts, space);
+ bgp_table_stats_rn(dest, top, ts, space);
}
}
@@ -11593,8 +11598,7 @@ struct peer_pcounts {
safi_t safi;
};
-static void bgp_peer_count_proc(struct bgp_node *rn,
- struct peer_pcounts *pc)
+static void bgp_peer_count_proc(struct bgp_dest *rn, struct peer_pcounts *pc)
{
const struct bgp_adj_in *ain;
const struct bgp_path_info *pi;
@@ -11604,7 +11608,7 @@ static void bgp_peer_count_proc(struct bgp_node *rn,
if (ain->peer == peer)
pc->count[PCOUNT_ADJ_IN]++;
- for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+ for (pi = bgp_dest_get_bgp_path_info(rn); pi; pi = pi->next) {
if (pi->peer != peer)
continue;
@@ -11641,7 +11645,7 @@ static void bgp_peer_count_proc(struct bgp_node *rn,
static int bgp_peer_count_walker(struct thread *t)
{
- struct bgp_node *rn, *rm;
+ struct bgp_dest *rn, *rm;
const struct bgp_table *table;
struct peer_pcounts *pc = THREAD_ARG(t);
@@ -11650,7 +11654,7 @@ static int bgp_peer_count_walker(struct thread *t)
/* Special handling for 2-level routing tables. */
for (rn = bgp_table_top(pc->table); rn;
rn = bgp_route_next(rn)) {
- table = bgp_node_get_bgp_table_info(rn);
+ table = bgp_dest_get_bgp_table_info(rn);
if (table != NULL)
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm))
@@ -11897,7 +11901,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
struct bgp_adj_out *adj;
unsigned long output_count = 0;
unsigned long filtered_count = 0;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
int header1 = 1;
struct bgp *bgp;
int header2 = 1;
@@ -11991,10 +11995,10 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
header1 = 0;
}
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
if (type == bgp_show_adj_route_received
|| type == bgp_show_adj_route_filtered) {
- for (ain = rn->adj_in; ain; ain = ain->next) {
+ for (ain = dest->adj_in; ain; ain = ain->next) {
if (ain->peer != peer)
continue;
@@ -12058,7 +12062,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
* filter list or prefix list
*/
const struct prefix *rn_p =
- bgp_node_get_prefix(rn);
+ bgp_dest_get_prefix(dest);
if ((bgp_input_filter(peer, rn_p, &attr, afi,
safi))
== FILTER_DENY)
@@ -12085,7 +12089,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
output_count++;
}
} else if (type == bgp_show_adj_route_advertised) {
- 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 || !adj->attr)
continue;
@@ -12157,7 +12161,7 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
}
const struct prefix *rn_p =
- bgp_node_get_prefix(rn);
+ bgp_dest_get_prefix(dest);
attr = *adj->attr;
ret = bgp_output_modifier(
@@ -12560,7 +12564,7 @@ static int bgp_distance_set(struct vty *vty, const char *distance_str,
safi_t safi;
struct prefix p;
uint8_t distance;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_distance *bdistance;
afi = bgp_node_afi(vty);
@@ -12575,13 +12579,13 @@ static int bgp_distance_set(struct vty *vty, const char *distance_str,
distance = atoi(distance_str);
/* Get BGP distance node. */
- rn = bgp_node_get(bgp_distance_table[afi][safi], &p);
- bdistance = bgp_node_get_bgp_distance_info(rn);
+ dest = bgp_node_get(bgp_distance_table[afi][safi], &p);
+ bdistance = bgp_dest_get_bgp_distance_info(dest);
if (bdistance)
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
else {
bdistance = bgp_distance_new();
- bgp_node_set_bgp_distance_info(rn, bdistance);
+ bgp_dest_set_bgp_distance_info(dest, bdistance);
}
/* Set distance value. */
@@ -12604,7 +12608,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
safi_t safi;
struct prefix p;
int distance;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_distance *bdistance;
afi = bgp_node_afi(vty);
@@ -12616,13 +12620,13 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
return CMD_WARNING_CONFIG_FAILED;
}
- rn = bgp_node_lookup(bgp_distance_table[afi][safi], &p);
- if (!rn) {
+ dest = bgp_node_lookup(bgp_distance_table[afi][safi], &p);
+ if (!dest) {
vty_out(vty, "Can't find specified prefix\n");
return CMD_WARNING_CONFIG_FAILED;
}
- bdistance = bgp_node_get_bgp_distance_info(rn);
+ bdistance = bgp_dest_get_bgp_distance_info(dest);
distance = atoi(distance_str);
if (bdistance->distance != distance) {
@@ -12633,9 +12637,9 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
XFREE(MTYPE_AS_LIST, bdistance->access_list);
bgp_distance_free(bdistance);
- bgp_node_set_bgp_path_info(rn, NULL);
- bgp_unlock_node(rn);
- bgp_unlock_node(rn);
+ bgp_dest_set_bgp_path_info(dest, NULL);
+ bgp_dest_unlock_node(dest);
+ bgp_dest_unlock_node(dest);
return CMD_SUCCESS;
}
@@ -12644,7 +12648,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
afi_t afi, safi_t safi, struct bgp *bgp)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct prefix q;
struct peer *peer;
struct bgp_distance *bdistance;
@@ -12661,10 +12665,10 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
/* Check source address. */
sockunion2hostprefix(&peer->su, &q);
- rn = bgp_node_match(bgp_distance_table[afi][safi], &q);
- if (rn) {
- bdistance = bgp_node_get_bgp_distance_info(rn);
- bgp_unlock_node(rn);
+ dest = bgp_node_match(bgp_distance_table[afi][safi], &q);
+ if (dest) {
+ bdistance = bgp_dest_get_bgp_distance_info(dest);
+ bgp_dest_unlock_node(dest);
if (bdistance->access_list) {
alist = access_list_lookup(afi, bdistance->access_list);
@@ -12676,10 +12680,10 @@ uint8_t bgp_distance_apply(const struct prefix *p, struct bgp_path_info *pinfo,
}
/* Backdoor check. */
- rn = bgp_node_lookup(bgp->route[afi][safi], p);
- if (rn) {
- bgp_static = bgp_node_get_bgp_static_info(rn);
- bgp_unlock_node(rn);
+ dest = bgp_node_lookup(bgp->route[afi][safi], p);
+ if (dest) {
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
+ bgp_dest_unlock_node(dest);
if (bgp_static->backdoor) {
if (bgp->distance_local[afi][safi])
@@ -12966,8 +12970,8 @@ static int bgp_clear_damp_route(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_path_info *pi;
struct bgp_path_info *pi_temp;
struct bgp *bgp;
@@ -13000,23 +13004,23 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) {
- for (rn = bgp_table_top(bgp->rib[AFI_IP][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_IP][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)
continue;
if ((rm = bgp_node_match(table, &match)) == NULL)
continue;
- const struct prefix *rm_p = bgp_node_get_prefix(rn);
+ const struct prefix *rm_p = bgp_dest_get_prefix(dest);
if (!prefix_check
|| rm_p->prefixlen == match.prefixlen) {
- pi = bgp_node_get_bgp_path_info(rm);
+ pi = bgp_dest_get_bgp_path_info(rm);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
pi_temp = pi->next;
@@ -13029,16 +13033,16 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
}
}
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
}
} else {
- if ((rn = bgp_node_match(bgp->rib[afi][safi], &match))
+ if ((dest = bgp_node_match(bgp->rib[afi][safi], &match))
!= NULL) {
- const struct prefix *rn_p = bgp_node_get_prefix(rn);
+ const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (!prefix_check
- || rn_p->prefixlen == match.prefixlen) {
- pi = bgp_node_get_bgp_path_info(rn);
+ || dest_p->prefixlen == match.prefixlen) {
+ pi = bgp_dest_get_bgp_path_info(dest);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
pi_temp = pi->next;
@@ -13051,7 +13055,7 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
}
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
}
@@ -13170,8 +13174,8 @@ DEFUN (show_bgp_peerhash,
static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi)
{
- struct bgp_node *prn;
- struct bgp_node *rn;
+ struct bgp_dest *pdest;
+ struct bgp_dest *dest;
struct bgp_table *table;
const struct prefix *p;
const struct prefix_rd *prd;
@@ -13181,20 +13185,21 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
char rdbuf[RD_ADDRSTRLEN];
/* Network configuration. */
- for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
- prn = bgp_route_next(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ for (pdest = bgp_table_top(bgp->route[afi][safi]); pdest;
+ pdest = bgp_route_next(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
if (!table)
continue;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ for (dest = bgp_table_top(table); dest;
+ dest = bgp_route_next(dest)) {
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
if (bgp_static == NULL)
continue;
- p = bgp_node_get_prefix(rn);
- prd = (const struct prefix_rd *)bgp_node_get_prefix(
- prn);
+ p = bgp_dest_get_prefix(dest);
+ prd = (const struct prefix_rd *)bgp_dest_get_prefix(
+ pdest);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
@@ -13222,8 +13227,8 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi)
{
- struct bgp_node *prn;
- struct bgp_node *rn;
+ struct bgp_dest *pdest;
+ struct bgp_dest *dest;
struct bgp_table *table;
const struct prefix *p;
const struct prefix_rd *prd;
@@ -13233,14 +13238,15 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
char rdbuf[RD_ADDRSTRLEN];
/* Network configuration. */
- for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
- prn = bgp_route_next(prn)) {
- table = bgp_node_get_bgp_table_info(prn);
+ for (pdest = bgp_table_top(bgp->route[afi][safi]); pdest;
+ pdest = bgp_route_next(pdest)) {
+ table = bgp_dest_get_bgp_table_info(pdest);
if (!table)
continue;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ for (dest = bgp_table_top(table); dest;
+ dest = bgp_route_next(dest)) {
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
if (bgp_static == NULL)
continue;
@@ -13252,8 +13258,8 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
bgp_static->router_mac, NULL, 0);
if (bgp_static->eth_s_id)
esi = esi2str(bgp_static->eth_s_id);
- p = bgp_node_get_prefix(rn);
- prd = (struct prefix_rd *)bgp_node_get_prefix(prn);
+ p = bgp_dest_get_prefix(dest);
+ prd = (struct prefix_rd *)bgp_dest_get_prefix(pdest);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
@@ -13296,7 +13302,7 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
const struct prefix *p;
struct bgp_static *bgp_static;
struct bgp_aggregate *bgp_aggregate;
@@ -13313,13 +13319,13 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
}
/* Network configuration. */
- for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- bgp_static = bgp_node_get_bgp_static_info(rn);
+ for (dest = bgp_table_top(bgp->route[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ bgp_static = bgp_dest_get_bgp_static_info(dest);
if (bgp_static == NULL)
continue;
- p = bgp_node_get_prefix(rn);
+ p = bgp_dest_get_prefix(dest);
vty_out(vty, " network %s/%d",
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@@ -13339,13 +13345,13 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
}
/* Aggregate-address configuration. */
- for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- bgp_aggregate = bgp_node_get_bgp_aggregate_info(rn);
+ for (dest = bgp_table_top(bgp->aggregate[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ bgp_aggregate = bgp_dest_get_bgp_aggregate_info(dest);
if (bgp_aggregate == NULL)
continue;
- p = bgp_node_get_prefix(rn);
+ p = bgp_dest_get_prefix(dest);
vty_out(vty, " aggregate-address %s/%d",
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@@ -13371,7 +13377,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_distance *bdistance;
/* Distance configuration. */
@@ -13387,12 +13393,12 @@ void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
bgp->distance_local[afi][safi]);
}
- for (rn = bgp_table_top(bgp_distance_table[afi][safi]); rn;
- rn = bgp_route_next(rn)) {
- bdistance = bgp_node_get_bgp_distance_info(rn);
+ for (dest = bgp_table_top(bgp_distance_table[afi][safi]); dest;
+ dest = bgp_route_next(dest)) {
+ bdistance = bgp_dest_get_bgp_distance_info(dest);
if (bdistance != NULL)
vty_out(vty, " distance %d %pRN %s\n",
- bdistance->distance, rn,
+ bdistance->distance, dest,
bdistance->access_list ? bdistance->access_list
: "");
}
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 7532dc123a..ee52dcc8c6 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -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),
- (bgp, afi, safi, bn, peer, 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 */
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index d096859322..aafeb14762 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -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(
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 3228b38990..d904b9f6f1 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -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);
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index e7aa02863c..719ff1452b 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -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],
- (struct prefix *)addr);
- if (rn) {
- bgp_unlock_node(rn);
+ dest = bgp_node_lookup(bgp->rib[AFI_IP][SAFI_UNICAST],
+ (struct prefix *)addr);
+ 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,8 +718,8 @@ 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],
- (struct prefix *)addr);
+ dest = bgp_node_get(bgp->rib[AFI_IP][SAFI_UNICAST],
+ (struct prefix *)addr);
offset++;
offsetlen--;
@@ -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;
}
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index 8acd42ffc0..185cb251c7 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -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;
}
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index c35833e66b..a9ec36d29b 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -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,
- struct bgp_nexthop_cache *bnc)
+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
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index a29721988e..426b84f91f 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -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;
}
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h
index 403ca139f6..9cad78c26d 100644
--- a/bgpd/bgp_updgrp.h
+++ b/bgpd/bgp_updgrp.h
@@ -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,
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index b460690849..e1c2865220 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -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,14 +465,14 @@ 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));
+ &path->tx_addpath));
if (!adj)
return;
}
@@ -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);
}
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 3da8a48f3c..f87e372540 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -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)) {
diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c
index 1b95d0656b..c8b8e2391d 100644
--- a/bgpd/bgp_vpn.c
+++ b/bgpd/bgp_vpn.c
@@ -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++;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index aa5857b9d4..2f93ac8dcd 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -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];
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index b7c255f16f..518532cb51 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -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);
}
}
}
diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h
index a069d01503..a068c03717 100644
--- a/bgpd/bgp_zebra.h
+++ b/bgpd/bgp_zebra.h
@@ -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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index ec6e00ea34..14bfc20b22 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -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);
}
}
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index d6b6a78f62..c935496280 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -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],
- (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_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],
- (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_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],
- (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, 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,51 +3665,55 @@ 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);
- if (!bpi)
- continue;
- fprintf(stderr, "%s: rn=%p\n", __func__, rn);
- for (; bpi; bpi = bpi->next) {
- rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
- }
- }
+ 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: dest=%p\n", __func__, dest);
+ for (; bpi; bpi = bpi->next) {
+ rfapiPrintBi((void *)2,
+ bpi); /* 2 => stderr */
+ }
+ }
}
}
#endif /* defined(DEBUG_RFAPI) */
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 41e6a64a64..c3ad95ff28 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -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);
}
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index 67f6a6a0fc..d74404ea56 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -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) {
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index bd3395b49f..0480704b27 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -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,
- prefix, NULL);
- for (ubpi = bgp_node_get_bgp_path_info(urn); ubpi; ubpi = ubpi->next) {
+ udest = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST,
+ prefix, NULL);
+ 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,19 +1961,19 @@ 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 */
- 0, /* addpath_id */
- iattr, /* bgp_update copies
- it */
- AFI_IP, SAFI_UNICAST,
- ZEBRA_ROUTE_VNC_DIRECT_RH,
- BGP_ROUTE_REDISTRIBUTE, NULL,
- /* RD not used for unicast */
- NULL,
- /* tag not used for unicast,
- or EVPN */
- 0, 0,
- NULL); /* EVPN not used */
+ bgp_update(
+ ri->peer, dest_p, /* prefix */
+ 0, /* addpath_id */
+ iattr, /* bgp_update copies
+ it */
+ AFI_IP, SAFI_UNICAST,
+ ZEBRA_ROUTE_VNC_DIRECT_RH,
+ BGP_ROUTE_REDISTRIBUTE, NULL,
+ /* RD not used for unicast */
+ NULL,
+ /* tag not used for unicast,
+ or EVPN */
+ 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,9 +2029,9 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
vnc_eti_delete(eti);
}
- bgp_withdraw(ri->peer, rn_p, /* prefix */
- 0, /* addpath_id */
- NULL, /* ignored */
+ bgp_withdraw(ri->peer, dest_p, /* prefix */
+ 0, /* addpath_id */
+ NULL, /* ignored */
AFI_IP, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE,
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 0a8e1618fc..85d64b5a72 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -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);
}
}
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 686dc394a7..008c7b28b7 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -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);
}
}
diff --git a/tests/bgpd/test_bgp_table.c b/tests/bgpd/test_bgp_table.c
index 7d81d42afb..4eb132df55 100644
--- a/tests/bgpd/test_bgp_table.c
+++ b/tests/bgpd/test_bgp_table.c
@@ -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);
diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c
index 87c214969f..99fb7b620d 100644
--- a/tests/bgpd/test_mpath.c
+++ b/tests/bgpd/test_mpath.c
@@ -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);