The bgp_info data is stored as a void pointer in `struct bgp_node`.
Abstract retrieval of this data and setting of this data
into functions so that in the future we can move around
what is stored in bgp_node.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
idalloc_drain_pool(
bgp->tx_addpath.id_allocators[afi][safi][addpath_type],
&(rn->tx_addpath.free_ids[addpath_type]));
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (pi->tx_addpath.addpath_tx_id[addpath_type]
!= IDALLOC_INVALID) {
idalloc_free(
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn))
- for (bi = rn->info; bi; bi = bi->next)
+ for (bi = bgp_node_get_bgp_path_info(rn); bi; bi = bi->next)
bgp_addpath_populate_path(allocator, bi, addpath_type);
}
continue;
/* Free Unused IDs back to the pool.*/
- for (pi = bn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_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 = bn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_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] =
table = bgp->rib[afi][SAFI_UNICAST];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- path = rn->info;
+ path = bgp_node_get_bgp_path_info(rn);
while (path) {
path = bgp_dump_route_node_record(afi, rn, path, seq);
seq++;
struct bgp_path_info *local_pi = NULL;
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
struct bgp_path_info *local_pi;
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
evp = (struct prefix_evpn *)&rn->p;
/* locate the local and remote entries if any */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
remote_pi = tmp_pi;
}
- /* we don't expect to see a remote_pi at this point.
+ /* we don't expect to see a remote_ri at this point.
* An ES route has esi + vtep_ip as the key,
* We shouldn't see the same route from any other vtep.
*/
*route_changed = 0;
/* locate the local route entry if any */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp_def->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
/* See if this is an update of an existing route, or a new add. */
local_pi = NULL;
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
bgp_path_info_reap(rn, local_pi);
/* tell zebra to re-add the best remote path */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn);
+ tmp_pi; tmp_pi = tmp_pi->next) {
if (CHECK_FLAG(tmp_pi->flags, BGP_PATH_SELECTED)) {
curr_select = tmp_pi;
break;
*pi = NULL;
/* Now, find matching route. */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next)
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next)
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
continue;
/* Identify local route. */
- for (tmp_pi = rn->info; tmp_pi; tmp_pi = tmp_pi->next) {
+ for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
+ tmp_pi = tmp_pi->next) {
if (tmp_pi->peer == bgp->peer_self
&& tmp_pi->type == ZEBRA_ROUTE_BGP
&& tmp_pi->sub_type == BGP_ROUTE_STATIC)
safi = SAFI_EVPN;
rdrn = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd);
- if (rdrn && rdrn->info) {
+ if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
table = (struct bgp_table *)rdrn->info;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
/* 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 = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
bgp_path_info_delete(rn, pi);
bgp_path_info_reap(rn, pi);
}
/* 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 = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
bgp_path_info_delete(rn, pi);
bgp_path_info_reap(rn, pi);
}
rn = bgp_node_get(es->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
rn = bgp_node_get(vpn->route_table, (struct prefix *)p);
/* Check if route entry is already present. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
return 0;
/* Find matching route entry. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->extra
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
break;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/*
* Consider "valid" remote routes applicable for
* this ES.
|| is_evpn_prefix_ipaddr_v6(evp)))
continue;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VRF.
*/
if (evp->prefix.route_type != rtype)
continue;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VNI. */
if (!(CHECK_FLAG(pi->flags, BGP_PATH_VALID)
rn = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
if (!rn) /* unexpected */
return 0;
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self &&
pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self
&& pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
/* Only care about "selected" routes - non-imported. */
/* TODO: Support for AddPath for EVPN. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& (!pi->extra || !pi->extra->parent)) {
bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p,
* attribute. Also, we only consider "non-imported" routes.
* TODO: Support for AddPath for EVPN.
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& (!pi->extra || !pi->extra->parent)) {
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
/* Consider "valid" remote routes applicable for
* this VNI. */
if (json)
json_prefix = json_object_new_object();
- if (rn->info) {
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi) {
/* Overall header/legend displayed once. */
if (header) {
bgp_evpn_show_route_header(vty, bgp,
/* For EVPN, the prefix is displayed for each path (to fit in
* with code that already exists).
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
json_object *json_path = NULL;
if (json)
if (json)
json_prefix = json_object_new_object();
- if (rn->info) {
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi) {
/* Overall header/legend displayed once. */
if (header) {
bgp_evpn_show_route_header(vty, bgp,
/* For EVPN, the prefix is displayed for each path (to fit in
* with code that already exists).
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
json_object *json_path = NULL;
if (vtep_ip.s_addr
tbl_ver = table->version;
for (rm = bgp_table_top(table); rm; rm = bgp_route_next(rm))
- for (pi = rm->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rm); pi;
+ pi = pi->next) {
total_count++;
if (type == bgp_show_type_neighbor) {
union sockunion *su = output_arg;
route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json);
/* Display each path for this prefix. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
json_object *json_path = NULL;
if (json)
route_vty_out_detail_header(vty, bgp, rn, NULL, afi, safi, json);
/* Display each path for this prefix. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
json_object *json_path = NULL;
if (json)
json_paths = json_object_new_array();
/* Display each path for this prefix. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
json_object *json_path = NULL;
if (json)
if (json)
json_prefix = json_object_new_object();
- if (rn->info) {
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi) {
/* RD header and legend - once overall. */
if (rd_header && !json) {
vty_out(vty,
json_paths = json_object_new_array();
/* Display each path for this prefix. */
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
json_object *json_path = NULL;
if (json)
if (type && evp->prefix.route_type != type)
continue;
- if (rn->info) {
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi) {
/* Overall header/legend displayed once. */
if (header) {
bgp_evpn_show_route_header(vty, bgp,
* fit in
* with code that already exists).
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
json_object *json_path = NULL;
path_cnt++;
add_prefix_to_json = 1;
return CMD_SUCCESS;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- if (rn->info == NULL)
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi == NULL)
continue;
if (use_json) {
json_paths = json_object_new_array();
display = NLRI_STRING_FORMAT_JSON;
}
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
total_count++;
route_vty_out_flowspec(vty, &rn->p, pi, display,
json_paths);
continue;
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
- route_vty_out_flowspec(vty, &rn->p,
- rn->info, use_json ?
- NLRI_STRING_FORMAT_JSON :
- NLRI_STRING_FORMAT_LARGE,
- json_paths);
+ route_vty_out_flowspec(
+ vty, &rn->p, bgp_node_get_bgp_path_info(rn),
+ use_json ? NLRI_STRING_FORMAT_JSON
+ : NLRI_STRING_FORMAT_LARGE,
+ json_paths);
display++;
}
}
/*
* match parent
*/
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
if (bpi->extra && bpi->extra->parent == parent)
break;
}
bn = bgp_afi_node_get(bgp_vpn->rib[afi][safi], afi, safi, p,
&(bgp_vrf->vpn_policy[afi].tovpn_rd));
+ if (!bn)
+ return;
/*
* vrf -> vpn
* match original bpi imported from
*/
- for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
if (bpi->extra && bpi->extra->parent == path_vrf) {
break;
}
char buf[PREFIX2STR_BUFFER];
- if (debug && bn->info) {
+ bpi = bgp_node_get_bgp_path_info(bn);
+ if (debug && bpi) {
zlog_debug(
"%s: looking at prefix %s", __func__,
prefix2str(&bn->p, buf, sizeof(buf)));
}
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (; bpi; bpi = bpi->next) {
if (debug)
zlog_debug("%s: type %d, sub_type %d",
__func__, bpi->type,
if (debug)
zlog_debug("%s: node=%p", __func__, bn);
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next) {
if (debug)
zlog_debug(
"%s: calling vpn_leak_from_vrf_update",
bgp->name_pretty);
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
- for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) {
+
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next) {
if (bpi->extra
&& (struct bgp_path_info *)bpi->extra->parent
== path_vpn) {
for (bn = bgp_table_top(bgp_vrf->rib[afi][safi]); bn;
bn = bgp_route_next(bn)) {
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next) {
if (bpi->extra && bpi->extra->bgp_orig != bgp_vrf) {
/* delete route */
for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next) {
if (bpi->extra
&& bpi->extra->bgp_orig == bgp_vrf)
if (!prn)
return NULL;
- if (prn->info == NULL) {
+ if (!bgp_node_has_bgp_path_info_data(prn)) {
bgp_unlock_node(prn);
return NULL;
}
{
struct bgp_path_info *top;
- top = rn->info;
+ top = bgp_node_get_bgp_path_info(rn);
- pi->next = rn->info;
+ pi->next = top;
pi->prev = NULL;
if (top)
top->prev = pi;
- rn->info = pi;
+ bgp_node_set_bgp_path_info(rn, pi);
bgp_path_info_lock(pi);
bgp_lock_node(rn);
if (pi->prev)
pi->prev->next = pi->next;
else
- rn->info = pi->next;
+ bgp_node_set_bgp_path_info(rn, pi->next);
bgp_path_info_mpath_dequeue(pi);
bgp_path_info_unlock(pi);
if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) {
/* Clear BGP_PATH_DMED_SELECTED for all paths */
- for (pi1 = rn->info; pi1; pi1 = pi1->next)
+ for (pi1 = bgp_node_get_bgp_path_info(rn); pi1;
+ pi1 = pi1->next)
bgp_path_info_unset_flag(rn, pi1,
BGP_PATH_DMED_SELECTED);
- for (pi1 = rn->info; pi1; pi1 = pi1->next) {
+ for (pi1 = bgp_node_get_bgp_path_info(rn); pi1;
+ pi1 = pi1->next) {
if (CHECK_FLAG(pi1->flags, BGP_PATH_DMED_CHECK))
continue;
if (BGP_PATH_HOLDDOWN(pi1))
/* Check old selected route and new selected route. */
old_select = NULL;
new_select = NULL;
- for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
old_select = pi;
}
if (do_mpath && new_select) {
- for (pi = rn->info; (pi != NULL) && (nextpi = pi->next, 1);
- pi = nextpi) {
+ for (pi = bgp_node_get_bgp_path_info(rn);
+ (pi != NULL) && (nextpi = pi->next, 1); pi = nextpi) {
if (debug)
bgp_path_info_path_with_addpath_rx_str(
{
struct bgp_path_info *pi;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
UNSET_FLAG(pi->flags, BGP_PATH_IGP_CHANGED);
bgp_adj_in_set(rn, peer, attr, addpath_id);
/* Check previously received route. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == peer && pi->type == type
&& pi->sub_type == sub_type
&& pi->addpath_rx_id == addpath_id)
}
/* Lookup withdrawn route. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == peer && pi->type == type
&& pi->sub_type == sub_type
&& pi->addpath_rx_id == addpath_id)
if (ain->peer != peer)
continue;
- struct bgp_path_info *pi = rn->info;
+ struct bgp_path_info *pi =
+ bgp_node_get_bgp_path_info(rn);
uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL;
/* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath.
*/
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (pi->peer != peer)
continue;
ain = ain_next;
}
- for (pi = rn->info; pi; pi = next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = next) {
next = pi->next;
if (pi->peer != peer)
continue;
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm))
- for (pi = rm->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rm); pi;
+ pi = pi->next) {
if (pi->peer != peer)
continue;
if (!CHECK_FLAG(pi->flags,
} else {
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn))
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
if (pi->peer != peer)
continue;
if (!CHECK_FLAG(pi->flags, BGP_PATH_STALE))
struct bgp_path_info *next;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
- for (pi = rn->info; pi; pi = next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = next) {
next = pi->next;
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& pi->type == ZEBRA_ROUTE_BGP
attr_new = bgp_attr_intern(&attr);
}
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, NULL);
/* Check selected route and self inserted route. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
rn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
/* Check selected route and self inserted route. */
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
attr_new = bgp_attr_intern(&attr);
}
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
break;
table = bgp->rib[afi][safi];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (pi->peer == bgp->peer_self
&& ((pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_STATIC)
{
struct bgp_node *rn;
struct bgp_table *table;
- struct bgp_path_info *pi, *new;
+ struct bgp_path_info *pi, *orig, *new;
table = bgp->rib[afi][safi];
rn = bgp_node_get(table, p);
- for (pi = rn->info; pi; pi = pi->next)
+ for (orig = pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_AGGREGATE)
break;
* If the aggregate information has not changed
* no need to re-install it again.
*/
- if (bgp_aggregate_info_same(rn->info, origin, aspath, community,
+ if (bgp_aggregate_info_same(orig, origin, aspath, community,
ecommunity, lcommunity)) {
bgp_unlock_node(rn);
bgp_path_info_add(rn, new);
bgp_process(bgp, rn, afi, safi);
} else {
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = orig; pi; pi = pi->next)
if (pi->peer == bgp->peer_self
&& pi->type == ZEBRA_ROUTE_BGP
&& pi->sub_type == BGP_ROUTE_AGGREGATE)
match = 0;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
continue;
match = 0;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (BGP_PATH_HOLDDOWN(pi))
continue;
new_attr = bgp_attr_intern(&attr_new);
- for (bpi = bn->info; bpi; bpi = bpi->next)
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi;
+ bpi = bpi->next)
if (bpi->peer == bgp->peer_self
&& bpi->sub_type == BGP_ROUTE_REDISTRIBUTE)
break;
rn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi,
SAFI_UNICAST, p, NULL);
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == type)
break;
table = bgp->rib[afi][SAFI_UNICAST];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (pi->peer == bgp->peer_self && pi->type == type
&& pi->instance == instance)
break;
/* Start processing of routes. */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- if (rn->info == NULL)
+ pi = bgp_node_get_bgp_path_info(rn);
+ if (pi == NULL)
continue;
display = 0;
else
json_paths = NULL;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (; pi; pi = pi->next) {
total_count++;
if (type == bgp_show_type_flap_statistics
|| type == bgp_show_type_flap_neighbor
vty_out(vty, "not allocated\n");
}
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
count++;
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
best = count;
continue;
}
- for (pi = rm->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rm); pi;
+ pi = pi->next) {
if (header) {
route_vty_out_detail_header(
vty, bgp, rm,
if ((rn = bgp_node_match(rib, &match)) != NULL) {
if (!prefix_check
|| rn->p.prefixlen == match.prefixlen) {
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi;
+ pi = pi->next) {
if (header) {
route_vty_out_detail_header(
vty, bgp, rn, NULL, afi,
if (rn == top)
continue;
- if (!rn->info)
+ if (!bgp_node_has_bgp_path_info_data(rn))
continue;
ts->counts[BGP_STATS_PREFIXES]++;
#endif
/* check if the prefix is included by any other announcements */
- while (prn && !prn->info)
+ while (prn && !bgp_node_has_bgp_path_info_data(prn))
prn = bgp_node_parent_nolock(prn);
if (prn == NULL || prn == top) {
if (space)
ts->total_space +=
pow(2.0, space - rn->p.prefixlen);
- } else if (prn->info)
+ } else if (bgp_node_has_bgp_path_info_data(prn))
ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
pinum++;
ts->counts[BGP_STATS_RIB]++;
if (ain->peer == peer)
pc->count[PCOUNT_ADJ_IN]++;
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
+
if (pi->peer != peer)
continue;
XFREE(MTYPE_AS_LIST, bdistance->access_list);
bgp_distance_free(bdistance);
- rn->info = NULL;
+ bgp_node_set_bgp_path_info(rn, NULL);
bgp_unlock_node(rn);
bgp_unlock_node(rn);
if (!prefix_check
|| rm->p.prefixlen == match.prefixlen) {
- pi = rm->info;
+ pi = bgp_node_get_bgp_path_info(rm);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
pi_temp = pi->next;
!= NULL) {
if (!prefix_check
|| rn->p.prefixlen == match.prefixlen) {
- pi = rn->info;
+ pi = bgp_node_get_bgp_path_info(rn);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
pi_temp = pi->next;
for (ain = bgp_node->adj_in; ain; ain = ain->next) {
int ret;
- struct bgp_path_info *path = bgp_node->info;
+ struct bgp_path_info *path = bgp_info_from_node(bgp_node);
mpls_label_t *label = NULL;
uint32_t num_labels = 0;
if (rn) {
bgp_unlock_node(rn);
- for (path = rn->info; path; path = path->next)
+ for (path = bgp_info_from_node(rn); path;
+ path = path->next)
if (sockunion_same(&path->peer->su, &su))
return path;
}
do {
min = NULL;
- for (path = rn->info; path; path = path->next) {
+ for (path = bgp_info_from_node(rn); path;
+ path = path->next) {
if (path->peer->su.sin.sin_family == AF_INET
&& ntohl(paddr.s_addr)
< ntohl(path->peer->su.sin
while (node && node->p.prefixlen <= p->prefixlen
&& prefix_match(&node->p, p)) {
- if (node->info && node->p.prefixlen == p->prefixlen) {
+ if (bgp_node_has_bgp_path_info_data(node)
+ && node->p.prefixlen == p->prefixlen) {
matched = node;
break;
}
else if (matched == NULL)
matched = node = bgp_node_from_rnode(node->parent);
- if (matched->info) {
+ if (bgp_node_has_bgp_path_info_data(matched)) {
bgp_lock_node(matched);
listnode_add(matches, matched);
}
while ((node = bgp_route_next_until_maxlen(node, matched, maxlen))) {
if (prefix_match(p, &node->p)) {
- if (node->info) {
+ if (bgp_node_has_bgp_path_info_data(node)) {
bgp_lock_node(node);
listnode_add(matches, node);
}
node->info = bnc;
}
+static inline struct bgp_path_info *
+bgp_node_get_bgp_path_info(struct bgp_node *node)
+{
+ return node->info;
+}
+
+static inline void bgp_node_set_bgp_path_info(struct bgp_node *node,
+ struct bgp_path_info *bi)
+{
+ node->info = bi;
+}
+
+static inline bool bgp_node_has_bgp_path_info_data(struct bgp_node *node)
+{
+ return !!node->info;
+}
+
#endif /* _QUAGGA_BGP_TABLE_H */
adj_next = adj->next;
if (adj->subgroup == subgrp) {
- for (pi = ctx->rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(ctx->rn);
+ pi; pi = pi->next) {
id = bgp_addpath_id_for_peer(peer, afi, safi,
&pi->tx_addpath);
if (addpath_capable) {
subgrp_withdraw_stale_addpath(ctx, subgrp);
- for (pi = ctx->rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(ctx->rn);
+ pi; pi = pi->next) {
/* Skip the bestpath for now */
if (pi == ctx->pi)
continue;
subgroup_default_originate(subgrp, 0);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
- for (ri = rn->info; ri; ri = ri->next)
+ for (ri = bgp_node_get_bgp_path_info(rn); ri; ri = ri->next)
if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)
|| (addpath_capable
SET_FLAG(bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
- for (ri = rn->info; ri; ri = ri->next) {
+ for (ri = bgp_node_get_bgp_path_info(rn);
+ ri; ri = ri->next) {
struct attr dummy_attr;
/* Provide dummy so the route-map can't modify
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_node *rm;
- struct attr *attr;
+ struct bgp_path_info *path;
int rd_header;
int header = 1;
json_object *json = NULL;
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
- if ((attr = rm->info) != NULL) {
+ path = bgp_node_get_bgp_path_info(rm);
+ if (path != NULL) {
if (header) {
if (use_json) {
json_object_int_add(
json_array);
} else {
route_vty_out_tmp(
- vty, &rm->p, attr,
+ vty, &rm->p, path->attr,
SAFI_MPLS_VPN, use_json,
json_array);
}
return;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
- for (pi = rn->info; pi; pi = pi->next)
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next)
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
(pi->type == ZEBRA_ROUTE_BGP
for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(rn)) {
- for (pi = rn->info; pi; pi = pi->next) {
+ for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (pi->sub_type == BGP_ROUTE_REDISTRIBUTE
&& pi->type == type
&& pi->instance == red->instance) {
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 ? bn->info : NULL));
+ afi, safi, bn, (bn ? bgp_node_get_bgp_path_info(bn) : NULL));
- for (bpi = (bn ? bn->info : NULL); bpi; bpi = bpi->next) {
+ for (bpi = (bn ? bgp_node_get_bgp_path_info(bn) : NULL); bpi;
+ bpi = bpi->next) {
vnc_zlog_debug_verbose(
"%s: trying bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p, local_pref=%u",
* ecommunity: POINTS TO interned/refcounted dynamic 2-part AS attr
* aspath: POINTS TO interned/refcounted hashed block
*/
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_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
/* debug */
if (VNC_DEBUG(VERBOSE)) {
- vnc_zlog_debug_verbose("%s: printing BI", __func__);
+ vnc_zlog_debug_verbose("%s: printing BPI", __func__);
rfapiPrintBi(NULL, new);
}
fprintf(stderr, "%s: vpn rdn=%p\n", __func__, rdn);
for (rn = bgp_table_top(rdn->info); rn;
rn = bgp_route_next(rn)) {
- if (!rn->info)
+ bpi = bgp_node_get_bgp_path_info(rn);
+
+ if (!bpi)
continue;
fprintf(stderr, "%s: rn=%p\n", __func__, rn);
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
}
}
fprintf(stderr, "%s: encap rdn=%p\n", __func__, rdn);
for (rn = bgp_table_top(rdn->info); rn;
rn = bgp_route_next(rn)) {
- if (!rn->info)
+ bpi = bgp_node_get_bgp_path_info(rn);
+ if (!bpi)
continue;
fprintf(stderr, "%s: rn=%p\n", __func__, rn);
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (; bpi; bpi = bpi->next) {
rfapiPrintBi((void *)2, bpi); /* 2 => stderr */
}
}
for (rn1 = bgp_table_top(bgp->rib[afi][safi]); rn1;
rn1 = bgp_route_next(rn1)) {
- if (rn1->info) {
+ if (bgp_node_has_bgp_path_info_data(rn1)) {
+
for (rn2 = bgp_table_top(rn1->info); rn2;
rn2 = bgp_route_next(rn2)) {
struct bgp_path_info *bpi;
- for (bpi = rn2->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(rn2);
+ bpi; bpi = bpi->next) {
uint32_t label = 0;
if (CHECK_FLAG(bpi->flags,
vty_out(vty, " bn=%p%s", bn, HVTYNL);
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(bn); 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) {
*/
urn = bgp_afi_node_get(bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST,
prefix, NULL);
- for (ubpi = urn->info; ubpi; ubpi = ubpi->next) {
+ for (ubpi = bgp_node_get_bgp_path_info(urn); ubpi; ubpi = ubpi->next) {
struct prefix unicast_nexthop;
if (CHECK_FLAG(ubpi->flags, BGP_PATH_REMOVED))
struct bgp_path_info *ri;
struct bgp_path_info *next;
- for (ri = rn->info, next = NULL; ri; ri = next) {
+ for (ri = bgp_node_get_bgp_path_info(rn), next = NULL;
+ ri; ri = next) {
next = ri->next;
/*
* skip prefix list check if no routes here
*/
- if (!rn->info)
+ if (!bgp_node_has_bgp_path_info_data(rn))
continue;
{
}
}
- for (ri = rn->info; ri; ri = ri->next) {
+ for (ri = bgp_node_get_bgp_path_info(rn);
+ ri; ri = ri->next) {
vnc_zlog_debug_verbose("%s: ri->sub_type: %d",
__func__, ri->sub_type);
struct bgp_path_info *ri;
struct bgp_path_info *next;
- for (ri = rn->info, next = NULL; ri; ri = next) {
+ for (ri = bgp_node_get_bgp_path_info(rn), next = NULL; ri; ri = next) {
next = ri->next;
return;
}
- /* Iterate over bgp_path_info items at this node */
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ /* Iterate over bgp_info items at this node */
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
bgp, afi, bpi, /* VPN bpi */
return;
}
- /* Iterate over bgp_path_info items at this node */
- for (bpi = bn->info; bpi; bpi = bpi->next) {
+ /* Iterate over bgp_info items at this node */
+ for (bpi = bgp_node_get_bgp_path_info(bn); bpi; bpi = bpi->next) {
vnc_import_bgp_del_route_mode_resolve_nve_one_bi(
bgp, afi, bpi, /* VPN bpi */
struct bgp_path_info *bpi;
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(rn); bpi;
+ bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
struct bgp_path_info *bpi;
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(rn); bpi;
+ bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
struct bgp_path_info *bpi;
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(rn); bpi;
+ bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
rn1 = bgp_route_next(rn1)) {
- if (rn1->info) {
+ if (bgp_node_has_bgp_path_info_data(rn1)) {
+
for (rn2 = bgp_table_top(rn1->info); rn2;
rn2 = bgp_route_next(rn2)) {
struct bgp_path_info *bpi;
struct bgp_path_info *nextbpi;
- for (bpi = rn2->info; bpi; bpi = nextbpi) {
+ for (bpi = bgp_node_get_bgp_path_info(rn2); bpi;
+ bpi = nextbpi) {
nextbpi = bpi->next;
struct bgp_path_info *bpi;
- for (bpi = rn->info; bpi; bpi = bpi->next) {
+ for (bpi = bgp_node_get_bgp_path_info(rn); bpi;
+ bpi = bpi->next) {
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
struct bgp_path_info *ri;
- for (ri = rn->info; ri; ri = ri->next) {
+ for (ri = bgp_node_get_bgp_path_info(rn); ri;
+ ri = ri->next) {
if (ri->type
== type) { /* has matching redist type */
break;