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 */ /* Create the attributes for an aggregate */
struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin, struct attr *bgp_attr_aggregate_intern(
struct aspath *aspath, struct bgp *bgp, uint8_t origin, struct aspath *aspath,
struct community *community, struct community *community, struct ecommunity *ecommunity,
struct ecommunity *ecommunity, struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
struct lcommunity *lcommunity, uint8_t atomic_aggregate, const struct prefix *p)
struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate,
struct prefix *p)
{ {
struct attr attr; struct attr attr;
struct attr *new; 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, 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,
mpls_label_t *label, uint32_t num_labels, const struct prefix_rd *prd, mpls_label_t *label,
int addpath_encode, uint32_t addpath_tx_id, uint32_t num_labels, int addpath_encode,
struct attr *attr) uint32_t addpath_tx_id, struct attr *attr)
{ {
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
if (addpath_encode) 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); 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); int size = PSIZE(p->prefixlen);
if (safi == SAFI_MPLS_VPN) 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; return attrlen_pnt;
} }
void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, afi_t afi, void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
safi_t safi, struct prefix_rd *prd, afi_t afi, safi_t safi,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels, mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id, int addpath_encode, uint32_t addpath_tx_id,
struct attr *attr) 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_unintern(struct attr **);
extern void bgp_attr_flush(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_default_set(struct attr *attr, uint8_t);
extern struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, uint8_t origin, extern struct attr *bgp_attr_aggregate_intern(
struct aspath *aspath, struct bgp *bgp, uint8_t origin, struct aspath *aspath,
struct community *community, struct community *community, struct ecommunity *ecommunity,
struct ecommunity *ecommunity, struct lcommunity *lcommunity, struct bgp_aggregate *aggregate,
struct lcommunity *lcommunity, uint8_t atomic_aggregate, const struct prefix *p);
struct bgp_aggregate *aggregate,
uint8_t atomic_aggregate,
struct prefix *p);
extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *, extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
struct stream *, struct attr *, struct stream *, struct attr *,
struct bpacket_attr_vec_arr *vecarr, 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 bpacket_attr_vec_arr *vecarr,
struct attr *attr); struct attr *attr);
extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi, 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, mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id, int addpath_encode, uint32_t addpath_tx_id,
struct attr *); struct attr *);
extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi, 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 void bgp_packet_mpattr_end(struct stream *s, size_t sizep);
extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi, extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
safi_t safi); safi_t safi);
extern void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, extern void bgp_packet_mpunreach_prefix(
afi_t afi, safi_t safi, struct stream *s, const struct prefix *p, afi_t afi, safi_t safi,
struct prefix_rd *prd, mpls_label_t *, const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels,
uint32_t, int, uint32_t, struct attr *); 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 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, 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); 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 attr *attr, afi_t afi, safi_t safi)
{ {
struct bpacket_attr_vec_arr vecarr; struct bpacket_attr_vec_arr vecarr;
@ -813,7 +813,8 @@ static struct stream *bmp_update(struct prefix *p, struct peer *peer,
return s; 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; struct stream *s;
size_t attrlen_pos = 0, mp_start, mplen_pos; 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, 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) safi_t safi, time_t uptime)
{ {
struct stream *hdr, *msg; struct stream *hdr, *msg;
@ -940,7 +941,7 @@ afibreak:
return true; return true;
} }
bmp->syncpeerid = 0; 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) { if (bmp->targets->afimon[afi][safi] & BMP_MON_POSTPOLICY) {
@ -988,12 +989,14 @@ afibreak:
bmp->syncpeerid = adjin->peer->qobj_node.nid; bmp->syncpeerid = adjin->peer->qobj_node.nid;
} }
const struct prefix *bn_p = bgp_node_get_prefix(bn);
if (bpi) 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); afi, safi, bpi->uptime);
if (adjin) if (adjin)
bmp_monitor(bmp, adjin->peer, 0, &bn->p, adjin->attr, bmp_monitor(bmp, adjin->peer, 0, bn_p, adjin->attr, afi, safi,
afi, safi, adjin->uptime); adjin->uptime);
return true; return true;
} }
@ -1130,16 +1133,13 @@ static void bmp_process_one(struct bmp_targets *bt, struct bgp *bgp,
struct bmp *bmp; struct bmp *bmp;
struct bmp_queue_entry *bqe, bqeref; struct bmp_queue_entry *bqe, bqeref;
size_t refcount; size_t refcount;
char buf[256];
prefix2str(&bn->p, buf, sizeof(buf));
refcount = bmp_session_count(&bt->sessions); refcount = bmp_session_count(&bt->sessions);
if (refcount == 0) if (refcount == 0)
return; return;
memset(&bqeref, 0, sizeof(bqeref)); 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.peerid = peer->qobj_node.nid;
bqeref.afi = afi; bqeref.afi = afi;
bqeref.safi = safi; bqeref.safi = safi;

View File

@ -155,9 +155,9 @@ static int bgp_reuse_timer(struct thread *t)
if (bdi->lastrecord == BGP_RECORD_UPDATE) { if (bdi->lastrecord == BGP_RECORD_UPDATE) {
bgp_path_info_unset_flag(bdi->rn, bdi->path, bgp_path_info_unset_flag(bdi->rn, bdi->path,
BGP_PATH_HISTORY); BGP_PATH_HISTORY);
bgp_aggregate_increment(bgp, &bdi->rn->p, bgp_aggregate_increment(
bdi->path, bdi->afi, bgp, bgp_node_get_prefix(bdi->rn),
bdi->safi); bdi->path, bdi->afi, bdi->safi);
bgp_process(bgp, bdi->rn, 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(bestpath, BESTPATH)) {
if (bgp_debug_per_prefix( 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)) BGP_DEBUG_BESTPATH, bgp_debug_bestpath_prefixes))
return true; 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, const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
struct prefix_rd *prd, const struct prefix_rd *prd,
union prefixconstptr pu, union prefixconstptr pu,
mpls_label_t *label, uint32_t num_labels, mpls_label_t *label, uint32_t num_labels,
int addpath_valid, uint32_t addpath_id, 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_bestpath(struct bgp_node *rn);
extern bool bgp_debug_zebra(const struct prefix *p); extern bool bgp_debug_zebra(const struct prefix *p);
extern const char *bgp_debug_rdpfxpath2str(afi_t, safi_t, struct prefix_rd *, extern const char *
union prefixconstptr, mpls_label_t *, bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi, const struct prefix_rd *prd,
uint32_t, int, uint32_t, char *, union prefixconstptr pu, mpls_label_t *label,
int); 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, const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data,
size_t datalen); size_t datalen);

View File

@ -307,6 +307,7 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn,
struct stream *obuf; struct stream *obuf;
size_t sizep; size_t sizep;
size_t endp; size_t endp;
const struct prefix *p = bgp_node_get_prefix(rn);
obuf = bgp_dump_obuf; obuf = bgp_dump_obuf;
stream_reset(obuf); stream_reset(obuf);
@ -325,19 +326,19 @@ bgp_dump_route_node_record(int afi, struct bgp_node *rn,
stream_putl(obuf, seq); stream_putl(obuf, seq);
/* Prefix length */ /* Prefix length */
stream_putc(obuf, rn->p.prefixlen); stream_putc(obuf, p->prefixlen);
/* Prefix */ /* Prefix */
if (afi == AFI_IP) { if (afi == AFI_IP) {
/* We'll dump only the useful bits (those not 0), but have to /* We'll dump only the useful bits (those not 0), but have to
* align on 8 bits */ * align on 8 bits */
stream_write(obuf, (uint8_t *)&rn->p.u.prefix4, stream_write(obuf, (uint8_t *)&p->u.prefix4,
(rn->p.prefixlen + 7) / 8); (p->prefixlen + 7) / 8);
} else if (afi == AFI_IP6) { } else if (afi == AFI_IP6) {
/* We'll dump only the useful bits (those not 0), but have to /* We'll dump only the useful bits (those not 0), but have to
* align on 8 bits */ * align on 8 bits */
stream_write(obuf, (uint8_t *)&rn->p.u.prefix6, stream_write(obuf, (uint8_t *)&p->u.prefix6,
(rn->p.prefixlen + 7) / 8); (p->prefixlen + 7) / 8);
} }
/* Save where we are now, so we can overwride the entry count later */ /* 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. */ /* Dump attribute. */
/* Skip prefix & AFI/SAFI for MP_NLRI */ /* 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); cur_endp = stream_get_endp(obuf);
if (cur_endp > BGP_MAX_PACKET_SIZE + BGP_DUMP_MSG_HEADER 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. * L3VPN routes.
*/ */
global_rn = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, 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) { if (global_rn) {
/* Delete route entry in the global EVPN table. */ /* Delete route entry in the global EVPN table. */
delete_evpn_route_entry(bgp, afi, safi, global_rn, &pi); delete_evpn_route_entry(bgp, afi, safi, global_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)) { && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (bgp_zebra_has_route_changed(rn, old_select)) { if (bgp_zebra_has_route_changed(rn, old_select)) {
ret = evpn_es_install_vtep(bgp, es, 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); old_select->attr->nexthop);
} }
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG); 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 if (new_select && new_select->type == ZEBRA_ROUTE_BGP
&& new_select->sub_type == BGP_ROUTE_IMPORTED) { && new_select->sub_type == BGP_ROUTE_IMPORTED) {
ret = evpn_es_install_vtep(bgp, es, 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); new_select->attr->nexthop);
} else { } else {
if (old_select && old_select->type == ZEBRA_ROUTE_BGP if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED) && old_select->sub_type == BGP_ROUTE_IMPORTED)
ret = evpn_es_uninstall_vtep( 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); 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)) { && !bgp_addpath_is_addpath_used(&bgp->tx_addpath, afi, safi)) {
if (bgp_zebra_has_route_changed(rn, old_select)) if (bgp_zebra_has_route_changed(rn, old_select))
ret = evpn_zebra_install( ret = evpn_zebra_install(
bgp, vpn, (struct prefix_evpn *)&rn->p, bgp, vpn, (const struct prefix_evpn *)bgp_node_get_prefix(rn),
old_select); old_select);
UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG); UNSET_FLAG(old_select->flags, BGP_PATH_MULTIPATH_CHG);
bgp_zebra_clear_route_change_flags(rn); 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 if (new_select && new_select->type == ZEBRA_ROUTE_BGP
&& new_select->sub_type == BGP_ROUTE_IMPORTED) { && 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); new_select);
/* If an old best existed and it was a "local" route, the only /* 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 { } else {
if (old_select && old_select->type == ZEBRA_ROUTE_BGP if (old_select && old_select->type == ZEBRA_ROUTE_BGP
&& old_select->sub_type == BGP_ROUTE_IMPORTED) && old_select->sub_type == BGP_ROUTE_IMPORTED)
ret = evpn_zebra_uninstall(bgp, vpn, ret = evpn_zebra_uninstall(
(struct prefix_evpn *)&rn->p, bgp, vpn,
(const struct prefix_evpn *)bgp_node_get_prefix(
rn),
old_select->attr->nexthop); 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 *local_pi = NULL; /* local route entry if any */
struct bgp_path_info *remote_pi = NULL; /* remote route entry if any */ struct bgp_path_info *remote_pi = NULL; /* remote route entry if any */
struct attr *attr_new = NULL; struct attr *attr_new = NULL;
struct prefix_evpn *evp = NULL; const struct prefix_evpn *evp = NULL;
*ri = NULL; *ri = NULL;
*route_changed = 1; *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 */ /* locate the local and remote entries if any */
for (tmp_pi = bgp_node_get_bgp_path_info(rn); tmp_pi; 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; uint32_t num_labels = 1;
int route_change = 1; int route_change = 1;
uint8_t sticky = 0; uint8_t sticky = 0;
struct prefix_evpn *evp; const struct prefix_evpn *evp;
*pi = NULL; *pi = NULL;
evp = (struct prefix_evpn *)&rn->p; evp = (const struct prefix_evpn *)bgp_node_get_prefix(rn);
memset(&label, 0, sizeof(label)); memset(&label, 0, sizeof(label));
/* See if this is an update of an existing route, or a new add. */ /* 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 if (curr_select && curr_select->type == ZEBRA_ROUTE_BGP
&& curr_select->sub_type == BGP_ROUTE_IMPORTED) && curr_select->sub_type == BGP_ROUTE_IMPORTED)
evpn_zebra_install(bgp, vpn, evpn_zebra_install(bgp, vpn,
(struct prefix_evpn *)&rn->p, (const struct prefix_evpn *)bgp_node_get_prefix(rn),
curr_select); curr_select);
} }
@ -1820,13 +1823,10 @@ static void evpn_cleanup_local_non_best_route(struct bgp *bgp,
struct bgp_node *rn, struct bgp_node *rn,
struct bgp_path_info *local_pi) struct bgp_path_info *local_pi)
{ {
char buf[PREFIX_STRLEN];
/* local path was not picked as the winner; kick it out */ /* local path was not picked as the winner; kick it out */
if (bgp_debug_zebra(NULL)) { if (bgp_debug_zebra(NULL))
zlog_debug("evicting local evpn prefix %s as remote won", zlog_debug("evicting local evpn prefix %pRN as remote won", rn);
prefix2str(&rn->p, buf, sizeof(buf)));
}
evpn_delete_old_local_route(bgp, vpn, rn, local_pi); evpn_delete_old_local_route(bgp, vpn, rn, local_pi);
bgp_path_info_reap(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; for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(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_node *rd_rn;
struct bgp_path_info *global_pi; 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)) { if (rdrn && bgp_node_has_bgp_path_info_data(rdrn)) {
table = bgp_node_get_bgp_table_info(rdrn); table = bgp_node_get_bgp_table_info(rdrn);
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { 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) if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue; 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. */ /* Next, walk this VNI's route table and delete local type-2 routes. */
for (rn = bgp_table_top(vpn->route_table); rn; for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(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) if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
continue; continue;
@ -2709,7 +2709,8 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
/* as it is an importation, change nexthop */ /* as it is an importation, change nexthop */
bgp_path_info_set_flag(rn, pi, BGP_PATH_ANNC_NH_SELF); 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. */ /* Perform route selection and update zebra, if required. */
bgp_process(bgp_vrf, rn, afi, safi); 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. */ /* Process for route leaking. */
vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp_vrf, pi); 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 */ /* Mark entry for deletion */
bgp_path_info_delete(rn, pi); bgp_path_info_delete(rn, pi);
@ -3107,7 +3109,9 @@ static int install_uninstall_routes_for_es(struct bgp *bgp,
continue; continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { 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; for (pi = bgp_node_get_bgp_path_info(rn); pi;
pi = pi->next) { pi = pi->next) {
@ -3214,7 +3218,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
continue; continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { 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 not mac-ip route skip this route */
if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_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; continue;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { 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) if (evp->prefix.route_type != rtype)
continue; 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; for (rn = bgp_table_top(vpn->route_table); rn;
rn = bgp_route_next(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. */ /* Identify MAC-IP local routes. */
if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE) 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; return ret;
} }
static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p, static void evpn_mpattr_encode_type5(struct stream *s, const struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label, const struct prefix_rd *prd,
uint32_t num_labels, struct attr *attr) mpls_label_t *label, uint32_t num_labels,
struct attr *attr)
{ {
int len; int len;
char temp[16]; char temp[16];
struct evpn_addr *p_evpn_p; const struct evpn_addr *p_evpn_p;
memset(&temp, 0, 16); memset(&temp, 0, 16);
if (p->family != AF_EVPN) 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) { for (pi = bgp_node_get_bgp_path_info(rn); pi; pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
&& is_route_injectable_into_evpn(pi)) { && is_route_injectable_into_evpn(pi)) {
bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p, bgp_evpn_withdraw_type5_route(
afi, safi); bgp_vrf, bgp_node_get_prefix(rn), afi,
safi);
break; break;
} }
} }
@ -4592,18 +4601,21 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
ret = route_map_apply( ret = route_map_apply(
bgp_vrf->adv_cmd_rmap[afi][safi] bgp_vrf->adv_cmd_rmap[afi][safi]
.map, .map,
&rn->p, RMAP_BGP, &tmp_pi); bgp_node_get_prefix(rn),
RMAP_BGP, &tmp_pi);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&tmp_attr); bgp_attr_flush(&tmp_attr);
continue; continue;
} }
bgp_evpn_advertise_type5_route( bgp_evpn_advertise_type5_route(
bgp_vrf, &rn->p, &tmp_attr, bgp_vrf,
afi, safi); bgp_node_get_prefix(rn),
&tmp_attr, afi, safi);
} else } else
bgp_evpn_advertise_type5_route( bgp_evpn_advertise_type5_route(
bgp_vrf, &rn->p, pi->attr, bgp_vrf,
afi, safi); bgp_node_get_prefix(rn),
pi->attr, afi, safi);
break; 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) * Encode EVPN prefix in Update (MP_REACH)
*/ */
void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p, void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label, const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct attr *attr, uint32_t num_labels, struct attr *attr,
int addpath_encode, uint32_t addpath_tx_id) 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, if (bgp_nexthop_self(bgp, afi,
pi->type, pi->sub_type, pi->type, pi->sub_type,
pi->attr, rn)) { 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 attr_str[BUFSIZ] = {0};
char pbuf[PREFIX_STRLEN];
bgp_dump_attr(pi->attr, attr_str, bgp_dump_attr(pi->attr,
BUFSIZ); attr_str, BUFSIZ);
if (bgp_debug_update(pi->peer, &rn->p,
NULL, 1))
zlog_debug( zlog_debug(
"%u: prefix %s with attr %s - DENIED due to martian or self nexthop", "%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop",
bgp->vrf_id, bgp->vrf_id, rn,
prefix2str(
&rn->p, pbuf,
sizeof(pbuf)),
attr_str); attr_str);
}
bgp_evpn_unimport_route(bgp, afi, safi, bgp_evpn_unimport_route(bgp, afi, safi,
&rn->p, pi); p, pi);
bgp_rib_remove(rn, pi, pi->peer, afi, bgp_rib_remove(rn, pi, pi->peer, afi,
safi); 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. * 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; 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, extern char *bgp_evpn_route2str(const struct prefix_evpn *p, char *buf,
int len); int len);
extern void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json); 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, extern void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label, const struct prefix_rd *prd,
uint32_t num_labels, struct attr *attr, mpls_label_t *label, uint32_t num_labels,
int addpath_encode, uint32_t addpath_tx_id); struct attr *attr, int addpath_encode,
uint32_t addpath_tx_id);
extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
struct bgp_nlri *packet, int withdraw); struct bgp_nlri *packet, int withdraw);
extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi, 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_on_disable(struct bgp *bgp);
extern void bgp_evpn_cleanup(struct bgp *bgp); extern void bgp_evpn_cleanup(struct bgp *bgp);
extern void bgp_evpn_init(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 bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx);
extern void update_advertise_vrf_routes(struct bgp *bgp_vrf); 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; uint16_t type;
struct rd_as rd_as; struct rd_as rd_as;
struct rd_ip rd_ip; 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. */ /* Decode RD type. */
type = decode_rd_type(pnt); type = decode_rd_type(pnt);
@ -647,8 +648,9 @@ static void show_esi_routes(struct bgp *bgp,
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
json_object *json_paths = NULL; json_object *json_paths = NULL;
json_object *json_prefix = 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)); sizeof(prefix_str));
if (json) if (json)
@ -678,7 +680,7 @@ static void show_esi_routes(struct bgp *bgp,
if (json) if (json)
json_path = json_object_new_array(); 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) if (json)
json_object_array_add(json_paths, json_path); 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", json_object_string_add(json_prefix, "prefix",
prefix_str); prefix_str);
json_object_int_add(json_prefix, "prefixLen", json_object_int_add(json_prefix, "prefixLen",
rn->p.prefixlen); p->prefixlen);
json_object_object_add(json_prefix, "paths", json_object_object_add(json_prefix, "paths",
json_paths); json_paths);
json_object_object_add(json, prefix_str, 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; tbl_ver = table->version;
for (rn = bgp_table_top(table); rn; for (rn = bgp_table_top(table); rn;
rn = bgp_route_next(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; int add_prefix_to_json = 0;
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
json_object *json_paths = NULL; json_object *json_paths = NULL;
json_object *json_prefix = 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)); sizeof(prefix_str));
if (type && evp->prefix.route_type != type) 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, AFI_L2VPN, SAFI_EVPN,
json_path); json_path);
else else
route_vty_out(vty, &rn->p, pi, 0, SAFI_EVPN, route_vty_out(vty, p, pi, 0, SAFI_EVPN,
json_path); json_path);
if (json) 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", json_object_string_add(json_prefix, "prefix",
prefix_str); prefix_str);
json_object_int_add(json_prefix, "prefixLen", json_object_int_add(json_prefix, "prefixLen",
rn->p.prefixlen); p->prefixlen);
json_object_object_add(json_prefix, "paths", json_object_object_add(json_prefix, "paths",
json_paths); json_paths);
json_object_object_add(json, prefix_str, 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)) { rn = bgp_route_next(rn)) {
uint64_t tbl_ver; uint64_t tbl_ver;
json_object *json_nroute = NULL; 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; continue;
table = bgp_node_get_bgp_table_info(rn); 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(); json_array = json_object_new_array();
if (option == SHOW_DISPLAY_TAGS) if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag(vty, &rm->p, pi, route_vty_out_tag(
no_display, SAFI_EVPN, vty, bgp_node_get_prefix(rm),
pi, no_display, SAFI_EVPN,
json_array); json_array);
else if (option == SHOW_DISPLAY_OVERLAY) else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay(vty, &rm->p, pi, route_vty_out_overlay(
no_display, vty, bgp_node_get_prefix(rm),
json_array); pi, no_display, json_array);
else else
route_vty_out(vty, &rm->p, pi, route_vty_out(vty,
no_display, SAFI_EVPN, bgp_node_get_prefix(rm),
pi, no_display, SAFI_EVPN,
json_array); json_array);
no_display = 1; no_display = 1;
} }
@ -1308,15 +1315,19 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
output_count++; output_count++;
if (use_json && json_array) { if (use_json && json_array) {
const struct prefix *p =
bgp_node_get_prefix(rm);
json_prefix_info = json_object_new_object(); json_prefix_info = json_object_new_object();
json_object_string_add(json_prefix_info, json_object_string_add(
"prefix", bgp_evpn_route2str( json_prefix_info, "prefix",
(struct prefix_evpn *)&rm->p, buf, bgp_evpn_route2str(
(struct prefix_evpn *)p, buf,
BUFSIZ)); BUFSIZ));
json_object_int_add(json_prefix_info, json_object_int_add(json_prefix_info,
"prefixLen", rm->p.prefixlen); "prefixLen", p->prefixlen);
json_object_object_add(json_prefix_info, json_object_object_add(json_prefix_info,
"paths", json_array); "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. */ /* Display all prefixes with this RD. */
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { 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_prefix = NULL;
json_object *json_paths = NULL; json_object *json_paths = NULL;
char prefix_str[BUFSIZ]; char prefix_str[BUFSIZ];
int add_prefix_to_json = 0; 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)); sizeof(prefix_str));
if (type && evp->prefix.route_type != type) 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 */ json_object *json_rd = NULL; /* contains routes for an RD */
int add_rd_to_json = 0; int add_rd_to_json = 0;
uint64_t tbl_ver; uint64_t tbl_ver;
const struct prefix *rd_rnp = bgp_node_get_prefix(rd_rn);
table = bgp_node_get_bgp_table_info(rd_rn); table = bgp_node_get_bgp_table_info(rd_rn);
if (table == NULL) if (table == NULL)
continue; continue;
tbl_ver = table->version; 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)); sizeof(rd_str));
if (json) 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 */ NULL; /* contains prefix under a RD */
json_object *json_paths = json_object *json_paths =
NULL; /* array of paths under a prefix*/ 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]; char prefix_str[BUFSIZ];
int add_prefix_to_json = 0; int add_prefix_to_json = 0;
const struct prefix *p = bgp_node_get_prefix(rn);
bgp_evpn_route2str((struct prefix_evpn *)&rn->p, bgp_evpn_route2str((struct prefix_evpn *)p, prefix_str,
prefix_str, sizeof(prefix_str)); sizeof(prefix_str));
if (type && evp->prefix.route_type != type) if (type && evp->prefix.route_type != type)
continue; 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", json_object_string_add(json_prefix, "prefix",
prefix_str); prefix_str);
json_object_int_add(json_prefix, "prefixLen", json_object_int_add(json_prefix, "prefixLen",
rn->p.prefixlen); p->prefixlen);
} }
/* Prefix and num paths displayed once per prefix. */ /* Prefix and num paths displayed once per prefix. */
if (detail) if (detail)
route_vty_out_detail_header( route_vty_out_detail_header(
vty, bgp, rn, vty, bgp, rn,
(struct prefix_rd *)&rd_rn->p, (struct prefix_rd *)rd_rnp, AFI_L2VPN,
AFI_L2VPN, SAFI_EVPN, json_prefix); SAFI_EVPN, json_prefix);
/* For EVPN, the prefix is displayed for each path (to /* For EVPN, the prefix is displayed for each path (to
* fit in * 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, vty, bgp, rn, pi, AFI_L2VPN,
SAFI_EVPN, json_path); SAFI_EVPN, json_path);
} else } else
route_vty_out(vty, &rn->p, pi, 0, route_vty_out(vty, p, pi, 0, SAFI_EVPN,
SAFI_EVPN, json_path); json_path);
if (json) if (json)
json_object_array_add(json_paths, 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; struct bgp_pbr_entry_action *api_action;
memset(&api, 0, sizeof(struct bgp_pbr_entry_main)); 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; return true;
for (i = 0; i < api.action_num; i++) { for (i = 0; i < api.action_num; i++) {
api_action = &api.actions[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) { for (; pi; pi = pi->next) {
total_count++; total_count++;
route_vty_out_flowspec(vty, &rn->p, pi, display, route_vty_out_flowspec(vty, bgp_node_get_prefix(rn), pi,
json_paths); display, json_paths);
} }
if (use_json) { if (use_json) {
vty_out(vty, "%s\n", 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) json_object *json_paths)
{ {
struct bgp_node *rn; struct bgp_node *rn;
struct prefix *prefix; const struct prefix *prefix;
int display = 0; int display = 0;
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { 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) if (prefix->family != AF_FLOWSPEC)
continue; continue;
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) { if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
route_vty_out_flowspec( 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 use_json ? NLRI_STRING_FORMAT_JSON
: NLRI_STRING_FORMAT_LARGE, : NLRI_STRING_FORMAT_LARGE,
json_paths); 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_path_info *pi;
struct bgp_node *rn; struct bgp_node *rn;
char addr[PREFIX_STRLEN];
pi = labelid; pi = labelid;
/* Is this path still valid? */ /* 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; rn = pi->net;
prefix2str(&rn->p, addr, PREFIX_STRLEN);
if (BGP_DEBUG(labelpool, LABELPOOL)) 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); new_label, allocated);
if (!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) { if (pi->attr->label_index != MPLS_INVALID_LABEL_INDEX) {
flog_err( flog_err(
EC_BGP_LABEL, EC_BGP_LABEL,
"%s: FEC %s Rejecting allocated label %u as Label Index is %u", "%s: FEC %pRN Rejecting allocated label %u as Label Index is %u",
__func__, addr, new_label, pi->attr->label_index); __func__, rn, new_label, pi->attr->label_index);
bgp_register_for_label(pi->net, pi); 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 */ /* Shouldn't happen: different label allocation */
flog_err(EC_BGP_LABEL, flog_err(EC_BGP_LABEL,
"%s: %s had label %u but got new assignment %u", "%s: %pRN had label %u but got new assignment %u",
__func__, addr, pi->attr->label, new_label); __func__, rn, pi->attr->label, new_label);
/* continue means use new one */ /* 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; bool with_label_index = false;
struct stream *s; struct stream *s;
struct prefix *p; const struct prefix *p;
mpls_label_t *local_label; mpls_label_t *local_label;
int command; int command;
uint16_t flags = 0; uint16_t flags = 0;
size_t flags_pos = 0; size_t flags_pos = 0;
char addr[PREFIX_STRLEN]; char addr[PREFIX_STRLEN];
p = &(rn->p); p = bgp_node_get_prefix(rn);
local_label = &(rn->local_label); local_label = &(rn->local_label);
/* this prevents the loop when we're called by /* this prevents the loop when we're called by
* bgp_reg_for_label_callback() * 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)) { for (prn = bgp_table_top(table); prn; prn = bgp_route_next(prn)) {
struct bgp_table *sub = prn->info; struct bgp_table *sub = prn->info;
const struct prefix *prn_p = bgp_node_get_prefix(prn);
if (!sub) if (!sub)
continue; continue;
for (rn = bgp_table_top(sub); rn; rn = bgp_route_next(rn)) { for (rn = bgp_table_top(sub); rn; rn = bgp_route_next(rn)) {
bool rn_affected; 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; struct prefix_rd prd;
uint32_t num_labels = 0; uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL; 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 && if (pevpn->family == AF_EVPN &&
pevpn->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE && 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) macaddr, ETH_ALEN) == 0)
rn_affected = true; rn_affected = true;
else else
@ -185,15 +187,15 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; 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 (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]; char pfx_buf[BGP_PRD_PATH_STRLEN];
bgp_debug_rdpfxpath2str( bgp_debug_rdpfxpath2str(
AFI_L2VPN, SAFI_EVPN, &prd, 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 ? 1 : 0,
pi->addpath_rx_id, pfx_buf, pi->addpath_rx_id, pfx_buf,
sizeof(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)); 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->addpath_rx_id,
pi->attr, AFI_L2VPN, SAFI_EVPN, pi->attr, AFI_L2VPN, SAFI_EVPN,
ZEBRA_ROUTE_BGP, 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 listnode *mp_node, *mp_next_node;
struct bgp_path_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath; struct bgp_path_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath;
int mpath_changed, debug; 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]; char path_buf[PATH_ADDPATH_STR_BUFFER];
mpath_changed = 0; mpath_changed = 0;
@ -459,9 +459,6 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
mp_node = listhead(mp_list); mp_node = listhead(mp_list);
debug = bgp_debug_bestpath(rn); debug = bgp_debug_bestpath(rn);
if (debug)
prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf));
if (new_best) { if (new_best) {
mpath_count++; mpath_count++;
if (new_best != old_best) if (new_best != old_best)
@ -480,8 +477,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (debug) if (debug)
zlog_debug( zlog_debug(
"%s: starting mpath update, newbest %s num candidates %d old-mpath-count %d", "%pRN: starting mpath update, newbest %s num candidates %d old-mpath-count %d",
pfx_buf, new_best ? new_best->peer->host : "NONE", rn, new_best ? new_best->peer->host : "NONE",
mp_list ? listcount(mp_list) : 0, old_mpath_count); 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) if (debug)
zlog_debug( zlog_debug(
"%s: comparing candidate %s with existing mpath %s", "%pRN: comparing candidate %s with existing mpath %s",
pfx_buf, rn,
tmp_info ? tmp_info->peer->host : "NONE", tmp_info ? tmp_info->peer->host : "NONE",
cur_mpath ? cur_mpath->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( bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%s: %s is still multipath, cur count %d", "%pRN: %s is still multipath, cur count %d",
pfx_buf, path_buf, mpath_count); rn, path_buf, mpath_count);
} }
} else { } else {
mpath_changed = 1; 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( bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%s: remove mpath %s nexthop %s, cur count %d", "%pRN: remove mpath %s nexthop %s, cur count %d",
pfx_buf, path_buf, rn, path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&cur_mpath->attr &cur_mpath->attr
->nexthop, ->nexthop,
@ -579,8 +576,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
bgp_path_info_path_with_addpath_rx_str( bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf); cur_mpath, path_buf);
zlog_debug( zlog_debug(
"%s: remove mpath %s nexthop %s, cur count %d", "%pRN: remove mpath %s nexthop %s, cur count %d",
pfx_buf, path_buf, rn, path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&cur_mpath->attr->nexthop, &cur_mpath->attr->nexthop,
nh_buf[0], sizeof(nh_buf[0])), 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( bgp_path_info_path_with_addpath_rx_str(
new_mpath, path_buf); new_mpath, path_buf);
zlog_debug( zlog_debug(
"%s: add mpath %s nexthop %s, cur count %d", "%pRN: add mpath %s nexthop %s, cur count %d",
pfx_buf, path_buf, rn, path_buf,
inet_ntop(AF_INET, inet_ntop(AF_INET,
&new_mpath->attr &new_mpath->attr
->nexthop, ->nexthop,
@ -641,8 +638,8 @@ void bgp_path_info_mpath_update(struct bgp_node *rn,
if (new_best) { if (new_best) {
if (debug) if (debug)
zlog_debug( zlog_debug(
"%s: New mpath count (incl newbest) %d mpath-change %s", "%pRN: New mpath count (incl newbest) %d mpath-change %s",
pfx_buf, mpath_count, rn, mpath_count,
mpath_changed ? "YES" : "NO"); mpath_changed ? "YES" : "NO");
bgp_path_info_mpath_count_set(new_best, mpath_count - 1); 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, struct bgp *bgp_orig, struct prefix *nexthop_orig,
int nexthop_self_flag, int debug) 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;
struct bgp_path_info *bpi_ultimate; struct bgp_path_info *bpi_ultimate;
struct bgp_path_info *new; struct bgp_path_info *new;
char buf_prefix[PREFIX_STRLEN];
if (debug) { if (debug)
prefix2str(&bn->p, buf_prefix, sizeof(buf_prefix)); zlog_debug(
zlog_debug("%s: entry: leak-to=%s, p=%s, type=%d, sub_type=%d", "%s: entry: leak-to=%s, p=%pRN, type=%d, sub_type=%d",
__func__, bgp->name_pretty, buf_prefix, __func__, bgp->name_pretty, bn, source_bpi->type,
source_bpi->type, source_bpi->sub_type); source_bpi->sub_type);
}
/* /*
* Routes that are redistributed into BGP from zebra do not get * 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); bgp_attr_unintern(&new_attr);
if (debug) if (debug)
zlog_debug( zlog_debug(
"%s: ->%s: %s: Found route, no change", "%s: ->%s: %pRN: Found route, no change",
__func__, bgp->name_pretty, __func__, bgp->name_pretty, bn);
buf_prefix);
return NULL; return NULL;
} }
@ -580,8 +577,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
bgp_unlock_node(bn); bgp_unlock_node(bn);
if (debug) if (debug)
zlog_debug("%s: ->%s: %s Found route, changed attr", zlog_debug("%s: ->%s: %pRN Found route, changed attr",
__func__, bgp->name_pretty, buf_prefix); __func__, bgp->name_pretty, bn);
return bpi; return bpi;
} }
@ -645,8 +642,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */
bgp_process(bgp, bn, afi, safi); bgp_process(bgp, bn, afi, safi);
if (debug) if (debug)
zlog_debug("%s: ->%s: %s: Added new route", __func__, zlog_debug("%s: ->%s: %pRN: Added new route", __func__,
bgp->name_pretty, buf_prefix); bgp->name_pretty, bn);
return new; return new;
} }
@ -657,7 +654,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */
struct bgp_path_info *path_vrf) /* route */ struct bgp_path_info *path_vrf) /* route */
{ {
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); 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); afi_t afi = family2afi(p->family);
struct attr static_attr = {0}; struct attr static_attr = {0};
struct attr *new_attr = NULL; 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 */ struct bgp_path_info *path_vrf) /* route */
{ {
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF); 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); afi_t afi = family2afi(p->family);
safi_t safi = SAFI_MPLS_VPN; safi_t safi = SAFI_MPLS_VPN;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_node *bn; struct bgp_node *bn;
const char *debugmsg; const char *debugmsg;
char buf_prefix[PREFIX_STRLEN];
if (debug) { if (debug) {
prefix2str(p, buf_prefix, sizeof(buf_prefix));
zlog_debug( zlog_debug(
"%s: entry: leak-from=%s, p=%s, type=%d, sub_type=%d", "%s: entry: leak-from=%s, p=%pRN, type=%d, sub_type=%d",
__func__, bgp_vrf->name_pretty, buf_prefix, __func__, bgp_vrf->name_pretty, path_vrf->net,
path_vrf->type, path_vrf->sub_type); path_vrf->type, path_vrf->sub_type);
} }
@ -980,14 +975,10 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
continue; continue;
for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) { for (bn = bgp_table_top(table); bn; bn = bgp_route_next(bn)) {
char buf[PREFIX2STR_BUFFER];
bpi = bgp_node_get_bgp_path_info(bn); bpi = bgp_node_get_bgp_path_info(bn);
if (debug && bpi) { if (debug && bpi) {
zlog_debug( zlog_debug("%s: looking at prefix %pRN",
"%s: looking at prefix %s", __func__, __func__, bn);
prefix2str(&bn->p, buf, sizeof(buf)));
} }
for (; bpi; bpi = bpi->next) { for (; bpi; bpi = bpi->next) {
@ -1005,8 +996,10 @@ void vpn_leak_from_vrf_withdraw_all(struct bgp *bgp_vpn, /* to */
if (debug) if (debug)
zlog_debug("%s: deleting it", zlog_debug("%s: deleting it",
__func__); __func__);
bgp_aggregate_decrement(bgp_vpn, &bn->p, bgp_aggregate_decrement(
bpi, afi, safi); bgp_vpn,
bgp_node_get_prefix(bn), bpi,
afi, safi);
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vpn, bn, afi, safi); 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 *bgp_vpn, /* from */
struct bgp_path_info *path_vpn) /* route */ 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); afi_t afi = family2afi(p->family);
struct attr static_attr = {0}; struct attr static_attr = {0};
@ -1228,12 +1221,9 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
} }
} }
if (debug) { if (debug)
char buf_prefix[PREFIX_STRLEN]; zlog_debug("%s: pfx %pRN: num_labels %d", __func__,
prefix2str(p, buf_prefix, sizeof(buf_prefix)); path_vpn->net, num_labels);
zlog_debug("%s: pfx %s: num_labels %d", __func__, buf_prefix,
num_labels);
}
/* /*
* For VRF-2-VRF route-leaking, * 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 */ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
struct bgp_path_info *path_vpn) /* route */ struct bgp_path_info *path_vpn) /* route */
{ {
struct prefix *p; const struct prefix *p;
afi_t afi; afi_t afi;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
struct bgp *bgp; struct bgp *bgp;
@ -1281,15 +1271,12 @@ void vpn_leak_to_vrf_withdraw(struct bgp *bgp_vpn, /* from */
struct bgp_node *bn; struct bgp_node *bn;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
const char *debugmsg; const char *debugmsg;
char buf_prefix[PREFIX_STRLEN];
int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF); int debug = BGP_DEBUG(vpn, VPN_LEAK_TO_VRF);
if (debug) { if (debug)
prefix2str(&path_vpn->net->p, buf_prefix, sizeof(buf_prefix)); zlog_debug("%s: entry: p=%pRN, type=%d, sub_type=%d", __func__,
zlog_debug("%s: entry: p=%s, type=%d, sub_type=%d", __func__, path_vpn->net, path_vpn->type, path_vpn->sub_type);
buf_prefix, path_vpn->type, path_vpn->sub_type);
}
if (debug) if (debug)
zlog_debug("%s: start (path_vpn=%p)", __func__, path_vpn); 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; return;
} }
p = &path_vpn->net->p; p = bgp_node_get_prefix(path_vpn->net);
afi = family2afi(p->family); afi = family2afi(p->family);
/* Loop over VRFs */ /* 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)) { && is_pi_family_vpn(bpi->extra->parent)) {
/* delete route */ /* delete route */
bgp_aggregate_decrement(bgp_vrf, &bn->p, bpi, bgp_aggregate_decrement(bgp_vrf,
afi, safi); bgp_node_get_prefix(bn),
bpi, afi, safi);
bgp_path_info_delete(bn, bpi); bgp_path_info_delete(bn, bpi);
bgp_process(bgp_vrf, bn, afi, safi); 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; for (prn = bgp_table_top(bgp_vpn->rib[afi][safi]); prn;
prn = bgp_route_next(prn)) { prn = bgp_route_next(prn)) {
const struct prefix *p = bgp_node_get_prefix(prn);
struct bgp_table *table; struct bgp_table *table;
struct bgp_node *bn; struct bgp_node *bn;
struct bgp_path_info *bpi; 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)); memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; 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 */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); 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) 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; 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; uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6;
struct bgp_addr tmp_addr = {{0}}, *addr = NULL; struct bgp_addr tmp_addr = {{0}}, *addr = NULL;
struct tip_addr tmp_tip, *tip = NULL; struct tip_addr tmp_tip, *tip = NULL;
const struct prefix *p = bgp_node_get_prefix(rn);
bool is_bgp_static_route = bool is_bgp_static_route =
((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC)) ((type == ZEBRA_ROUTE_BGP) && (sub_type == BGP_ROUTE_STATIC))
? true ? true
@ -489,8 +489,8 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
switch (new_afi) { switch (new_afi) {
case AF_INET: case AF_INET:
if (is_bgp_static_route) { if (is_bgp_static_route) {
tmp_addr.p.u.prefix4 = rn->p.u.prefix4; tmp_addr.p.u.prefix4 = p->u.prefix4;
tmp_addr.p.prefixlen = rn->p.prefixlen; tmp_addr.p.prefixlen = p->prefixlen;
} else { } else {
/* Here we need to find out which nexthop to be used*/ /* Here we need to find out which nexthop to be used*/
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { 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; break;
case AF_INET6: case AF_INET6:
if (is_bgp_static_route) { if (is_bgp_static_route) {
tmp_addr.p.u.prefix6 = rn->p.u.prefix6; tmp_addr.p.u.prefix6 = p->u.prefix6;
tmp_addr.p.prefixlen = rn->p.prefixlen; tmp_addr.p.prefixlen = p->prefixlen;
} else { } else {
tmp_addr.p.u.prefix6 = attr->mp_nexthop_global; tmp_addr.p.u.prefix6 = attr->mp_nexthop_global;
tmp_addr.p.prefixlen = IPV6_MAX_BITLEN; 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; for (rn = bgp_table_top(table[afi]); rn;
rn = bgp_route_next(rn)) { rn = bgp_route_next(rn)) {
struct peer *peer; struct peer *peer;
const struct prefix *p = bgp_node_get_prefix(rn);
bnc = bgp_node_get_bgp_nexthop_info(rn); bnc = bgp_node_get_bgp_nexthop_info(rn);
if (!bnc) 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)) { if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)) {
vty_out(vty, vty_out(vty,
" %s valid [IGP metric %d], #paths %d", " %s valid [IGP metric %d], #paths %d",
inet_ntop(rn->p.family, inet_ntop(p->family, &p->u.prefix, buf,
&rn->p.u.prefix, buf,
sizeof(buf)), sizeof(buf)),
bnc->metric, bnc->path_count); bnc->metric, bnc->path_count);
if (peer) if (peer)
@ -787,8 +787,7 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp, int detail,
} else { } else {
vty_out(vty, " %s invalid", vty_out(vty, " %s invalid",
inet_ntop(rn->p.family, inet_ntop(p->family, &p->u.prefix, buf,
&rn->p.u.prefix, buf,
sizeof(buf))); sizeof(buf)));
if (peer) if (peer)
vty_out(vty, ", peer %s", peer->host); 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 bgp_nexthop_cache *bnc;
struct prefix p; struct prefix p;
int is_bgp_static_route = 0; int is_bgp_static_route = 0;
const struct prefix *bnc_p;
if (pi) { if (pi) {
is_bgp_static_route = ((pi->type == ZEBRA_ROUTE_BGP) 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); bgp_unlock_node(rn);
if (is_bgp_static_route) { if (is_bgp_static_route) {
SET_FLAG(bnc->flags, 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) { if (bgp_route->inst_type == BGP_INSTANCE_TYPE_VIEW) {
SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED); SET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
SET_FLAG(bnc->flags, BGP_NEXTHOP_VALID); SET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
} else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED) && } else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)
!is_default_host_route(&bnc->node->p)) && !is_default_host_route(bnc_p))
register_zebra_rnh(bnc, is_bgp_static_route); register_zebra_rnh(bnc, is_bgp_static_route);
if (pi && pi->nexthop != bnc) { if (pi && pi->nexthop != bnc) {
@ -528,7 +531,7 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
? 1 ? 1
: 0; : 0;
struct bgp_node *net = pi->net; 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 (p_orig->family == AF_FLOWSPEC) {
if (!pi->peer) if (!pi->peer)
@ -541,8 +544,8 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
case AFI_IP: case AFI_IP:
p->family = AF_INET; p->family = AF_INET;
if (is_bgp_static) { if (is_bgp_static) {
p->u.prefix4 = pi->net->p.u.prefix4; p->u.prefix4 = p_orig->u.prefix4;
p->prefixlen = pi->net->p.prefixlen; p->prefixlen = p_orig->prefixlen;
} else { } else {
p->u.prefix4 = pi->attr->nexthop; p->u.prefix4 = pi->attr->nexthop;
p->prefixlen = IPV4_MAX_BITLEN; 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; p->family = AF_INET6;
if (is_bgp_static) { if (is_bgp_static) {
p->u.prefix6 = pi->net->p.u.prefix6; p->u.prefix6 = p_orig->u.prefix6;
p->prefixlen = pi->net->p.prefixlen; p->prefixlen = p_orig->prefixlen;
} else { } else {
p->u.prefix6 = pi->attr->mp_nexthop_global; p->u.prefix6 = pi->attr->mp_nexthop_global;
p->prefixlen = IPV6_MAX_BITLEN; 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) static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
{ {
struct prefix *p; const struct prefix *p;
bool exact_match = false; bool exact_match = false;
int ret; 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", "%s: We have not connected yet, cannot send nexthops",
__func__); __func__);
} }
p = &(bnc->node->p); p = bgp_node_get_prefix(bnc->node);
if ((command == ZEBRA_NEXTHOP_REGISTER if ((command == ZEBRA_NEXTHOP_REGISTER
|| command == ZEBRA_IMPORT_ROUTE_REGISTER) || command == ZEBRA_IMPORT_ROUTE_REGISTER)
&& (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED) && (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)
@ -691,6 +694,7 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
struct bgp_table *table; struct bgp_table *table;
safi_t safi; safi_t safi;
struct bgp *bgp_path; struct bgp *bgp_path;
const struct prefix *p;
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
@ -710,7 +714,8 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
rn = path->net; rn = path->net;
assert(rn && bgp_node_table(rn)); 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); table = bgp_node_table(rn);
safi = table->safi; safi = table->safi;
@ -744,27 +749,23 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
bgp_isvalid_nexthop(bnc) ? 1 : 0; bgp_isvalid_nexthop(bnc) ? 1 : 0;
} }
if (BGP_DEBUG(nht, NHT)) { if (BGP_DEBUG(nht, NHT))
char buf[PREFIX_STRLEN]; zlog_debug("%s: prefix %pRN (vrf %s) %svalid", __func__,
rn, bgp_path->name,
prefix2str(&rn->p, buf, PREFIX_STRLEN);
zlog_debug("%s: prefix %s (vrf %s) %svalid",
__func__, buf, bgp_path->name,
(bnc_is_valid_nexthop ? "" : "not ")); (bnc_is_valid_nexthop ? "" : "not "));
}
if ((CHECK_FLAG(path->flags, BGP_PATH_VALID) ? 1 : 0) if ((CHECK_FLAG(path->flags, BGP_PATH_VALID) ? 1 : 0)
!= bnc_is_valid_nexthop) { != bnc_is_valid_nexthop) {
if (CHECK_FLAG(path->flags, BGP_PATH_VALID)) { if (CHECK_FLAG(path->flags, BGP_PATH_VALID)) {
bgp_aggregate_decrement(bgp_path, &rn->p, bgp_aggregate_decrement(bgp_path, p, path, afi,
path, afi, safi); safi);
bgp_path_info_unset_flag(rn, path, bgp_path_info_unset_flag(rn, path,
BGP_PATH_VALID); BGP_PATH_VALID);
} else { } else {
bgp_path_info_set_flag(rn, path, bgp_path_info_set_flag(rn, path,
BGP_PATH_VALID); BGP_PATH_VALID);
bgp_aggregate_increment(bgp_path, &rn->p, bgp_aggregate_increment(bgp_path, p, path, afi,
path, afi, safi); safi);
} }
} }
@ -780,14 +781,13 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
|| CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED)) || CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED))
SET_FLAG(path->flags, BGP_PATH_IGP_CHANGED); SET_FLAG(path->flags, BGP_PATH_IGP_CHANGED);
if (safi == SAFI_EVPN && if (safi == SAFI_EVPN && bgp_evpn_is_prefix_nht_supported(p)) {
bgp_evpn_is_prefix_nht_supported(&rn->p)) {
if (CHECK_FLAG(path->flags, BGP_PATH_VALID)) if (CHECK_FLAG(path->flags, BGP_PATH_VALID))
bgp_evpn_import_route(bgp_path, afi, safi, bgp_evpn_import_route(bgp_path, afi, safi, p,
&rn->p, path); path);
else else
bgp_evpn_unimport_route(bgp_path, afi, safi, bgp_evpn_unimport_route(bgp_path, afi, safi, p,
&rn->p, path); path);
} }
bgp_process(bgp_path, rn, afi, safi); 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 #if ENABLE_BGP_VNC
/* type == RD_TYPE_VNC_ETH */ /* 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->type = RD_TYPE_VNC_ETH;
rd_vnc_eth->local_nve_id = pnt[1]; rd_vnc_eth->local_nve_id = pnt[1];
@ -159,9 +159,9 @@ out:
return lret; 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; uint16_t type;
struct rd_as rd_as; struct rd_as rd_as;
struct rd_ip rd_ip; 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_as4(const uint8_t *pnt, struct rd_as *rd_as);
extern void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip); extern void decode_rd_ip(const uint8_t *pnt, struct rd_ip *rd_ip);
#if ENABLE_BGP_VNC #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 #endif
extern int str2prefix_rd(const char *, struct prefix_rd *); 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, extern void form_auto_rd(struct in_addr router_id, uint16_t rd_id,
struct prefix_rd *prd); 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_delete(struct bgp *);
extern void bgp_static_redo_import_check(struct bgp *); extern void bgp_static_redo_import_check(struct bgp *);
extern void bgp_purge_static_redist_routes(struct bgp *bgp); extern void bgp_purge_static_redist_routes(struct bgp *bgp);
extern void bgp_static_update(struct bgp *, struct prefix *, extern void bgp_static_update(struct bgp *bgp, const struct prefix *p,
struct bgp_static *, afi_t, safi_t); struct bgp_static *s, afi_t afi, safi_t safi);
extern void bgp_static_withdraw(struct bgp *, struct prefix *, afi_t, safi_t); 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, extern int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
const char *, const char *, const char *, 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, extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t,
safi_t); safi_t);
extern void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi, extern void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p,
safi_t safi, struct bgp_aggregate *aggregate); afi_t afi, safi_t safi,
extern void bgp_aggregate_route(struct bgp *bgp, struct prefix *p, afi_t afi, struct bgp_aggregate *aggregate);
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, extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
struct bgp_path_info *path, afi_t afi, struct bgp_path_info *path, afi_t afi,
safi_t safi); 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, extern void route_vty_out_tag(struct vty *vty, const struct prefix *p,
struct bgp_path_info *path, int display, struct bgp_path_info *path, int display,
safi_t safi, json_object *json); 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, struct attr *attr, safi_t safi, bool use_json,
json_object *json_ar); json_object *json_ar);
extern void route_vty_out_overlay(struct vty *vty, const struct prefix *p, 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) route_map_object_t type, void *object)
{ {
struct prefix_rd *prd_rule = NULL; 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; struct bgp_path_info *path = NULL;
if (type == RMAP_BGP) { 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) if (path->net == NULL || path->net->prn == NULL)
return RMAP_NOMATCH; 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) if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
return RMAP_MATCH; 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; bgp_static->rmap.map = map;
if (route_update && !bgp_static->backdoor) { 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( zlog_debug(
"Processing route_map %s update on static route %s", "Processing route_map %s update on static route %s",
rmap_name, rmap_name,
inet_ntop(bn->p.family, inet_ntop(bn_p->family,
&bn->p.u.prefix, buf, &bn_p->u.prefix, buf,
INET6_ADDRSTRLEN)); INET6_ADDRSTRLEN));
bgp_static_update(bgp, &bn->p, bgp_static, afi, bgp_static_update(bgp, bn_p, bgp_static, afi,
safi); safi);
} }
} }
@ -3666,14 +3670,17 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
aggregate->rmap.map = map; aggregate->rmap.map = map;
if (route_update) { 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( zlog_debug(
"Processing route_map %s update on aggregate-address route %s", "Processing route_map %s update on aggregate-address route %s",
rmap_name, rmap_name,
inet_ntop(bn->p.family, inet_ntop(bn_p->family,
&bn->p.u.prefix, buf, &bn_p->u.prefix, buf,
INET6_ADDRSTRLEN)); INET6_ADDRSTRLEN));
bgp_aggregate_route(bgp, &bn->p, afi, safi, bgp_aggregate_route(bgp, bn_p, afi, safi,
aggregate); aggregate);
} }
} }

View File

@ -438,10 +438,10 @@ static void revalidate_bgp_node(struct bgp_node *bgp_node, afi_t afi,
label = path->extra->label; label = path->extra->label;
num_labels = path->extra->num_labels; num_labels = path->extra->num_labels;
} }
ret = bgp_update(ain->peer, &bgp_node->p, ain->addpath_rx_id, ret = bgp_update(ain->peer, bgp_node_get_prefix(bgp_node),
ain->attr, afi, safi, ZEBRA_ROUTE_BGP, ain->addpath_rx_id, ain->attr, afi, safi,
BGP_ROUTE_NORMAL, NULL, label, num_labels, 1, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
NULL); num_labels, 1, NULL);
if (ret < 0) if (ret < 0)
return; return;

View File

@ -761,20 +761,23 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
} }
if (min) { if (min) {
const struct prefix *rn_p =
bgp_node_get_prefix(rn);
*length = *length =
v->namelen + BGP_PATHATTR_ENTRY_OFFSET; v->namelen + BGP_PATHATTR_ENTRY_OFFSET;
offset = name + v->namelen; offset = name + v->namelen;
oid_copy_addr(offset, &rn->p.u.prefix4, oid_copy_addr(offset, &rn_p->u.prefix4,
IN_ADDR_SIZE); IN_ADDR_SIZE);
offset += IN_ADDR_SIZE; offset += IN_ADDR_SIZE;
*offset = rn->p.prefixlen; *offset = rn_p->prefixlen;
offset++; offset++;
oid_copy_addr(offset, oid_copy_addr(offset,
&min->peer->su.sin.sin_addr, &min->peer->su.sin.sin_addr,
IN_ADDR_SIZE); IN_ADDR_SIZE);
addr->prefix = rn->p.u.prefix4; addr->prefix = rn_p->u.prefix4;
addr->prefixlen = rn->p.prefixlen; addr->prefixlen = rn_p->prefixlen;
bgp_unlock_node(rn); 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, bgp_route_next_until_maxlen(struct bgp_node *node, const struct bgp_node *limit,
const uint8_t maxlen) const uint8_t maxlen)
{ {
if (node->l_left && node->p.prefixlen < maxlen const struct prefix *p = bgp_node_get_prefix(node);
&& node->l_left->p.prefixlen <= maxlen) {
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); 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); 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) if (node == NULL)
return; return;
while (node && const struct prefix *node_p = bgp_node_get_prefix(node);
node->p.prefixlen <= p->prefixlen && prefix_match(&node->p, p)) {
while (node && node_p->prefixlen <= p->prefixlen
&& prefix_match(node_p, p)) {
if (bgp_node_has_bgp_path_info_data(node) if (bgp_node_has_bgp_path_info_data(node)
&& node->p.prefixlen == p->prefixlen) { && node_p->prefixlen == p->prefixlen) {
matched = node; matched = node;
break; break;
} }
node = bgp_node_from_rnode(node->link[prefix_bit( 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) if (!node)
return; return;
if (matched == NULL && node->p.prefixlen <= maxlen node_p = bgp_node_get_prefix(node);
&& prefix_match(p, &node->p) && node->parent == NULL) if (matched == NULL && node_p->prefixlen <= maxlen
&& prefix_match(p, node_p) && node->parent == NULL)
matched = node; matched = node;
else if ((matched == NULL && node->p.prefixlen > maxlen) || !node->parent) else if ((matched == NULL && node_p->prefixlen > maxlen)
|| !node->parent)
return; return;
else if (matched == NULL && node->parent) else if (matched == NULL && node->parent)
matched = node = bgp_node_from_rnode(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))) { 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)) { if (bgp_node_has_bgp_path_info_data(node)) {
bgp_lock_node(node); bgp_lock_node(node);
listnode_add(matches, 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; return !!node->info;
} }
static inline const struct prefix *bgp_node_get_prefix(struct bgp_node *node)
{
return &node->p;
}
#endif /* _QUAGGA_BGP_TABLE_H */ #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); peer = UPDGRP_PEER(updgrp);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi); addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
if (BGP_DEBUG(update, UPDATE_OUT)) { if (BGP_DEBUG(update, UPDATE_OUT))
char buf_prefix[PREFIX_STRLEN]; zlog_debug("%s: afi=%s, safi=%s, p=%pRN", __func__,
prefix2str(&ctx->rn->p, buf_prefix, sizeof(buf_prefix)); afi2str(afi), safi2str(safi), ctx->rn);
zlog_debug("%s: afi=%s, safi=%s, p=%s", __func__, afi2str(afi),
safi2str(safi), buf_prefix);
}
UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) { UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
@ -242,7 +239,9 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
output_count = 0; 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) RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out)
if (adj->subgroup == subgrp) { if (adj->subgroup == subgrp) {
if (header1) { if (header1) {
@ -261,20 +260,20 @@ static void subgrp_show_adjq_vty(struct update_subgroup *subgrp,
} }
if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv if ((flags & UPDWALK_FLAGS_ADVQUEUE) && adj->adv
&& adj->adv->baa) { && adj->adv->baa) {
route_vty_out_tmp(vty, &rn->p, route_vty_out_tmp(
adj->adv->baa->attr, vty, rn_p, adj->adv->baa->attr,
SUBGRP_SAFI(subgrp), SUBGRP_SAFI(subgrp), 0, NULL);
0, NULL);
output_count++; output_count++;
} }
if ((flags & UPDWALK_FLAGS_ADVERTISED) if ((flags & UPDWALK_FLAGS_ADVERTISED)
&& adj->attr) { && adj->attr) {
route_vty_out_tmp( route_vty_out_tmp(vty, rn_p, adj->attr,
vty, &rn->p, adj->attr, SUBGRP_SAFI(subgrp),
SUBGRP_SAFI(subgrp), 0, NULL); 0, NULL);
output_count++; output_count++;
} }
} }
}
if (output_count != 0) if (output_count != 0)
vty_out(vty, "\nTotal number of prefixes %ld\n", output_count); 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)) PEER_FLAG_DEFAULT_ORIGINATE))
subgroup_default_originate(subgrp, 0); 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) for (ri = bgp_node_get_bgp_path_info(rn); ri; ri = ri->next)
if (CHECK_FLAG(ri->flags, BGP_PATH_SELECTED) 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], peer->addpath_type[afi][safi],
ri))) { ri))) {
if (subgroup_announce_check(rn, ri, subgrp, if (subgroup_announce_check(rn, ri, subgrp,
&rn->p, &attr)) rn_p, &attr))
bgp_adj_out_set_subgroup(rn, subgrp, bgp_adj_out_set_subgroup(rn, subgrp,
&attr, ri); &attr, ri);
else else
@ -642,6 +643,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
peer, afi, safi, peer, afi, safi,
&ri->tx_addpath)); &ri->tx_addpath));
} }
}
/* /*
* We walked through the whole table -- make sure our version number * 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; for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) { rn = bgp_route_next(rn)) {
ret = route_map_apply(peer->default_rmap[afi][safi].map, 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) if (ret != RMAP_DENYMATCH)
break; break;

View File

@ -726,8 +726,11 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
adv = bgp_adv_fifo_first(&subgrp->sync->update); adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) { while (adv) {
const struct prefix *rn_p;
assert(adv->rn); assert(adv->rn);
rn = adv->rn; rn = adv->rn;
rn_p = bgp_node_get_prefix(rn);
adj = adv->adj; adj = adv->adj;
addpath_tx_id = adj->addpath_tx_id; addpath_tx_id = adj->addpath_tx_id;
path = adv->pathi; 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)) space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW; - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = space_needed = BGP_NLRI_LENGTH + addpath_overhead
BGP_NLRI_LENGTH + addpath_overhead + bgp_packet_mpattr_prefix_size(afi, safi, rn_p);
+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);
/* When remaining space can't include NLRI and it's length. */ /* When remaining space can't include NLRI and it's length. */
if (space_remaining < space_needed) if (space_remaining < space_needed)
@ -798,7 +800,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
- BGP_MAX_PACKET_SIZE_OVERFLOW; - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = BGP_NLRI_LENGTH + addpath_overhead space_needed = BGP_NLRI_LENGTH + addpath_overhead
+ bgp_packet_mpattr_prefix_size( + bgp_packet_mpattr_prefix_size(
afi, safi, &rn->p); afi, safi, rn_p);
/* If the attributes alone do not leave any room for /* If the attributes alone do not leave any room for
* NLRI then * NLRI then
@ -828,12 +830,13 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
if ((afi == AFI_IP && safi == SAFI_UNICAST) if ((afi == AFI_IP && safi == SAFI_UNICAST)
&& !peer_cap_enhe(peer, afi, safi)) && !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); addpath_tx_id);
else { else {
/* Encode the prefix in MP_REACH_NLRI attribute */ /* Encode the prefix in MP_REACH_NLRI attribute */
if (rn->prn) 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) { if (safi == SAFI_LABELED_UNICAST) {
label = bgp_adv_label(rn, path, peer, afi, 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, snlri, peer, afi, safi, &vecarr,
adv->baa->attr); 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, label_pnt, num_labels,
addpath_encode, addpath_tx_id, addpath_encode, addpath_tx_id,
adv->baa->attr); adv->baa->attr);
@ -858,7 +861,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
num_pfx++; 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]; char pfx_buf[BGP_PRD_PATH_STRLEN];
if (!send_attr_printed) { if (!send_attr_printed) {
@ -882,10 +885,10 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
send_attr_printed = 1; send_attr_printed = 1;
} }
bgp_debug_rdpfxpath2str(afi, safi, prd, &rn->p, bgp_debug_rdpfxpath2str(afi, safi, prd, rn_p, label_pnt,
label_pnt, num_labels, num_labels, addpath_encode,
addpath_encode, addpath_tx_id, addpath_tx_id, pfx_buf,
pfx_buf, sizeof(pfx_buf)); sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s", zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s",
subgrp->update_group->id, subgrp->id, subgrp->update_group->id, subgrp->id,
pfx_buf); pfx_buf);
@ -964,7 +967,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
int addpath_encode = 0; int addpath_encode = 0;
int addpath_overhead = 0; int addpath_overhead = 0;
uint32_t addpath_tx_id = 0; uint32_t addpath_tx_id = 0;
struct prefix_rd *prd = NULL; const struct prefix_rd *prd = NULL;
if (!subgrp) if (!subgrp)
@ -982,16 +985,19 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0; addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) { while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
const struct prefix *rn_p;
assert(adv->rn); assert(adv->rn);
adj = adv->adj; adj = adv->adj;
rn = adv->rn; rn = adv->rn;
rn_p = bgp_node_get_prefix(rn);
addpath_tx_id = adj->addpath_tx_id; addpath_tx_id = adj->addpath_tx_id;
space_remaining = space_remaining =
STREAM_WRITEABLE(s) - BGP_MAX_PACKET_SIZE_OVERFLOW; STREAM_WRITEABLE(s) - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed = space_needed = BGP_NLRI_LENGTH + addpath_overhead
BGP_NLRI_LENGTH + addpath_overhead + BGP_TOTAL_ATTR_LEN + BGP_TOTAL_ATTR_LEN
+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p); + bgp_packet_mpattr_prefix_size(afi, safi, rn_p);
if (space_remaining < space_needed) if (space_remaining < space_needed)
break; break;
@ -1004,13 +1010,15 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
if (afi == AFI_IP && safi == SAFI_UNICAST if (afi == AFI_IP && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi)) && !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); addpath_tx_id);
else { else {
if (rn->prn) 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) { if (first_time) {
iana_afi_t pkt_afi; iana_afi_t pkt_afi;
iana_safi_t pkt_safi; iana_safi_t pkt_safi;
@ -1019,8 +1027,8 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
pkt_safi = safi_int2iana(safi); pkt_safi = safi_int2iana(safi);
attrlen_pos = stream_get_endp(s); attrlen_pos = stream_get_endp(s);
/* total attr length = 0 for now. reevaluate /* total attr length = 0 for now.
* later */ * reevaluate later */
stream_putw(s, 0); stream_putw(s, 0);
mp_start = stream_get_endp(s); mp_start = stream_get_endp(s);
mplen_pos = bgp_packet_mpunreach_start(s, afi, 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); 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, NULL, 0, addpath_encode,
addpath_tx_id, NULL); addpath_tx_id, NULL);
} }
num_pfx++; 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]; 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, addpath_encode, addpath_tx_id,
pfx_buf, sizeof(pfx_buf)); pfx_buf, sizeof(pfx_buf));
zlog_debug("u%" PRIu64 ":s%" PRIu64 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; for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next(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; continue;
table = bgp_node_get_bgp_table_info(rn); 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 #if ENABLE_BGP_VNC
struct rd_vnc_eth rd_vnc_eth = {0}; struct rd_vnc_eth rd_vnc_eth = {0};
#endif #endif
uint8_t *pnt; const uint8_t *pnt;
pnt = rn->p.u.val; pnt = rn_p->u.val;
/* Decode RD type. */ /* Decode RD type. */
type = decode_rd_type(pnt); type = decode_rd_type(pnt);
@ -221,9 +223,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
} }
rd_header = 0; rd_header = 0;
} }
route_vty_out_tmp(vty, &rm->p, attr, route_vty_out_tmp(vty, bgp_node_get_prefix(rm), attr,
safi, use_json, safi, use_json, json_routes);
json_routes);
output_count++; 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) { if (safi == SAFI_MPLS_VPN) {
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { 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; continue;
table = bgp_node_get_bgp_table_info(rn); table = bgp_node_get_bgp_table_info(rn);
if (table != NULL) { if (table == NULL)
continue;
if ((rm = bgp_node_match(table, &match)) if ((rm = bgp_node_match(table, &match)) != NULL) {
!= NULL) { const struct prefix *rm_p =
if (rm->p.prefixlen bgp_node_get_prefix(rm);
== match.prefixlen) {
if (rm_p->prefixlen == match.prefixlen) {
SET_FLAG(rm->flags, SET_FLAG(rm->flags,
BGP_NODE_USER_CLEAR); BGP_NODE_USER_CLEAR);
bgp_process(bgp, rm, afi, safi); 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); bgp_unlock_node(rm);
} }
} }
}
} else { } else {
if ((rn = bgp_node_match(rib, &match)) != NULL) { 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); SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR);
bgp_process(bgp, rn, afi, safi); 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)); prefix2str(p, buf_prefix, sizeof(buf_prefix));
if (safi == SAFI_FLOWSPEC) { 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; 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_NORMAL
|| pi->sub_type == BGP_ROUTE_IMPORTED))) || pi->sub_type == BGP_ROUTE_IMPORTED)))
bgp_zebra_announce(rn, &rn->p, pi, bgp, afi, bgp_zebra_announce(rn, bgp_node_get_prefix(rn),
safi); pi, bgp, afi, safi);
} }
void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info, 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))( safi))(
it, /* which import table */ it, /* which import table */
FIF_ACTION_UPDATE, bpi->peer, FIF_ACTION_UPDATE, bpi->peer,
NULL, &rn2->p, /* prefix */ NULL, bgp_node_get_prefix(rn2),
NULL, afi, NULL, afi,
(struct prefix_rd *)&rn1->p, (struct prefix_rd *)
bgp_node_get_prefix(
rn1),
bpi->attr, bpi->type, bpi->attr, bpi->type,
bpi->sub_type, &label); bpi->sub_type, &label);
} }

View File

@ -1273,7 +1273,7 @@ static void rfapiMonitorEthDetachImport(
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
char buf_prefix[PREFIX_STRLEN]; 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 #endif
/* /*

View File

@ -1813,7 +1813,8 @@ int rfapiRibFTDFilterRecentPrefix(
{ {
char buf_pfx[PREFIX_STRLEN]; 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); vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx);
} }
#endif #endif
@ -1994,7 +1995,8 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: RIB skiplist for this prefix follows", __func__); "%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 #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) { && ri->sub_type == BGP_ROUTE_REDISTRIBUTE) {
bgp_withdraw( bgp_withdraw(
ri->peer, &rn->p, /* prefix */ ri->peer, bgp_node_get_prefix(rn),
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* ignored */ NULL, /* ignored */
AFI_IP, SAFI_UNICAST, 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_table *table;
struct bgp_node *rn; struct bgp_node *rn;
struct bgp_path_info *ri; struct bgp_path_info *ri;
const struct prefix *prn_p = bgp_node_get_prefix(prn);
memset(&prd, 0, sizeof(prd)); memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; 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 */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); 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; continue;
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;
/* /*
* skip prefix list check if no routes here * 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)) if (!bgp_node_has_bgp_path_info_data(rn))
continue; continue;
{ vnc_zlog_debug_verbose("%s: checking prefix %pRN",
char prefixstr[PREFIX_STRLEN]; __func__, rn);
prefix2str(&rn->p, prefixstr, rn_p = bgp_node_get_prefix(rn);
sizeof(prefixstr));
vnc_zlog_debug_verbose("%s: checking prefix %s",
__func__, prefixstr);
}
/* /*
* prefix list check * prefix list check
*/ */
if (hc->plist_export_bgp[afi]) { if (hc->plist_export_bgp[afi]) {
if (prefix_list_apply(hc->plist_export_bgp[afi], if (prefix_list_apply(hc->plist_export_bgp[afi],
&rn->p) rn_p)
== PREFIX_DENY) { == PREFIX_DENY) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -1920,8 +1918,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
info.attr = &hattr; info.attr = &hattr;
ret = route_map_apply( ret = route_map_apply(
hc->routemap_export_bgp, hc->routemap_export_bgp,
&rn->p, RMAP_BGP, rn_p, RMAP_BGP, &info);
&info);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr); bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -1940,7 +1937,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
* this route * this route
*/ */
eti = vnc_eti_get( eti = vnc_eti_get(
bgp, EXPORT_TYPE_BGP, &rn->p, bgp, EXPORT_TYPE_BGP, rn_p,
ri->peer, ri->peer,
ZEBRA_ROUTE_VNC_DIRECT_RH, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE); BGP_ROUTE_REDISTRIBUTE);
@ -1961,8 +1958,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
"%s: calling bgp_update", "%s: calling bgp_update",
__func__); __func__);
bgp_update( bgp_update(ri->peer, rn_p, /* prefix */
ri->peer, &rn->p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
iattr, /* bgp_update copies iattr, /* bgp_update copies
it */ it */
@ -1973,7 +1969,8 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
NULL, NULL,
/* tag not used for unicast, /* tag not used for unicast,
or EVPN */ or EVPN */
0, 0, NULL); /* EVPN not used */ 0, 0,
NULL); /* EVPN not used */
bgp_attr_unintern(&iattr); 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; for (rn = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); rn;
rn = bgp_route_next(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 *ri;
struct bgp_path_info *next; 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) * Delete routes immediately (no timer)
*/ */
eti = vnc_eti_checktimer( 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, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE); BGP_ROUTE_REDISTRIBUTE);
if (eti) { if (eti) {
@ -2028,7 +2025,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
vnc_eti_delete(eti); vnc_eti_delete(eti);
} }
bgp_withdraw(ri->peer, &rn->p, /* prefix */ bgp_withdraw(ri->peer, rn_p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* ignored */ NULL, /* ignored */
AFI_IP, SAFI_UNICAST, 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, struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
vnc_export_type_t etype, vnc_export_type_t etype,
struct prefix *p, struct peer *peer, const struct prefix *p,
uint8_t type, uint8_t subtype) struct peer *peer, uint8_t type,
uint8_t subtype)
{ {
struct agg_node *etn; struct agg_node *etn;
struct vnc_export_info *eti; 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 void vnc_eti_delete(struct vnc_export_info *goner);
extern struct vnc_export_info * extern struct vnc_export_info *
vnc_eti_checktimer(struct bgp *bgp, vnc_export_type_t etype, struct prefix *p, vnc_eti_checktimer(struct bgp *bgp, vnc_export_type_t etype,
struct peer *peer, uint8_t type, uint8_t subtype); const struct prefix *p, struct peer *peer, uint8_t type,
uint8_t subtype);
#endif /* _QUAGGA_VNC_VNC_EXPORT_TABLE_H_ */ #endif /* _QUAGGA_VNC_VNC_EXPORT_TABLE_H_ */

View File

@ -674,8 +674,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
continue; continue;
vnc_import_bgp_add_route_mode_resolve_nve_one_rd( vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
(struct prefix_rd *)&bnp->p, table, afi, bgp, prefix, (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
ecom, &local_pref, med, &pfx_unicast_nexthop); 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; continue;
vnc_import_bgp_del_route_mode_resolve_nve_one_rd( vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
(struct prefix_rd *)&bnp->p, table, afi, bgp, prefix, (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
&pfx_unicast_nexthop); /* TBD how is this set? */ afi, bgp, prefix, &pfx_unicast_nexthop);
} }
if (ecom) 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)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; 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( 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)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_exterior_add_route(bgp_exterior, &rn->p, vnc_import_bgp_exterior_add_route(
bpi); bgp_exterior, bgp_node_get_prefix(rn), bpi);
} }
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -2842,7 +2844,8 @@ void vnc_import_bgp_exterior_redist_enable_it(
continue; continue;
vnc_import_bgp_exterior_add_route_it( 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; for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
rn1 = bgp_route_next(rn1)) { rn1 = bgp_route_next(rn1)) {
const struct prefix *rn1_p;
if (bgp_node_has_bgp_path_info_data(rn1)) { if (!bgp_node_has_bgp_path_info_data(rn1))
continue;
for (rn2 = bgp_table_top(
bgp_node_get_bgp_table_info(rn1));
rn2; rn2 = bgp_route_next(rn2)) {
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 *bpi;
struct bgp_path_info *nextbpi; struct bgp_path_info *nextbpi;
@ -2887,46 +2892,35 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
nextbpi = bpi->next; nextbpi = bpi->next;
if (bpi->type if (bpi->type != ZEBRA_ROUTE_BGP_DIRECT)
== ZEBRA_ROUTE_BGP_DIRECT) { continue;
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
vncHDBgpDirect.peer = bpi->peer; vncHDBgpDirect.peer = bpi->peer;
assert(bpi->extra); assert(bpi->extra);
rfd = bpi->extra->vnc.export rfd = bpi->extra->vnc.export.rfapi_handle;
.rfapi_handle;
vnc_zlog_debug_verbose( 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]", "%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, __func__, bpi, bpi->peer, bpi->type,
bpi->peer, bpi->type,
bpi->sub_type, bpi->sub_type,
(bpi->extra (bpi->extra ? bpi->extra->vnc.export
? bpi->extra
->vnc
.export
.rfapi_handle .rfapi_handle
: NULL), : NULL),
rfd); rfd);
del_vnc_route(rfd, bpi->peer, bgp,
del_vnc_route( SAFI_MPLS_VPN, rn2_p,
rfd, bpi->peer, bgp, (struct prefix_rd *)rn1_p,
SAFI_MPLS_VPN, &rn2->p, bpi->type, bpi->sub_type, NULL,
(struct prefix_rd *)&rn1
->p,
bpi->type,
bpi->sub_type, NULL,
1); /* kill */ 1); /* kill */
vncHDBgpDirect.peer = NULL; vncHDBgpDirect.peer = NULL;
} }
} }
} }
}
}
/* Clear RHN list */ /* Clear RHN list */
if (bgp->rfapi->resolve_nve_nexthop) { if (bgp->rfapi->resolve_nve_nexthop) {
struct prefix_bag *pb; 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)) if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue; continue;
vnc_import_bgp_exterior_del_route(bgp_exterior, vnc_import_bgp_exterior_del_route(
&rn->p, bpi); bgp_exterior, bgp_node_get_prefix(rn),
bpi);
} }
} }
#if DEBUG_RHN_LIST #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; for (prn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); prn;
prn = bgp_route_next(prn)) { prn = bgp_route_next(prn)) {
const struct prefix *prn_p = bgp_node_get_prefix(prn);
memset(&prd, 0, sizeof(prd)); memset(&prd, 0, sizeof(prd));
prd.family = AF_UNSPEC; prd.family = AF_UNSPEC;
prd.prefixlen = 64; 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 */ /* This is the per-RD table of prefixes */
table = bgp_node_get_bgp_table_info(prn); 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( del_vnc_route(
&vncHD1VR, /* use dummy ptr as cookie */ &vncHD1VR, /* use dummy ptr as cookie */
vncHD1VR.peer, bgp, SAFI_MPLS_VPN, vncHD1VR.peer, bgp, SAFI_MPLS_VPN,
&(rn->p), &prd, type, bgp_node_get_prefix(rn), &prd, type,
BGP_ROUTE_REDISTRIBUTE, NULL, 0); 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 int oid_compare(const oid *, int, const oid *, int);
extern void oid2in_addr(oid[], int, struct in_addr *); extern void oid2in_addr(oid[], int, struct in_addr *);
extern void *oid_copy(void *, const void *, size_t); 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 #ifdef __cplusplus
} }

View File

@ -64,10 +64,10 @@ void oid2in_addr(oid oid[], int len, struct in_addr *addr)
*pnt++ = oid[i]; *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; int i;
uint8_t *pnt; const uint8_t *pnt;
if (len == 0) if (len == 0)
return; return;

View File

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

View File

@ -196,7 +196,7 @@ extern int stream_put_prefix_addpath(struct stream *s,
int addpath_encode, int addpath_encode,
uint32_t addpath_tx_id); uint32_t addpath_tx_id);
extern int stream_put_prefix(struct stream *s, const struct prefix *p); 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, mpls_label_t *, int addpath_encode,
uint32_t addpath_tx_id); uint32_t addpath_tx_id);
extern void stream_get(void *, struct stream *, size_t); 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)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, bnode)) {
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
prefix2str(&bnode->p, buf, PREFIX2STR_BUFFER); prefix2str(bgp_node_get_prefix(bnode), buf, PREFIX2STR_BUFFER);
printf("%s\n", buf); printf("%s\n", buf);
} }
} }
@ -106,7 +106,7 @@ static void check_lookup_result(struct list *list, va_list arglist)
assert(0); assert(0);
for (ALL_LIST_ELEMENTS_RO(list, listnode, bnode)) { 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; found = true;
} }