return true;
}
bmp->syncpeerid = 0;
- prefix_copy(&bmp->syncpos, &bn->p);
+ prefix_copy(&bmp->syncpos, bgp_node_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);
+
if (bpi)
- bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L, &bn->p, bpi->attr,
+ bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L, bn_p, bpi->attr,
afi, safi, bpi->uptime);
if (adjin)
- bmp_monitor(bmp, adjin->peer, 0, &bn->p, adjin->attr,
- afi, safi, adjin->uptime);
+ bmp_monitor(bmp, adjin->peer, 0, bn_p, adjin->attr, afi, safi,
+ adjin->uptime);
return true;
}
struct bmp *bmp;
struct bmp_queue_entry *bqe, bqeref;
size_t refcount;
- char buf[256];
-
- prefix2str(&bn->p, buf, sizeof(buf));
refcount = bmp_session_count(&bt->sessions);
if (refcount == 0)
return;
memset(&bqeref, 0, sizeof(bqeref));
- prefix_copy(&bqeref.p, &bn->p);
+ prefix_copy(&bqeref.p, bgp_node_get_prefix(bn));
bqeref.peerid = peer->qobj_node.nid;
bqeref.afi = afi;
bqeref.safi = safi;
if (bdi->lastrecord == BGP_RECORD_UPDATE) {
bgp_path_info_unset_flag(bdi->rn, bdi->path,
BGP_PATH_HISTORY);
- bgp_aggregate_increment(bgp, &bdi->rn->p,
- bdi->path, bdi->afi,
- bdi->safi);
+ bgp_aggregate_increment(
+ bgp, bgp_node_get_prefix(bdi->rn),
+ bdi->path, bdi->afi, bdi->safi);
bgp_process(bgp, bdi->rn, bdi->afi, bdi->safi);
}
{
if (BGP_DEBUG(bestpath, BESTPATH)) {
if (bgp_debug_per_prefix(
- &rn->p, term_bgp_debug_bestpath,
+ bgp_node_get_prefix(rn), term_bgp_debug_bestpath,
BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes))
return true;
}
struct stream *obuf;
size_t sizep;
size_t endp;
+ const struct prefix *p = bgp_node_get_prefix(rn);
obuf = bgp_dump_obuf;
stream_reset(obuf);
stream_putl(obuf, seq);
/* Prefix length */
- stream_putc(obuf, rn->p.prefixlen);
+ stream_putc(obuf, p->prefixlen);
/* Prefix */
if (afi == AFI_IP) {
/* We'll dump only the useful bits (those not 0), but have to
* align on 8 bits */
- stream_write(obuf, (uint8_t *)&rn->p.u.prefix4,
- (rn->p.prefixlen + 7) / 8);
+ stream_write(obuf, (uint8_t *)&p->u.prefix4,
+ (p->prefixlen + 7) / 8);
} else if (afi == AFI_IP6) {
/* We'll dump only the useful bits (those not 0), but have to
* align on 8 bits */
- stream_write(obuf, (uint8_t *)&rn->p.u.prefix6,
- (rn->p.prefixlen + 7) / 8);
+ stream_write(obuf, (uint8_t *)&p->u.prefix6,
+ (p->prefixlen + 7) / 8);
}
/* Save where we are now, so we can overwride the entry count later */
/* Dump attribute. */
/* Skip prefix & AFI/SAFI for MP_NLRI */
- bgp_dump_routes_attr(obuf, path->attr, &rn->p);
+ bgp_dump_routes_attr(obuf, path->attr, p);
cur_endp = stream_get_endp(obuf);
if (cur_endp > BGP_MAX_PACKET_SIZE + BGP_DUMP_MSG_HEADER
* L3VPN routes.
*/
global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi,
- (struct prefix *)&rn->p, &vpn->prd);
+ bgp_node_get_prefix(rn), &vpn->prd);
if (global_rn) {
/* Delete route entry in the global EVPN table. */
delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi);
&& !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,
- (struct prefix_evpn *)&rn->p,
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn),
old_select->attr->nexthop);
}
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_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 *)&rn->p,
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn),
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 *)&rn->p,
+ bgp, es, (struct prefix_evpn *)bgp_node_get_prefix(rn),
old_select->attr->nexthop);
}
&& !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (bgp_zebra_has_route_changed(rn, old_select))
ret = evpn_zebra_install(
- bgp, vpn, (struct prefix_evpn *)&rn->p,
+ bgp, vpn, (const struct prefix_evpn *)bgp_node_get_prefix(rn),
old_select);
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
bgp_zebra_clear_route_change_flags(rn);
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 *)&rn->p,
- new_select);
+ ret = evpn_zebra_install(
+ bgp, vpn, (struct prefix_evpn *)bgp_node_get_prefix(rn),
+ new_select);
/* If an old best existed and it was a "local" route, the only
* reason
} else {
if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED)
- ret = evpn_zebra_uninstall(bgp, vpn,
- (struct prefix_evpn *)&rn->p,
- old_select->attr->nexthop);
+ ret = evpn_zebra_uninstall(
+ bgp, vpn,
+ (const struct prefix_evpn *)bgp_node_get_prefix(
+ rn),
+ old_select->attr->nexthop);
}
/* Clear any route change flags. */
struct bgp_path_info *local_pi = NULL; /* local route entry if any */
struct bgp_path_info *remote_pi = NULL; /* remote route entry if any */
struct attr *attr_new = NULL;
- struct prefix_evpn *evp = NULL;
+ const struct prefix_evpn *evp = NULL;
*ri = NULL;
*route_changed = 1;
- evp = (struct prefix_evpn *)&rn->p;
+ evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
/* locate the local and remote entries if any */
for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi;
uint32_t num_labels = 1;
int route_change = 1;
uint8_t sticky = 0;
- struct prefix_evpn *evp;
+ const struct prefix_evpn *evp;
*pi = NULL;
- evp = (struct prefix_evpn *)&rn->p;
+ evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
memset(&label, 0, sizeof(label));
/* See if this is an update of an existing route, or a new add. */
if (curr_select && curr_select->type == ZEBRA_ROUTE_BGP
&& curr_select->sub_type == BGP_ROUTE_IMPORTED)
evpn_zebra_install(bgp, vpn,
- (struct prefix_evpn *)&rn->p,
- curr_select);
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn),
+ curr_select);
}
/*
struct bgp_node *rn,
struct bgp_path_info *local_pi)
{
- char buf[PREFIX_STRLEN];
-
/* local path was not picked as the winner; kick it out */
- if (bgp_debug_zebra(NULL)) {
- zlog_debug("evicting local evpn prefix %s as remote won",
- prefix2str(&rn->p, buf, sizeof(buf)));
- }
+ if (bgp_debug_zebra(NULL))
+ zlog_debug("evicting local evpn prefix %pRN as remote won", rn);
+
evpn_delete_old_local_route(bgp, vpn, rn, local_pi);
bgp_path_info_reap(rn, local_pi);
*/
for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
struct bgp_node *rd_rn;
struct bgp_path_info *global_pi;
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)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
/* 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)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue;
/* as it is an importation, change nexthop */
bgp_path_info_set_flag(rn, pi, BGP_PATH_ANNC_NH_SELF);
- bgp_aggregate_increment(bgp_vrf, &rn->p, pi, afi, safi);
+ bgp_aggregate_increment(bgp_vrf, bgp_node_get_prefix(rn), pi, afi,
+ safi);
/* Perform route selection and update zebra, if required. */
bgp_process(bgp_vrf, rn, afi, safi);
/* Process for route leaking. */
vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp_vrf, pi);
- bgp_aggregate_decrement(bgp_vrf, &rn->p, pi, afi, safi);
+ bgp_aggregate_decrement(bgp_vrf, bgp_node_get_prefix(rn), pi, afi,
+ safi);
/* Mark entry for deletion */
bgp_path_info_delete(rn, pi);
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(
+ rn);
for (pi = bgp_node_get_bgp_path_info(rn); pi;
pi = pi->next) {
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
/* if not mac-ip route skip this route */
if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(
+ rn);
if (evp->prefix.route_type != rtype)
continue;
*/
for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn);
/* Identify MAC-IP local routes. */
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
for (pi = bgp_node_get_bgp_path_info(rn); 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, &rn->p,
- afi, safi);
+ bgp_evpn_withdraw_type5_route(
+ bgp_vrf, bgp_node_get_prefix(rn), afi,
+ safi);
break;
}
}
ret = route_map_apply(
bgp_vrf->adv_cmd_rmap[afi][safi]
.map,
- &rn->p, RMAP_BGP, &tmp_pi);
+ bgp_node_get_prefix(rn),
+ RMAP_BGP, &tmp_pi);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&tmp_attr);
continue;
}
bgp_evpn_advertise_type5_route(
- bgp_vrf, &rn->p, &tmp_attr,
- afi, safi);
+ bgp_vrf,
+ bgp_node_get_prefix(rn),
+ &tmp_attr, afi, safi);
} else
bgp_evpn_advertise_type5_route(
- bgp_vrf, &rn->p, pi->attr,
- afi, safi);
+ bgp_vrf,
+ bgp_node_get_prefix(rn),
+ pi->attr, afi, safi);
break;
}
}
if (bgp_nexthop_self(bgp, afi,
pi->type, pi->sub_type,
pi->attr, rn)) {
+ const struct prefix *p =
+ bgp_node_get_prefix(rn);
- char attr_str[BUFSIZ] = {0};
- char pbuf[PREFIX_STRLEN];
+ if (bgp_debug_update(pi->peer, p, NULL,
+ 1)) {
+ char attr_str[BUFSIZ] = {0};
- bgp_dump_attr(pi->attr, attr_str,
- BUFSIZ);
+ bgp_dump_attr(pi->attr,
+ attr_str, BUFSIZ);
- if (bgp_debug_update(pi->peer, &rn->p,
- NULL, 1))
zlog_debug(
- "%u: prefix %s with attr %s - DENIED due to martian or self nexthop",
- bgp->vrf_id,
- prefix2str(
- &rn->p, pbuf,
- sizeof(pbuf)),
+ "%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop",
+ bgp->vrf_id, rn,
attr_str);
-
+ }
bgp_evpn_unimport_route(bgp, afi, safi,
- &rn->p, pi);
+ p, pi);
bgp_rib_remove(rn, pi, pi->peer, afi,
safi);
uint16_t type;
struct rd_as rd_as;
struct rd_ip rd_ip;
- uint8_t *pnt;
+ const uint8_t *pnt;
+ const struct prefix *p = bgp_node_get_prefix(rd_rn);
- pnt = rd_rn->p.u.val;
+ pnt = p->u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
char prefix_str[BUFSIZ];
json_object *json_paths = NULL;
json_object *json_prefix = NULL;
+ const struct prefix *p = bgp_node_get_prefix(rn);
- bgp_evpn_route2str((struct prefix_evpn *)&rn->p, prefix_str,
+ bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str,
sizeof(prefix_str));
if (json)
if (json)
json_path = json_object_new_array();
- route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN, json_path);
+ route_vty_out(vty, p, pi, 0, SAFI_EVPN, json_path);
if (json)
json_object_array_add(json_paths, json_path);
json_object_string_add(json_prefix, "prefix",
prefix_str);
json_object_int_add(json_prefix, "prefixLen",
- rn->p.prefixlen);
+ p->prefixlen);
json_object_object_add(json_prefix, "paths",
json_paths);
json_object_object_add(json, prefix_str,
tbl_ver = table->version;
for (rn = bgp_table_top(table); rn;
rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn);
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);
- bgp_evpn_route2str((struct prefix_evpn *)&rn->p, prefix_str,
+ bgp_evpn_route2str((const struct prefix_evpn *)p, prefix_str,
sizeof(prefix_str));
if (type && evp->prefix.route_type != type)
AFI_L2VPN, SAFI_EVPN,
json_path);
else
- route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN,
+ route_vty_out(vty, p, pi, 0, SAFI_EVPN,
json_path);
if (json)
json_object_string_add(json_prefix, "prefix",
prefix_str);
json_object_int_add(json_prefix, "prefixLen",
- rn->p.prefixlen);
+ p->prefixlen);
json_object_object_add(json_prefix, "paths",
json_paths);
json_object_object_add(json, prefix_str,
rn = bgp_route_next(rn)) {
uint64_t tbl_ver;
json_object *json_nroute = NULL;
+ const struct prefix *p = bgp_node_get_prefix(rn);
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ if (prd && memcmp(p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
json_array = json_object_new_array();
if (option == SHOW_DISPLAY_TAGS)
- route_vty_out_tag(vty, &rm->p, pi,
- no_display, SAFI_EVPN,
- json_array);
+ route_vty_out_tag(
+ vty, bgp_node_get_prefix(rm),
+ pi, no_display, SAFI_EVPN,
+ json_array);
else if (option == SHOW_DISPLAY_OVERLAY)
- route_vty_out_overlay(vty, &rm->p, pi,
- no_display,
- json_array);
+ route_vty_out_overlay(
+ vty, bgp_node_get_prefix(rm),
+ pi, no_display, json_array);
else
- route_vty_out(vty, &rm->p, pi,
- no_display, SAFI_EVPN,
+ route_vty_out(vty,
+ bgp_node_get_prefix(rm),
+ pi, no_display, SAFI_EVPN,
json_array);
no_display = 1;
}
output_count++;
if (use_json && json_array) {
+ const struct prefix *p =
+ bgp_node_get_prefix(rm);
+
json_prefix_info = json_object_new_object();
- json_object_string_add(json_prefix_info,
- "prefix", bgp_evpn_route2str(
- (struct prefix_evpn *)&rm->p, buf,
- BUFSIZ));
+ json_object_string_add(
+ json_prefix_info, "prefix",
+ bgp_evpn_route2str(
+ (struct prefix_evpn *)p, buf,
+ BUFSIZ));
json_object_int_add(json_prefix_info,
- "prefixLen", rm->p.prefixlen);
+ "prefixLen", p->prefixlen);
json_object_object_add(json_prefix_info,
"paths", json_array);
/* Display all prefixes with this RD. */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(rn);
json_object *json_prefix = NULL;
json_object *json_paths = NULL;
char prefix_str[BUFSIZ];
int add_prefix_to_json = 0;
- bgp_evpn_route2str((struct prefix_evpn *)&rn->p, prefix_str,
+ bgp_evpn_route2str((struct prefix_evpn *)evp, prefix_str,
sizeof(prefix_str));
if (type && evp->prefix.route_type != type)
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);
table = bgp_node_get_bgp_table_info(rd_rn);
if (table == NULL)
continue;
tbl_ver = table->version;
- prefix_rd2str((struct prefix_rd *)&rd_rn->p, rd_str,
+ prefix_rd2str((struct prefix_rd *)rd_rnp, rd_str,
sizeof(rd_str));
if (json)
NULL; /* contains prefix under a RD */
json_object *json_paths =
NULL; /* array of paths under a prefix*/
- struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_node_get_prefix(
+ rn);
char prefix_str[BUFSIZ];
int add_prefix_to_json = 0;
+ const struct prefix *p = bgp_node_get_prefix(rn);
- bgp_evpn_route2str((struct prefix_evpn *)&rn->p,
- prefix_str, sizeof(prefix_str));
+ bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str,
+ sizeof(prefix_str));
if (type && evp->prefix.route_type != type)
continue;
json_object_string_add(json_prefix, "prefix",
prefix_str);
json_object_int_add(json_prefix, "prefixLen",
- rn->p.prefixlen);
+ p->prefixlen);
}
/* Prefix and num paths displayed once per prefix. */
if (detail)
route_vty_out_detail_header(
vty, bgp, rn,
- (struct prefix_rd *)&rd_rn->p,
- AFI_L2VPN, SAFI_EVPN, json_prefix);
+ (struct prefix_rd *)rd_rnp, AFI_L2VPN,
+ SAFI_EVPN, json_prefix);
/* For EVPN, the prefix is displayed for each path (to
* fit in
vty, bgp, rn, pi, AFI_L2VPN,
SAFI_EVPN, json_path);
} else
- route_vty_out(vty, &rn->p, pi, 0,
- SAFI_EVPN, json_path);
+ route_vty_out(vty, p, pi, 0, SAFI_EVPN,
+ json_path);
if (json)
json_object_array_add(json_paths,
struct bgp_pbr_entry_action *api_action;
memset(&api, 0, sizeof(struct bgp_pbr_entry_main));
- if (bgp_pbr_build_and_validate_entry(&rn->p, pi, &api) < 0)
+ if (bgp_pbr_build_and_validate_entry(bgp_node_get_prefix(rn), pi, &api)
+ < 0)
return true;
for (i = 0; i < api.action_num; i++) {
api_action = &api.actions[i];
}
for (; pi; pi = pi->next) {
total_count++;
- route_vty_out_flowspec(vty, &rn->p, pi, display,
- json_paths);
+ route_vty_out_flowspec(vty, bgp_node_get_prefix(rn), pi,
+ display, json_paths);
}
if (use_json) {
vty_out(vty, "%s\n",
json_object *json_paths)
{
struct bgp_node *rn;
- struct prefix *prefix;
+ const struct prefix *prefix;
int display = 0;
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
- prefix = &rn->p;
+ prefix = bgp_node_get_prefix(rn);
if (prefix->family != AF_FLOWSPEC)
continue;
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
route_vty_out_flowspec(
- vty, &rn->p, bgp_node_get_bgp_path_info(rn),
+ vty, prefix, bgp_node_get_bgp_path_info(rn),
use_json ? NLRI_STRING_FORMAT_JSON
: NLRI_STRING_FORMAT_LARGE,
json_paths);
{
struct bgp_path_info *pi;
struct bgp_node *rn;
- char addr[PREFIX_STRLEN];
pi = labelid;
/* Is this path still valid? */
}
rn = pi->net;
- prefix2str(&rn->p, addr, PREFIX_STRLEN);
if (BGP_DEBUG(labelpool, LABELPOOL))
- zlog_debug("%s: FEC %s label=%u, allocated=%d", __func__, addr,
+ zlog_debug("%s: FEC %pRN label=%u, allocated=%d", __func__, rn,
new_label, allocated);
if (!allocated) {
if (pi->attr->label_index != MPLS_INVALID_LABEL_INDEX) {
flog_err(
EC_BGP_LABEL,
- "%s: FEC %s Rejecting allocated label %u as Label Index is %u",
- __func__, addr, new_label, pi->attr->label_index);
+ "%s: FEC %pRN Rejecting allocated label %u as Label Index is %u",
+ __func__, rn, 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: %s had label %u but got new assignment %u",
- __func__, addr, pi->attr->label, new_label);
+ "%s: %pRN had label %u but got new assignment %u",
+ __func__, rn, pi->attr->label, new_label);
/* continue means use new one */
}
{
bool with_label_index = false;
struct stream *s;
- struct prefix *p;
+ const struct prefix *p;
mpls_label_t *local_label;
int command;
uint16_t flags = 0;
size_t flags_pos = 0;
char addr[PREFIX_STRLEN];
- p = &(rn->p);
+ p = bgp_node_get_prefix(rn);
local_label = &(rn->local_label);
/* this prevents the loop when we're called by
* bgp_reg_for_label_callback()
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);
if (!sub)
continue;
for (rn = bgp_table_top(sub); rn; rn = bgp_route_next(rn)) {
bool rn_affected;
- struct prefix_evpn *pevpn = (struct prefix_evpn *)&rn->p;
+ const struct prefix *p = bgp_node_get_prefix(rn);
+ const struct prefix_evpn *pevpn = (const struct prefix_evpn *)p;
struct prefix_rd prd;
uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL;
if (pevpn->family == AF_EVPN &&
pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE &&
- memcmp(&rn->p.u.prefix_evpn.macip_addr.mac,
+ memcmp(&p->u.prefix_evpn.macip_addr.mac,
macaddr, ETH_ALEN) == 0)
rn_affected = true;
else
prd.family = AF_UNSPEC;
prd.prefixlen = 64;
- memcpy(&prd.val, &prn->p.u.val, 8);
+ memcpy(&prd.val, prn_p->u.val, 8);
if (CHECK_FLAG(pi->flags, BGP_PATH_REMOVED)) {
- if (bgp_debug_update(peer, &rn->p, NULL, 1)) {
+ if (bgp_debug_update(peer, p, NULL, 1)) {
char pfx_buf[BGP_PRD_PATH_STRLEN];
bgp_debug_rdpfxpath2str(
AFI_L2VPN, SAFI_EVPN, &prd,
- &rn->p, label_pnt, num_labels,
+ p, label_pnt, num_labels,
pi->addpath_rx_id ? 1 : 0,
pi->addpath_rx_id, pfx_buf,
sizeof(pfx_buf));
}
memcpy(&evpn, &pi->attr->evpn_overlay, sizeof(evpn));
- int32_t ret = bgp_update(peer, &rn->p,
+ int32_t ret = bgp_update(peer, p,
pi->addpath_rx_id,
pi->attr, AFI_L2VPN, SAFI_EVPN,
ZEBRA_ROUTE_BGP,
struct listnode *mp_node, *mp_next_node;
struct bgp_path_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath;
int mpath_changed, debug;
- char pfx_buf[PREFIX2STR_BUFFER], nh_buf[2][INET6_ADDRSTRLEN];
+ char nh_buf[2][INET6_ADDRSTRLEN];
char path_buf[PATH_ADDPATH_STR_BUFFER];
mpath_changed = 0;
mp_node = listhead(mp_list);
debug = bgp_debug_bestpath(rn);
- if (debug)
- prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
-
if (new_best) {
mpath_count++;
if (new_best != old_best)
if (debug)
zlog_debug(
- "%s: starting mpath update, newbest %s num candidates %d old-mpath-count %d",
- pfx_buf, new_best ? new_best->peer->host : "NONE",
+ "%pRN: starting mpath update, newbest %s num candidates %d old-mpath-count %d",
+ rn, new_best ? new_best->peer->host : "NONE",
mp_list ? listcount(mp_list) : 0, old_mpath_count);
/*
if (debug)
zlog_debug(
- "%s: comparing candidate %s with existing mpath %s",
- pfx_buf,
+ "%pRN: comparing candidate %s with existing mpath %s",
+ rn,
tmp_info ? tmp_info->peer->host : "NONE",
cur_mpath ? cur_mpath->peer->host : "NONE");
bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf);
zlog_debug(
- "%s: %s is still multipath, cur count %d",
- pfx_buf, path_buf, mpath_count);
+ "%pRN: %s is still multipath, cur count %d",
+ rn, path_buf, mpath_count);
}
} else {
mpath_changed = 1;
bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf);
zlog_debug(
- "%s: remove mpath %s nexthop %s, cur count %d",
- pfx_buf, path_buf,
+ "%pRN: remove mpath %s nexthop %s, cur count %d",
+ rn, path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr
->nexthop,
bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf);
zlog_debug(
- "%s: remove mpath %s nexthop %s, cur count %d",
- pfx_buf, path_buf,
+ "%pRN: remove mpath %s nexthop %s, cur count %d",
+ rn, path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr->nexthop,
nh_buf[0], sizeof(nh_buf[0])),
bgp_path_info_path_with_addpath_rx_str(
new_mpath, path_buf);
zlog_debug(
- "%s: add mpath %s nexthop %s, cur count %d",
- pfx_buf, path_buf,
+ "%pRN: add mpath %s nexthop %s, cur count %d",
+ rn, path_buf,
inet_ntop(AF_INET,
&new_mpath->attr
->nexthop,
if (new_best) {
if (debug)
zlog_debug(
- "%s: New mpath count (incl newbest) %d mpath-change %s",
- pfx_buf, mpath_count,
+ "%pRN: New mpath count (incl newbest) %d mpath-change %s",
+ rn, mpath_count,
mpath_changed ? "YES" : "NO");
bgp_path_info_mpath_count_set(new_best, mpath_count - 1);
struct bgp *bgp_orig, struct prefix *nexthop_orig,
int nexthop_self_flag, int debug)
{
- struct prefix *p = &bn->p;
+ const struct prefix *p = bgp_node_get_prefix(bn);
struct bgp_path_info *bpi;
struct bgp_path_info *bpi_ultimate;
struct bgp_path_info *new;
- char buf_prefix[PREFIX_STRLEN];
- if (debug) {
- prefix2str(&bn->p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: entry: leak-to=%s, p=%s, type=%d, sub_type=%d",
- __func__, bgp->name_pretty, buf_prefix,
- source_bpi->type, source_bpi->sub_type);
- }
+ if (debug)
+ zlog_debug(
+ "%s: entry: leak-to=%s, p=%pRN, type=%d, sub_type=%d",
+ __func__, bgp->name_pretty, bn, source_bpi->type,
+ source_bpi->sub_type);
/*
* Routes that are redistributed into BGP from zebra do not get
bgp_attr_unintern(&new_attr);
if (debug)
zlog_debug(
- "%s: ->%s: %s: Found route, no change",
- __func__, bgp->name_pretty,
- buf_prefix);
+ "%s: ->%s: %pRN: Found route, no change",
+ __func__, bgp->name_pretty, bn);
return NULL;
}
bgp_unlock_node(bn);
if (debug)
- zlog_debug("%s: ->%s: %s Found route, changed attr",
- __func__, bgp->name_pretty, buf_prefix);
+ zlog_debug("%s: ->%s: %pRN Found route, changed attr",
+ __func__, bgp->name_pretty, bn);
return bpi;
}
bgp_process(bgp, bn, afi, safi);
if (debug)
- zlog_debug("%s: ->%s: %s: Added new route", __func__,
- bgp->name_pretty, buf_prefix);
+ zlog_debug("%s: ->%s: %pRN: Added new route", __func__,
+ bgp->name_pretty, bn);
return new;
}
struct bgp_path_info *path_vrf) /* route */
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
- struct prefix *p = &path_vrf->net->p;
+ const struct prefix *p = bgp_node_get_prefix(path_vrf->net);
afi_t afi = family2afi(p->family);
struct attr static_attr = {0};
struct attr *new_attr = NULL;
struct bgp_path_info *path_vrf) /* route */
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
- struct prefix *p = &path_vrf->net->p;
+ const struct prefix *p = bgp_node_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;
const char *debugmsg;
- char buf_prefix[PREFIX_STRLEN];
if (debug) {
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
zlog_debug(
- "%s: entry: leak-from=%s, p=%s, type=%d, sub_type=%d",
- __func__, bgp_vrf->name_pretty, buf_prefix,
+ "%s: entry: leak-from=%s, p=%pRN, type=%d, sub_type=%d",
+ __func__, bgp_vrf->name_pretty, path_vrf->net,
path_vrf->type, path_vrf->sub_type);
}
continue;
for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
-
- char buf[PREFIX2STR_BUFFER];
-
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)));
+ zlog_debug("%s: looking at prefix %pRN",
+ __func__, bn);
}
for (; bpi; bpi = bpi->next) {
if (debug)
zlog_debug("%s: deleting it",
__func__);
- bgp_aggregate_decrement(bgp_vpn, &bn->p,
- bpi, afi, safi);
+ bgp_aggregate_decrement(
+ bgp_vpn,
+ bgp_node_get_prefix(bn), bpi,
+ afi, safi);
bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vpn, bn, afi, safi);
}
struct bgp *bgp_vpn, /* from */
struct bgp_path_info *path_vpn) /* route */
{
- struct prefix *p = &path_vpn->net->p;
+ const struct prefix *p = bgp_node_get_prefix(path_vpn->net);
afi_t afi = family2afi(p->family);
struct attr static_attr = {0};
}
}
- if (debug) {
- char buf_prefix[PREFIX_STRLEN];
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: pfx %s: num_labels %d", __func__, buf_prefix,
- num_labels);
- }
+ if (debug)
+ zlog_debug("%s: pfx %pRN: num_labels %d", __func__,
+ path_vpn->net, num_labels);
/*
* For VRF-2-VRF route-leaking,
void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
struct bgp_path_info *path_vpn) /* route */
{
- struct prefix *p;
+ const struct prefix *p;
afi_t afi;
safi_t safi = SAFI_UNICAST;
struct bgp *bgp;
struct bgp_node *bn;
struct bgp_path_info *bpi;
const char *debugmsg;
- char buf_prefix[PREFIX_STRLEN];
int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
- if (debug) {
- prefix2str(&path_vpn->net->p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: entry: p=%s, type=%d, sub_type=%d", __func__,
- buf_prefix, path_vpn->type, path_vpn->sub_type);
- }
+ if (debug)
+ zlog_debug("%s: entry: p=%pRN, type=%d, sub_type=%d", __func__,
+ path_vpn->net, path_vpn->type, path_vpn->sub_type);
if (debug)
zlog_debug("%s: start (path_vpn=%p)", __func__, path_vpn);
return;
}
- p = &path_vpn->net->p;
+ p = bgp_node_get_prefix(path_vpn->net);
afi = family2afi(p->family);
/* Loop over VRFs */
&& is_pi_family_vpn(bpi->extra->parent)) {
/* delete route */
- bgp_aggregate_decrement(bgp_vrf, &bn->p, bpi,
- afi, safi);
+ bgp_aggregate_decrement(bgp_vrf,
+ bgp_node_get_prefix(bn),
+ bpi, afi, safi);
bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vrf, bn, afi, safi);
}
*/
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);
struct bgp_table *table;
struct bgp_node *bn;
struct bgp_path_info *bpi;
memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC;
prd.prefixlen = 64;
- memcpy(prd.val, prn->p.u.val, 8);
+ memcpy(prd.val, &p->u.val, 8);
/* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn);
char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size)
{
- prefix2str(&(bnc->node->p), buf, size);
+ prefix2str(bgp_node_get_prefix(bnc->node), buf, size);
return buf;
}
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);
bool is_bgp_static_route =
((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC))
? true
switch (new_afi) {
case AF_INET:
if (is_bgp_static_route) {
- tmp_addr.p.u.prefix4 = rn->p.u.prefix4;
- tmp_addr.p.prefixlen = rn->p.prefixlen;
+ tmp_addr.p.u.prefix4 = p->u.prefix4;
+ tmp_addr.p.prefixlen = p->prefixlen;
} else {
/* Here we need to find out which nexthop to be used*/
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
break;
case AF_INET6:
if (is_bgp_static_route) {
- tmp_addr.p.u.prefix6 = rn->p.u.prefix6;
- tmp_addr.p.prefixlen = rn->p.prefixlen;
+ tmp_addr.p.u.prefix6 = p->u.prefix6;
+ tmp_addr.p.prefixlen = p->prefixlen;
} else {
tmp_addr.p.u.prefix6 = attr->mp_nexthop_global;
tmp_addr.p.prefixlen = IPV6_MAX_BITLEN;
for (rn = bgp_table_top(table[afi]); rn;
rn = bgp_route_next(rn)) {
struct peer *peer;
+ const struct prefix *p = bgp_node_get_prefix(rn);
bnc = bgp_node_get_bgp_nexthop_info(rn);
if (!bnc)
if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)) {
vty_out(vty,
" %s valid [IGP metric %d], #paths %d",
- inet_ntop(rn->p.family,
- &rn->p.u.prefix, buf,
+ inet_ntop(p->family, &p->u.prefix, buf,
sizeof(buf)),
bnc->metric, bnc->path_count);
if (peer)
} else {
vty_out(vty, " %s invalid",
- inet_ntop(rn->p.family,
- &rn->p.u.prefix, buf,
+ inet_ntop(p->family, &p->u.prefix, buf,
sizeof(buf)));
if (peer)
vty_out(vty, ", peer %s", peer->host);
struct bgp_nexthop_cache *bnc;
struct prefix p;
int is_bgp_static_route = 0;
+ const struct prefix *bnc_p;
if (pi) {
is_bgp_static_route = ((pi->type == ZEBRA_ROUTE_BGP)
}
}
+ bnc_p = bgp_node_get_prefix(bnc->node);
+
bgp_unlock_node(rn);
if (is_bgp_static_route) {
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
if (bgp_route->inst_type == BGP_INSTANCE_TYPE_VIEW) {
SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
SET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
- } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED) &&
- !is_default_host_route(&bnc->node->p))
+ } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)
+ && !is_default_host_route(bnc_p))
register_zebra_rnh(bnc, is_bgp_static_route);
if (pi && pi->nexthop != bnc) {
? 1
: 0;
struct bgp_node *net = pi->net;
- struct prefix *p_orig = &net->p;
+ const struct prefix *p_orig = bgp_node_get_prefix(net);
if (p_orig->family == AF_FLOWSPEC) {
if (!pi->peer)
case AFI_IP:
p->family = AF_INET;
if (is_bgp_static) {
- p->u.prefix4 = pi->net->p.u.prefix4;
- p->prefixlen = pi->net->p.prefixlen;
+ p->u.prefix4 = p_orig->u.prefix4;
+ p->prefixlen = p_orig->prefixlen;
} else {
p->u.prefix4 = pi->attr->nexthop;
p->prefixlen = IPV4_MAX_BITLEN;
p->family = AF_INET6;
if (is_bgp_static) {
- p->u.prefix6 = pi->net->p.u.prefix6;
- p->prefixlen = pi->net->p.prefixlen;
+ p->u.prefix6 = p_orig->u.prefix6;
+ p->prefixlen = p_orig->prefixlen;
} else {
p->u.prefix6 = pi->attr->mp_nexthop_global;
p->prefixlen = IPV6_MAX_BITLEN;
*/
static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
{
- struct prefix *p;
+ const struct prefix *p;
bool exact_match = false;
int ret;
"%s: We have not connected yet, cannot send nexthops",
__func__);
}
- p = &(bnc->node->p);
+ p = bgp_node_get_prefix(bnc->node);
if ((command == ZEBRA_NEXTHOP_REGISTER
|| command == ZEBRA_IMPORT_ROUTE_REGISTER)
&& (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)
struct bgp_table *table;
safi_t safi;
struct bgp *bgp_path;
+ const struct prefix *p;
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
rn = path->net;
assert(rn && bgp_node_table(rn));
- afi = family2afi(rn->p.family);
+ p = bgp_node_get_prefix(rn);
+ afi = family2afi(p->family);
table = bgp_node_table(rn);
safi = table->safi;
bgp_isvalid_nexthop(bnc) ? 1 : 0;
}
- if (BGP_DEBUG(nht, NHT)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&rn->p, buf, PREFIX_STRLEN);
- zlog_debug("%s: prefix %s (vrf %s) %svalid",
- __func__, buf, bgp_path->name,
- (bnc_is_valid_nexthop ? "" : "not "));
- }
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug("%s: prefix %pRN (vrf %s) %svalid", __func__,
+ rn, bgp_path->name,
+ (bnc_is_valid_nexthop ? "" : "not "));
if ((CHECK_FLAG(path->flags, BGP_PATH_VALID) ? 1 : 0)
!= bnc_is_valid_nexthop) {
if (CHECK_FLAG(path->flags, BGP_PATH_VALID)) {
- bgp_aggregate_decrement(bgp_path, &rn->p,
- path, afi, safi);
+ bgp_aggregate_decrement(bgp_path, p, path, afi,
+ safi);
bgp_path_info_unset_flag(rn, path,
BGP_PATH_VALID);
} else {
bgp_path_info_set_flag(rn, path,
BGP_PATH_VALID);
- bgp_aggregate_increment(bgp_path, &rn->p,
- path, afi, safi);
+ bgp_aggregate_increment(bgp_path, p, path, afi,
+ safi);
}
}
|| CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED))
SET_FLAG(path->flags, BGP_PATH_IGP_CHANGED);
- if (safi == SAFI_EVPN &&
- bgp_evpn_is_prefix_nht_supported(&rn->p)) {
+ if (safi == SAFI_EVPN && bgp_evpn_is_prefix_nht_supported(p)) {
if (CHECK_FLAG(path->flags, BGP_PATH_VALID))
- bgp_evpn_import_route(bgp_path, afi, safi,
- &rn->p, path);
+ bgp_evpn_import_route(bgp_path, afi, safi, p,
+ path);
else
- bgp_evpn_unimport_route(bgp_path, afi, safi,
- &rn->p, path);
+ bgp_evpn_unimport_route(bgp_path, afi, safi, p,
+ path);
}
bgp_process(bgp_path, rn, afi, safi);
struct bgp_table *table = NULL;
afi_t afi = 0;
safi_t safi = 0;
- char buf[PREFIX2STR_BUFFER];
/* If the flag BGP_NODE_SELECT_DEFER is set and new path is added
* then the route selection is deferred
return 0;
if (CHECK_FLAG(rn->flags, BGP_NODE_PROCESS_SCHEDULED)) {
- if (BGP_DEBUG(update, UPDATE_OUT)) {
- prefix2str(&rn->p, buf, PREFIX2STR_BUFFER);
+ if (BGP_DEBUG(update, UPDATE_OUT))
zlog_debug(
- "Route %s is in workqueue and being processed, not deferred.",
- buf);
- }
+ "Route %pRN is in workqueue and being processed, not deferred.",
+ rn);
+
return 0;
}
if (set_flag && table) {
if (bgp && (bgp->gr_info[afi][safi].t_select_deferral)) {
SET_FLAG(rn->flags, BGP_NODE_SELECT_DEFER);
- prefix2str(&rn->p, buf, PREFIX2STR_BUFFER);
if (rn->rt_node == NULL)
rn->rt_node = listnode_add(
bgp->gr_info[afi][safi].route_list, rn);
if (BGP_DEBUG(update, UPDATE_OUT))
- zlog_debug("DEFER route %s, rn %p, node %p",
- buf, rn, rn->rt_node);
+ zlog_debug("DEFER route %pRN, rn %p, node %p",
+ rn, rn, rn->rt_node);
return 0;
}
}
*/
if (newattr->sticky != existattr->sticky) {
if (!debug) {
- prefix2str(&new->net->p, pfx_buf,
+ prefix2str(bgp_node_get_prefix(new->net),
+ pfx_buf,
sizeof(*pfx_buf)
* PREFIX2STR_BUFFER);
bgp_path_info_path_with_addpath_rx_str(new,
debug = bgp_debug_bestpath(rn);
if (debug)
- prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
+ prefix2str(bgp_node_get_prefix(rn), pfx_buf, sizeof(pfx_buf));
rn->reason = bgp_path_selection_none;
/* bgp deterministic-med */
struct bgp_node *rn,
uint32_t addpath_tx_id)
{
- struct prefix *p;
+ const struct prefix *p;
struct peer *onlypeer;
struct attr attr;
afi_t afi;
safi_t safi;
- p = &rn->p;
+ p = bgp_node_get_prefix(rn);
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
struct bgp_path_info *new_select;
struct bgp_path_info *old_select;
struct bgp_path_info_pair old_and_new;
- char pfx_buf[PREFIX2STR_BUFFER];
int debug = 0;
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
if (rn)
debug = bgp_debug_bestpath(rn);
- if (debug) {
- prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
+ if (debug)
zlog_debug(
- "%s: bgp delete in progress, ignoring event, p=%s",
- __func__, pfx_buf);
- }
+ "%s: bgp delete in progress, ignoring event, p=%pRN",
+ __func__, rn);
return;
}
/* Is it end of initial update? (after startup) */
return;
}
- struct prefix *p = &rn->p;
+ const struct prefix *p = bgp_node_get_prefix(rn);
debug = bgp_debug_bestpath(rn);
- if (debug) {
- prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
- zlog_debug("%s: p=%s afi=%s, safi=%s start", __func__, pfx_buf,
+ if (debug)
+ zlog_debug("%s: p=%pRN afi=%s, safi=%s start", __func__, rn,
afi2str(afi), safi2str(safi));
- }
/* The best path calculation for the route is deferred if
* BGP_NODE_SELECT_DEFER is set
bgp_unregister_for_label(rn);
}
- if (debug) {
- prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
+ if (debug)
zlog_debug(
- "%s: p=%s afi=%s, safi=%s, old_select=%p, new_select=%p",
- __func__, pfx_buf, afi2str(afi), safi2str(safi),
+ "%s: p=%pRN afi=%s, safi=%s, old_select=%p, new_select=%p",
+ __func__, rn, 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.
/* advertise/withdraw type-5 routes */
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
+ const struct prefix *p = bgp_node_get_prefix(rn);
+
if (advertise_type5_routes(bgp, afi) &&
new_select &&
is_route_injectable_into_evpn(new_select)) {
ret = route_map_apply(
bgp->adv_cmd_rmap[afi][safi].map,
- &rn->p, RMAP_BGP, &rmap_path);
+ p, RMAP_BGP, &rmap_path);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&dummy_attr);
bgp_evpn_withdraw_type5_route(
- bgp, &rn->p, afi, safi);
+ bgp, p, afi, safi);
} else
bgp_evpn_advertise_type5_route(
- bgp, &rn->p, &dummy_attr,
+ bgp, p, &dummy_attr,
afi, safi);
} else {
- bgp_evpn_advertise_type5_route(bgp,
- &rn->p,
+ bgp_evpn_advertise_type5_route(bgp, p,
new_select->attr,
afi, safi);
} else if (advertise_type5_routes(bgp, afi) &&
old_select &&
is_route_injectable_into_evpn(old_select))
- bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);
+ bgp_evpn_withdraw_type5_route(bgp, p, afi, safi);
}
/* Clear any route change flags. */
struct bgp *bgp = NULL;
bool delete_route = false;
- bgp_aggregate_decrement(peer->bgp, &rn->p, pi, afi, safi);
+ bgp_aggregate_decrement(peer->bgp, bgp_node_get_prefix(rn),
+ pi, afi, safi);
if (!CHECK_FLAG(pi->flags, BGP_PATH_HISTORY)) {
bgp_path_info_delete(rn, pi); /* keep historical info */
struct peer *peer, afi_t afi, safi_t safi,
struct prefix_rd *prd)
{
+ const struct prefix *p = bgp_node_get_prefix(rn);
+
/* apply dampening, if result is suppressed, we'll be retaining
* the bgp_path_info in the RIB for historical reference.
*/
&& peer->sort == BGP_PEER_EBGP)
if ((bgp_damp_withdraw(pi, rn, afi, safi, 0))
== BGP_DAMP_SUPPRESSED) {
- bgp_aggregate_decrement(peer->bgp, &rn->p, pi, afi,
+ bgp_aggregate_decrement(peer->bgp, p, pi, afi,
safi);
return;
}
table = bgp_node_get_bgp_table_info(prn);
vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
- peer->bgp, prd, table, &rn->p, pi);
+ peer->bgp, prd, table, p, pi);
}
bgp_unlock_node(prn);
}
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
- vnc_import_bgp_del_route(peer->bgp, &rn->p, pi);
- vnc_import_bgp_exterior_del_route(peer->bgp, &rn->p,
- pi);
+ vnc_import_bgp_del_route(peer->bgp, p, pi);
+ vnc_import_bgp_exterior_del_route(peer->bgp, p, pi);
}
}
#endif
/* If this is an EVPN route, process for un-import. */
if (safi == SAFI_EVPN)
- bgp_evpn_unimport_route(peer->bgp, afi, safi, &rn->p, pi);
+ bgp_evpn_unimport_route(peer->bgp, afi, safi, p, pi);
bgp_rib_remove(rn, pi, peer, afi, safi);
}
else
memset(&evpn, 0, sizeof(evpn));
- ret = bgp_update(peer, &rn->p, ain->addpath_rx_id,
- ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
+ ret = bgp_update(peer, bgp_node_get_prefix(rn),
+ ain->addpath_rx_id, ain->attr,
+ afi, safi, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, prd, label_pnt,
num_labels, 1, &evpn);
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
table = bgp_node_get_bgp_table_info(rn);
- if (table != NULL) {
- struct prefix_rd prd;
- prd.family = AF_UNSPEC;
- prd.prefixlen = 64;
- memcpy(&prd.val, rn->p.u.val, 8);
+ if (table == NULL)
+ continue;
- bgp_soft_reconfig_table(peer, afi, safi, table,
- &prd);
- }
+ const struct prefix *p = bgp_node_get_prefix(rn);
+ struct prefix_rd prd;
+
+ prd.family = AF_UNSPEC;
+ prd.prefixlen = 64;
+ memcpy(&prd.val, p->u.val, 8);
+
+ bgp_soft_reconfig_table(peer, afi, safi, table, &prd);
}
}
/* If this is an EVPN route, process for
* un-import. */
if (safi == SAFI_EVPN)
- bgp_evpn_unimport_route(bgp, afi, safi, &rn->p,
+ bgp_evpn_unimport_route(bgp, afi, safi,
+ bgp_node_get_prefix(rn),
pi);
/* Handle withdraw for VRF route-leaking and L3VPN */
if (SAFI_UNICAST == safi
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);
+
next = pi->next;
/* Unimport EVPN routes from VRFs */
if (safi == SAFI_EVPN)
bgp_evpn_unimport_route(bgp, AFI_L2VPN,
- SAFI_EVPN,
- &rn->p, pi);
+ SAFI_EVPN, p, pi);
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& pi->type == ZEBRA_ROUTE_BGP
|| pi->sub_type == BGP_ROUTE_IMPORTED)) {
if (bgp_fibupd_safi(safi))
- bgp_zebra_withdraw(&rn->p, pi, bgp,
- safi);
+ bgp_zebra_withdraw(p, pi, bgp, safi);
bgp_path_info_reap(rn, pi);
}
}
bgp_static =
bgp_node_get_bgp_static_info(
rm);
- bgp_static_update_safi(bgp, &rm->p,
+ bgp_static_update_safi(bgp,
+ bgp_node_get_prefix(rm),
bgp_static, afi,
safi);
}
} else {
bgp_static_update(
- bgp, &rn->p,
+ bgp, bgp_node_get_prefix(rn),
bgp_node_get_bgp_static_info(rn), afi,
safi);
}
continue;
bgp_static_withdraw_safi(
- bgp, &rm->p, AFI_IP, safi,
- (struct prefix_rd *)&rn->p);
+ bgp, bgp_node_get_prefix(rm),
+ AFI_IP, safi,
+ (struct prefix_rd *)
+ bgp_node_get_prefix(
+ rn));
bgp_static_free(bgp_static);
bgp_node_set_bgp_static_info(rn, NULL);
bgp_unlock_node(rn);
}
} else {
bgp_static = bgp_node_get_bgp_static_info(rn);
- bgp_static_withdraw(bgp, &rn->p, afi, safi);
+ bgp_static_withdraw(bgp,
+ bgp_node_get_prefix(rn),
+ afi, safi);
bgp_static_free(bgp_static);
bgp_node_set_bgp_static_info(rn, NULL);
bgp_unlock_node(rn);
bgp_static =
bgp_node_get_bgp_static_info(
rm);
- bgp_static_update_safi(bgp, &rm->p,
+ bgp_static_update_safi(bgp,
+ bgp_node_get_prefix(rm),
bgp_static, afi,
safi);
}
} else {
bgp_static = bgp_node_get_bgp_static_info(rn);
- bgp_static_update(bgp, &rn->p, bgp_static, afi,
+ bgp_static_update(bgp, bgp_node_get_prefix(rn),
+ bgp_static, afi,
safi);
}
}
|| (pi->type != ZEBRA_ROUTE_BGP
&& pi->sub_type
== BGP_ROUTE_REDISTRIBUTE))) {
- bgp_aggregate_decrement(bgp, &rn->p, pi, afi,
- safi);
+ bgp_aggregate_decrement(bgp,
+ bgp_node_get_prefix(rn),
+ pi, afi, safi);
bgp_unlink_nexthop(pi);
bgp_path_info_delete(rn, pi);
bgp_process(bgp, rn, afi, safi);
top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn;
rn = bgp_route_next_until(rn, top)) {
- if (rn->p.prefixlen <= p->prefixlen)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (rn_p->prefixlen <= p->prefixlen)
continue;
match = 0;
top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn;
rn = bgp_route_next_until(rn, top)) {
- if (rn->p.prefixlen <= p->prefixlen)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (rn_p->prefixlen <= p->prefixlen)
continue;
match = 0;
/* Aggregate address configuration check. */
for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
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);
+ if (aggregate != NULL && rn_p->prefixlen < p->prefixlen) {
+ bgp_add_route_to_aggregate(bgp, rn_p, pi, afi, safi,
+ aggregate);
}
}
bgp_unlock_node(child);
/* Aggregate address configuration check. */
for (rn = child; rn; rn = bgp_node_parent_nolock(rn)) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
aggregate = bgp_node_get_bgp_aggregate_info(rn);
- if (aggregate != NULL && rn->p.prefixlen < p->prefixlen) {
- bgp_remove_route_from_aggregate(bgp, afi, safi,
- del, aggregate, &rn->p);
+ if (aggregate != NULL && rn_p->prefixlen < p->prefixlen) {
+ bgp_remove_route_from_aggregate(bgp, afi, safi, del,
+ aggregate, rn_p);
}
}
bgp_unlock_node(child);
vpn_leak_from_vrf_withdraw(bgp_get_default(),
bgp, pi);
}
- bgp_aggregate_decrement(bgp, &rn->p, pi, afi,
- SAFI_UNICAST);
+ bgp_aggregate_decrement(bgp, bgp_node_get_prefix(rn),
+ pi, afi, SAFI_UNICAST);
bgp_path_info_delete(rn, pi);
bgp_process(bgp, rn, afi, SAFI_UNICAST);
}
}
if (safi == SAFI_EVPN) {
if (!json_paths) {
- bgp_evpn_route2str((struct prefix_evpn *)&bn->p,
- buf2, sizeof(buf2));
+ bgp_evpn_route2str(
+ (struct prefix_evpn *)
+ bgp_node_get_prefix(bn),
+ buf2, sizeof(buf2));
vty_out(vty, " Route %s", buf2);
if (tag_buf[0] != '\0')
vty_out(vty, " VNI %s", tag_buf);
rn = parent_ri->net;
if (rn && rn->prn) {
prn = rn->prn;
- prefix_rd2str((struct prefix_rd *)&prn->p,
+ prefix_rd2str((struct prefix_rd *)
+ bgp_node_get_prefix(prn),
buf1, sizeof(buf1));
if (is_pi_family_evpn(parent_ri)) {
- bgp_evpn_route2str((struct prefix_evpn *)&rn->p,
- buf2, sizeof(buf2));
+ bgp_evpn_route2str(
+ (struct prefix_evpn *)
+ bgp_node_get_prefix(rn),
+ buf2, sizeof(buf2));
vty_out(vty, " Imported from %s:%s, VNI %s\n", buf1, buf2, tag_buf);
} else
vty_out(vty, " Imported from %s:%s\n", buf1, buf2);
/* Line2 display Next-hop, Neighbor, Router-id */
/* Display the nexthop */
- if ((bn->p.family == AF_INET || bn->p.family == AF_ETHERNET
- || bn->p.family == AF_EVPN)
+ const struct prefix *bn_p = bgp_node_get_prefix(bn);
+
+ if ((bn_p->family == AF_INET || bn_p->family == AF_ETHERNET
+ || bn_p->family == AF_EVPN)
&& (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
if (path->peer == bgp->peer_self) {
if (safi == SAFI_EVPN
- || (bn->p.family == AF_INET
+ || (bn_p->family == AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) {
if (json_paths)
json_object_string_add(json_peer, "peerId",
/* 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);
+
pi = bgp_node_get_bgp_path_info(rn);
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, rn_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, rn_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(rn_p->u.prefix4.s_addr);
if (IN_CLASSC(destination)
- && rn->p.prefixlen == 24)
+ && rn_p->prefixlen == 24)
continue;
if (IN_CLASSB(destination)
- && rn->p.prefixlen == 16)
+ && rn_p->prefixlen == 16)
continue;
if (IN_CLASSA(destination)
- && rn->p.prefixlen == 8)
+ && rn_p->prefixlen == 8)
continue;
}
if (type == bgp_show_type_prefix_longer) {
p = output_arg;
- if (!prefix_match(p, &rn->p))
+ if (!prefix_match(p, rn_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, AFI_IP,
- safi, use_json, json_paths);
+ damp_route_vty_out(vty, rn_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, AFI_IP,
- safi, use_json, json_paths);
+ flap_route_vty_out(vty, rn_p, pi, display,
+ AFI_IP, safi, use_json,
+ json_paths);
else
- route_vty_out(vty, &rn->p, pi, display, safi,
+ route_vty_out(vty, rn_p, pi, display, safi,
json_paths);
display++;
}
if (!use_json)
continue;
- p = &rn->p;
/* encode prefix */
- if (p->family == AF_FLOWSPEC) {
+ if (rn_p->family == AF_FLOWSPEC) {
char retstr[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
- bgp_fs_nlri_get_string((unsigned char *)
- p->u.prefix_flowspec.ptr,
- p->u.prefix_flowspec
- .prefixlen,
- retstr,
- NLRI_STRING_FORMAT_MIN,
- NULL);
+ bgp_fs_nlri_get_string(
+ (unsigned char *)
+ rn_p->u.prefix_flowspec.ptr,
+ rn_p->u.prefix_flowspec.prefixlen,
+ retstr, NLRI_STRING_FORMAT_MIN, NULL);
if (first)
- vty_out(vty, "\"%s/%d\": ",
- retstr,
- p->u.prefix_flowspec.prefixlen);
+ vty_out(vty, "\"%s/%d\": ", retstr,
+ rn_p->u.prefix_flowspec
+ .prefixlen);
else
- vty_out(vty, ",\"%s/%d\": ",
- retstr,
- p->u.prefix_flowspec.prefixlen);
+ vty_out(vty, ",\"%s/%d\": ", retstr,
+ rn_p->u.prefix_flowspec
+ .prefixlen);
} else {
- prefix2str(p, buf2, sizeof(buf2));
+ prefix2str(rn_p, buf2, sizeof(buf2));
if (first)
vty_out(vty, "\"%s\": ", buf2);
else
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);
+
next = bgp_route_next(rn);
- if (prd_match && memcmp(rn->p.u.val, prd_match->val, 8) != 0)
+ if (prd_match && memcmp(rn_p->u.val, prd_match->val, 8) != 0)
continue;
itable = bgp_node_get_bgp_table_info(rn);
struct prefix_rd prd;
char rd[RD_ADDRSTRLEN];
- memcpy(&prd, &(rn->p), sizeof(struct prefix_rd));
+ memcpy(&prd, rn_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,
afi_t afi, safi_t safi, json_object *json)
{
struct bgp_path_info *pi;
- struct prefix *p;
+ const struct prefix *p;
struct peer *peer;
struct listnode *node, *nnode;
char buf1[RD_ADDRSTRLEN];
mpls_label_t label = 0;
json_object *json_adv_to = NULL;
- p = &rn->p;
+ p = bgp_node_get_prefix(rn);
has_valid_label = bgp_is_valid_label(&rn->local_label);
if (has_valid_label)
if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) {
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
if (!table)
if ((rm = bgp_node_match(table, &match)) == NULL)
continue;
+ const struct prefix *rm_p = bgp_node_get_prefix(rm);
if (prefix_check
- && rm->p.prefixlen != match.prefixlen) {
+ && rm_p->prefixlen != match.prefixlen) {
bgp_unlock_node(rm);
continue;
}
- bgp_show_path_info((struct prefix_rd *)&rn->p, rm,
- vty, bgp, afi, safi, json,
- pathtype, &display);
+ bgp_show_path_info((struct prefix_rd *)rn_p, rm, vty,
+ bgp, afi, safi, json, pathtype,
+ &display);
bgp_unlock_node(rm);
}
bool is_exact_pfxlen_match = FALSE;
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (prd && memcmp(&rn_p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
if (!table)
*/
for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) {
+ const struct prefix *rm_p =
+ bgp_node_get_prefix(rm);
/*
* Get prefixlen of the ip-prefix within type5
* evpn route
*/
- if (evpn_type5_prefix_match(&rm->p,
- &match) && rm->info) {
+ if (evpn_type5_prefix_match(rm_p, &match)
+ && rm->info) {
longest_pfx = rm;
int type5_pfxlen =
- bgp_evpn_get_type5_prefixlen(&rm->p);
+ bgp_evpn_get_type5_prefixlen(
+ rm_p);
if (type5_pfxlen == match.prefixlen) {
is_exact_pfxlen_match = TRUE;
bgp_unlock_node(rm);
rm = longest_pfx;
bgp_lock_node(rm);
- bgp_show_path_info((struct prefix_rd *)&rn->p, rm,
- vty, bgp, afi, safi, json,
- pathtype, &display);
+ bgp_show_path_info((struct prefix_rd *)rn_p, rm, vty,
+ bgp, afi, safi, json, pathtype,
+ &display);
bgp_unlock_node(rm);
}
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 (!prefix_check
- || rn->p.prefixlen == match.prefixlen) {
+ || rn_p->prefixlen == match.prefixlen) {
bgp_show_path_info(NULL, rn, vty, bgp, afi,
safi, json,
pathtype, &display);
{
struct bgp_node *prn = bgp_node_parent_nolock(rn);
struct bgp_path_info *pi;
+ const struct prefix *rn_p;
if (rn == top)
return;
if (!bgp_node_has_bgp_path_info_data(rn))
return;
+ rn_p = bgp_node_get_prefix(rn);
ts->counts[BGP_STATS_PREFIXES]++;
- ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
+ ts->counts[BGP_STATS_TOTPLEN] += rn_p->prefixlen;
#if 0
ts->counts[BGP_STATS_AVGPLEN]
= ravg_tally (ts->counts[BGP_STATS_PREFIXES],
ts->counts[BGP_STATS_AVGPLEN],
- rn->p.prefixlen);
+ rn_p->prefixlen);
#endif
/* check if the prefix is included by any other announcements */
ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
/* announced address space */
if (space)
- ts->total_space += pow(2.0, space - rn->p.prefixlen);
+ ts->total_space += pow(2.0, space - rn_p->prefixlen);
} else if (bgp_node_has_bgp_path_info_data(prn))
ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
/* Filter prefix using distribute list,
* filter list or prefix list
*/
- if ((bgp_input_filter(peer, &rn->p, &attr, afi,
- safi)) == FILTER_DENY)
+ const struct prefix *rn_p =
+ bgp_node_get_prefix(rn);
+ if ((bgp_input_filter(peer, rn_p, &attr, afi,
+ safi))
+ == FILTER_DENY)
route_filtered = true;
/* Filter prefix using route-map */
- ret = bgp_input_modifier(peer, &rn->p, &attr,
- afi, safi, rmap_name, NULL, 0,
- NULL);
+ ret = bgp_input_modifier(peer, rn_p, &attr, afi,
+ safi, rmap_name, NULL,
+ 0, NULL);
if (type == bgp_show_adj_route_filtered &&
!route_filtered && ret != RMAP_DENY) {
(route_filtered || ret == RMAP_DENY))
filtered_count++;
- route_vty_out_tmp(vty, &rn->p, &attr, safi,
+ route_vty_out_tmp(vty, rn_p, &attr, safi,
use_json, json_ar);
bgp_attr_undup(&attr, ain->attr);
output_count++;
header2 = 0;
}
+ const struct prefix *rn_p =
+ bgp_node_get_prefix(rn);
+
attr = *adj->attr;
ret = bgp_output_modifier(
- peer, &rn->p, &attr, afi, safi,
+ peer, rn_p, &attr, afi, safi,
rmap_name);
if (ret != RMAP_DENY) {
- route_vty_out_tmp(vty, &rn->p,
- &attr, safi,
- use_json,
- json_ar);
+ route_vty_out_tmp(
+ vty, rn_p, &attr, safi,
+ use_json, json_ar);
output_count++;
} else {
filtered_count++;
|| (safi == SAFI_EVPN)) {
for (rn = bgp_table_top(bgp->rib[AFI_IP][safi]); rn;
rn = bgp_route_next(rn)) {
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
if (!table)
if ((rm = bgp_node_match(table, &match)) == NULL)
continue;
+ const struct prefix *rm_p = bgp_node_get_prefix(rn);
+
if (!prefix_check
- || rm->p.prefixlen == match.prefixlen) {
+ || rm_p->prefixlen == match.prefixlen) {
pi = bgp_node_get_bgp_path_info(rm);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
} else {
if ((rn = bgp_node_match(bgp->rib[afi][safi], &match))
!= NULL) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
if (!prefix_check
- || rn->p.prefixlen == match.prefixlen) {
+ || rn_p->prefixlen == match.prefixlen) {
pi = bgp_node_get_bgp_path_info(rn);
while (pi) {
if (pi->extra && pi->extra->damp_info) {
struct bgp_node *prn;
struct bgp_node *rn;
struct bgp_table *table;
- struct prefix *p;
- struct prefix_rd *prd;
+ const struct prefix *p;
+ const struct prefix_rd *prd;
struct bgp_static *bgp_static;
mpls_label_t label;
char buf[SU_ADDRSTRLEN];
if (bgp_static == NULL)
continue;
- p = &rn->p;
- prd = (struct prefix_rd *)&prn->p;
+ p = bgp_node_get_prefix(rn);
+ prd = (const struct prefix_rd *)bgp_node_get_prefix(
+ prn);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
struct bgp_node *prn;
struct bgp_node *rn;
struct bgp_table *table;
- struct prefix *p;
- struct prefix_rd *prd;
+ const struct prefix *p;
+ const struct prefix_rd *prd;
struct bgp_static *bgp_static;
char buf[PREFIX_STRLEN * 2];
char buf2[SU_ADDRSTRLEN];
bgp_static->router_mac, NULL, 0);
if (bgp_static->eth_s_id)
esi = esi2str(bgp_static->eth_s_id);
- p = &rn->p;
- prd = (struct prefix_rd *)&prn->p;
+ p = bgp_node_get_prefix(rn);
+ prd = (struct prefix_rd *)bgp_node_get_prefix(prn);
/* "network" configuration display. */
prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
safi_t safi)
{
struct bgp_node *rn;
- struct prefix *p;
+ const struct prefix *p;
struct bgp_static *bgp_static;
struct bgp_aggregate *bgp_aggregate;
char buf[SU_ADDRSTRLEN];
if (bgp_static == NULL)
continue;
- p = &rn->p;
+ p = bgp_node_get_prefix(rn);
vty_out(vty, " network %s/%d",
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
if (bgp_aggregate == NULL)
continue;
- p = &rn->p;
+ p = bgp_node_get_prefix(rn);
vty_out(vty, " aggregate-address %s/%d",
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
for (rn = bgp_table_top(bgp_distance_table[afi][safi]); rn;
rn = bgp_route_next(rn)) {
bdistance = bgp_node_get_bgp_distance_info(rn);
- if (bdistance != NULL) {
- char buf[PREFIX_STRLEN];
-
- vty_out(vty, " distance %d %s %s\n",
- bdistance->distance,
- prefix2str(&rn->p, buf, sizeof(buf)),
+ if (bdistance != NULL)
+ vty_out(vty, " distance %d %pRN %s\n",
+ bdistance->distance, rn,
bdistance->access_list ? bdistance->access_list
: "");
- }
}
}
route_map_object_t type, void *object)
{
struct prefix_rd *prd_rule = NULL;
- struct prefix_rd *prd_route = NULL;
+ const struct prefix_rd *prd_route = NULL;
struct bgp_path_info *path = NULL;
if (type == RMAP_BGP) {
if (path->net == NULL || path->net->prn == NULL)
return RMAP_NOMATCH;
- prd_route = (struct prefix_rd *)&path->net->prn->p;
+ prd_route =
+ (struct prefix_rd *)bgp_node_get_prefix(path->net->prn);
if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
return RMAP_MATCH;
}
bgp_static->rmap.map = map;
if (route_update && !bgp_static->backdoor) {
- if (bgp_debug_zebra(&bn->p))
+ const struct prefix *bn_p =
+ bgp_node_get_prefix(bn);
+
+ if (bgp_debug_zebra(bn_p))
zlog_debug(
"Processing route_map %s update on static route %s",
rmap_name,
- inet_ntop(bn->p.family,
- &bn->p.u.prefix, buf,
+ inet_ntop(bn_p->family,
+ &bn_p->u.prefix, buf,
INET6_ADDRSTRLEN));
- bgp_static_update(bgp, &bn->p, bgp_static, afi,
+ bgp_static_update(bgp, bn_p, bgp_static, afi,
safi);
}
}
aggregate->rmap.map = map;
if (route_update) {
- if (bgp_debug_zebra(&bn->p))
+ const struct prefix *bn_p =
+ bgp_node_get_prefix(bn);
+
+ if (bgp_debug_zebra(bn_p))
zlog_debug(
"Processing route_map %s update on aggregate-address route %s",
rmap_name,
- inet_ntop(bn->p.family,
- &bn->p.u.prefix, buf,
+ inet_ntop(bn_p->family,
+ &bn_p->u.prefix, buf,
INET6_ADDRSTRLEN));
- bgp_aggregate_route(bgp, &bn->p, afi, safi,
+ bgp_aggregate_route(bgp, bn_p, afi, safi,
aggregate);
}
}
label = path->extra->label;
num_labels = path->extra->num_labels;
}
- ret = bgp_update(ain->peer, &bgp_node->p, ain->addpath_rx_id,
- ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
- BGP_ROUTE_NORMAL, NULL, label, num_labels, 1,
- NULL);
+ ret = bgp_update(ain->peer, bgp_node_get_prefix(bgp_node),
+ ain->addpath_rx_id, ain->attr, afi, safi,
+ ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
+ num_labels, 1, NULL);
if (ret < 0)
return;
}
if (min) {
+ const struct prefix *rn_p =
+ bgp_node_get_prefix(rn);
+
*length =
v->namelen + BGP_PATHATTR_ENTRY_OFFSET;
offset = name + v->namelen;
- oid_copy_addr(offset, &rn->p.u.prefix4,
+ oid_copy_addr(offset, &rn_p->u.prefix4,
IN_ADDR_SIZE);
offset += IN_ADDR_SIZE;
- *offset = rn->p.prefixlen;
+ *offset = rn_p->prefixlen;
offset++;
oid_copy_addr(offset,
&min->peer->su.sin.sin_addr,
IN_ADDR_SIZE);
- addr->prefix = rn->p.u.prefix4;
- addr->prefixlen = rn->p.prefixlen;
+ addr->prefix = rn_p->u.prefix4;
+ addr->prefixlen = rn_p->prefixlen;
bgp_unlock_node(rn);
bgp_route_next_until_maxlen(struct bgp_node *node, const struct bgp_node *limit,
const uint8_t maxlen)
{
- if (node->l_left && node->p.prefixlen < maxlen
- && node->l_left->p.prefixlen <= maxlen) {
- return bgp_node_from_rnode(node->l_left);
+ const struct prefix *p = bgp_node_get_prefix(node);
+
+ if (node->l_left) {
+ const struct prefix *left_p =
+ bgp_node_get_prefix(bgp_node_from_rnode(node->l_left));
+
+ if (p->prefixlen < maxlen && left_p->prefixlen <= maxlen)
+ return bgp_node_from_rnode(node->l_left);
}
- if (node->l_right && node->p.prefixlen < maxlen
- && node->l_right->p.prefixlen <= maxlen) {
- return bgp_node_from_rnode(node->l_right);
+
+ if (node->l_right) {
+ const struct prefix *right_p =
+ bgp_node_get_prefix(bgp_node_from_rnode(node->l_right));
+
+ if (p->prefixlen < maxlen && right_p->prefixlen <= maxlen)
+ return bgp_node_from_rnode(node->l_right);
}
while (node->parent && node != limit) {
if (node == NULL)
return;
- while (node &&
- node->p.prefixlen <= p->prefixlen && prefix_match(&node->p, p)) {
+ const struct prefix *node_p = bgp_node_get_prefix(node);
+
+ while (node && node_p->prefixlen <= p->prefixlen
+ && prefix_match(node_p, p)) {
if (bgp_node_has_bgp_path_info_data(node)
- && node->p.prefixlen == p->prefixlen) {
+ && node_p->prefixlen == p->prefixlen) {
matched = node;
break;
}
node = bgp_node_from_rnode(node->link[prefix_bit(
- &p->u.prefix, node->p.prefixlen)]);
+ &p->u.prefix, node_p->prefixlen)]);
+ node_p = bgp_node_get_prefix(node);
}
if (!node)
return;
- if (matched == NULL && node->p.prefixlen <= maxlen
- && prefix_match(p, &node->p) && node->parent == NULL)
+ node_p = bgp_node_get_prefix(node);
+ if (matched == NULL && node_p->prefixlen <= maxlen
+ && prefix_match(p, node_p) && node->parent == NULL)
matched = node;
- else if ((matched == NULL && node->p.prefixlen > maxlen) || !node->parent)
+ else if ((matched == NULL && node_p->prefixlen > maxlen)
+ || !node->parent)
return;
else if (matched == NULL && node->parent)
matched = node = bgp_node_from_rnode(node->parent);
}
while ((node = bgp_route_next_until_maxlen(node, matched, maxlen))) {
- if (prefix_match(p, &node->p)) {
+ node_p = bgp_node_get_prefix(node);
+ if (prefix_match(p, node_p)) {
if (bgp_node_has_bgp_path_info_data(node)) {
bgp_lock_node(node);
listnode_add(matches, node);
return !!node->info;
}
+static inline const struct prefix *bgp_node_get_prefix(struct bgp_node *node)
+{
+ return &node->p;
+}
+
#endif /* _QUAGGA_BGP_TABLE_H */
peer = UPDGRP_PEER(updgrp);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
- if (BGP_DEBUG(update, UPDATE_OUT)) {
- char buf_prefix[PREFIX_STRLEN];
- prefix2str(&ctx->rn->p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: afi=%s, safi=%s, p=%s", __func__, afi2str(afi),
- safi2str(safi), buf_prefix);
- }
+ if (BGP_DEBUG(update, UPDATE_OUT))
+ zlog_debug("%s: afi=%s, safi=%s, p=%pRN", __func__,
+ afi2str(afi), safi2str(safi), ctx->rn);
UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
output_count = 0;
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
+ for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out)
if (adj->subgroup == subgrp) {
if (header1) {
}
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, rn_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, rn_p, adj->attr,
+ SUBGRP_SAFI(subgrp),
+ 0, NULL);
output_count++;
}
}
+ }
if (output_count != 0)
vty_out(vty, "\nTotal number of prefixes %ld\n", output_count);
}
PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate(subgrp, 0);
- for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
+ for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
for (ri = bgp_node_get_bgp_path_info(rn); ri; ri = ri->next)
if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED)
peer->addpath_type[afi][safi],
ri))) {
if (subgroup_announce_check(rn, ri, subgrp,
- &rn->p, &attr))
+ rn_p, &attr))
bgp_adj_out_set_subgroup(rn, subgrp,
&attr, ri);
else
peer, afi, safi,
&ri->tx_addpath));
}
+ }
/*
* We walked through the whole table -- make sure our version number
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
ret = route_map_apply(peer->default_rmap[afi][safi].map,
- &rn->p, RMAP_BGP, &bpi_rmap);
+ bgp_node_get_prefix(rn), RMAP_BGP,
+ &bpi_rmap);
if (ret != RMAP_DENYMATCH)
break;
adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) {
+ const struct prefix *rn_p;
+
assert(adv->rn);
rn = adv->rn;
+ rn_p = bgp_node_get_prefix(rn);
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, rn_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, rn_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, rn_p, addpath_encode,
addpath_tx_id);
else {
/* Encode the prefix in MP_REACH_NLRI attribute */
if (rn->prn)
- prd = (struct prefix_rd *)&rn->prn->p;
+ prd = (struct prefix_rd *)bgp_node_get_prefix(
+ rn->prn);
if (safi == SAFI_LABELED_UNICAST) {
label = bgp_adv_label(rn, path, peer, afi,
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, rn_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, rn_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, rn_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);
int addpath_encode = 0;
int addpath_overhead = 0;
uint32_t addpath_tx_id = 0;
- struct prefix_rd *prd = NULL;
+ const struct prefix_rd *prd = NULL;
if (!subgrp)
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
+ const struct prefix *rn_p;
+
assert(adv->rn);
adj = adv->adj;
rn = adv->rn;
+ rn_p = bgp_node_get_prefix(rn);
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, rn_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, rn_p, addpath_encode,
addpath_tx_id);
else {
if (rn->prn)
- prd = (struct prefix_rd *)&rn->prn->p;
+ prd = (struct prefix_rd *)bgp_node_get_prefix(
+ rn->prn);
- /* If first time, format the MP_UNREACH header */
+ /* If first time, format the MP_UNREACH header
+ */
if (first_time) {
iana_afi_t pkt_afi;
iana_safi_t pkt_safi;
pkt_safi = safi_int2iana(safi);
attrlen_pos = stream_get_endp(s);
- /* total attr length = 0 for now. reevaluate
- * later */
+ /* total attr length = 0 for now.
+ * reevaluate later */
stream_putw(s, 0);
mp_start = stream_get_endp(s);
mplen_pos = bgp_packet_mpunreach_start(s, afi,
subgrp->id, pkt_afi, pkt_safi);
}
- bgp_packet_mpunreach_prefix(s, &rn->p, afi, safi, prd,
+ bgp_packet_mpunreach_prefix(s, rn_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, rn_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, rn_p, NULL, 0,
addpath_encode, addpath_tx_id,
pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
#if ENABLE_BGP_VNC
struct rd_vnc_eth rd_vnc_eth = {0};
#endif
- uint8_t *pnt;
+ const uint8_t *pnt;
- pnt = rn->p.u.val;
+ pnt = rn_p->u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
}
rd_header = 0;
}
- route_vty_out_tmp(vty, &rm->p, attr,
- safi, use_json,
- json_routes);
+ route_vty_out_tmp(vty, bgp_node_get_prefix(rm), attr,
+ safi, use_json, json_routes);
output_count++;
}
if (safi == SAFI_MPLS_VPN) {
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
- if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0)
continue;
table = bgp_node_get_bgp_table_info(rn);
- if (table != NULL) {
+ if (table == NULL)
+ continue;
- if ((rm = bgp_node_match(table, &match))
- != NULL) {
- if (rm->p.prefixlen
- == match.prefixlen) {
- SET_FLAG(rm->flags,
- BGP_NODE_USER_CLEAR);
- bgp_process(bgp, rm, afi, safi);
- }
- bgp_unlock_node(rm);
+ if ((rm = bgp_node_match(table, &match)) != NULL) {
+ const struct prefix *rm_p =
+ bgp_node_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);
}
}
} else {
if ((rn = bgp_node_match(rib, &match)) != NULL) {
- if (rn->p.prefixlen == match.prefixlen) {
+ const struct prefix *rn_p = bgp_node_get_prefix(rn);
+
+ if (rn_p->prefixlen == match.prefixlen) {
SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
bgp_process(bgp, rn, afi, safi);
}
prefix2str(p, buf_prefix, sizeof(buf_prefix));
if (safi == SAFI_FLOWSPEC) {
- bgp_pbr_update_entry(bgp, &rn->p, info, afi, safi, true);
+ bgp_pbr_update_entry(bgp, bgp_node_get_prefix(rn),
+ info, afi, safi, true);
return;
}
&& (pi->sub_type == BGP_ROUTE_NORMAL
|| pi->sub_type == BGP_ROUTE_IMPORTED)))
- bgp_zebra_announce(rn, &rn->p, pi, bgp, afi,
- safi);
+ bgp_zebra_announce(rn, bgp_node_get_prefix(rn),
+ pi, bgp, afi, safi);
}
void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
safi))(
it, /* which import table */
FIF_ACTION_UPDATE, bpi->peer,
- NULL, &rn2->p, /* prefix */
+ NULL, bgp_node_get_prefix(rn2),
NULL, afi,
- (struct prefix_rd *)&rn1->p,
+ (struct prefix_rd *)
+ bgp_node_get_prefix(
+ rn1),
bpi->attr, bpi->type,
bpi->sub_type, &label);
}
#if DEBUG_L2_EXTRA
char buf_prefix[PREFIX_STRLEN];
- prefix2str(&rn->p, buf_prefix, sizeof(buf_prefix));
+ prefix2str(agg_node_get_prefix(rn), buf_prefix, sizeof(buf_prefix));
#endif
/*
{
char buf_pfx[PREFIX_STRLEN];
- prefix2str(&it_rn->p, buf_pfx, sizeof(buf_pfx));
+ prefix2str(agg_node_get_prefix(it_rn), buf_pfx,
+ sizeof(buf_pfx));
vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx);
}
#endif
}
vnc_zlog_debug_verbose(
"%s: RIB skiplist for this prefix follows", __func__);
- rfapiRibShowRibSl(NULL, &rn->p, (struct skiplist *)rn->info);
+ rfapiRibShowRibSl(NULL, agg_node_get_prefix(rn),
+ (struct skiplist *)rn->info);
#endif
&& ri->sub_type == BGP_ROUTE_REDISTRIBUTE) {
bgp_withdraw(
- ri->peer, &rn->p, /* prefix */
- 0, /* addpath_id */
- NULL, /* ignored */
+ ri->peer, bgp_node_get_prefix(rn),
+ 0, /* addpath_id */
+ NULL, /* ignored */
AFI_IP, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE,
struct bgp_table *table;
struct bgp_node *rn;
struct bgp_path_info *ri;
+ const struct prefix *prn_p = bgp_node_get_prefix(prn);
memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC;
prd.prefixlen = 64;
- memcpy(prd.val, prn->p.u.val, 8);
+ memcpy(prd.val, prn_p->u.val, 8);
/* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn);
continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
+ const struct prefix *rn_p;
/*
* skip prefix list check if no routes here
if (!bgp_node_has_bgp_path_info_data(rn))
continue;
- {
- char prefixstr[PREFIX_STRLEN];
+ vnc_zlog_debug_verbose("%s: checking prefix %pRN",
+ __func__, rn);
- prefix2str(&rn->p, prefixstr,
- sizeof(prefixstr));
- vnc_zlog_debug_verbose("%s: checking prefix %s",
- __func__, prefixstr);
- }
+ rn_p = bgp_node_get_prefix(rn);
/*
* prefix list check
*/
if (hc->plist_export_bgp[afi]) {
if (prefix_list_apply(hc->plist_export_bgp[afi],
- &rn->p)
+ rn_p)
== PREFIX_DENY) {
vnc_zlog_debug_verbose(
info.attr = &hattr;
ret = route_map_apply(
hc->routemap_export_bgp,
- &rn->p, RMAP_BGP,
- &info);
+ rn_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, rn_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, 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_attr_unintern(&iattr);
}
*/
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);
struct bgp_path_info *ri;
struct bgp_path_info *next;
* Delete routes immediately (no timer)
*/
eti = vnc_eti_checktimer(
- bgp, EXPORT_TYPE_BGP, &rn->p, ri->peer,
+ bgp, EXPORT_TYPE_BGP, rn_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 */
+ bgp_withdraw(ri->peer, rn_p, /* prefix */
+ 0, /* addpath_id */
NULL, /* ignored */
AFI_IP, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT_RH,
continue;
vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
- (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
- ecom, &local_pref, med, &pfx_unicast_nexthop);
+ (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+ afi, bgp, prefix, ecom, &local_pref, med,
+ &pfx_unicast_nexthop);
}
continue;
vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
- (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
- &pfx_unicast_nexthop); /* TBD how is this set? */
+ (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+ afi, bgp, prefix, &pfx_unicast_nexthop);
}
if (ecom)
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_add_route(bgp, &rn->p, bpi);
+ vnc_import_bgp_add_route(bgp, bgp_node_get_prefix(rn),
+ bpi);
}
}
vnc_zlog_debug_verbose(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_exterior_add_route(bgp_exterior, &rn->p,
- bpi);
+ vnc_import_bgp_exterior_add_route(
+ bgp_exterior, bgp_node_get_prefix(rn), bpi);
}
}
vnc_zlog_debug_verbose(
continue;
vnc_import_bgp_exterior_add_route_it(
- bgp_exterior, &rn->p, bpi, it_only);
+ bgp_exterior, bgp_node_get_prefix(rn), bpi,
+ it_only);
}
}
}
*/
for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
rn1 = bgp_route_next(rn1)) {
+ const struct prefix *rn1_p;
if (!bgp_node_has_bgp_path_info_data(rn1))
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);
struct bgp_path_info *bpi;
struct bgp_path_info *nextbpi;
rfd);
del_vnc_route(rfd, bpi->peer, bgp,
- SAFI_MPLS_VPN, &rn2->p,
- (struct prefix_rd *)&rn1->p,
+ SAFI_MPLS_VPN, rn2_p,
+ (struct prefix_rd *)rn1_p,
bpi->type, bpi->sub_type, NULL,
1); /* kill */
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_exterior_del_route(bgp_exterior,
- &rn->p, bpi);
+ vnc_import_bgp_exterior_del_route(
+ bgp_exterior, bgp_node_get_prefix(rn),
+ bpi);
}
}
#if DEBUG_RHN_LIST
*/
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);
+
memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC;
prd.prefixlen = 64;
- memcpy(prd.val, prn->p.u.val, 8);
+ memcpy(prd.val, prn_p->u.val, 8);
/* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn);
del_vnc_route(
&vncHD1VR, /* use dummy ptr as cookie */
vncHD1VR.peer, bgp, SAFI_MPLS_VPN,
- &(rn->p), &prd, type,
+ bgp_node_get_prefix(rn), &prd, type,
BGP_ROUTE_REDISTRIBUTE, NULL, 0);
}
}
for (ALL_LIST_ELEMENTS_RO(list, listnode, bnode)) {
char buf[PREFIX2STR_BUFFER];
- prefix2str(&bnode->p, buf, PREFIX2STR_BUFFER);
+ prefix2str(bgp_node_get_prefix(bnode), buf, PREFIX2STR_BUFFER);
printf("%s\n", buf);
}
}
assert(0);
for (ALL_LIST_ELEMENTS_RO(list, listnode, bnode)) {
- if (prefix_same(&bnode->p, &p))
+ if (prefix_same(bgp_node_get_prefix(bnode), &p))
found = true;
}