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(
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);
}
}
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;
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);
* 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;
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,
}
/* 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] =
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);
}
}
-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;
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);
}
-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);
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;
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;
struct bgp_advertise *prev;
/* Prefix information. */
- struct bgp_node *rn;
+ struct bgp_dest *dest;
/* Reference pointer. */
struct bgp_adj_out *adj;
TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
/* Prefix information. */
- struct bgp_node *rn;
+ struct bgp_dest *dest;
uint32_t addpath_tx_id;
#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 *);
}
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;
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) {
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,
{
struct bmp_queue_entry *bqe;
struct peer *peer;
- struct bgp_node *bn;
+ struct bgp_dest *bn;
bool written = false;
bqe = bmp_pull(bmp);
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;
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;
}
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;
/* 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)
}
/* 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;
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;
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)) {
/* 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);
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;
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 =
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;
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);
}
#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
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;
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);
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;
}
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 *
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);
unsigned int seq)
{
struct bgp_path_info *path;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp *bgp;
struct bgp_table *table;
/* 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++;
}
}
* 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);
* 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;
* 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)
/*
* 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;
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;
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;
}
* 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;
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;
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);
}
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
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;
}
/*
* 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
/*
* 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
*/
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];
*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
/* 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)
/* 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);
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));
/* 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,
* 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
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. */
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;
*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
/* 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 */
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;
/* 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);
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;
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 */
* 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;
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
/* 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);
/* 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)
/* 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. */
/* 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);
}
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;
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);
}
/*
*/
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);
}
/*
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;
/* 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;
* 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
*/
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
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. */
* 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;
*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
/* Mark route for delete. */
if (tmp_pi)
- bgp_path_info_delete(rn, tmp_pi);
+ bgp_path_info_delete(dest, tmp_pi);
}
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;
}
{
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 */
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;
}
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;
* 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;
}
{
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;
/* 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
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;
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);
* 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 {
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;
{
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;
}
{
afi_t afi;
safi_t safi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
afi = AFI_L2VPN;
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;
*/
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);
}
}
*/
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);
}
}
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;
/* 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;
}
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;
/* 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. */
/* 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))
}
/* 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;
}
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;
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;
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. */
/* 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
&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;
}
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. */
/* 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))
}
/* 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;
}
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)
/* 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;
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;
}
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;
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;
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;
}
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;
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;
}
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;
* 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
{
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;
* 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
|| 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.
{
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;
* 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. */
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;
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)
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)
* 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;
{
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;
/* 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;
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;
}
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)) {
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);
}
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;
}
{
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;
* 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
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)) {
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);
}
}
{
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);
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;
{
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 ||
;
/* 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)
{
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 ||
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)
}
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;
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;
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));
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) {
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;
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;
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) {
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
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;
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;
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;
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;
}
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;
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();
{
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;
/* 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;
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);
{
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;
/* 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;
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);
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;
/* 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;
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);
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;
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;
}
/* 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];
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) {
}
/* 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++;
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)
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;
/* 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)
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));
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) {
/* 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;
}
/* 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
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,
{
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++) {
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;
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) {
}
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",
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);
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;
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;
if (CHECK_FLAG(to->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
return remote_label;
- return rn->local_label;
+ return dest->local_label;
}
/**
bool allocated)
{
struct bgp_path_info *pi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
pi = labelid;
/* Is this path still valid? */
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) {
/*
*/
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;
}
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);
/* 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
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;
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()
*/
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));
#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);
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 */
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;
}
* 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)
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)) {
1, &evpn);
if (ret < 0)
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
}
}
* 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,
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++;
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);
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");
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;
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,
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])),
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,
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);
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,
*/
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;
/*
* 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;
}
/* 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",
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)
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)
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;
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) {
* 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;
}
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 */
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);
__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);
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);
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(
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;
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;
}
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;
return;
}
- p = bgp_node_get_prefix(path_vpn->net);
+ p = bgp_dest_get_prefix(path_vpn->net);
afi = family2afi(p->family);
/* Loop over VRFs */
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
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);
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
/* 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);
afi_t afi)
{
struct prefix_rd prd;
- struct bgp_node *prn;
+ struct bgp_dest *pdest;
safi_t safi = SAFI_MPLS_VPN;
assert(bgp_vpn);
/*
* 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));
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
{
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 ||
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)
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;
}
/* 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;
}
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);
}
}
{
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;
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)) {
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);
}
}
}
{
struct prefix p;
struct prefix *addr;
- struct bgp_node *rn = NULL;
+ struct bgp_dest *dest = NULL;
struct bgp_connected_ref *bc;
addr = ifc->address;
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;
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
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;
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;
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;
}
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;
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) {
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;
}
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;
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) {
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;
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);
}
}
}
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;
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;
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);
}
}
}
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)) {
}
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);
#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;
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);
}
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);
}
}
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;
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;
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];
}
}
- 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);
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;
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)",
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))
"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;
}
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));
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];
"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;
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;
&& (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)
"%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)
*/
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;
|| (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;
/*
} 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;
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);
}
*/
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) {
*/
void bgp_nht_register_nexthops(struct bgp *bgp)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_nexthop_cache *bnc;
afi_t 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;
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;
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;
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;
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;
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,
#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 */
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);
}
/* 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;
/* 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;
*/
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);
}
/* 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;
/* 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);
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);
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
*/
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(
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 };
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)
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)
{
/* 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
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);
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)
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;
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) {
/* 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;
*/
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__,
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;
}
}
}
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)
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)
}
}
- 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;
*/
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;
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
/* 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);
}
}
* 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);
* 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;
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;
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);
* 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;
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));
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;
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
|| 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);
|| new_select->sub_type
== BGP_ROUTE_IMPORTED))
- bgp_zebra_announce(rn, p, old_select,
+ bgp_zebra_announce(dest, p, old_select,
bgp, afi, safi);
}
}
* 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);
}
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);
}
}
#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. */
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
}
}
- 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;
/* 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;
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)) {
}
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);
}
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;
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;
}
} 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)
/* 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);
#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)) {
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;
new->peer = peer;
new->attr = attr;
new->uptime = bgp_clock();
- new->net = rn;
+ new->net = dest;
return new;
}
/* 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 =
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;
}
|| 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:
|| 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:
{
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;
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;
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)
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;
}
}
* 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);
/* 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);
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)
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 */
{
/* 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;
peer->host, pfx_buf);
}
- bgp_path_info_restore(rn, pi);
+ bgp_path_info_restore(dest, pi);
}
/* Received Logging. */
/* 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.
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)) {
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;
}
}
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];
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
/* 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
}
/* 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) {
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];
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;
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
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
/* 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) {
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
/*
{
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
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.
*/
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)) {
"%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)
/* 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)) {
}
/* Unlock bgp_node_get() lock. */
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
return 0;
}
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;
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;
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;
}
}
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)
&& (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;
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;
&& 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 ||
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;
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);
}
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)
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;
* 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;
}
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)
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;
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;
/* 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;
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;
}
}
} 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;
}
}
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;
bgp_zebra_withdraw(p, pi, bgp, safi);
}
- bgp_path_info_reap(rn, pi);
+ bgp_path_info_reap(dest, pi);
}
}
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) {
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);
}
}
}
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;
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);
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;
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
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)) {
__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
* 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
pi);
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
aspath_unintern(&attr.aspath);
return;
}
/* 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];
"%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
*/
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
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;
}
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);
}
/*
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;
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};
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);
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;
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);
/* 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) {
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;
}
/* 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) {
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) {
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. */
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)) {
/* 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. */
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();
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;
{
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);
}
}
{
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);
}
}
}
{
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);
}
}
}
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
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);
}
}
}
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;
}
}
}
- 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();
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);
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;
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");
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;
*/
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);
* 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,
}
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
/* 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 */
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;
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;
*/
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++;
}
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);
}
- bgp_unlock_node(top);
+ bgp_dest_unlock_node(top);
if (aggregate->incomplete_origin_count > 0)
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;
/* 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;
if (pi->extra->suppress == 0) {
bgp_path_info_set_flag(
- rn, pi, BGP_PATH_ATTR_CHANGED);
+ dest, pi,
+ BGP_PATH_ATTR_CHANGED);
match++;
}
}
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);
lcommunity_free(&aggregate->lcommunity);
}
- bgp_unlock_node(top);
+ bgp_dest_unlock_node(top);
}
static void bgp_add_route_to_aggregate(struct bgp *bgp,
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;
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;
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. */
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. */
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);
}
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;
}
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;
}
/* 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");
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;
}
}
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);
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;
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;
&& !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. */
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)
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)
unsigned short instance)
{
afi_t afi;
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_path_info *pi;
struct bgp_redist *red;
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;
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);
}
}
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;
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);
}
}
}
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];
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')
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
/* 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)
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;
}
/* 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;
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;
}
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;
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) {
}
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++;
}
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
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;
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,
/* 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;
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) {
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;
* 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();
}
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;
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 */
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;
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;
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
rm_p);
if (type5_pfxlen == match.prefixlen) {
is_exact_pfxlen_match = true;
- bgp_unlock_node(rm);
+ bgp_dest_unlock_node(rm);
break;
}
}
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)
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);
}
}
}
#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;
#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,
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;
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);
}
}
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;
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;
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);
/* 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))
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;
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;
* 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)
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;
}
const struct prefix *rn_p =
- bgp_node_get_prefix(rn);
+ bgp_dest_get_prefix(dest);
attr = *adj->attr;
ret = bgp_output_modifier(
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);
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. */
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);
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) {
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;
}
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;
/* 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);
}
/* 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])
{
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;
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;
}
}
- 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;
}
}
- bgp_unlock_node(rn);
+ bgp_dest_unlock_node(dest);
}
}
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;
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));
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;
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;
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));
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;
}
/* 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),
}
/* 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),
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. */
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
: "");
}
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;
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)
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)
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;
/* 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);
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);
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
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,
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);
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,
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,
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 */
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;
}
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;
/* 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;
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(
/* 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;
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(
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;
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);
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;
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);
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;
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;
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;
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--;
} 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)
if (min) {
const struct prefix *rn_p =
- bgp_node_get_prefix(rn);
+ bgp_dest_get_prefix(dest);
*length =
v->namelen + BGP_PATHATTR_ENTRY_OFFSET;
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;
}
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);
}
/*
{
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) {
* 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;
} 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 */
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)
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))
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;
}
#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"
#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;
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;
enum bgp_path_selection_reason reason;
};
+extern void bgp_delete_listnode(struct bgp_dest *dest);
/*
* bgp_table_iter_t
*
/*
- * 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)
/*
* 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));
}
/*
/*
* 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));
}
/*
*
* 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
/*
* 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;
}
/* 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;
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,
}
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
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)
/* 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);
if (!pi) {
subgroup_process_announce_selected(
- subgrp, NULL, ctx->rn,
+ subgrp, NULL, ctx->dest,
adj->addpath_tx_id);
}
}
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) {
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));
*/
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));
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));
* 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);
}
}
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;
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,
}
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++;
}
}
* 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;
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);
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)
{
/* 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;
}
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);
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)
{
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);
* 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 */
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)
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);
}
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);
}
}
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;
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
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));
*/
void subgroup_announce_route(struct update_subgroup *subgrp)
{
- struct bgp_node *rn;
+ struct bgp_dest *dest;
struct bgp_table *table;
struct peer *onlypeer;
&& 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);
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;
* 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;
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
/* 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 {
* 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. */
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);
}
}
* 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);
}
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;
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;
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)
- 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
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;
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);
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) {
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);
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;
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;
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
*/
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
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)) {
{
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;
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;
break;
}
- if (bgp_node_get_bgp_path_info(rm) == NULL)
+ if (bgp_dest_get_bgp_path_info(rm) == NULL)
continue;
if (!attr)
#endif
const uint8_t *pnt;
- pnt = rn_p->u.val;
+ pnt = dest_p->u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
}
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++;
}
{
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;
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);
}
}
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,
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);
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];
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)
{
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;
}
/* 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;
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);
}
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)
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) {
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);
}
}
}
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);
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);
}
}
}
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);
/* 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);
}
}
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];
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(
__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);
}
/*
__func__, safi, buf);
}
done:
- bgp_unlock_node(bn);
+ bgp_dest_unlock_node(bn);
}
struct rfapi_nexthop *rfapi_nexthop_new(struct rfapi_nexthop *copyme)
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;
* 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
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",
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. */
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",
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(
#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) */
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);
* 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;
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);
}
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;
} 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) {
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;
* 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))
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);
* 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;
&& 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,
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);
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(
}
}
- 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);
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(
* 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);
"%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);
}
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);
* 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;
* 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) {
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,
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)
}
/* 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__);
}
/* 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(
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)) {
* (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);
}
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)
/* 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__);
}
/* 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 */
prefix); /* unicast route prefix */
}
- bgp_unlock_node(bn);
+ bgp_dest_unlock_node(bd);
}
static void
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",
* (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);
}
/* 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);
}
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);
}
}
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;
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(
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__);
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);
}
}
* 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__);
* 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;
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 */
{
- 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);
}
}
{
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__);
/*
* 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 */
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);
}
}
{
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;
}
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,
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;
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);
}
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);
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);