Merge pull request #6085 from donaldsharp/bgp_node_get_prefix

Bgp node get prefix
This commit is contained in:
Sri Mohana Singamsetty 2020-03-26 19:07:36 -07:00 committed by GitHub
commit 0298bb01bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 785 additions and 678 deletions

View File

@ -898,14 +898,11 @@ struct attr *bgp_attr_default_set(struct attr *attr, uint8_t origin)
}
/* Create the attributes for an aggregate */
struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
struct aspath *aspath,
struct community *community,
struct ecommunity *ecommunity,
struct lcommunity *lcommunity,
struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate,
struct prefix *p)
struct attr *bgp_attr_aggregate_intern(
struct bgp *bgp, uint8_t origin, struct aspath *aspath,
struct community *community, struct ecommunity *ecommunity,
struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate, const struct prefix *p)
{
struct attr attr;
struct attr *new;
@ -3418,10 +3415,10 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
}
void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
struct prefix *p, struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id,
struct attr *attr)
const struct prefix *p,
const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, int addpath_encode,
uint32_t addpath_tx_id, struct attr *attr)
{
if (safi == SAFI_MPLS_VPN) {
if (addpath_encode)
@ -3447,7 +3444,8 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
stream_put_prefix_addpath(s, p, addpath_encode, addpath_tx_id);
}
size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi, struct prefix *p)
size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
const struct prefix *p)
{
int size = PSIZE(p->prefixlen);
if (safi == SAFI_MPLS_VPN)
@ -4081,8 +4079,9 @@ size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi, safi_t safi)
return attrlen_pnt;
}
void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, afi_t afi,
safi_t safi, struct prefix_rd *prd,
void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
afi_t afi, safi_t safi,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id,
struct attr *attr)

View File

@ -310,14 +310,11 @@ extern void bgp_attr_unintern_sub(struct attr *);
extern void bgp_attr_unintern(struct attr **);
extern void bgp_attr_flush(struct attr *);
extern struct attr *bgp_attr_default_set(struct attr *attr, uint8_t);
extern struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin,
struct aspath *aspath,
struct community *community,
struct ecommunity *ecommunity,
struct lcommunity *lcommunity,
struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate,
struct prefix *p);
extern struct attr *bgp_attr_aggregate_intern(
struct bgp *bgp, uint8_t origin, struct aspath *aspath,
struct community *community, struct ecommunity *ecommunity,
struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate, const struct prefix *p);
extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
struct stream *, struct attr *,
struct bpacket_attr_vec_arr *vecarr,
@ -372,20 +369,21 @@ extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer,
struct bpacket_attr_vec_arr *vecarr,
struct attr *attr);
extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
struct prefix *p, struct prefix_rd *prd,
const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id,
struct attr *);
extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
struct prefix *p);
const struct prefix *p);
extern void bgp_packet_mpattr_end(struct stream *s, size_t sizep);
extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
safi_t safi);
extern void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p,
afi_t afi, safi_t safi,
struct prefix_rd *prd, mpls_label_t *,
uint32_t, int, uint32_t, struct attr *);
extern void bgp_packet_mpunreach_prefix(
struct stream *s, const struct prefix *p, afi_t afi, safi_t safi,
const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id, struct attr *attr);
extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);
extern bgp_attr_parse_ret_t bgp_attr_nexthop_valid(struct peer *peer,

View File

@ -765,7 +765,7 @@ static void bmp_eor(struct bmp *bmp, afi_t afi, safi_t safi, uint8_t flags)
stream_free(s);
}
static struct stream *bmp_update(struct prefix *p, struct peer *peer,
static struct stream *bmp_update(const struct prefix *p, struct peer *peer,
struct attr *attr, afi_t afi, safi_t safi)
{
struct bpacket_attr_vec_arr vecarr;
@ -813,7 +813,8 @@ static struct stream *bmp_update(struct prefix *p, struct peer *peer,
return s;
}
static struct stream *bmp_withdraw(struct prefix *p, afi_t afi, safi_t safi)
static struct stream *bmp_withdraw(const struct prefix *p, afi_t afi,
safi_t safi)
{
struct stream *s;
size_t attrlen_pos = 0, mp_start, mplen_pos;
@ -853,7 +854,7 @@ static struct stream *bmp_withdraw(struct prefix *p, afi_t afi, safi_t safi)
}
static void bmp_monitor(struct bmp *bmp, struct peer *peer, uint8_t flags,
struct prefix *p, struct attr *attr, afi_t afi,
const struct prefix *p, struct attr *attr, afi_t afi,
safi_t safi, time_t uptime)
{
struct stream *hdr, *msg;
@ -940,7 +941,7 @@ afibreak:
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) {
@ -988,12 +989,14 @@ afibreak:
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;
}
@ -1130,16 +1133,13 @@ static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
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;

View File

@ -155,9 +155,9 @@ static int bgp_reuse_timer(struct thread *t)
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);
}

View File

@ -2532,7 +2532,7 @@ bool bgp_debug_bestpath(struct bgp_node *rn)
{
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;
}
@ -2553,7 +2553,7 @@ bool bgp_debug_zebra(const struct prefix *p)
}
const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
struct prefix_rd *prd,
const struct prefix_rd *prd,
union prefixconstptr pu,
mpls_label_t *label, uint32_t num_labels,
int addpath_valid, uint32_t addpath_id,

View File

@ -171,10 +171,11 @@ extern bool bgp_debug_update(struct peer *peer, const struct prefix *p,
extern bool bgp_debug_bestpath(struct bgp_node *rn);
extern bool bgp_debug_zebra(const struct prefix *p);
extern const char *bgp_debug_rdpfxpath2str(afi_t, safi_t, struct prefix_rd *,
union prefixconstptr, mpls_label_t *,
uint32_t, int, uint32_t, char *,
int);
extern const char *
bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, const struct prefix_rd *prd,
union prefixconstptr pu, mpls_label_t *label,
uint32_t num_labels, int addpath_valid,
uint32_t addpath_id, char *str, int size);
const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data,
size_t datalen);

View File

@ -307,6 +307,7 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn,
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);
@ -325,19 +326,19 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn,
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 */
@ -361,7 +362,7 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn,
/* 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

View File

@ -1005,7 +1005,7 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
* 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);
@ -1128,7 +1128,7 @@ static int evpn_es_route_select_install(struct bgp *bgp,
&& !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);
@ -1157,13 +1157,13 @@ static int evpn_es_route_select_install(struct bgp *bgp,
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);
}
@ -1208,7 +1208,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
&& !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);
@ -1234,7 +1234,8 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
if (new_select && new_select->type == ZEBRA_ROUTE_BGP
&& new_select->sub_type == BGP_ROUTE_IMPORTED) {
ret = evpn_zebra_install(bgp, vpn, (struct prefix_evpn *)&rn->p,
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
@ -1251,8 +1252,10 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
} 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,
ret = evpn_zebra_uninstall(
bgp, vpn,
(const struct prefix_evpn *)bgp_node_get_prefix(
rn),
old_select->attr->nexthop);
}
@ -1330,11 +1333,11 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, struct evpnes *es,
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;
@ -1662,10 +1665,10 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
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. */
@ -1797,7 +1800,7 @@ static void evpn_zebra_reinstall_best_route(struct bgp *bgp,
if (curr_select && curr_select->type == ZEBRA_ROUTE_BGP
&& curr_select->sub_type == BGP_ROUTE_IMPORTED)
evpn_zebra_install(bgp, vpn,
(struct prefix_evpn *)&rn->p,
(const struct prefix_evpn *)bgp_node_get_prefix(rn),
curr_select);
}
@ -1820,13 +1823,10 @@ static void evpn_cleanup_local_non_best_route(struct bgp *bgp,
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);
@ -2145,7 +2145,7 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
*/
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;
@ -2278,7 +2278,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
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;
@ -2319,7 +2319,7 @@ static int delete_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
/* Next, walk this VNI's route table and delete local type-2 routes. */
for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(rn)) {
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;
@ -2709,7 +2709,8 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
/* 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);
@ -2876,7 +2877,8 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
/* 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);
@ -3107,7 +3109,9 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
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) {
@ -3214,7 +3218,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
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
@ -3302,7 +3306,9 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
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;
@ -3774,7 +3780,8 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn)
*/
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)
@ -4297,13 +4304,14 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
return ret;
}
static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct attr *attr)
static void evpn_mpattr_encode_type5(struct stream *s, const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
struct attr *attr)
{
int len;
char temp[16];
struct evpn_addr *p_evpn_p;
const struct evpn_addr *p_evpn_p;
memset(&temp, 0, 16);
if (p->family != AF_EVPN)
@ -4499,8 +4507,9 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)
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;
}
}
@ -4592,18 +4601,21 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
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;
}
}
@ -5030,8 +5042,8 @@ char *bgp_evpn_route2str(const struct prefix_evpn *p, char *buf, int len)
/*
* Encode EVPN prefix in Update (MP_REACH)
*/
void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label,
void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct attr *attr,
int addpath_encode, uint32_t addpath_tx_id)
{
@ -5601,25 +5613,23 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
if (bgp_nexthop_self(bgp, afi,
pi->type, pi->sub_type,
pi->attr, rn)) {
const struct prefix *p =
bgp_node_get_prefix(rn);
if (bgp_debug_update(pi->peer, p, NULL,
1)) {
char attr_str[BUFSIZ] = {0};
char pbuf[PREFIX_STRLEN];
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);
@ -6264,7 +6274,7 @@ void bgp_evpn_vrf_delete(struct bgp *bgp_vrf)
/*
* Get the prefixlen of the ip prefix carried within the type5 evpn route.
*/
int bgp_evpn_get_type5_prefixlen(struct prefix *pfx)
int bgp_evpn_get_type5_prefixlen(const struct prefix *pfx)
{
struct prefix_evpn *evp = (struct prefix_evpn *)pfx;

View File

@ -157,10 +157,11 @@ extern char *bgp_evpn_label2str(mpls_label_t *label, uint32_t num_labels,
extern char *bgp_evpn_route2str(const struct prefix_evpn *p, char *buf,
int len);
extern void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json);
extern void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct attr *attr,
int addpath_encode, uint32_t addpath_tx_id);
extern void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
struct attr *attr, int addpath_encode,
uint32_t addpath_tx_id);
extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
struct bgp_nlri *packet, int withdraw);
extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi,
@ -195,7 +196,7 @@ extern void bgp_evpn_flood_control_change(struct bgp *bgp);
extern void bgp_evpn_cleanup_on_disable(struct bgp *bgp);
extern void bgp_evpn_cleanup(struct bgp *bgp);
extern void bgp_evpn_init(struct bgp *bgp);
extern int bgp_evpn_get_type5_prefixlen(struct prefix *pfx);
extern int bgp_evpn_get_type5_prefixlen(const struct prefix *pfx);
extern bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx);
extern void update_advertise_vrf_routes(struct bgp *bgp_vrf);

View File

@ -281,9 +281,10 @@ static void bgp_evpn_show_route_rd_header(struct vty *vty,
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);
@ -647,8 +648,9 @@ static void show_esi_routes(struct bgp *bgp,
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)
@ -678,7 +680,7 @@ static void show_esi_routes(struct bgp *bgp,
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);
@ -692,7 +694,7 @@ static void show_esi_routes(struct bgp *bgp,
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,
@ -735,13 +737,15 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
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)
@ -784,7 +788,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int 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)
@ -799,7 +803,7 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type,
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,
@ -1188,8 +1192,9 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
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);
@ -1290,16 +1295,18 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
json_array = json_object_new_array();
if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag(vty, &rm->p, pi,
no_display, SAFI_EVPN,
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;
}
@ -1308,15 +1315,19 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
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,
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);
@ -2580,13 +2591,14 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
/* Display all prefixes with this RD. */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
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)
@ -2703,13 +2715,14 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int 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)
@ -2723,12 +2736,15 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
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;
@ -2764,15 +2780,15 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
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
@ -2792,8 +2808,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
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,

View File

@ -607,7 +607,8 @@ bool bgp_flowspec_get_first_nh(struct bgp *bgp, struct bgp_path_info *pi,
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];

View File

@ -409,8 +409,8 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
}
for (; pi; pi = pi->next) {
total_count++;
route_vty_out_flowspec(vty, &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",
@ -554,18 +554,18 @@ extern int bgp_flowspec_display_match_per_ip(afi_t afi, struct bgp_table *rib,
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);

View File

@ -132,7 +132,6 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
{
struct bgp_path_info *pi;
struct bgp_node *rn;
char addr[PREFIX_STRLEN];
pi = labelid;
/* Is this path still valid? */
@ -145,10 +144,9 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
}
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) {
@ -174,8 +172,8 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
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);
@ -189,8 +187,8 @@ int bgp_reg_for_label_callback(mpls_label_t new_label, void *labelid,
}
/* Shouldn't happen: different label allocation */
flog_err(EC_BGP_LABEL,
"%s: %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 */
}
@ -210,14 +208,14 @@ void bgp_reg_dereg_for_label(struct bgp_node *rn, struct bgp_path_info *pi,
{
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()

View File

@ -142,13 +142,15 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
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;
@ -156,7 +158,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
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
@ -185,15 +187,15 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
prd.family = AF_UNSPEC;
prd.prefixlen = 64;
memcpy(&prd.val, &prn->p.u.val, 8);
memcpy(&prd.val, 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));
@ -205,7 +207,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
}
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,

View File

@ -447,7 +447,7 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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;
@ -459,9 +459,6 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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)
@ -480,8 +477,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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);
/*
@ -513,8 +510,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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");
@ -537,8 +534,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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;
@ -546,8 +543,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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,
@ -579,8 +576,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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])),
@ -624,8 +621,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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,
@ -641,8 +638,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
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);

View File

@ -468,18 +468,16 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
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
@ -518,9 +516,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
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;
}
@ -580,8 +577,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
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;
}
@ -645,8 +642,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
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;
}
@ -657,7 +654,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
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;
@ -891,19 +888,17 @@ void vpn_leak_from_vrf_withdraw(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */
{
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
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);
}
@ -980,14 +975,10 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
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) {
@ -1005,8 +996,10 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
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);
}
@ -1049,7 +1042,7 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
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};
@ -1228,12 +1221,9 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
}
}
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,
@ -1273,7 +1263,7 @@ void vpn_leak_to_vrf_update(struct bgp *bgp_vpn, /* from */
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;
@ -1281,15 +1271,12 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
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);
@ -1310,7 +1297,7 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
return;
}
p = &path_vpn->net->p;
p = bgp_node_get_prefix(path_vpn->net);
afi = family2afi(p->family);
/* Loop over VRFs */
@ -1381,8 +1368,9 @@ void vpn_leak_to_vrf_withdraw_all(struct bgp *bgp_vrf, /* to */
&& 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);
}
@ -1405,7 +1393,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
*/
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;
@ -1413,7 +1401,7 @@ void vpn_leak_to_vrf_update_all(struct bgp *bgp_vrf, /* to */
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);

View File

@ -49,7 +49,7 @@ DEFINE_MTYPE_STATIC(BGPD, MARTIAN_STRING, "BGP Martian Address Intf String");
char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size)
{
prefix2str(&(bnc->node->p), buf, size);
prefix2str(bgp_node_get_prefix(bnc->node), buf, size);
return buf;
}
@ -476,7 +476,7 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
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
@ -489,8 +489,8 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
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)) {
@ -510,8 +510,8 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
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;
@ -763,6 +763,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail,
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)
@ -772,8 +773,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail,
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)
@ -787,8 +787,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail,
} 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);

View File

@ -130,6 +130,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
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)
@ -181,6 +182,8 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
}
}
bnc_p = bgp_node_get_prefix(bnc->node);
bgp_unlock_node(rn);
if (is_bgp_static_route) {
SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
@ -226,8 +229,8 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,
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) {
@ -528,7 +531,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
? 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)
@ -541,8 +544,8 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
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;
@ -552,8 +555,8 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
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;
@ -581,7 +584,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
*/
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;
@ -603,7 +606,7 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
"%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)
@ -691,6 +694,7 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
struct bgp_table *table;
safi_t safi;
struct bgp *bgp_path;
const struct prefix *p;
if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER];
@ -710,7 +714,8 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
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;
@ -744,27 +749,23 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
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,
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);
}
}
@ -780,14 +781,13 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
|| 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);

View File

@ -87,7 +87,7 @@ void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip)
#if ENABLE_BGP_VNC
/* type == RD_TYPE_VNC_ETH */
void decode_rd_vnc_eth(uint8_t *pnt, struct rd_vnc_eth *rd_vnc_eth)
void decode_rd_vnc_eth(const uint8_t *pnt, struct rd_vnc_eth *rd_vnc_eth)
{
rd_vnc_eth->type = RD_TYPE_VNC_ETH;
rd_vnc_eth->local_nve_id = pnt[1];
@ -159,9 +159,9 @@ out:
return lret;
}
char *prefix_rd2str(struct prefix_rd *prd, char *buf, size_t size)
char *prefix_rd2str(const struct prefix_rd *prd, char *buf, size_t size)
{
uint8_t *pnt;
const uint8_t *pnt;
uint16_t type;
struct rd_as rd_as;
struct rd_ip rd_ip;

View File

@ -61,11 +61,12 @@ extern void decode_rd_as(const uint8_t *pnt, struct rd_as *rd_as);
extern void decode_rd_as4(const uint8_t *pnt, struct rd_as *rd_as);
extern void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip);
#if ENABLE_BGP_VNC
extern void decode_rd_vnc_eth(uint8_t *pnt, struct rd_vnc_eth *rd_vnc_eth);
extern void decode_rd_vnc_eth(const uint8_t *pnt,
struct rd_vnc_eth *rd_vnc_eth);
#endif
extern int str2prefix_rd(const char *, struct prefix_rd *);
extern char *prefix_rd2str(struct prefix_rd *, char *, size_t);
extern char *prefix_rd2str(const struct prefix_rd *, char *, size_t);
extern void form_auto_rd(struct in_addr router_id, uint16_t rd_id,
struct prefix_rd *prd);

File diff suppressed because it is too large Load Diff

View File

@ -544,9 +544,10 @@ extern void bgp_static_add(struct bgp *);
extern void bgp_static_delete(struct bgp *);
extern void bgp_static_redo_import_check(struct bgp *);
extern void bgp_purge_static_redist_routes(struct bgp *bgp);
extern void bgp_static_update(struct bgp *, struct prefix *,
struct bgp_static *, afi_t, safi_t);
extern void bgp_static_withdraw(struct bgp *, struct prefix *, afi_t, safi_t);
extern void bgp_static_update(struct bgp *bgp, const struct prefix *p,
struct bgp_static *s, afi_t afi, safi_t safi);
extern void bgp_static_withdraw(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi);
extern int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
const char *, const char *, const char *,
@ -584,10 +585,12 @@ extern void bgp_config_write_network(struct vty *, struct bgp *, afi_t, safi_t);
extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t,
safi_t);
extern void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi,
safi_t safi, struct bgp_aggregate *aggregate);
extern void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, afi_t afi,
safi_t safi, struct bgp_aggregate *aggregate);
extern void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi,
struct bgp_aggregate *aggregate);
extern void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
afi_t afi, safi_t safi,
struct bgp_aggregate *aggregate);
extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
struct bgp_path_info *path, afi_t afi,
safi_t safi);
@ -613,7 +616,7 @@ extern void route_vty_out(struct vty *vty, const struct prefix *p,
extern void route_vty_out_tag(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display,
safi_t safi, json_object *json);
extern void route_vty_out_tmp(struct vty *vty, struct prefix *p,
extern void route_vty_out_tmp(struct vty *vty, const struct prefix *p,
struct attr *attr, safi_t safi, bool use_json,
json_object *json_ar);
extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p,

View File

@ -1015,7 +1015,7 @@ route_match_rd(void *rule, const struct prefix *prefix,
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) {
@ -1028,7 +1028,8 @@ route_match_rd(void *rule, const struct prefix *prefix,
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;
}
@ -3637,14 +3638,17 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
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);
}
}
@ -3666,14 +3670,17 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
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);
}
}

View File

@ -438,10 +438,10 @@ static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
label = path->extra->label;
num_labels = path->extra->num_labels;
}
ret = bgp_update(ain->peer, &bgp_node->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;

View File

@ -761,20 +761,23 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
}
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);

View File

@ -168,12 +168,21 @@ static struct bgp_node *
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) {
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) {
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);
}
@ -197,24 +206,29 @@ void bgp_table_range_lookup(const struct bgp_table *table,
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);
@ -228,7 +242,8 @@ void bgp_table_range_lookup(const struct bgp_table *table,
}
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);

View File

@ -443,4 +443,9 @@ static inline bool bgp_node_has_bgp_path_info_data(struct bgp_node *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 */

View File

@ -148,12 +148,9 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
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) {
@ -242,7 +239,9 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
output_count = 0;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
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) {
@ -261,20 +260,20 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
}
if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv
&& adj->adv->baa) {
route_vty_out_tmp(vty, &rn->p,
adj->adv->baa->attr,
SUBGRP_SAFI(subgrp),
0, NULL);
route_vty_out_tmp(
vty, 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);
}
@ -623,7 +622,9 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate(subgrp, 0);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
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)
@ -632,7 +633,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
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
@ -642,6 +643,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
peer, afi, safi,
&ri->tx_addpath));
}
}
/*
* We walked through the whole table -- make sure our version number
@ -761,7 +763,8 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
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;

View File

@ -726,8 +726,11 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) {
const struct prefix *rn_p;
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;
@ -750,9 +753,8 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed =
BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);
space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(afi, safi, rn_p);
/* When remaining space can't include NLRI and it's length. */
if (space_remaining < space_needed)
@ -798,7 +800,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
- BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size(
afi, safi, &rn->p);
afi, safi, rn_p);
/* If the attributes alone do not leave any room for
* NLRI then
@ -828,12 +830,13 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if ((afi == AFI_IP && safi == SAFI_UNICAST)
&& !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, &rn->p, addpath_encode,
stream_put_prefix_addpath(s, 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,
@ -850,7 +853,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
snlri, peer, afi, safi, &vecarr,
adv->baa->attr);
bgp_packet_mpattr_prefix(snlri, afi, safi, &rn->p, prd,
bgp_packet_mpattr_prefix(snlri, afi, safi, rn_p, prd,
label_pnt, num_labels,
addpath_encode, addpath_tx_id,
adv->baa->attr);
@ -858,7 +861,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
num_pfx++;
if (bgp_debug_update(NULL, &rn->p, subgrp->update_group, 0)) {
if (bgp_debug_update(NULL, rn_p, subgrp->update_group, 0)) {
char pfx_buf[BGP_PRD_PATH_STRLEN];
if (!send_attr_printed) {
@ -882,10 +885,10 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
send_attr_printed = 1;
}
bgp_debug_rdpfxpath2str(afi, safi, prd, &rn->p,
label_pnt, num_labels,
addpath_encode, addpath_tx_id,
pfx_buf, sizeof(pfx_buf));
bgp_debug_rdpfxpath2str(afi, safi, prd, 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);
@ -964,7 +967,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
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)
@ -982,16 +985,19 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
const struct prefix *rn_p;
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;
@ -1004,13 +1010,15 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
if (afi == AFI_IP && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi))
stream_put_prefix_addpath(s, &rn->p, addpath_encode,
stream_put_prefix_addpath(s, 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;
@ -1019,8 +1027,8 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
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,
@ -1034,17 +1042,17 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
subgrp->id, pkt_afi, pkt_safi);
}
bgp_packet_mpunreach_prefix(s, &rn->p, afi, safi, prd,
bgp_packet_mpunreach_prefix(s, 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

View File

@ -78,7 +78,9 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
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);
@ -156,9 +158,9 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
#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);
@ -221,9 +223,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
}
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++;
}

View File

@ -7955,16 +7955,20 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
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) {
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);
@ -7972,10 +7976,11 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
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);
}

View File

@ -1184,7 +1184,8 @@ void bgp_zebra_announce(struct bgp_node *rn, const struct prefix *p,
prefix2str(p, buf_prefix, sizeof(buf_prefix));
if (safi == SAFI_FLOWSPEC) {
bgp_pbr_update_entry(bgp, &rn->p, info, afi, safi, true);
bgp_pbr_update_entry(bgp, bgp_node_get_prefix(rn),
info, afi, safi, true);
return;
}
@ -1480,8 +1481,8 @@ void bgp_zebra_announce_table(struct bgp *bgp, afi_t afi, safi_t safi)
&& (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,

View File

@ -4213,9 +4213,11 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
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);
}

View File

@ -1273,7 +1273,7 @@ static void rfapiMonitorEthDetachImport(
#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
/*

View File

@ -1813,7 +1813,8 @@ int rfapiRibFTDFilterRecentPrefix(
{
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
@ -1994,7 +1995,8 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
}
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

View File

@ -487,7 +487,7 @@ static void vnc_direct_bgp_vpn_disable_ce(struct bgp *bgp, afi_t afi)
&& ri->sub_type == BGP_ROUTE_REDISTRIBUTE) {
bgp_withdraw(
ri->peer, &rn->p, /* prefix */
ri->peer, bgp_node_get_prefix(rn),
0, /* addpath_id */
NULL, /* ignored */
AFI_IP, SAFI_UNICAST,
@ -1841,11 +1841,12 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
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);
@ -1854,6 +1855,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
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
@ -1861,21 +1863,17 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
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(
@ -1920,8 +1918,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
info.attr = &hattr;
ret = route_map_apply(
hc->routemap_export_bgp,
&rn->p, RMAP_BGP,
&info);
rn_p, RMAP_BGP, &info);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(
@ -1940,7 +1937,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
* this route
*/
eti = vnc_eti_get(
bgp, EXPORT_TYPE_BGP, &rn->p,
bgp, EXPORT_TYPE_BGP, rn_p,
ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
@ -1961,8 +1958,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
"%s: calling bgp_update",
__func__);
bgp_update(
ri->peer, &rn->p, /* prefix */
bgp_update(ri->peer, rn_p, /* prefix */
0, /* addpath_id */
iattr, /* bgp_update copies
it */
@ -1973,7 +1969,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
NULL,
/* tag not used for unicast,
or EVPN */
0, 0, NULL); /* EVPN not used */
0, 0,
NULL); /* EVPN not used */
bgp_attr_unintern(&iattr);
}
@ -2002,7 +1999,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
*/
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;
@ -2019,7 +2016,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
* Delete routes immediately (no timer)
*/
eti = vnc_eti_checktimer(
bgp, EXPORT_TYPE_BGP, &rn->p, ri->peer,
bgp, EXPORT_TYPE_BGP, rn_p, ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
if (eti) {
@ -2028,7 +2025,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
vnc_eti_delete(eti);
}
bgp_withdraw(ri->peer, &rn->p, /* prefix */
bgp_withdraw(ri->peer, rn_p, /* prefix */
0, /* addpath_id */
NULL, /* ignored */
AFI_IP, SAFI_UNICAST,

View File

@ -165,8 +165,9 @@ void vnc_eti_delete(struct vnc_export_info *goner)
struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
vnc_export_type_t etype,
struct prefix *p, struct peer *peer,
uint8_t type, uint8_t subtype)
const struct prefix *p,
struct peer *peer, uint8_t type,
uint8_t subtype)
{
struct agg_node *etn;
struct vnc_export_info *eti;

View File

@ -58,8 +58,9 @@ vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype, const struct prefix *p,
extern void vnc_eti_delete(struct vnc_export_info *goner);
extern struct vnc_export_info *
vnc_eti_checktimer(struct bgp *bgp, vnc_export_type_t etype, struct prefix *p,
struct peer *peer, uint8_t type, uint8_t subtype);
vnc_eti_checktimer(struct bgp *bgp, vnc_export_type_t etype,
const struct prefix *p, struct peer *peer, uint8_t type,
uint8_t subtype);
#endif /* _QUAGGA_VNC_VNC_EXPORT_TABLE_H_ */

View File

@ -674,8 +674,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
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);
}
@ -1377,8 +1378,8 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
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)
@ -2754,7 +2755,8 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi)
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(
@ -2795,8 +2797,8 @@ void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi)
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(
@ -2842,7 +2844,8 @@ void vnc_import_bgp_exterior_redist_enable_it(
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);
}
}
}
@ -2872,13 +2875,15 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
*/
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)) {
for (rn2 = bgp_table_top(
bgp_node_get_bgp_table_info(rn1));
rn2; rn2 = bgp_route_next(rn2)) {
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;
@ -2887,46 +2892,35 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
nextbpi = bpi->next;
if (bpi->type
== ZEBRA_ROUTE_BGP_DIRECT) {
if (bpi->type != ZEBRA_ROUTE_BGP_DIRECT)
continue;
struct rfapi_descriptor *rfd;
vncHDBgpDirect.peer = bpi->peer;
assert(bpi->extra);
rfd = bpi->extra->vnc.export
.rfapi_handle;
rfd = bpi->extra->vnc.export.rfapi_handle;
vnc_zlog_debug_verbose(
"%s: deleting bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p [passing rfd=%p]",
__func__, bpi,
bpi->peer, bpi->type,
__func__, bpi, bpi->peer, bpi->type,
bpi->sub_type,
(bpi->extra
? bpi->extra
->vnc
.export
(bpi->extra ? bpi->extra->vnc.export
.rfapi_handle
: NULL),
rfd);
del_vnc_route(
rfd, bpi->peer, bgp,
SAFI_MPLS_VPN, &rn2->p,
(struct prefix_rd *)&rn1
->p,
bpi->type,
bpi->sub_type, NULL,
del_vnc_route(rfd, bpi->peer, bgp,
SAFI_MPLS_VPN, rn2_p,
(struct prefix_rd *)rn1_p,
bpi->type, bpi->sub_type, NULL,
1); /* kill */
vncHDBgpDirect.peer = NULL;
}
}
}
}
}
/* Clear RHN list */
if (bgp->rfapi->resolve_nve_nexthop) {
struct prefix_bag *pb;
@ -2979,8 +2973,9 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi)
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

View File

@ -304,10 +304,12 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
*/
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);
@ -329,7 +331,7 @@ static void vnc_redistribute_withdraw(struct bgp *bgp, afi_t afi, uint8_t type)
del_vnc_route(
&vncHD1VR, /* use dummy ptr as cookie */
vncHD1VR.peer, bgp, SAFI_MPLS_VPN,
&(rn->p), &prd, type,
bgp_node_get_prefix(rn), &prd, type,
BGP_ROUTE_REDISTRIBUTE, NULL, 0);
}
}

View File

@ -105,7 +105,7 @@ extern int smux_trap(struct variable *, size_t, const oid *, size_t,
extern int oid_compare(const oid *, int, const oid *, int);
extern void oid2in_addr(oid[], int, struct in_addr *);
extern void *oid_copy(void *, const void *, size_t);
extern void oid_copy_addr(oid[], struct in_addr *, int);
extern void oid_copy_addr(oid[], const struct in_addr *, int);
#ifdef __cplusplus
}

View File

@ -64,10 +64,10 @@ void oid2in_addr(oid oid[], int len, struct in_addr *addr)
*pnt++ = oid[i];
}
void oid_copy_addr(oid oid[], struct in_addr *addr, int len)
void oid_copy_addr(oid oid[], const struct in_addr *addr, int len)
{
int i;
uint8_t *pnt;
const uint8_t *pnt;
if (len == 0)
return;

View File

@ -898,7 +898,7 @@ int stream_put_prefix(struct stream *s, const struct prefix *p)
}
/* Put NLRI with label */
int stream_put_labeled_prefix(struct stream *s, struct prefix *p,
int stream_put_labeled_prefix(struct stream *s, const struct prefix *p,
mpls_label_t *label, int addpath_encode,
uint32_t addpath_tx_id)
{

View File

@ -196,7 +196,7 @@ extern int stream_put_prefix_addpath(struct stream *s,
int addpath_encode,
uint32_t addpath_tx_id);
extern int stream_put_prefix(struct stream *s, const struct prefix *p);
extern int stream_put_labeled_prefix(struct stream *, struct prefix *,
extern int stream_put_labeled_prefix(struct stream *, const struct prefix *,
mpls_label_t *, int addpath_encode,
uint32_t addpath_tx_id);
extern void stream_get(void *, struct stream *, size_t);

View File

@ -82,7 +82,7 @@ static void print_range_result(struct list *list)
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);
}
}
@ -106,7 +106,7 @@ static void check_lookup_result(struct list *list, va_list arglist)
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;
}