bgpd, lib, ripngd: Add agg_node_get_prefix

Modify code to use lookup function agg_node_get_prefix()
as the abstraction layer.  When we rework bgp_node to
bgp_dest this will allow us to greatly limit the amount
of work needed to do that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2020-03-21 23:37:24 -04:00
parent 5a1ae2c237
commit 26a3ffd60e
17 changed files with 245 additions and 288 deletions

View file

@ -4028,7 +4028,7 @@ filtered:
return 0; return 0;
} }
int bgp_withdraw(struct peer *peer, struct prefix *p, uint32_t addpath_id, int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
struct attr *attr, afi_t afi, safi_t safi, int type, struct attr *attr, afi_t afi, safi_t safi, int type,
int sub_type, struct prefix_rd *prd, mpls_label_t *label, int sub_type, struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct bgp_route_evpn *evpn) uint32_t num_labels, struct bgp_route_evpn *evpn)

View file

@ -564,9 +564,11 @@ extern int bgp_update(struct peer *peer, const struct prefix *p,
struct prefix_rd *prd, mpls_label_t *label, struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, int soft_reconfig, uint32_t num_labels, int soft_reconfig,
struct bgp_route_evpn *evpn); struct bgp_route_evpn *evpn);
extern int bgp_withdraw(struct peer *, struct prefix *, uint32_t, struct attr *, extern int bgp_withdraw(struct peer *peer, const struct prefix *p,
afi_t, safi_t, int, int, struct prefix_rd *, uint32_t addpath_id, struct attr *attr, afi_t afi,
mpls_label_t *, uint32_t, struct bgp_route_evpn *); safi_t safi, int type, int sub_type,
struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, struct bgp_route_evpn *evpn);
/* for bgp_nexthop and bgp_damp */ /* for bgp_nexthop and bgp_damp */
extern void bgp_process(struct bgp *, struct bgp_node *, afi_t, safi_t); extern void bgp_process(struct bgp *, struct bgp_node *, afi_t, safi_t);

View file

@ -663,14 +663,17 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
* If no less-specific routes, try to use the 0/0 node * If no less-specific routes, try to use the 0/0 node
*/ */
if (!par) { if (!par) {
const struct prefix *p;
/* this isn't necessarily 0/0 */ /* this isn't necessarily 0/0 */
par = agg_route_table_top(original_vpn_node); par = agg_route_table_top(original_vpn_node);
if (par)
p = agg_node_get_prefix(par);
/* /*
* If we got the top node but it wasn't 0/0, * If we got the top node but it wasn't 0/0,
* ignore it * ignore it
*/ */
if (par && par->p.prefixlen) { if (par && p->prefixlen) {
agg_unlock_node(par); /* maybe free */ agg_unlock_node(par); /* maybe free */
par = NULL; par = NULL;
} }
@ -685,9 +688,10 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
*/ */
if (!par) { if (!par) {
struct prefix pfx_default; struct prefix pfx_default;
const struct prefix *p = agg_node_get_prefix(original_vpn_node);
memset(&pfx_default, 0, sizeof(pfx_default)); memset(&pfx_default, 0, sizeof(pfx_default));
pfx_default.family = original_vpn_node->p.family; pfx_default.family = p->family;
/* creates default node if none exists */ /* creates default node if none exists */
par = agg_node_get(agg_get_table(original_vpn_node), par = agg_node_get(agg_get_table(original_vpn_node),
@ -768,6 +772,7 @@ static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node)
struct rfapi_monitor_vpn *mlast; struct rfapi_monitor_vpn *mlast;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct agg_node *par; struct agg_node *par;
const struct prefix *new_vpn_node_p = agg_node_get_prefix(new_vpn_node);
RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0); RFAPI_CHECK_REFCOUNT(new_vpn_node, SAFI_MPLS_VPN, 0);
@ -808,12 +813,11 @@ static void rfapiMonitorMoveLonger(struct agg_node *new_vpn_node)
* specific updated node * specific updated node
*/ */
for (mlast = NULL, monitor = RFAPI_MONITOR_VPN(par); monitor;) { for (mlast = NULL, monitor = RFAPI_MONITOR_VPN(par); monitor;) {
/* /*
* If new longest match for monitor prefix is the new * If new longest match for monitor prefix is the new
* route's prefix, move monitor to new route's prefix * route's prefix, move monitor to new route's prefix
*/ */
if (prefix_match(&new_vpn_node->p, &monitor->p)) { if (prefix_match(new_vpn_node_p, &monitor->p)) {
/* detach */ /* detach */
if (mlast) { if (mlast) {
mlast->next = monitor->next; mlast->next = monitor->next;
@ -1266,6 +1270,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
{ {
struct rfapi_next_hop_entry *new; struct rfapi_next_hop_entry *new;
int have_vnc_tunnel_un = 0; int have_vnc_tunnel_un = 0;
const struct prefix *p = agg_node_get_prefix(rn);
#ifdef DEBUG_ENCAP_MONITOR #ifdef DEBUG_ENCAP_MONITOR
vnc_zlog_debug_verbose("%s: entry, bpi %p, rn %p", __func__, bpi, rn); vnc_zlog_debug_verbose("%s: entry, bpi %p, rn %p", __func__, bpi, rn);
@ -1289,8 +1294,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR; vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR;
memcpy(&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet, memcpy(&vo->v.l2addr.macaddr, &p->u.prefix_eth.octet, ETH_ALEN);
ETH_ALEN);
/* only low 3 bytes of this are significant */ /* only low 3 bytes of this are significant */
(void)rfapiEcommunityGetLNI(bpi->attr->ecommunity, (void)rfapiEcommunityGetLNI(bpi->attr->ecommunity,
&vo->v.l2addr.logical_net_id); &vo->v.l2addr.logical_net_id);
@ -1493,7 +1497,8 @@ static int rfapiNhlAddNodeRoutes(
struct prefix pfx_un; struct prefix pfx_un;
struct skiplist *seen_nexthops; struct skiplist *seen_nexthops;
int count = 0; int count = 0;
int is_l2 = (rn->p.family == AF_ETHERNET); const struct prefix *p = agg_node_get_prefix(rn);
int is_l2 = (p->family == AF_ETHERNET);
if (rfd_rib_node) { if (rfd_rib_node) {
struct agg_table *atable = agg_get_table(rfd_rib_node); struct agg_table *atable = agg_get_table(rfd_rib_node);
@ -1626,14 +1631,14 @@ static int rfapiNhlAddSubtree(
* hands in node->link */ * hands in node->link */
if (agg_node_left(rn) && agg_node_left(rn) != omit_node) { if (agg_node_left(rn) && agg_node_left(rn) != omit_node) {
if (agg_node_left(rn)->info) { if (agg_node_left(rn)->info) {
const struct prefix *p =
agg_node_get_prefix(agg_node_left(rn));
int count = 0; int count = 0;
struct agg_node *rib_rn = NULL; struct agg_node *rib_rn = NULL;
rfapiQprefix2Rprefix(&agg_node_left(rn)->p, &rprefix); rfapiQprefix2Rprefix(p, &rprefix);
if (rfd_rib_table) { if (rfd_rib_table)
rib_rn = agg_node_get(rfd_rib_table, rib_rn = agg_node_get(rfd_rib_table, p);
&agg_node_left(rn)->p);
}
count = rfapiNhlAddNodeRoutes( count = rfapiNhlAddNodeRoutes(
agg_node_left(rn), &rprefix, lifetime, 0, head, agg_node_left(rn), &rprefix, lifetime, 0, head,
@ -1653,14 +1658,15 @@ static int rfapiNhlAddSubtree(
if (agg_node_right(rn) && agg_node_right(rn) != omit_node) { if (agg_node_right(rn) && agg_node_right(rn) != omit_node) {
if (agg_node_right(rn)->info) { if (agg_node_right(rn)->info) {
const struct prefix *p =
agg_node_get_prefix(agg_node_right(rn));
int count = 0; int count = 0;
struct agg_node *rib_rn = NULL; struct agg_node *rib_rn = NULL;
rfapiQprefix2Rprefix(&agg_node_right(rn)->p, &rprefix); rfapiQprefix2Rprefix(p, &rprefix);
if (rfd_rib_table) { if (rfd_rib_table)
rib_rn = agg_node_get(rfd_rib_table, rib_rn = agg_node_get(rfd_rib_table, p);
&agg_node_right(rn)->p);
}
count = rfapiNhlAddNodeRoutes( count = rfapiNhlAddNodeRoutes(
agg_node_right(rn), &rprefix, lifetime, 0, head, agg_node_right(rn), &rprefix, lifetime, 0, head,
tail, exclude_vnaddr, rib_rn, tail, exclude_vnaddr, rib_rn,
@ -1712,23 +1718,18 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
struct rfapi_next_hop_entry *answer = NULL; struct rfapi_next_hop_entry *answer = NULL;
struct rfapi_next_hop_entry *last = NULL; struct rfapi_next_hop_entry *last = NULL;
struct agg_node *parent; struct agg_node *parent;
const struct prefix *p = agg_node_get_prefix(rn);
int count = 0; int count = 0;
struct agg_node *rib_rn; struct agg_node *rib_rn;
#ifdef DEBUG_RETURNED_NHL #ifdef DEBUG_RETURNED_NHL
{ vnc_zlog_debug_verbose("%s: called with node pfx=%rRN", __func__, rn);
char buf[PREFIX_STRLEN];
prefix2str(&rn->p, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__,
buf);
}
rfapiDebugBacktrace(); rfapiDebugBacktrace();
#endif #endif
rfapiQprefix2Rprefix(&rn->p, &rprefix); rfapiQprefix2Rprefix(p, &rprefix);
rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL; rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, p) : NULL;
/* /*
* Add non-withdrawn routes at this node * Add non-withdrawn routes at this node
@ -1780,9 +1781,10 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
* Add non-withdrawn routes from less-specific prefix * Add non-withdrawn routes from less-specific prefix
*/ */
if (parent) { if (parent) {
rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &parent->p) const struct prefix *p = agg_node_get_prefix(parent);
: NULL;
rfapiQprefix2Rprefix(&parent->p, &rprefix); rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, p) : NULL;
rfapiQprefix2Rprefix(p, &rprefix);
count += rfapiNhlAddNodeRoutes(parent, &rprefix, lifetime, 0, count += rfapiNhlAddNodeRoutes(parent, &rprefix, lifetime, 0,
&answer, &last, exclude_vnaddr, &answer, &last, exclude_vnaddr,
rib_rn, pfx_target_original); rib_rn, pfx_target_original);
@ -1863,7 +1865,9 @@ struct rfapi_next_hop_entry *rfapiEthRouteNode2NextHopList(
struct rfapi_next_hop_entry *last = NULL; struct rfapi_next_hop_entry *last = NULL;
struct agg_node *rib_rn; struct agg_node *rib_rn;
rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, &rn->p) : NULL; rib_rn = rfd_rib_table
? agg_node_get(rfd_rib_table, agg_node_get_prefix(rn))
: NULL;
count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last, count = rfapiNhlAddNodeRoutes(rn, rprefix, lifetime, 0, &answer, &last,
NULL, rib_rn, pfx_target_original); NULL, rib_rn, pfx_target_original);
@ -2090,6 +2094,7 @@ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */
struct bgp_path_info *bpi) /* new BPI */ struct bgp_path_info *bpi) /* new BPI */
{ {
struct skiplist *sl; struct skiplist *sl;
const struct prefix *p;
assert(rn); assert(rn);
assert(bpi); assert(bpi);
@ -2106,7 +2111,8 @@ static void rfapiItBiIndexAdd(struct agg_node *rn, /* Import table VPN node */
sl = RFAPI_RDINDEX_W_ALLOC(rn); sl = RFAPI_RDINDEX_W_ALLOC(rn);
if (!sl) { if (!sl) {
if (AF_ETHERNET == rn->p.family) { p = agg_node_get_prefix(rn);
if (AF_ETHERNET == p->family) {
sl = skiplist_new(0, rfapi_bi_peer_rd_aux_cmp, NULL); sl = skiplist_new(0, rfapi_bi_peer_rd_aux_cmp, NULL);
} else { } else {
sl = skiplist_new(0, rfapi_bi_peer_rd_cmp, NULL); sl = skiplist_new(0, rfapi_bi_peer_rd_cmp, NULL);
@ -2376,7 +2382,7 @@ static int rfapiWithdrawTimerVPN(struct thread *t)
struct rfapi_withdraw *wcb = t->arg; struct rfapi_withdraw *wcb = t->arg;
struct bgp_path_info *bpi = wcb->info; struct bgp_path_info *bpi = wcb->info;
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
const struct prefix *p;
struct rfapi_monitor_vpn *moved; struct rfapi_monitor_vpn *moved;
afi_t afi; afi_t afi;
@ -2399,15 +2405,8 @@ static int rfapiWithdrawTimerVPN(struct thread *t)
RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, wcb->lockoffset); RFAPI_CHECK_REFCOUNT(wcb->node, SAFI_MPLS_VPN, wcb->lockoffset);
{ vnc_zlog_debug_verbose("%s: removing bpi %p at prefix %pRN", __func__,
char buf[BUFSIZ]; bpi, wcb->node);
vnc_zlog_debug_verbose(
"%s: removing bpi %p at prefix %s/%d", __func__, bpi,
rfapi_ntop(wcb->node->p.family, &wcb->node->p.u.prefix,
buf, BUFSIZ),
wcb->node->p.prefixlen);
}
/* /*
* Remove the route (doubly-linked) * Remove the route (doubly-linked)
@ -2416,7 +2415,8 @@ static int rfapiWithdrawTimerVPN(struct thread *t)
&& VALID_INTERIOR_TYPE(bpi->type)) && VALID_INTERIOR_TYPE(bpi->type))
RFAPI_MONITOR_EXTERIOR(wcb->node)->valid_interior_count--; RFAPI_MONITOR_EXTERIOR(wcb->node)->valid_interior_count--;
afi = family2afi(wcb->node->p.family); p = agg_node_get_prefix(wcb->node);
afi = family2afi(p->family);
wcb->import_table->holddown_count[afi] -= 1; /* keep count consistent */ wcb->import_table->holddown_count[afi] -= 1; /* keep count consistent */
rfapiItBiIndexDel(wcb->node, bpi); rfapiItBiIndexDel(wcb->node, bpi);
rfapiBgpInfoDetach(wcb->node, bpi); /* with removed bpi */ rfapiBgpInfoDetach(wcb->node, bpi); /* with removed bpi */
@ -3077,11 +3077,8 @@ static void rfapiBgpInfoFilteredImportEncap(
if (action == FIF_ACTION_WITHDRAW) { if (action == FIF_ACTION_WITHDRAW) {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: withdrawing at prefix %s/%d", "%s: withdrawing at prefix %pRN",
__func__, __func__, rn);
inet_ntop(rn->p.family, &rn->p.u.prefix,
buf, BUFSIZ),
rn->p.prefixlen);
rfapiBiStartWithdrawTimer( rfapiBiStartWithdrawTimer(
import_table, rn, bpi, afi, SAFI_ENCAP, import_table, rn, bpi, afi, SAFI_ENCAP,
@ -3089,13 +3086,11 @@ static void rfapiBgpInfoFilteredImportEncap(
} else { } else {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: %s at prefix %s/%d", __func__, "%s: %s at prefix %pRN", __func__,
((action == FIF_ACTION_KILL) ((action == FIF_ACTION_KILL)
? "killing" ? "killing"
: "replacing"), : "replacing"),
inet_ntop(rn->p.family, &rn->p.u.prefix, rn);
buf, BUFSIZ),
rn->p.prefixlen);
/* /*
* If this route is waiting to be deleted * If this route is waiting to be deleted
@ -3163,10 +3158,8 @@ static void rfapiBgpInfoFilteredImportEncap(
rn = agg_node_get(rt, p); rn = agg_node_get(rt, p);
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose("%s: (afi=%d, rn=%p) inserting at prefix %pRN",
"%s: (afi=%d, rn=%p) inserting at prefix %s/%d", __func__, afi, __func__, afi, rn, rn);
rn, inet_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ),
rn->p.prefixlen);
rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_ENCAP); rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_ENCAP);
@ -3249,6 +3242,7 @@ static void rfapiBgpInfoFilteredImportEncap(
__func__, rn); __func__, rn);
#endif #endif
for (m = RFAPI_MONITOR_ENCAP(rn); m; m = m->next) { for (m = RFAPI_MONITOR_ENCAP(rn); m; m = m->next) {
const struct prefix *p;
/* /*
* For each referenced bpi/route, copy the ENCAP route's * For each referenced bpi/route, copy the ENCAP route's
@ -3276,9 +3270,9 @@ static void rfapiBgpInfoFilteredImportEncap(
* list * list
* per prefix. * per prefix.
*/ */
p = agg_node_get_prefix(m->node);
referenced_vpn_prefix = referenced_vpn_prefix =
agg_node_get(referenced_vpn_table, &m->node->p); agg_node_get(referenced_vpn_table, p);
assert(referenced_vpn_prefix); assert(referenced_vpn_prefix);
for (mnext = referenced_vpn_prefix->info; mnext; for (mnext = referenced_vpn_prefix->info; mnext;
mnext = mnext->next) { mnext = mnext->next) {
@ -3528,11 +3522,8 @@ void rfapiBgpInfoFilteredImportVPN(
BGP_PATH_REMOVED); BGP_PATH_REMOVED);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: withdrawing at prefix %s/%d%s", "%s: withdrawing at prefix %pRN%s",
__func__, rfapi_ntop(rn->p.family, __func__, rn,
&rn->p.u.prefix,
buf, BUFSIZ),
rn->p.prefixlen,
(washolddown (washolddown
? " (already being withdrawn)" ? " (already being withdrawn)"
: "")); : ""));
@ -3551,14 +3542,11 @@ void rfapiBgpInfoFilteredImportVPN(
VNC_ITRCCK; VNC_ITRCCK;
} else { } else {
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: %s at prefix %s/%d", __func__, "%s: %s at prefix %pRN", __func__,
((action == FIF_ACTION_KILL) ((action == FIF_ACTION_KILL)
? "killing" ? "killing"
: "replacing"), : "replacing"),
rfapi_ntop(rn->p.family, rn);
&rn->p.u.prefix, buf,
BUFSIZ),
rn->p.prefixlen);
/* /*
* If this route is waiting to be deleted * If this route is waiting to be deleted
@ -3676,10 +3664,8 @@ void rfapiBgpInfoFilteredImportVPN(
info_new->extra->vnc.import.aux_prefix = *aux_prefix; info_new->extra->vnc.import.aux_prefix = *aux_prefix;
} }
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose("%s: inserting bpi %p at prefix %pRN #%d",
"%s: inserting bpi %p at prefix %s/%d #%d", __func__, info_new, __func__, info_new, rn, rn->lock);
rfapi_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ),
rn->p.prefixlen, rn->lock);
rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_MPLS_VPN); rfapiBgpInfoAttachSorted(rn, info_new, afi, SAFI_MPLS_VPN);
rfapiItBiIndexAdd(rn, info_new); rfapiItBiIndexAdd(rn, info_new);
@ -4447,27 +4433,20 @@ static void rfapiDeleteRemotePrefixesIt(
for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct bgp_path_info *next; struct bgp_path_info *next;
const struct prefix *rn_p = agg_node_get_prefix(rn);
if (p && VNC_DEBUG(IMPORT_DEL_REMOTE)) { if (p && VNC_DEBUG(IMPORT_DEL_REMOTE)) {
char p1line[PREFIX_STRLEN]; char p1line[PREFIX_STRLEN];
char p2line[PREFIX_STRLEN];
prefix2str(p, p1line, sizeof(p1line)); prefix2str(p, p1line, sizeof(p1line));
prefix2str(&rn->p, p2line, sizeof(p2line)); vnc_zlog_debug_any("%s: want %s, have %pRN",
vnc_zlog_debug_any("%s: want %s, have %s", __func__, p1line, rn);
__func__, p1line, p2line);
} }
if (p && prefix_cmp(p, &rn->p)) if (p && prefix_cmp(p, rn_p))
continue; continue;
{ vnc_zlog_debug_verbose("%s: rn pfx=%pRN", __func__, rn);
char buf_pfx[PREFIX_STRLEN];
prefix2str(&rn->p, buf_pfx, sizeof(buf_pfx));
vnc_zlog_debug_verbose("%s: rn pfx=%s",
__func__, buf_pfx);
}
/* TBD is this valid for afi == AFI_L2VPN? */ /* TBD is this valid for afi == AFI_L2VPN? */
RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1); RFAPI_CHECK_REFCOUNT(rn, SAFI_MPLS_VPN, 1);
@ -4599,7 +4578,7 @@ static void rfapiDeleteRemotePrefixesIt(
} }
} }
vnc_direct_bgp_rh_del_route(bgp, afi, &rn->p, vnc_direct_bgp_rh_del_route(bgp, afi, rn_p,
bpi->peer); bpi->peer);
RFAPI_UPDATE_ITABLE_COUNT(bpi, it, afi, -1); RFAPI_UPDATE_ITABLE_COUNT(bpi, it, afi, -1);

View file

@ -789,7 +789,8 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
* been responsible for the response, i.e., any monitors for * been responsible for the response, i.e., any monitors for
* the exact prefix or a parent of it. * the exact prefix or a parent of it.
*/ */
void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p) void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd,
const struct prefix *p)
{ {
struct agg_node *rn; struct agg_node *rn;
@ -818,12 +819,14 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
for (rn = agg_route_top(rfd->mon); rn; for (rn = agg_route_top(rfd->mon); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
const struct prefix *p_node;
if (!((m = rn->info))) if (!((m = rn->info)))
continue; continue;
p_node = agg_node_get_prefix(m->node);
/* NB order of test is significant ! */ /* NB order of test is significant ! */
if (!m->node || prefix_match(&m->node->p, p)) { if (!m->node || prefix_match(p_node, p)) {
rfapiMonitorTimerRestart(m); rfapiMonitorTimerRestart(m);
} }
} }
@ -841,7 +844,8 @@ void rfapiMonitorItNodeChanged(
struct skiplist *nves_seen; struct skiplist *nves_seen;
struct agg_node *rn = it_node; struct agg_node *rn = it_node;
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
afi_t afi = family2afi(rn->p.family); const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
char buf_prefix[PREFIX_STRLEN]; char buf_prefix[PREFIX_STRLEN];
#endif #endif
@ -931,17 +935,14 @@ void rfapiMonitorItNodeChanged(
assert(!skiplist_insert(nves_seen, assert(!skiplist_insert(nves_seen,
m->rfd, NULL)); m->rfd, NULL));
char buf_attach_pfx[PREFIX_STRLEN];
char buf_target_pfx[PREFIX_STRLEN]; char buf_target_pfx[PREFIX_STRLEN];
prefix2str(&m->node->p, buf_attach_pfx,
sizeof(buf_attach_pfx));
prefix2str(&m->p, buf_target_pfx, prefix2str(&m->p, buf_target_pfx,
sizeof(buf_target_pfx)); sizeof(buf_target_pfx));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: update rfd %p attached to pfx %s (targ=%s)", "%s: update rfd %p attached to pfx %pRN (targ=%s)",
__func__, m->rfd, __func__, m->rfd, m->node,
buf_attach_pfx, buf_target_pfx); buf_target_pfx);
/* /*
* update its RIB * update its RIB

View file

@ -167,7 +167,7 @@ extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp);
extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn); extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn);
extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd,
struct prefix *p); const struct prefix *p);
extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table, extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table,
struct agg_node *it_node, struct agg_node *it_node,

View file

@ -272,9 +272,6 @@ struct rfapi {
? ((prefix)->prefixlen == 128) \ ? ((prefix)->prefixlen == 128) \
: 0)) : 0))
extern void rfapiQprefix2Rprefix(struct prefix *qprefix,
struct rfapi_ip_prefix *rprefix);
extern int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr, extern int rfapi_find_rfd(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
struct rfapi_ip_addr *un_addr, struct rfapi_ip_addr *un_addr,
struct rfapi_descriptor **rfd); struct rfapi_descriptor **rfd);

View file

@ -340,7 +340,6 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
{ {
struct thread *t = ri->timer; struct thread *t = ri->timer;
struct rfapi_rib_tcb *tcb = NULL; struct rfapi_rib_tcb *tcb = NULL;
char buf_prefix[PREFIX_STRLEN];
if (t) { if (t) {
tcb = t->arg; tcb = t->arg;
@ -361,9 +360,8 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
UNSET_FLAG(tcb->flags, RFAPI_RIB_TCB_FLAG_DELETED); UNSET_FLAG(tcb->flags, RFAPI_RIB_TCB_FLAG_DELETED);
} }
prefix2str(&rn->p, buf_prefix, sizeof(buf_prefix)); vnc_zlog_debug_verbose("%s: rfd %p pfx %pRN life %u", __func__, rfd, rn,
vnc_zlog_debug_verbose("%s: rfd %p pfx %s life %u", __func__, rfd, ri->lifetime);
buf_prefix, ri->lifetime);
ri->timer = NULL; ri->timer = NULL;
thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, ri->lifetime, thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, ri->lifetime,
&ri->timer); &ri->timer);
@ -741,11 +739,12 @@ int rfapiRibPreloadBi(
struct rfapi_rib_key rk; struct rfapi_rib_key rk;
struct agg_node *trn; struct agg_node *trn;
afi_t afi; afi_t afi;
const struct prefix *p = agg_node_get_prefix(rfd_rib_node);
if (!rfd_rib_node) if (!rfd_rib_node)
return 0; return 0;
afi = family2afi(rfd_rib_node->p.family); afi = family2afi(p->family);
rfd = agg_get_table_info(agg_get_table(rfd_rib_node)); rfd = agg_get_table_info(agg_get_table(rfd_rib_node));
@ -803,8 +802,7 @@ int rfapiRibPreloadBi(
/* /*
* Update last sent time for prefix * Update last sent time for prefix
*/ */
trn = agg_node_get(rfd->rsp_times[afi], trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
&rfd_rib_node->p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock(); trn->info = (void *)(uintptr_t)bgp_clock();
if (trn->lock > 1) if (trn->lock > 1)
agg_unlock_node(trn); agg_unlock_node(trn);
@ -852,10 +850,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
struct list *lPendCost = NULL; struct list *lPendCost = NULL;
struct list *delete_list = NULL; struct list *delete_list = NULL;
int printedprefix = 0; int printedprefix = 0;
char buf_prefix[PREFIX_STRLEN];
int rib_node_started_nonempty = 0; int rib_node_started_nonempty = 0;
int sendingsomeroutes = 0; int sendingsomeroutes = 0;
const struct prefix *p;
#if DEBUG_PROCESS_PENDING_NODE #if DEBUG_PROCESS_PENDING_NODE
unsigned int count_rib_initial = 0; unsigned int count_rib_initial = 0;
unsigned int count_pend_vn_initial = 0; unsigned int count_pend_vn_initial = 0;
@ -863,12 +860,12 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
#endif #endif
assert(pn); assert(pn);
prefix2str(&pn->p, buf_prefix, sizeof(buf_prefix)); p = agg_node_get_prefix(pn);
vnc_zlog_debug_verbose("%s: afi=%d, %s pn->info=%p", __func__, afi, vnc_zlog_debug_verbose("%s: afi=%d, %pRN pn->info=%p", __func__, afi,
buf_prefix, pn->info); pn, pn->info);
if (AFI_L2VPN != afi) { if (AFI_L2VPN != afi) {
rfapiQprefix2Rprefix(&pn->p, &hp); rfapiQprefix2Rprefix(p, &hp);
} }
RFAPI_RIB_CHECK_COUNTS(1, 0); RFAPI_RIB_CHECK_COUNTS(1, 0);
@ -876,7 +873,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
/* /*
* Find corresponding RIB node * Find corresponding RIB node
*/ */
rn = agg_node_get(rfd->rib[afi], &pn->p); /* locks rn */ rn = agg_node_get(rfd->rib[afi], p); /* locks rn */
/* /*
* RIB skiplist has key=rfapi_addr={vn,un}, val = rfapi_info, * RIB skiplist has key=rfapi_addr={vn,un}, val = rfapi_info,
@ -935,9 +932,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
prefix2str(&ri->rk.vn, buf, sizeof(buf)); prefix2str(&ri->rk.vn, buf, sizeof(buf));
prefix2str(&ri->un, buf2, sizeof(buf2)); prefix2str(&ri->un, buf2, sizeof(buf2));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: put dl pfx=%s vn=%s un=%s cost=%d life=%d vn_options=%p", "%s: put dl pfx=%pRN vn=%s un=%s cost=%d life=%d vn_options=%p",
__func__, buf_prefix, buf, buf2, __func__, pn, buf, buf2, ri->cost,
ri->cost, ri->lifetime, ri->vn_options); ri->lifetime, ri->vn_options);
skiplist_delete_first(slRibPt); skiplist_delete_first(slRibPt);
} }
@ -1186,8 +1183,7 @@ callback:
vnc_zlog_debug_verbose("%s: lPendCost->count now %d", __func__, vnc_zlog_debug_verbose("%s: lPendCost->count now %d", __func__,
lPendCost->count); lPendCost->count);
vnc_zlog_debug_verbose("%s: For prefix %s (a)", __func__, vnc_zlog_debug_verbose("%s: For prefix %pRN (a)", __func__, pn);
buf_prefix);
printedprefix = 1; printedprefix = 1;
for (ALL_LIST_ELEMENTS(lPendCost, node, nnode, ri)) { for (ALL_LIST_ELEMENTS(lPendCost, node, nnode, ri)) {
@ -1246,7 +1242,7 @@ callback:
* update this NVE's timestamp for this prefix * update this NVE's timestamp for this prefix
*/ */
trn = agg_node_get(rfd->rsp_times[afi], trn = agg_node_get(rfd->rsp_times[afi],
&pn->p); /* locks trn */ p); /* locks trn */
trn->info = (void *)(uintptr_t)bgp_clock(); trn->info = (void *)(uintptr_t)bgp_clock();
if (trn->lock > 1) if (trn->lock > 1)
agg_unlock_node(trn); agg_unlock_node(trn);
@ -1268,8 +1264,8 @@ callback:
char buf2[BUFSIZ]; char buf2[BUFSIZ];
if (!printedprefix) { if (!printedprefix) {
vnc_zlog_debug_verbose("%s: For prefix %s (d)", vnc_zlog_debug_verbose("%s: For prefix %pRN (d)",
__func__, buf_prefix); __func__, pn);
} }
vnc_zlog_debug_verbose("%s: delete_list has %d elements", vnc_zlog_debug_verbose("%s: delete_list has %d elements",
__func__, delete_list->count); __func__, delete_list->count);
@ -1465,7 +1461,7 @@ callback:
} }
if (sendingsomeroutes) if (sendingsomeroutes)
rfapiMonitorTimersRestart(rfd, &pn->p); rfapiMonitorTimersRestart(rfd, p);
agg_unlock_node(rn); /* agg_node_get() */ agg_unlock_node(rn); /* agg_node_get() */
@ -1589,7 +1585,7 @@ void rfapiRibUpdatePendingNode(
struct rfapi_import_table *it, /* needed for L2 */ struct rfapi_import_table *it, /* needed for L2 */
struct agg_node *it_node, uint32_t lifetime) struct agg_node *it_node, uint32_t lifetime)
{ {
struct prefix *prefix; const struct prefix *prefix;
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct agg_node *pn; struct agg_node *pn;
afi_t afi; afi_t afi;
@ -1606,7 +1602,7 @@ void rfapiRibUpdatePendingNode(
RFAPI_RIB_CHECK_COUNTS(1, 0); RFAPI_RIB_CHECK_COUNTS(1, 0);
prefix = &it_node->p; prefix = agg_node_get_prefix(it_node);
afi = family2afi(prefix->family); afi = family2afi(prefix->family);
prefix2str(prefix, buf, sizeof(buf)); prefix2str(prefix, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf); vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf);
@ -1794,7 +1790,8 @@ int rfapiRibFTDFilterRecentPrefix(
struct prefix *pfx_target_original) /* query target */ struct prefix *pfx_target_original) /* query target */
{ {
struct bgp *bgp = rfd->bgp; struct bgp *bgp = rfd->bgp;
afi_t afi = family2afi(it_rn->p.family); const struct prefix *p = agg_node_get_prefix(it_rn);
afi_t afi = family2afi(p->family);
time_t prefix_time; time_t prefix_time;
struct agg_node *trn; struct agg_node *trn;
@ -1809,7 +1806,7 @@ int rfapiRibFTDFilterRecentPrefix(
* This matches behavior of now-obsolete rfapiRibFTDFilterRecent(), * This matches behavior of now-obsolete rfapiRibFTDFilterRecent(),
* but we need to decide if that is correct. * but we need to decide if that is correct.
*/ */
if (it_rn->p.family == AF_ETHERNET) if (p->family == AF_ETHERNET)
return 0; return 0;
#ifdef DEBUG_FTD_FILTER_RECENT #ifdef DEBUG_FTD_FILTER_RECENT
@ -1824,7 +1821,7 @@ int rfapiRibFTDFilterRecentPrefix(
/* /*
* prefix covers target address, so allow prefix * prefix covers target address, so allow prefix
*/ */
if (prefix_match(&it_rn->p, pfx_target_original)) { if (prefix_match(p, pfx_target_original)) {
#ifdef DEBUG_FTD_FILTER_RECENT #ifdef DEBUG_FTD_FILTER_RECENT
vnc_zlog_debug_verbose("%s: prefix covers target, allowed", vnc_zlog_debug_verbose("%s: prefix covers target, allowed",
__func__); __func__);
@ -1835,7 +1832,7 @@ int rfapiRibFTDFilterRecentPrefix(
/* /*
* check this NVE's timestamp for this prefix * check this NVE's timestamp for this prefix
*/ */
trn = agg_node_get(rfd->rsp_times[afi], &it_rn->p); /* locks trn */ trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */
prefix_time = (time_t)trn->info; prefix_time = (time_t)trn->info;
if (trn->lock > 1) if (trn->lock > 1)
agg_unlock_node(trn); agg_unlock_node(trn);
@ -2114,11 +2111,10 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
{ {
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
struct listnode *node; struct listnode *node;
char buf[PREFIX_STRLEN]; const struct prefix *p = agg_node_get_prefix(it_node);
prefix2str(&it_node->p, buf, sizeof(buf)); vnc_zlog_debug_verbose("%s: entry, it=%p, afi=%d, it_node=%p, pfx=%pRN",
vnc_zlog_debug_verbose("%s: entry, it=%p, afi=%d, it_node=%p, pfx=%s", __func__, it, afi, it_node, it_node);
__func__, it, afi, it_node, buf);
if (AFI_L2VPN == afi) { if (AFI_L2VPN == afi) {
/* /*
@ -2157,7 +2153,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* delete * delete
*/ */
if ((rn = agg_node_lookup(m->rfd->rib[afi], if ((rn = agg_node_lookup(m->rfd->rib[afi],
&it_node->p))) { p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, m->rfd, it, it_node, bgp, m->rfd, it, it_node,
m->rfd->response_lifetime); m->rfd->response_lifetime);
@ -2179,8 +2175,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* this * this
* NVE, it's OK to send an update with the delete * NVE, it's OK to send an update with the delete
*/ */
if ((rn = agg_node_lookup(m->rfd->rib[afi], if ((rn = agg_node_lookup(m->rfd->rib[afi], p))) {
&it_node->p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, m->rfd, it, it_node, bgp, m->rfd, it, it_node,
m->rfd->response_lifetime); m->rfd->response_lifetime);
@ -2212,8 +2207,7 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
* prefix * prefix
* previously, we should send an updated response. * previously, we should send an updated response.
*/ */
if ((rn = agg_node_lookup(rfd->rib[afi], if ((rn = agg_node_lookup(rfd->rib[afi], p))) {
&it_node->p))) {
rfapiRibUpdatePendingNode( rfapiRibUpdatePendingNode(
bgp, rfd, it, it_node, bgp, rfd, it, it_node,
rfd->response_lifetime); rfd->response_lifetime);
@ -2416,7 +2410,8 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
for (rn = agg_route_top(rfd->rib[afi]); rn; for (rn = agg_route_top(rfd->rib[afi]); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
const struct prefix *p =
agg_node_get_prefix(rn);
struct skiplist *sl; struct skiplist *sl;
char str_pfx[PREFIX_STRLEN]; char str_pfx[PREFIX_STRLEN];
int printedprefix = 0; int printedprefix = 0;
@ -2433,9 +2428,8 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
nhs_total += skiplist_count(sl); nhs_total += skiplist_count(sl);
++prefixes_total; ++prefixes_total;
if (pfx_match if (pfx_match && !prefix_match(pfx_match, p)
&& !prefix_match(pfx_match, &rn->p) && !prefix_match(p, pfx_match))
&& !prefix_match(&rn->p, pfx_match))
continue; continue;
++prefixes_displayed; ++prefixes_displayed;
@ -2472,7 +2466,7 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
str_un, str_un,
BUFSIZ)); BUFSIZ));
} }
prefix2str(&rn->p, str_pfx, sizeof(str_pfx)); prefix2str(p, str_pfx, sizeof(str_pfx));
// fp(out, " %s\n", buf); /* prefix */ // fp(out, " %s\n", buf); /* prefix */
routes_displayed++; routes_displayed++;

View file

@ -194,7 +194,7 @@ int rfapiQprefix2Raddr(struct prefix *qprefix, struct rfapi_ip_addr *raddr)
* Translate Quagga prefix to RFAPI prefix * Translate Quagga prefix to RFAPI prefix
*/ */
/* rprefix->cost set to 0 */ /* rprefix->cost set to 0 */
void rfapiQprefix2Rprefix(struct prefix *qprefix, void rfapiQprefix2Rprefix(const struct prefix *qprefix,
struct rfapi_ip_prefix *rprefix) struct rfapi_ip_prefix *rprefix)
{ {
memset(rprefix, 0, sizeof(struct rfapi_ip_prefix)); memset(rprefix, 0, sizeof(struct rfapi_ip_prefix));
@ -743,7 +743,6 @@ static void rfapiDebugPrintMonitorEncap(void *stream,
void rfapiShowItNode(void *stream, struct agg_node *rn) void rfapiShowItNode(void *stream, struct agg_node *rn)
{ {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
char buf[BUFSIZ];
int (*fp)(void *, const char *, ...); int (*fp)(void *, const char *, ...);
struct vty *vty; struct vty *vty;
@ -753,9 +752,7 @@ void rfapiShowItNode(void *stream, struct agg_node *rn)
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0) if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
return; return;
fp(out, "%s/%d @%p #%d%s", fp(out, "%pRN @%p #%d%s", rn, rn, rn->lock, HVTYNL);
rfapi_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ),
rn->p.prefixlen, rn, rn->lock, HVTYNL);
for (bpi = rn->info; bpi; bpi = bpi->next) { for (bpi = rn->info; bpi; bpi = bpi->next) {
rfapiPrintBi(stream, bpi); rfapiPrintBi(stream, bpi);
@ -782,14 +779,15 @@ void rfapiShowImportTable(void *stream, const char *label, struct agg_table *rt,
for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
const struct prefix *p = agg_node_get_prefix(rn);
if (rn->p.family == AF_ETHERNET) { if (p->family == AF_ETHERNET) {
rfapiEthAddr2Str(&rn->p.u.prefix_eth, buf, BUFSIZ); rfapiEthAddr2Str(&p->u.prefix_eth, buf, BUFSIZ);
} else { } else {
inet_ntop(rn->p.family, &rn->p.u.prefix, buf, BUFSIZ); inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ);
} }
fp(out, "%s/%d @%p #%d%s", buf, rn->p.prefixlen, rn, fp(out, "%s/%d @%p #%d%s", buf, p->prefixlen, rn,
rn->lock - 1, /* account for loop iterator locking */ rn->lock - 1, /* account for loop iterator locking */
HVTYNL); HVTYNL);
@ -868,6 +866,8 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
if (rfd->mon) { if (rfd->mon) {
for (rn = agg_route_top(rfd->mon); rn; for (rn = agg_route_top(rfd->mon); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
const struct prefix *p =
agg_node_get_prefix(rn);
struct rfapi_monitor_vpn *m; struct rfapi_monitor_vpn *m;
char buf_remain[BUFSIZ]; char buf_remain[BUFSIZ];
char buf_pfx[BUFSIZ]; char buf_pfx[BUFSIZ];
@ -879,9 +879,8 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match)
++queries_total; ++queries_total;
if (pfx_match if (pfx_match && !prefix_match(pfx_match, p)
&& !prefix_match(pfx_match, &rn->p) && !prefix_match(p, pfx_match))
&& !prefix_match(&rn->p, pfx_match))
continue; continue;
++queries_displayed; ++queries_displayed;
@ -1028,6 +1027,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
char buf_vn[BUFSIZ]; char buf_vn[BUFSIZ];
char buf_lifetime[BUFSIZ]; char buf_lifetime[BUFSIZ];
int nlines = 0; int nlines = 0;
const struct prefix *p = agg_node_get_prefix(rn);
if (!stream) if (!stream)
return 0; /* for debug log, print into buf & call output once */ return 0; /* for debug log, print into buf & call output once */
@ -1040,8 +1040,8 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
*/ */
buf_pfx[0] = 0; buf_pfx[0] = 0;
snprintf(buf_pfx, BUFSIZ, "%s/%d", snprintf(buf_pfx, BUFSIZ, "%s/%d",
rfapi_ntop(rn->p.family, &rn->p.u.prefix, buf_ntop, BUFSIZ), rfapi_ntop(p->family, &p->u.prefix, buf_ntop, BUFSIZ),
rn->p.prefixlen); p->prefixlen);
buf_pfx[BUFSIZ - 1] = 0; buf_pfx[BUFSIZ - 1] = 0;
nlines++; nlines++;
@ -1155,7 +1155,7 @@ static int rfapiPrintRemoteRegBi(struct bgp *bgp, void *stream,
} }
fp(out, "%s", HVTYNL); fp(out, "%s", HVTYNL);
if (rn->p.family == AF_ETHERNET) { if (p->family == AF_ETHERNET) {
/* /*
* If there is a corresponding IP address && != VN address, * If there is a corresponding IP address && != VN address,
* print that on the next line * print that on the next line
@ -1221,13 +1221,13 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream,
for (rn = agg_route_top(it->imported_vpn[afi]); rn; for (rn = agg_route_top(it->imported_vpn[afi]); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
const struct prefix *p = agg_node_get_prefix(rn);
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
int count_only; int count_only;
/* allow for wider or more narrow mask from user */ /* allow for wider or more narrow mask from user */
if (prefix_only && !prefix_match(prefix_only, &rn->p) if (prefix_only && !prefix_match(prefix_only, p)
&& !prefix_match(&rn->p, prefix_only)) && !prefix_match(p, prefix_only))
count_only = 1; count_only = 1;
else else
count_only = 0; count_only = 0;

View file

@ -43,7 +43,7 @@ extern void rfapiRprefixApplyMask(struct rfapi_ip_prefix *rprefix);
extern int rfapiQprefix2Raddr(struct prefix *qprefix, extern int rfapiQprefix2Raddr(struct prefix *qprefix,
struct rfapi_ip_addr *raddr); struct rfapi_ip_addr *raddr);
extern void rfapiQprefix2Rprefix(struct prefix *qprefix, extern void rfapiQprefix2Rprefix(const struct prefix *qprefix,
struct rfapi_ip_prefix *rprefix); struct rfapi_ip_prefix *rprefix);
extern int rfapiRprefix2Qprefix(struct rfapi_ip_prefix *rprefix, extern int rfapiRprefix2Qprefix(struct rfapi_ip_prefix *rprefix,

View file

@ -177,7 +177,7 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
{ {
struct attr *attr = bpi->attr; struct attr *attr = bpi->attr;
struct peer *peer = bpi->peer; struct peer *peer = bpi->peer;
struct prefix *prefix = &rn->p; const struct prefix *prefix = agg_node_get_prefix(rn);
afi_t afi = family2afi(prefix->family); afi_t afi = family2afi(prefix->family);
struct bgp_node *urn; struct bgp_node *urn;
struct bgp_path_info *ubpi; struct bgp_path_info *ubpi;
@ -330,7 +330,8 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn,
struct bgp_path_info *bpi) struct bgp_path_info *bpi)
{ {
afi_t afi = family2afi(rn->p.family); const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
struct bgp_path_info *vbpi; struct bgp_path_info *vbpi;
struct prefix ce_nexthop; struct prefix ce_nexthop;
@ -395,8 +396,8 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn,
/* /*
* withdraw the route * withdraw the route
*/ */
bgp_withdraw(bpi->peer, &rn->p, 0, /* addpath_id */ bgp_withdraw(bpi->peer, p, 0, /* addpath_id */
NULL, /* attr, ignored */ NULL, /* attr, ignored */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, 0, NULL); /* tag not used for unicast */ NULL, 0, NULL); /* tag not used for unicast */
@ -432,17 +433,11 @@ static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi)
*/ */
for (rn = agg_route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn; for (rn = agg_route_top(bgp->rfapi->it_ce->imported_vpn[afi]); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
if (!rn->info) if (!rn->info)
continue; continue;
{ vnc_zlog_debug_verbose("%s: checking prefix %pRN", __func__,
char prefixstr[PREFIX_STRLEN]; rn);
prefix2str(&rn->p, prefixstr, sizeof(prefixstr));
vnc_zlog_debug_verbose("%s: checking prefix %s",
__func__, prefixstr);
}
for (ri = rn->info; ri; ri = ri->next) { for (ri = rn->info; ri; ri = ri->next) {
@ -698,7 +693,8 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp,
struct attr attr = {0}; struct attr attr = {0};
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct rfapi_rfg_name *rfgn; struct rfapi_rfg_name *rfgn;
afi_t afi = family2afi(rn->p.family); const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
if (!afi) { if (!afi) {
flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of route node", flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of route node",
@ -769,7 +765,7 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp,
*/ */
if (rfgn->rfg->plist_export_bgp[afi]) { if (rfgn->rfg->plist_export_bgp[afi]) {
if (prefix_list_apply(rfgn->rfg->plist_export_bgp[afi], if (prefix_list_apply(rfgn->rfg->plist_export_bgp[afi],
&rn->p) p)
== PREFIX_DENY) == PREFIX_DENY)
continue; continue;
@ -808,7 +804,8 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp,
{ {
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct rfapi_rfg_name *rfgn; struct rfapi_rfg_name *rfgn;
afi_t afi = family2afi(rn->p.family); const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
if (!afi) { if (!afi) {
flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi route node", flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi route node",
@ -877,9 +874,9 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp,
if (rfapiRaddr2Qprefix(&irfd->vn_addr, &nhp)) if (rfapiRaddr2Qprefix(&irfd->vn_addr, &nhp))
continue; continue;
bgp_withdraw(irfd->peer, &rn->p, /* prefix */ bgp_withdraw(irfd->peer, p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* attr, ignored */ NULL, /* attr, ignored */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, BGP_ROUTE_REDISTRIBUTE,
NULL, /* RD not used for unicast */ NULL, /* RD not used for unicast */
@ -907,9 +904,9 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp,
if (rfapiRaddr2Qprefix(&irfd->vn_addr, &nhp)) if (rfapiRaddr2Qprefix(&irfd->vn_addr, &nhp))
continue; continue;
bgp_withdraw(irfd->peer, &rn->p, /* prefix */ bgp_withdraw(irfd->peer, p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* attr, ignored */ NULL, /* attr, ignored */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, BGP_ROUTE_REDISTRIBUTE,
NULL, /* RD not used for unicast */ NULL, /* RD not used for unicast */
@ -998,6 +995,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
struct attr hattr; struct attr hattr;
struct attr *iattr; struct attr *iattr;
struct bgp_path_info info; struct bgp_path_info info;
const struct prefix *p =
agg_node_get_prefix(rn);
if (rfapiRaddr2Qprefix(&irfd->vn_addr, if (rfapiRaddr2Qprefix(&irfd->vn_addr,
&nhp)) &nhp))
@ -1010,7 +1009,7 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
if (prefix_list_apply( if (prefix_list_apply(
rfgn->rfg->plist_export_bgp rfgn->rfg->plist_export_bgp
[afi], [afi],
&rn->p) p)
== PREFIX_DENY) == PREFIX_DENY)
continue; continue;
@ -1033,8 +1032,7 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
ret = route_map_apply( ret = route_map_apply(
rfgn->rfg rfgn->rfg
->routemap_export_bgp, ->routemap_export_bgp,
&rn->p, RMAP_BGP, p, RMAP_BGP, &info);
&info);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr); bgp_attr_flush(&hattr);
continue; continue;
@ -1044,8 +1042,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
iattr = bgp_attr_intern(&hattr); iattr = bgp_attr_intern(&hattr);
bgp_attr_flush(&hattr); bgp_attr_flush(&hattr);
bgp_update( bgp_update(
irfd->peer, &rn->p, /* prefix */ irfd->peer, p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
iattr, /* bgp_update copies iattr, /* bgp_update copies
it */ it */
afi, SAFI_UNICAST, afi, SAFI_UNICAST,
@ -1134,7 +1132,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
const struct prefix *p =
agg_node_get_prefix(rn);
struct prefix nhp; struct prefix nhp;
struct rfapi_descriptor *irfd = rfd; struct rfapi_descriptor *irfd = rfd;
@ -1142,10 +1141,9 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
&nhp)) &nhp))
continue; continue;
bgp_withdraw(irfd->peer, bgp_withdraw(irfd->peer, p, /* prefix */
&rn->p, /* prefix */ 0, /* addpath_id */
0, /* addpath_id */ NULL, /* attr, ignored */
NULL, /* attr, ignored */
afi, SAFI_UNICAST, afi, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, BGP_ROUTE_REDISTRIBUTE,
@ -1169,6 +1167,7 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
struct bgp_path_info info; struct bgp_path_info info;
struct attr hattr; struct attr hattr;
struct attr *iattr; struct attr *iattr;
const struct prefix *p = agg_node_get_prefix(rn);
if (irfd == NULL && rfg->type != RFAPI_GROUP_CFG_VRF) { if (irfd == NULL && rfg->type != RFAPI_GROUP_CFG_VRF) {
/* need new rfapi_handle, for peer strcture /* need new rfapi_handle, for peer strcture
@ -1242,8 +1241,8 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
info.peer = irfd->peer; info.peer = irfd->peer;
info.attr = &hattr; info.attr = &hattr;
ret = route_map_apply(rfg->routemap_export_bgp, &rn->p, ret = route_map_apply(rfg->routemap_export_bgp, p, RMAP_BGP,
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(
@ -1261,9 +1260,9 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
iattr = bgp_attr_intern(&hattr); iattr = bgp_attr_intern(&hattr);
bgp_attr_flush(&hattr); bgp_attr_flush(&hattr);
bgp_update(irfd->peer, &rn->p, /* prefix */ bgp_update(irfd->peer, p, /* prefix */
0, /* addpath_id */ 0, /* addpath_id */
iattr, /* bgp_update copies it */ iattr, /* bgp_update copies it */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, /* tag not used for unicast */ NULL, /* tag not used for unicast */
@ -1317,7 +1316,7 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp,
for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) { for (rn = agg_route_top(rt); rn; rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
const struct prefix *p = agg_node_get_prefix(rn);
struct listnode *ln; struct listnode *ln;
/* /*
@ -1325,7 +1324,7 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp,
*/ */
if (rfg->plist_export_bgp[afi]) { if (rfg->plist_export_bgp[afi]) {
if (prefix_list_apply( if (prefix_list_apply(
rfg->plist_export_bgp[afi], &rn->p) rfg->plist_export_bgp[afi], p)
== PREFIX_DENY) == PREFIX_DENY)
continue; continue;
@ -1374,9 +1373,10 @@ static void vnc_direct_del_rn_group_rd(struct bgp *bgp,
{ {
if (irfd == NULL) if (irfd == NULL)
return; return;
bgp_withdraw(irfd->peer, &rn->p, /* prefix */
0, /* addpath_id */ bgp_withdraw(irfd->peer, agg_node_get_prefix(rn), /* prefix */
NULL, /* attr, ignored */ 0, /* addpath_id */
NULL, /* attr, ignored */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT, afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */ BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, 0, NULL); /* tag not used for unicast */ NULL, 0, NULL); /* tag not used for unicast */
@ -1493,9 +1493,9 @@ static void vnc_direct_bgp_unexport_table(afi_t afi, struct agg_table *rt,
irfd)) { irfd)) {
bgp_withdraw(irfd->peer, bgp_withdraw(irfd->peer,
&rn->p, /* prefix */ agg_node_get_prefix(rn),
0, /* addpath_id */ 0, /* addpath_id */
NULL, /* attr, ignored */ NULL, /* attr, ignored */
afi, SAFI_UNICAST, afi, SAFI_UNICAST,
ZEBRA_ROUTE_VNC_DIRECT, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, BGP_ROUTE_REDISTRIBUTE,
@ -1732,13 +1732,14 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
static int vncExportWithdrawTimer(struct thread *t) static int vncExportWithdrawTimer(struct thread *t)
{ {
struct vnc_export_info *eti = t->arg; struct vnc_export_info *eti = t->arg;
const struct prefix *p = agg_node_get_prefix(eti->node);
/* /*
* withdraw the route * withdraw the route
*/ */
bgp_withdraw(eti->peer, &eti->node->p, 0, /* addpath_id */ bgp_withdraw(eti->peer, p, 0, /* addpath_id */
NULL, /* attr, ignored */ NULL, /* attr, ignored */
family2afi(eti->node->p.family), SAFI_UNICAST, eti->type, family2afi(p->family), SAFI_UNICAST, eti->type,
eti->subtype, NULL, /* RD not used for unicast */ eti->subtype, NULL, /* RD not used for unicast */
NULL, 0, NULL, 0,
NULL); /* tag not used for unicast, EVPN neither */ NULL); /* tag not used for unicast, EVPN neither */

View file

@ -2028,7 +2028,8 @@ void vnc_import_bgp_exterior_add_route_interior(
struct agg_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_path_info *bpi_interior) /* VPN IT route */ struct bgp_path_info *bpi_interior) /* VPN IT route */
{ {
afi_t afi = family2afi(rn_interior->p.family); const struct prefix *p = agg_node_get_prefix(rn_interior);
afi_t afi = family2afi(p->family);
struct agg_node *par; struct agg_node *par;
struct bgp_path_info *bpi_exterior; struct bgp_path_info *bpi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */ struct prefix *pfx_exterior; /* exterior pfx */
@ -2058,13 +2059,8 @@ void vnc_import_bgp_exterior_add_route_interior(
} }
/*debugging */ /*debugging */
{ vnc_zlog_debug_verbose("%s: interior prefix=%pRN, bpi type=%d",
char str_pfx[PREFIX_STRLEN]; __func__, rn_interior, bpi_interior->type);
prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx));
vnc_zlog_debug_verbose("%s: interior prefix=%s, bpi type=%d",
__func__, str_pfx, bpi_interior->type);
}
if (RFAPI_HAS_MONITOR_EXTERIOR(rn_interior)) { if (RFAPI_HAS_MONITOR_EXTERIOR(rn_interior)) {
@ -2179,7 +2175,7 @@ void vnc_import_bgp_exterior_add_route_interior(
rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr, rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr,
&pfx_nexthop); &pfx_nexthop);
if (prefix_match(&rn_interior->p, &pfx_nexthop)) { if (prefix_match(p, &pfx_nexthop)) {
struct bgp_path_info *bpi; struct bgp_path_info *bpi;
struct prefix_rd *prd; struct prefix_rd *prd;
@ -2322,7 +2318,7 @@ void vnc_import_bgp_exterior_add_route_interior(
rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr, rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr,
&pfx_nexthop); &pfx_nexthop);
if (prefix_match(&rn_interior->p, &pfx_nexthop)) { if (prefix_match(p, &pfx_nexthop)) {
struct prefix_rd *prd; struct prefix_rd *prd;
struct attr new_attr; struct attr new_attr;
@ -2410,7 +2406,8 @@ void vnc_import_bgp_exterior_del_route_interior(
struct agg_node *rn_interior, /* VPN IT node */ struct agg_node *rn_interior, /* VPN IT node */
struct bgp_path_info *bpi_interior) /* VPN IT route */ struct bgp_path_info *bpi_interior) /* VPN IT route */
{ {
afi_t afi = family2afi(rn_interior->p.family); const struct prefix *p = agg_node_get_prefix(rn_interior);
afi_t afi = family2afi(p->family);
struct agg_node *par; struct agg_node *par;
struct bgp_path_info *bpi_exterior; struct bgp_path_info *bpi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */ struct prefix *pfx_exterior; /* exterior pfx */
@ -2444,14 +2441,8 @@ void vnc_import_bgp_exterior_del_route_interior(
} }
/*debugging */ /*debugging */
{ vnc_zlog_debug_verbose("%s: interior prefix=%pRN, bpi type=%d",
char str_pfx[PREFIX_STRLEN]; __func__, rn_interior, bpi_interior->type);
prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx));
vnc_zlog_debug_verbose("%s: interior prefix=%s, bpi type=%d",
__func__, str_pfx, bpi_interior->type);
}
/* /*
* Remove constructed routes based on the deleted interior route * Remove constructed routes based on the deleted interior route

View file

@ -380,7 +380,7 @@ static int vnc_zebra_read_route(ZAPI_CALLBACK_ARGS)
/* /*
* low-level message builder * low-level message builder
*/ */
static void vnc_zebra_route_msg(struct prefix *p, unsigned int nhp_count, static void vnc_zebra_route_msg(const struct prefix *p, unsigned int nhp_count,
void *nhp_ary, int add) /* 1 = add, 0 = del */ void *nhp_ary, int add) /* 1 = add, 0 = del */
{ {
struct zapi_route api; struct zapi_route api;
@ -560,7 +560,7 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
int add) /* !0 = add, 0 = del */ int add) /* !0 = add, 0 = del */
{ {
struct list *nves; struct list *nves;
const struct prefix *p = agg_node_get_prefix(rn);
unsigned int nexthop_count = 0; unsigned int nexthop_count = 0;
void *nh_ary = NULL; void *nh_ary = NULL;
void *nhp_ary = NULL; void *nhp_ary = NULL;
@ -570,15 +570,15 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
if (zclient_vnc->sock < 0) if (zclient_vnc->sock < 0)
return; return;
if (rn->p.family != AF_INET && rn->p.family != AF_INET6) { if (p->family != AF_INET && p->family != AF_INET6) {
flog_err(EC_LIB_DEVELOPMENT, flog_err(EC_LIB_DEVELOPMENT,
"%s: invalid route node addr family", __func__); "%s: invalid route node addr family", __func__);
return; return;
} }
if (!vrf_bitmap_check(zclient_vnc->redist[family2afi(rn->p.family)] if (!vrf_bitmap_check(
[ZEBRA_ROUTE_VNC], zclient_vnc->redist[family2afi(p->family)][ZEBRA_ROUTE_VNC],
VRF_DEFAULT)) VRF_DEFAULT))
return; return;
if (!bgp->rfapi_cfg) { if (!bgp->rfapi_cfg) {
@ -592,17 +592,16 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
return; return;
} }
import_table_to_nve_list_zebra(bgp, import_table, &nves, rn->p.family); import_table_to_nve_list_zebra(bgp, import_table, &nves, p->family);
if (nves) { if (nves) {
nve_list_to_nh_array(rn->p.family, nves, &nexthop_count, nve_list_to_nh_array(p->family, nves, &nexthop_count, &nh_ary,
&nh_ary, &nhp_ary); &nhp_ary);
list_delete(&nves); list_delete(&nves);
if (nexthop_count) if (nexthop_count)
vnc_zebra_route_msg(&rn->p, nexthop_count, nhp_ary, vnc_zebra_route_msg(p, nexthop_count, nhp_ary, add);
add);
} }
XFREE(MTYPE_TMP, nhp_ary); XFREE(MTYPE_TMP, nhp_ary);
@ -695,15 +694,14 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd,
*/ */
for (rn = agg_route_top(rt); rn; for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
if (!rn->info)
continue;
if (rn->info) { vnc_zlog_debug_verbose("%s: sending %s",
__func__,
vnc_zlog_debug_verbose( (add ? "add" : "del"));
"%s: sending %s", __func__, vnc_zebra_route_msg(agg_node_get_prefix(rn), 1,
(add ? "add" : "del")); &pAddr, add);
vnc_zebra_route_msg(&rn->p, 1, &pAddr,
add);
}
} }
} }
} }
@ -778,9 +776,9 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
for (rn = agg_route_top(rt); rn; for (rn = agg_route_top(rt); rn;
rn = agg_route_next(rn)) { rn = agg_route_next(rn)) {
if (rn->info) { if (rn->info) {
vnc_zebra_route_msg(&rn->p, vnc_zebra_route_msg(
nexthop_count, agg_node_get_prefix(rn),
nhp_ary, add); nexthop_count, nhp_ary, add);
} }
} }
} }

View file

@ -155,6 +155,12 @@ static inline struct agg_table *agg_get_table(struct agg_node *node)
return (struct agg_table *)route_table_get_info(node->table); return (struct agg_table *)route_table_get_info(node->table);
} }
static inline const struct prefix *
agg_node_get_prefix(const struct agg_node *node)
{
return &node->p;
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -867,17 +867,12 @@ int ripng_network_write(struct vty *vty, struct ripng *ripng)
unsigned int i; unsigned int i;
const char *ifname; const char *ifname;
struct agg_node *node; struct agg_node *node;
char buf[BUFSIZ];
/* Write enable network. */ /* Write enable network. */
for (node = agg_route_top(ripng->enable_network); node; for (node = agg_route_top(ripng->enable_network); node;
node = agg_route_next(node)) node = agg_route_next(node))
if (node->info) { if (node->info)
struct prefix *p = &node->p; vty_out(vty, " %pRN\n", node);
vty_out(vty, " %s/%d\n",
inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
p->prefixlen);
}
/* Write enable interface. */ /* Write enable interface. */
for (i = 0; i < vector_active(ripng->enable_if); i++) for (i = 0; i < vector_active(ripng->enable_if); i++)

View file

@ -158,7 +158,8 @@ int ripngd_instance_state_routes_route_get_keys(const void *list_entry,
const struct agg_node *rn = list_entry; const struct agg_node *rn = list_entry;
keys->num = 1; keys->num = 1;
(void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0])); (void)prefix2str(agg_node_get_prefix(rn), keys->key[0],
sizeof(keys->key[0]));
return NB_OK; return NB_OK;
} }
@ -191,7 +192,7 @@ ripngd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const struct agg_node *rn = list_entry; const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info); const struct ripng_info *rinfo = listnode_head(rn->info);
return yang_data_new_ipv6p(xpath, &rinfo->rp->p); return yang_data_new_ipv6p(xpath, agg_node_get_prefix(rinfo->rp));
} }
/* /*

View file

@ -46,12 +46,13 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
struct listnode *listnode = NULL; struct listnode *listnode = NULL;
struct ripng_info *rinfo = NULL; struct ripng_info *rinfo = NULL;
int count = 0; int count = 0;
const struct prefix *p = agg_node_get_prefix(rp);
memset(&api, 0, sizeof(api)); memset(&api, 0, sizeof(api));
api.vrf_id = ripng->vrf->vrf_id; api.vrf_id = ripng->vrf->vrf_id;
api.type = ZEBRA_ROUTE_RIPNG; api.type = ZEBRA_ROUTE_RIPNG;
api.safi = SAFI_UNICAST; api.safi = SAFI_UNICAST;
api.prefix = rp->p; api.prefix = *p;
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
@ -85,18 +86,17 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
if (IS_RIPNG_DEBUG_ZEBRA) { if (IS_RIPNG_DEBUG_ZEBRA) {
if (ripng->ecmp) if (ripng->ecmp)
zlog_debug("%s: %s/%d nexthops %d", zlog_debug("%s: %pRN nexthops %d",
(cmd == ZEBRA_ROUTE_ADD) (cmd == ZEBRA_ROUTE_ADD)
? "Install into zebra" ? "Install into zebra"
: "Delete from zebra", : "Delete from zebra",
inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen, rp, count);
count);
else else
zlog_debug( zlog_debug("%s: %pRN",
"%s: %s/%d", (cmd == ZEBRA_ROUTE_ADD)
(cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra" ? "Install into zebra"
: "Delete from zebra", : "Delete from zebra",
inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen); rp);
} }
} }

View file

@ -1087,7 +1087,8 @@ void ripng_redistribute_withdraw(struct ripng *ripng, int type)
if (IS_RIPNG_DEBUG_EVENT) { if (IS_RIPNG_DEBUG_EVENT) {
struct prefix_ipv6 *p = struct prefix_ipv6 *p =
(struct prefix_ipv6 *)&rp->p; (struct prefix_ipv6 *)
agg_node_get_prefix(rp);
zlog_debug( zlog_debug(
"Poisone %s/%d on the interface %s [withdraw]", "Poisone %s/%d on the interface %s [withdraw]",
@ -1619,7 +1620,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
* following * following
* information. * information.
*/ */
p = (struct prefix_ipv6 *)&rp->p; p = (struct prefix_ipv6 *)agg_node_get_prefix(rp);
rinfo->metric_out = rinfo->metric; rinfo->metric_out = rinfo->metric;
rinfo->tag_out = rinfo->tag; rinfo->tag_out = rinfo->tag;
memset(&rinfo->nexthop_out, 0, memset(&rinfo->nexthop_out, 0,
@ -1761,7 +1762,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
* following * following
* information. * information.
*/ */
p = (struct prefix_ipv6 *)&rp->p; p = (struct prefix_ipv6 *)agg_node_get_prefix(rp);
aggregate->metric_set = 0; aggregate->metric_set = 0;
aggregate->metric_out = aggregate->metric; aggregate->metric_out = aggregate->metric;
aggregate->tag_out = aggregate->tag; aggregate->tag_out = aggregate->tag;
@ -2053,7 +2054,6 @@ DEFUN (show_ipv6_ripng,
struct agg_node *rp; struct agg_node *rp;
struct ripng_info *rinfo; struct ripng_info *rinfo;
struct ripng_aggregate *aggregate; struct ripng_aggregate *aggregate;
struct prefix_ipv6 *p;
struct list *list = NULL; struct list *list = NULL;
struct listnode *listnode = NULL; struct listnode *listnode = NULL;
int len; int len;
@ -2085,15 +2085,11 @@ DEFUN (show_ipv6_ripng,
for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) { for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
if ((aggregate = rp->aggregate) != NULL) { if ((aggregate = rp->aggregate) != NULL) {
p = (struct prefix_ipv6 *)&rp->p;
#ifdef DEBUG #ifdef DEBUG
vty_out(vty, "R(a) %d/%d %s/%d ", aggregate->count, vty_out(vty, "R(a) %d/%d %pRN ", aggregate->count,
aggregate->suppress, inet6_ntoa(p->prefix), aggregate->suppress, rp);
p->prefixlen);
#else #else
vty_out(vty, "R(a) %s/%d ", inet6_ntoa(p->prefix), vty_out(vty, "R(a) %pRN ", rp);
p->prefixlen);
#endif /* DEBUG */ #endif /* DEBUG */
vty_out(vty, "\n"); vty_out(vty, "\n");
vty_out(vty, "%*s", 18, " "); vty_out(vty, "%*s", 18, " ");
@ -2105,19 +2101,15 @@ DEFUN (show_ipv6_ripng,
if ((list = rp->info) != NULL) if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
p = (struct prefix_ipv6 *)&rp->p;
#ifdef DEBUG #ifdef DEBUG
vty_out(vty, "%c(%s) 0/%d %s/%d ", vty_out(vty, "%c(%s) 0/%d %pRN ",
zebra_route_char(rinfo->type), zebra_route_char(rinfo->type),
ripng_route_subtype_print(rinfo), ripng_route_subtype_print(rinfo),
rinfo->suppress, inet6_ntoa(p->prefix), rinfo->suppress, rp);
p->prefixlen);
#else #else
vty_out(vty, "%c(%s) %s/%d ", vty_out(vty, "%c(%s) %pRN ",
zebra_route_char(rinfo->type), zebra_route_char(rinfo->type),
ripng_route_subtype_print(rinfo), ripng_route_subtype_print(rinfo), rp);
inet6_ntoa(p->prefix), p->prefixlen);
#endif /* DEBUG */ #endif /* DEBUG */
vty_out(vty, "\n"); vty_out(vty, "\n");
vty_out(vty, "%*s", 18, " "); vty_out(vty, "%*s", 18, " ");