]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/rfapi/vnc_import_bgp.c
Merge pull request #5881 from patrasar/2386420
[mirror_frr.git] / bgpd / rfapi / vnc_import_bgp.c
index 6e8969ad18c8b62de10c22e11ae27c610c1b8ece..0a8e1618fc8883426de03b94274d24b1e3ce8522 100644 (file)
@@ -104,7 +104,7 @@ uint32_t calc_local_pref(struct attr *attr, struct peer *peer)
        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:
@@ -128,14 +128,14 @@ struct prefix_bag {
 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;
@@ -275,7 +275,12 @@ static void vnc_rhnck(char *tag)
        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
 
@@ -299,9 +304,9 @@ static void vnc_rhnck(char *tag)
  */
 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;
@@ -356,7 +361,8 @@ static int process_unicast_route(struct bgp *bgp,            /* in */
         * 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;
@@ -414,7 +420,7 @@ static int process_unicast_route(struct bgp *bgp,            /* in */
                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;
@@ -424,10 +430,10 @@ static int process_unicast_route(struct bgp *bgp,          /* in */
 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;
@@ -508,11 +514,12 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_bi(
 }
 
 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 */
 {
@@ -551,8 +558,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
 }
 
 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);
 
@@ -672,8 +679,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
                        continue;
 
                vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
-                       (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
-                       ecom, &local_pref, med, &pfx_unicast_nexthop);
+                       (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+                       afi, bgp, prefix, ecom, &local_pref, med,
+                       &pfx_unicast_nexthop);
        }
 
 
@@ -685,7 +693,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
 
 
 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);
@@ -798,7 +806,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
         * 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;
@@ -872,10 +881,9 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
                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;
@@ -1000,7 +1008,8 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
         * 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;
@@ -1077,7 +1086,7 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
 }
 
 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;
@@ -1150,7 +1159,7 @@ static void vnc_import_bgp_del_route_mode_plain(struct bgp *bgp,
 }
 
 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;
@@ -1233,7 +1242,7 @@ static void vnc_import_bgp_del_route_mode_nvegroup(struct bgp *bgp,
 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;
 
@@ -1269,8 +1278,9 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_bi(
 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;
@@ -1309,7 +1319,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
 
 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;
@@ -1373,8 +1383,8 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
                        continue;
 
                vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
-                       (struct prefix_rd *)&bnp->p, table, afi, bgp, prefix,
-                       &pfx_unicast_nexthop); /* TBD how is this set? */
+                       (struct prefix_rd *)bgp_node_get_prefix(bnp), table,
+                       afi, bgp, prefix, &pfx_unicast_nexthop);
        }
 
        if (ecom)
@@ -1393,7 +1403,7 @@ vnc_import_bgp_del_route_mode_resolve_nve(struct bgp *bgp, afi_t afi,
 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);
@@ -1530,7 +1540,7 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
 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);
@@ -1672,8 +1682,8 @@ static int is_usable_interior_route(struct bgp_path_info *bpi_interior)
  */
 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;
@@ -1779,7 +1789,7 @@ static void vnc_import_bgp_exterior_add_route_it(
 
                                /* 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 =
@@ -1841,9 +1851,9 @@ static void vnc_import_bgp_exterior_add_route_it(
 }
 
 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);
 }
@@ -1858,8 +1868,8 @@ void vnc_import_bgp_exterior_add_route(
  * 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;
@@ -2024,7 +2034,8 @@ void vnc_import_bgp_exterior_add_route_interior(
        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 */
@@ -2054,13 +2065,8 @@ void vnc_import_bgp_exterior_add_route_interior(
        }
 
        /*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)) {
 
@@ -2104,7 +2110,7 @@ void vnc_import_bgp_exterior_add_route_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))) {
@@ -2175,7 +2181,7 @@ void vnc_import_bgp_exterior_add_route_interior(
                        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;
@@ -2240,7 +2246,7 @@ void vnc_import_bgp_exterior_add_route_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))) {
@@ -2318,7 +2324,7 @@ void vnc_import_bgp_exterior_add_route_interior(
                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;
@@ -2360,7 +2366,7 @@ void vnc_import_bgp_exterior_add_route_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))) {
@@ -2406,7 +2412,8 @@ void vnc_import_bgp_exterior_del_route_interior(
        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 */
@@ -2440,14 +2447,8 @@ void vnc_import_bgp_exterior_del_route_interior(
        }
 
        /*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
@@ -2550,7 +2551,7 @@ void vnc_import_bgp_exterior_del_route_interior(
 
                                /* 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))) {
@@ -2594,7 +2595,7 @@ void vnc_import_bgp_exterior_del_route_interior(
  *                     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);
@@ -2663,7 +2664,7 @@ void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix,
 /*
  * "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);
@@ -2759,7 +2760,8 @@ void vnc_import_bgp_redist_enable(struct bgp *bgp, afi_t afi)
                        if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
                                continue;
 
-                       vnc_import_bgp_add_route(bgp, &rn->p, bpi);
+                       vnc_import_bgp_add_route(bgp, bgp_node_get_prefix(rn),
+                                                bpi);
                }
        }
        vnc_zlog_debug_verbose(
@@ -2800,8 +2802,8 @@ void vnc_import_bgp_exterior_redist_enable(struct bgp *bgp, afi_t afi)
                        if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
                                continue;
 
-                       vnc_import_bgp_exterior_add_route(bgp_exterior, &rn->p,
-                                                         bpi);
+                       vnc_import_bgp_exterior_add_route(
+                               bgp_exterior, bgp_node_get_prefix(rn), bpi);
                }
        }
        vnc_zlog_debug_verbose(
@@ -2847,7 +2849,8 @@ void vnc_import_bgp_exterior_redist_enable_it(
                                continue;
 
                        vnc_import_bgp_exterior_add_route_it(
-                               bgp_exterior, &rn->p, bpi, it_only);
+                               bgp_exterior, bgp_node_get_prefix(rn), bpi,
+                               it_only);
                }
        }
 }
@@ -2877,58 +2880,49 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi)
         */
        for (rn1 = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn1;
             rn1 = bgp_route_next(rn1)) {
+               const struct prefix *rn1_p;
 
-               if (bgp_node_has_bgp_path_info_data(rn1)) {
-
-                       for (rn2 = bgp_table_top(
-                                    bgp_node_get_bgp_table_info(rn1));
-                            rn2; rn2 = bgp_route_next(rn2)) {
-
-                               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;
                        }
                }
        }
@@ -2984,8 +2978,9 @@ void vnc_import_bgp_exterior_redist_disable(struct bgp *bgp, afi_t afi)
                                if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED))
                                        continue;
 
-                               vnc_import_bgp_exterior_del_route(bgp_exterior,
-                                                                 &rn->p, bpi);
+                               vnc_import_bgp_exterior_del_route(
+                                       bgp_exterior, bgp_node_get_prefix(rn),
+                                       bpi);
                        }
                }
 #if DEBUG_RHN_LIST