From 2ea8581da4ba6f97bebde4845a234d7c810e5515 Mon Sep 17 00:00:00 2001 From: Sumukha Tumkur Vani Date: Tue, 26 Apr 2022 09:36:55 -0700 Subject: [PATCH] Removing Vnet with scope default (#2239) * [Vnetorch] Delete vnet vrf object when scope is not default --- orchagent/vnetorch.cpp | 11 +++++++---- tests/test_vnet.py | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/orchagent/vnetorch.cpp b/orchagent/vnetorch.cpp index 5e81fb0d75f8..5f51de167dc2 100644 --- a/orchagent/vnetorch.cpp +++ b/orchagent/vnetorch.cpp @@ -312,11 +312,14 @@ VNetVrfObject::~VNetVrfObject() set vr_ent = getVRids(); for (auto it : vr_ent) { - sai_status_t status = sai_virtual_router_api->remove_virtual_router(it); - if (status != SAI_STATUS_SUCCESS) + if (it != gVirtualRouterId) { - SWSS_LOG_ERROR("Failed to remove virtual router name: %s, rv:%d", - vnet_name_.c_str(), status); + sai_status_t status = sai_virtual_router_api->remove_virtual_router(it); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to remove virtual router name: %s, rv:%d", + vnet_name_.c_str(), status); + } } gFlowCounterRouteOrch->onRemoveVR(it); } diff --git a/tests/test_vnet.py b/tests/test_vnet.py index 0f0e5540920f..39cb648c8cd9 100644 --- a/tests/test_vnet.py +++ b/tests/test_vnet.py @@ -1439,6 +1439,9 @@ def test_vnet_orch_5(self, dvs, testlog): vnet_obj.check_default_vnet_entry(dvs, 'Vnet_5') vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet_5', '4789') + delete_vnet_entry(dvs, 'Vnet_5') + vnet_obj.check_default_vnet_entry(dvs, 'Vnet_5') + ''' Test 6 - Test VxLAN tunnel with multiple maps '''