return local_pref;
}
-static int is_host_prefix(struct prefix *p)
+static int is_host_prefix(const struct prefix *p)
{
switch (p->family) {
case AF_INET:
static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
0xf8, 0xfc, 0xfe, 0xff};
-int vnc_prefix_cmp(void *pfx1, void *pfx2)
+int vnc_prefix_cmp(const void *pfx1, const void *pfx2)
{
int offset;
int shift;
uint8_t mask;
- struct prefix *p1 = pfx1;
- struct prefix *p2 = pfx2;
+ const struct prefix *p1 = pfx1;
+ const struct prefix *p2 = pfx2;
if (p1->family < p2->family)
return -1;
vnc_zlog_debug_verbose("%s: vnc_rhnck OK", tag);
}
-#define VNC_RHNCK(n) do {char buf[BUFSIZ];sprintf(buf,"%s: %s", __func__, #n);vnc_rhnck(buf);} while (0)
+#define VNC_RHNCK(n) \
+ do { \
+ char buf[BUFSIZ]; \
+ snprintf(buf, sizeof(buf), "%s: %s", __func__, #n); \
+ vnc_rhnck(buf); \
+ } while (0)
#else
*/
static int process_unicast_route(struct bgp *bgp, /* in */
afi_t afi, /* in */
- struct prefix *prefix, /* in */
- struct bgp_path_info *info, /* in */
- struct ecommunity **ecom, /* OUT */
+ const struct prefix *prefix, /* in */
+ struct bgp_path_info *info, /* in */
+ struct ecommunity **ecom, /* OUT */
struct prefix *unicast_nexthop) /* OUT */
{
struct rfapi_cfg *hc = bgp->rfapi_cfg;
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
- bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
+ /* hattr becomes a ghost attr */
+ hattr = *attr;
if (rmap) {
struct bgp_path_info info;
localadmin = htons(hc->resolve_nve_roo_local_admin);
memcpy(vnc_gateway_magic.val + 6, (char *)&localadmin, 2);
- ecommunity_add_val(*ecom, &vnc_gateway_magic);
+ ecommunity_add_val(*ecom, &vnc_gateway_magic, false, false);
}
return 0;
static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */
struct prefix_rd *prd, /* RD */
- struct prefix *prefix, /* unicast route prefix */
- uint32_t *local_pref, /* NULL = no local_pref */
- uint32_t *med, /* NULL = no med */
- struct ecommunity *ecom) /* generated ecoms */
+ const struct prefix *prefix, /* unicast route prefix */
+ uint32_t *local_pref, /* NULL = no local_pref */
+ uint32_t *med, /* NULL = no med */
+ struct ecommunity *ecom) /* generated ecoms */
{
struct prefix un;
struct prefix nexthop;
}
static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
- struct prefix_rd *prd, /* RD */
+ struct prefix_rd *prd, /* RD */
struct bgp_table *table_rd, /* per-rd VPN route table */
- afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */
- struct ecommunity *ecom, /* generated ecoms */
- uint32_t *local_pref, /* NULL = no local_pref */
+ afi_t afi, struct bgp *bgp,
+ const struct prefix *prefix, /* unicast prefix */
+ struct ecommunity *ecom, /* generated ecoms */
+ uint32_t *local_pref, /* NULL = no local_pref */
uint32_t *med, /* NULL = no med */
struct prefix *ubpi_nexthop) /* unicast nexthop */
{
}
static void vnc_import_bgp_add_route_mode_resolve_nve(
- struct bgp *bgp, struct prefix *prefix, /* unicast prefix */
- struct bgp_path_info *info) /* unicast info */
+ struct bgp *bgp, const struct prefix *prefix, /* unicast prefix */
+ struct bgp_path_info *info) /* unicast info */
{
afi_t afi = family2afi(prefix->family);
continue;
vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
- (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
- ecom, &local_pref, med, &pfx_unicast_nexthop);
+ (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+ afi, bgp, prefix, ecom, &local_pref, med,
+ &pfx_unicast_nexthop);
}
static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
- struct prefix *prefix,
+ const struct prefix *prefix,
struct bgp_path_info *info)
{
afi_t afi = family2afi(prefix->family);
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
- bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
+ /* hattr becomes a ghost attr */
+ hattr = *attr;
if (rmap) {
struct bgp_path_info info;
ecommunity_free(&ecom);
}
-static void
-vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
- struct bgp_path_info *info,
- struct rfapi_nve_group_cfg *rfg)
+static void vnc_import_bgp_add_route_mode_nvegroup(
+ struct bgp *bgp, const struct prefix *prefix,
+ struct bgp_path_info *info, struct rfapi_nve_group_cfg *rfg)
{
afi_t afi = family2afi(prefix->family);
struct peer *peer = info->peer;
* all of the possible returns above.
*/
memset(&hattr, 0, sizeof(struct attr));
- bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
+ /* hattr becomes a ghost attr */
+ hattr = *attr;
if (rmap) {
struct bgp_path_info path;
}
static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp,
- struct prefix *prefix,
+ const struct prefix *prefix,
struct bgp_path_info *info)
{
struct prefix_rd prd;
}
static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp,
- struct prefix *prefix,
+ const struct prefix *prefix,
struct bgp_path_info *info)
{
struct prefix_rd prd;
static void vnc_import_bgp_del_route_mode_resolve_nve_one_bi(
struct bgp *bgp, afi_t afi, struct bgp_path_info *bpi, /* VPN bpi */
struct prefix_rd *prd, /* RD */
- struct prefix *prefix) /* unicast route prefix */
+ const struct prefix *prefix) /* unicast route prefix */
{
struct prefix un;
static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
struct prefix_rd *prd,
struct bgp_table *table_rd, /* per-rd VPN route table */
- afi_t afi, struct bgp *bgp, struct prefix *prefix, /* unicast prefix */
- struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */
+ afi_t afi, struct bgp *bgp,
+ const struct prefix *prefix, /* unicast prefix */
+ const struct prefix *ubpi_nexthop) /* unicast bpi's nexthop */
{
struct bgp_node *bn;
struct bgp_path_info *bpi;
static void
vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
- struct prefix *prefix,
+ const struct prefix *prefix,
struct bgp_path_info *info)
{
struct ecommunity *ecom = NULL;
continue;
vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
- (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
- &pfx_unicast_nexthop); /* TBD how is this set? */
+ (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+ afi, bgp, prefix, &pfx_unicast_nexthop);
}
if (ecom)
void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
struct bgp *bgp, struct prefix_rd *prd, /* RD */
struct bgp_table *table_rd, /* per-rd VPN route table */
- struct prefix *prefix, /* VPN prefix */
+ const struct prefix *prefix, /* VPN prefix */
struct bgp_path_info *bpi) /* new VPN host route */
{
afi_t afi = family2afi(prefix->family);
void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
struct bgp *bgp, struct prefix_rd *prd, /* RD */
struct bgp_table *table_rd, /* per-rd VPN route table */
- struct prefix *prefix, /* VPN prefix */
+ const struct prefix *prefix, /* VPN prefix */
struct bgp_path_info *bpi) /* old VPN host route */
{
afi_t afi = family2afi(prefix->family);
*/
static void vnc_import_bgp_exterior_add_route_it(
struct bgp *bgp, /* exterior instance, we hope */
- struct prefix *prefix, /* unicast prefix */
- struct bgp_path_info *info, /* unicast info */
+ const struct prefix *prefix, /* unicast prefix */
+ struct bgp_path_info *info, /* unicast info */
struct rfapi_import_table *it_only) /* NULL, or limit to this IT */
{
struct rfapi *h;
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
- bgp_attr_dup(&new_attr, bpi_interior->attr);
+ new_attr = *bpi_interior->attr;
if (info->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
new_attr.local_pref =
RFAPI_MONITOR_EXTERIOR(rn)->source =
skiplist_new(
0, NULL,
- (void (*)(void *))
- prefix_free);
+ prefix_free_lists);
agg_lock_node(rn); /* for skiplist */
}
agg_lock_node(rn); /* for skiplist entry */
}
void vnc_import_bgp_exterior_add_route(
- struct bgp *bgp, /* exterior instance, we hope */
- struct prefix *prefix, /* unicast prefix */
- struct bgp_path_info *info) /* unicast info */
+ struct bgp *bgp, /* exterior instance, we hope */
+ const struct prefix *prefix, /* unicast prefix */
+ struct bgp_path_info *info) /* unicast info */
{
vnc_import_bgp_exterior_add_route_it(bgp, prefix, info, NULL);
}
* right routes.
*/
void vnc_import_bgp_exterior_del_route(
- struct bgp *bgp, struct prefix *prefix, /* unicast prefix */
- struct bgp_path_info *info) /* unicast info */
+ struct bgp *bgp, const struct prefix *prefix, /* unicast prefix */
+ struct bgp_path_info *info) /* unicast info */
{
struct rfapi *h;
struct rfapi_cfg *hc;
struct agg_node *rn_interior, /* VPN IT node */
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 bgp_path_info *bpi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */
}
/*debugging */
- {
- char str_pfx[PREFIX_STRLEN];
-
- 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);
- }
+ vnc_zlog_debug_verbose("%s: interior prefix=%pRN, bpi type=%d",
+ __func__, rn_interior, bpi_interior->type);
if (RFAPI_HAS_MONITOR_EXTERIOR(rn_interior)) {
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
- bgp_attr_dup(&new_attr, bpi_interior->attr);
+ new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr,
&pfx_nexthop);
- if (prefix_match(&rn_interior->p, &pfx_nexthop)) {
+ if (prefix_match(p, &pfx_nexthop)) {
struct bgp_path_info *bpi;
struct prefix_rd *prd;
->source) {
RFAPI_MONITOR_EXTERIOR(rn_interior)
->source = skiplist_new(
- 0, NULL,
- (void (*)(void *))prefix_free);
+ 0, NULL, prefix_free_lists);
agg_lock_node(rn_interior);
}
skiplist_insert(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
- bgp_attr_dup(&new_attr, bpi_interior->attr);
+ new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
rfapiUnicastNexthop2Prefix(afi, bpi_exterior->attr,
&pfx_nexthop);
- if (prefix_match(&rn_interior->p, &pfx_nexthop)) {
+ if (prefix_match(p, &pfx_nexthop)) {
struct prefix_rd *prd;
struct attr new_attr;
if (!RFAPI_MONITOR_EXTERIOR(rn_interior)->source) {
RFAPI_MONITOR_EXTERIOR(rn_interior)->source =
skiplist_new(
- 0, NULL,
- (void (*)(void *))prefix_free);
+ 0, NULL, prefix_free_lists);
agg_lock_node(rn_interior); /* sl */
}
skiplist_insert(
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
- bgp_attr_dup(&new_attr, bpi_interior->attr);
+ new_attr = *bpi_interior->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
struct agg_node *rn_interior, /* VPN IT node */
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 bgp_path_info *bpi_exterior;
struct prefix *pfx_exterior; /* exterior pfx */
}
/*debugging */
- {
- char str_pfx[PREFIX_STRLEN];
-
- 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);
- }
+ vnc_zlog_debug_verbose("%s: interior prefix=%pRN, bpi type=%d",
+ __func__, rn_interior, bpi_interior->type);
/*
* Remove constructed routes based on the deleted interior route
if (!RFAPI_MONITOR_EXTERIOR(par)->source) {
RFAPI_MONITOR_EXTERIOR(par)->source =
skiplist_new(
- 0, NULL,
- (void (*)(void *))prefix_free);
+ 0, NULL, prefix_free_lists);
agg_lock_node(par); /* sl */
}
skiplist_insert(RFAPI_MONITOR_EXTERIOR(par)->source,
/* use local_pref from unicast route */
memset(&new_attr, 0, sizeof(struct attr));
- bgp_attr_dup(&new_attr, bpi->attr);
+ new_attr = *bpi->attr;
if (bpi_exterior
&& (bpi_exterior->attr->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) {
* Generic add/delete unicast routes
***********************************************************************/
-void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix,
+void vnc_import_bgp_add_route(struct bgp *bgp, const struct prefix *prefix,
struct bgp_path_info *info)
{
afi_t afi = family2afi(prefix->family);
/*
* "Withdrawing a Route" import process
*/
-void vnc_import_bgp_del_route(struct bgp *bgp, struct prefix *prefix,
+void vnc_import_bgp_del_route(struct bgp *bgp, const struct prefix *prefix,
struct bgp_path_info *info) /* unicast info */
{
afi_t afi = family2afi(prefix->family);
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_add_route(bgp, &rn->p, bpi);
+ vnc_import_bgp_add_route(bgp, bgp_node_get_prefix(rn),
+ bpi);
}
}
vnc_zlog_debug_verbose(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_exterior_add_route(bgp_exterior, &rn->p,
- bpi);
+ vnc_import_bgp_exterior_add_route(
+ bgp_exterior, bgp_node_get_prefix(rn), bpi);
}
}
vnc_zlog_debug_verbose(
continue;
vnc_import_bgp_exterior_add_route_it(
- bgp_exterior, &rn->p, bpi, it_only);
+ bgp_exterior, bgp_node_get_prefix(rn), bpi,
+ it_only);
}
}
}
*/
for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
rn1 = bgp_route_next(rn1)) {
+ const struct prefix *rn1_p;
- if (bgp_node_has_bgp_path_info_data(rn1)) {
-
- for (rn2 = bgp_table_top(
- bgp_node_get_bgp_table_info(rn1));
- rn2; rn2 = bgp_route_next(rn2)) {
-
- struct bgp_path_info *bpi;
- struct bgp_path_info *nextbpi;
-
- for (bpi = bgp_node_get_bgp_path_info(rn2); bpi;
- bpi = nextbpi) {
-
- nextbpi = bpi->next;
+ if (!bgp_node_has_bgp_path_info_data(rn1))
+ continue;
- if (bpi->type
- == ZEBRA_ROUTE_BGP_DIRECT) {
+ rn1_p = bgp_node_get_prefix(rn1);
+ for (rn2 = bgp_table_top(bgp_node_get_bgp_table_info(rn1)); rn2;
+ rn2 = bgp_route_next(rn2)) {
+ const struct prefix *rn2_p = bgp_node_get_prefix(rn2);
+ struct bgp_path_info *bpi;
+ struct bgp_path_info *nextbpi;
- struct rfapi_descriptor *rfd;
- vncHDBgpDirect.peer = bpi->peer;
+ for (bpi = bgp_node_get_bgp_path_info(rn2); bpi;
+ bpi = nextbpi) {
- assert(bpi->extra);
+ nextbpi = bpi->next;
- rfd = bpi->extra->vnc.export
- .rfapi_handle;
+ if (bpi->type != ZEBRA_ROUTE_BGP_DIRECT)
+ continue;
- vnc_zlog_debug_verbose(
- "%s: deleting bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p [passing rfd=%p]",
- __func__, bpi,
- bpi->peer, bpi->type,
- bpi->sub_type,
- (bpi->extra
- ? bpi->extra
- ->vnc
- .export
- .rfapi_handle
- : NULL),
- rfd);
+ struct rfapi_descriptor *rfd;
+ vncHDBgpDirect.peer = bpi->peer;
+ assert(bpi->extra);
- del_vnc_route(
- rfd, bpi->peer, bgp,
- SAFI_MPLS_VPN, &rn2->p,
- (struct prefix_rd *)&rn1
- ->p,
- bpi->type,
- bpi->sub_type, NULL,
- 1); /* kill */
+ rfd = bpi->extra->vnc.export.rfapi_handle;
- vncHDBgpDirect.peer = NULL;
- }
- }
+ vnc_zlog_debug_verbose(
+ "%s: deleting bpi=%p, bpi->peer=%p, bpi->type=%d, bpi->sub_type=%d, bpi->extra->vnc.export.rfapi_handle=%p [passing rfd=%p]",
+ __func__, bpi, bpi->peer, bpi->type,
+ bpi->sub_type,
+ (bpi->extra ? bpi->extra->vnc.export
+ .rfapi_handle
+ : NULL),
+ rfd);
+
+ del_vnc_route(rfd, bpi->peer, bgp,
+ SAFI_MPLS_VPN, rn2_p,
+ (struct prefix_rd *)rn1_p,
+ bpi->type, bpi->sub_type, NULL,
+ 1); /* kill */
+
+ vncHDBgpDirect.peer = NULL;
}
}
}
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
continue;
- vnc_import_bgp_exterior_del_route(bgp_exterior,
- &rn->p, bpi);
+ vnc_import_bgp_exterior_del_route(
+ bgp_exterior, bgp_node_get_prefix(rn),
+ bpi);
}
}
#if DEBUG_RHN_LIST