diff --git a/orchagent/intfsorch.cpp b/orchagent/intfsorch.cpp index cf6a926cfdf6..44978658928e 100644 --- a/orchagent/intfsorch.cpp +++ b/orchagent/intfsorch.cpp @@ -670,9 +670,17 @@ void IntfsOrch::removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix) sai_status_t status = sai_route_api->remove_route_entry(&unicast_route_entry); if (status != SAI_STATUS_SUCCESS) { - SWSS_LOG_ERROR("Failed to remove subnet route to %s from %s, rv:%d", - ip_prefix.to_string().c_str(), port.m_alias.c_str(), status); - throw runtime_error("Failed to remove subnet route."); + if (status == SAI_STATUS_ITEM_NOT_FOUND) + { + SWSS_LOG_ERROR("No subnet route found for %s", ip_prefix.to_string().c_str()); + return; + } + else + { + SWSS_LOG_ERROR("Failed to remove subnet route to %s from %s, rv:%d", + ip_prefix.to_string().c_str(), port.m_alias.c_str(), status); + throw runtime_error("Failed to remove subnet route."); + } } SWSS_LOG_NOTICE("Remove subnet route to %s from %s", diff --git a/orchagent/vnetorch.cpp b/orchagent/vnetorch.cpp index 9346ba1a586f..b5a0739a6097 100644 --- a/orchagent/vnetorch.cpp +++ b/orchagent/vnetorch.cpp @@ -1329,7 +1329,7 @@ VNetOrch::VNetOrch(DBConnector *db, const std::string& tableName, VNET_EXEC op) if (op == VNET_EXEC::VNET_EXEC_VRF) { - vr_cntxt = { VR_TYPE::ING_VR_VALID, VR_TYPE::EGR_VR_VALID }; + vr_cntxt = { VR_TYPE::ING_VR_VALID }; } else { @@ -1647,8 +1647,9 @@ bool VNetRouteOrch::doRouteTask(const string& vnet, IpPrefix& ipP if (!vnet_orch_->isVnetExists(vnet)) { - SWSS_LOG_WARN("VNET %s doesn't exist", vnet.c_str()); - return false; + SWSS_LOG_WARN("VNET %s doesn't exist for prefix %s, op %s", + vnet.c_str(), ipPrefix.to_string().c_str(), op.c_str()); + return (op == DEL_COMMAND)?true:false; } set vr_set; @@ -1710,8 +1711,9 @@ bool VNetRouteOrch::doRouteTask(const string& vnet, IpPrefix& ipP if (!vnet_orch_->isVnetExists(vnet)) { - SWSS_LOG_WARN("VNET %s doesn't exist", vnet.c_str()); - return false; + SWSS_LOG_WARN("VNET %s doesn't exist for prefix %s, op %s", + vnet.c_str(), ipPrefix.to_string().c_str(), op.c_str()); + return (op == DEL_COMMAND)?true:false; } auto *vrf_obj = vnet_orch_->getTypePtr(vnet); @@ -1799,14 +1801,18 @@ bool VNetRouteOrch::doRouteTask(const string& vnet, IpPrefix& ipP for (auto vr_id : vr_set) { + if (vr_id == SAI_NULL_OBJECT_ID) + { + continue; + } if (op == SET_COMMAND && !add_route(vr_id, pfx, nh_id)) { - SWSS_LOG_ERROR("Route add failed for %s", ipPrefix.to_string().c_str()); + SWSS_LOG_INFO("Route add failed for %s", ipPrefix.to_string().c_str()); break; } else if (op == DEL_COMMAND && !del_route(vr_id, pfx)) { - SWSS_LOG_ERROR("Route del failed for %s", ipPrefix.to_string().c_str()); + SWSS_LOG_INFO("Route del failed for %s", ipPrefix.to_string().c_str()); break; } } diff --git a/orchagent/vnetorch.h b/orchagent/vnetorch.h index a7da8d90fe64..8999d8cbe0ec 100644 --- a/orchagent/vnetorch.h +++ b/orchagent/vnetorch.h @@ -142,7 +142,14 @@ class VNetVrfObject : public VNetObject sai_object_id_t getDecapMapId() const { - return getVRidEgress(); + if (std::find(vr_cntxt.begin(), vr_cntxt.end(), VR_TYPE::EGR_VR_VALID) != vr_cntxt.end()) + { + return getVRidEgress(); + } + else + { + return getVRidIngress(); + } } sai_object_id_t getVRid() const diff --git a/tests/test_vnet.py b/tests/test_vnet.py index 5eac68381ce3..2870f5bd8edd 100644 --- a/tests/test_vnet.py +++ b/tests/test_vnet.py @@ -63,7 +63,7 @@ def get_all_created_entries(db, table, existed_entries): tbl = swsscommon.Table(db, table) entries = set(tbl.getKeys()) new_entries = list(entries - existed_entries) - assert len(new_entries) > 0, "No created entries." + assert len(new_entries) >= 0, "Get all could be no new created entries." new_entries.sort() return new_entries @@ -521,13 +521,13 @@ def check_vxlan_tunnel_entry(self, dvs, tunnel_name, vnet_name, vni_id): def check_vnet_entry(self, dvs, name, peer_list=[]): asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) #Check virtual router objects - assert how_many_entries_exist(asic_db, self.ASIC_VRF_TABLE) == (len(self.vnet_vr_ids) + 2),\ + assert how_many_entries_exist(asic_db, self.ASIC_VRF_TABLE) == (len(self.vnet_vr_ids) + 1),\ "The VR objects are not created" - new_vr_ids = get_created_entries(asic_db, self.ASIC_VRF_TABLE, self.vnet_vr_ids, 2) + new_vr_ids = get_created_entries(asic_db, self.ASIC_VRF_TABLE, self.vnet_vr_ids, 1) self.vnet_vr_ids.update(new_vr_ids) - self.vr_map[name] = { 'ing':new_vr_ids[0], 'egr':new_vr_ids[1], 'peer':peer_list } + self.vr_map[name] = { 'ing':new_vr_ids[0], 'egr':new_vr_ids[0], 'peer':peer_list } def check_default_vnet_entry(self, dvs, name): asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0) @@ -544,9 +544,7 @@ def check_del_vnet_entry(self, dvs, name): def vnet_route_ids(self, dvs, name, local=False): vr_set = set() - if local: - vr_set.add(self.vr_map[name].get('egr')) - else: + if not local: vr_set.add(self.vr_map[name].get('ing')) try: @@ -599,7 +597,10 @@ def check_vnet_local_routes(self, dvs, name): new_route = get_created_entries(asic_db, self.ASIC_ROUTE_ENTRY, self.routes, count) - #Check if the route is duplicated to egress VRF + #Routes are not replicated to egress VRF, return if count is 0, else check peering + if not count: + return + asic_vrs = set() for idx in range(count): rt_key = json.loads(new_route[idx])