summaryrefslogtreecommitdiff
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
authorDon Slice <dslice@nvidia.com>2021-07-16 14:36:10 -0400
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-09-18 18:03:10 +0300
commit4d0e7a49cf8d4311a485281fa50bbff6ee8ca6cc (patch)
tree874719ce2686284bf405b6f62815343a433b1684 /bgpd/bgp_route.c
parent6109043c54b0c0efccc2d5ca8317cb7fb2529fb9 (diff)
bgpd: VRF-Lite fix default bgp delete
1. bgp coredump is observed when we delete default bgp instance when we have multi-vrf; and route-leaking is enabled between default, non-default vrfs. Removing default router bgp when routes leaked between non-default vrfs. - Routes are leaked from VRF-A to VRF-B - VPN table is created with auto RD/RT in default instance. - Default instance is deleted, we try to unimport the routes from all VRFs - non-default VRF schedules a work-queue to process deleted routes. - Meanwhile default bgp instance clears VPN tables and free the route entries as well, which are still referenced by non-default VRFs which have imported routes. - When work queue process starts to delete imported route in VRF-A it cores as it accesses freed memory. - Whenever we delete bgp in default vrf, we skip deleting routes in the vpn table, import and export lists. - The default hidden bgp instance will not be listed in any of the show commands. - Whenever we create new default instance, handle it with AS number change i.e. old hidden default bgp's AS number is updated and also changing local_as for all peers. 2. A default instance is created with ASN of the vrf with the import statement. This may not be the ASN desired for the default table - First problem with current behavior. Define two vrfs with different ASNs and then add import between. starting without any bgp config (no default instance) A default instance is created with ASN of the vrf with the import statement. This may not be the ASN desired for the default table - Second related problem. Start with a default instance and a vrf in a different ASN. Do an import statement in the vrf for a bgp vrf instance not yet defined and it auto-creates that bgp/vrf instance and it inherits the ASN of the importing vrf - Handle bgp instances with different ASNs and handle ASN for auto created BGP instance Signed-off-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 1f1b900444..223e0cb88a 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3618,7 +3618,16 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
struct bgp_path_info_pair old_and_new;
int debug = 0;
- if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
+ /*
+ * For default bgp instance, which is deleted i.e. marked hidden
+ * we are skipping SAFI_MPLS_VPN route table deletion
+ * in bgp_cleanup_routes.
+ * So, we need to delete routes from VPNV4 table.
+ * Here for !IS_BGP_INSTANCE_HIDDEN,
+ * !(SAFI_MPLS_VPN && AF_IP/AF_IP6),
+ * we ignore the event for the prefix.
+ */
+ if (BGP_INSTANCE_HIDDEN_DELETE_IN_PROGRESS(bgp, afi, safi)) {
if (dest)
debug = bgp_debug_bestpath(dest);
if (debug)
@@ -6444,16 +6453,21 @@ void bgp_cleanup_routes(struct bgp *bgp)
if (afi != AFI_L2VPN) {
safi_t safi;
safi = SAFI_MPLS_VPN;
- for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
- dest = bgp_route_next(dest)) {
- table = bgp_dest_get_bgp_table_info(dest);
- if (table != NULL) {
- bgp_cleanup_table(bgp, table, afi, safi);
- bgp_table_finish(&table);
- bgp_dest_set_bgp_table_info(dest, NULL);
- dest = bgp_dest_unlock_node(dest);
-
- assert(dest);
+ if (!IS_BGP_INSTANCE_HIDDEN(bgp)) {
+ for (dest = bgp_table_top(bgp->rib[afi][safi]);
+ dest; dest = bgp_route_next(dest)) {
+ table = bgp_dest_get_bgp_table_info(
+ dest);
+ if (table != NULL) {
+ bgp_cleanup_table(bgp, table,
+ afi, safi);
+ bgp_table_finish(&table);
+ bgp_dest_set_bgp_table_info(dest,
+ NULL);
+ dest = bgp_dest_unlock_node(
+ dest);
+ assert(dest);
+ }
}
}
safi = SAFI_ENCAP;
@@ -12157,7 +12171,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
bgp = bgp_get_default();
}
- if (bgp == NULL) {
+ if (bgp == NULL || IS_BGP_INSTANCE_HIDDEN(bgp)) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
else
@@ -12203,6 +12217,8 @@ static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi,
vty_out(vty, "{\n");
for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) {
+ if (IS_BGP_INSTANCE_HIDDEN(bgp))
+ continue;
route_output = true;
if (use_json) {
if (!is_first)
@@ -12721,7 +12737,7 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str,
{
if (!bgp) {
bgp = bgp_get_default();
- if (!bgp) {
+ if (!bgp || IS_BGP_INSTANCE_HIDDEN(bgp)) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
else
@@ -14379,7 +14395,7 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix,
int idx = 0;
char *network = NULL;
struct bgp *bgp = bgp_get_default();
- if (!bgp) {
+ if (!bgp || IS_BGP_INSTANCE_HIDDEN(bgp)) {
vty_out(vty, "Can't find default instance\n");
return CMD_WARNING;
}
@@ -15881,7 +15897,7 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
/* BGP structure lookup. */
if (view_name) {
bgp = bgp_lookup_by_name(view_name);
- if (bgp == NULL) {
+ if (bgp == NULL || IS_BGP_INSTANCE_HIDDEN(bgp)) {
vty_out(vty, "%% Can't find BGP instance %s\n",
view_name);
return CMD_WARNING;