Skip to content

Commit 3461710

Browse files
authored
Single VRF for ingress and egress flows, skip route replication (#1045)
* Single VRF approach for VNets, no egress replication
1 parent 953474a commit 3461710

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

orchagent/intfsorch.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,17 @@ void IntfsOrch::removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix)
670670
sai_status_t status = sai_route_api->remove_route_entry(&unicast_route_entry);
671671
if (status != SAI_STATUS_SUCCESS)
672672
{
673-
SWSS_LOG_ERROR("Failed to remove subnet route to %s from %s, rv:%d",
674-
ip_prefix.to_string().c_str(), port.m_alias.c_str(), status);
675-
throw runtime_error("Failed to remove subnet route.");
673+
if (status == SAI_STATUS_ITEM_NOT_FOUND)
674+
{
675+
SWSS_LOG_ERROR("No subnet route found for %s", ip_prefix.to_string().c_str());
676+
return;
677+
}
678+
else
679+
{
680+
SWSS_LOG_ERROR("Failed to remove subnet route to %s from %s, rv:%d",
681+
ip_prefix.to_string().c_str(), port.m_alias.c_str(), status);
682+
throw runtime_error("Failed to remove subnet route.");
683+
}
676684
}
677685

678686
SWSS_LOG_NOTICE("Remove subnet route to %s from %s",

orchagent/vnetorch.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ VNetOrch::VNetOrch(DBConnector *db, const std::string& tableName, VNET_EXEC op)
13291329

13301330
if (op == VNET_EXEC::VNET_EXEC_VRF)
13311331
{
1332-
vr_cntxt = { VR_TYPE::ING_VR_VALID, VR_TYPE::EGR_VR_VALID };
1332+
vr_cntxt = { VR_TYPE::ING_VR_VALID };
13331333
}
13341334
else
13351335
{
@@ -1647,8 +1647,9 @@ bool VNetRouteOrch::doRouteTask<VNetVrfObject>(const string& vnet, IpPrefix& ipP
16471647

16481648
if (!vnet_orch_->isVnetExists(vnet))
16491649
{
1650-
SWSS_LOG_WARN("VNET %s doesn't exist", vnet.c_str());
1651-
return false;
1650+
SWSS_LOG_WARN("VNET %s doesn't exist for prefix %s, op %s",
1651+
vnet.c_str(), ipPrefix.to_string().c_str(), op.c_str());
1652+
return (op == DEL_COMMAND)?true:false;
16521653
}
16531654

16541655
set<sai_object_id_t> vr_set;
@@ -1710,8 +1711,9 @@ bool VNetRouteOrch::doRouteTask<VNetVrfObject>(const string& vnet, IpPrefix& ipP
17101711

17111712
if (!vnet_orch_->isVnetExists(vnet))
17121713
{
1713-
SWSS_LOG_WARN("VNET %s doesn't exist", vnet.c_str());
1714-
return false;
1714+
SWSS_LOG_WARN("VNET %s doesn't exist for prefix %s, op %s",
1715+
vnet.c_str(), ipPrefix.to_string().c_str(), op.c_str());
1716+
return (op == DEL_COMMAND)?true:false;
17151717
}
17161718

17171719
auto *vrf_obj = vnet_orch_->getTypePtr<VNetVrfObject>(vnet);
@@ -1799,14 +1801,18 @@ bool VNetRouteOrch::doRouteTask<VNetVrfObject>(const string& vnet, IpPrefix& ipP
17991801

18001802
for (auto vr_id : vr_set)
18011803
{
1804+
if (vr_id == SAI_NULL_OBJECT_ID)
1805+
{
1806+
continue;
1807+
}
18021808
if (op == SET_COMMAND && !add_route(vr_id, pfx, nh_id))
18031809
{
1804-
SWSS_LOG_ERROR("Route add failed for %s", ipPrefix.to_string().c_str());
1810+
SWSS_LOG_INFO("Route add failed for %s", ipPrefix.to_string().c_str());
18051811
break;
18061812
}
18071813
else if (op == DEL_COMMAND && !del_route(vr_id, pfx))
18081814
{
1809-
SWSS_LOG_ERROR("Route del failed for %s", ipPrefix.to_string().c_str());
1815+
SWSS_LOG_INFO("Route del failed for %s", ipPrefix.to_string().c_str());
18101816
break;
18111817
}
18121818
}

orchagent/vnetorch.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,14 @@ class VNetVrfObject : public VNetObject
142142

143143
sai_object_id_t getDecapMapId() const
144144
{
145-
return getVRidEgress();
145+
if (std::find(vr_cntxt.begin(), vr_cntxt.end(), VR_TYPE::EGR_VR_VALID) != vr_cntxt.end())
146+
{
147+
return getVRidEgress();
148+
}
149+
else
150+
{
151+
return getVRidIngress();
152+
}
146153
}
147154

148155
sai_object_id_t getVRid() const

tests/test_vnet.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_all_created_entries(db, table, existed_entries):
6363
tbl = swsscommon.Table(db, table)
6464
entries = set(tbl.getKeys())
6565
new_entries = list(entries - existed_entries)
66-
assert len(new_entries) > 0, "No created entries."
66+
assert len(new_entries) >= 0, "Get all could be no new created entries."
6767
new_entries.sort()
6868
return new_entries
6969

@@ -521,13 +521,13 @@ def check_vxlan_tunnel_entry(self, dvs, tunnel_name, vnet_name, vni_id):
521521
def check_vnet_entry(self, dvs, name, peer_list=[]):
522522
asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
523523
#Check virtual router objects
524-
assert how_many_entries_exist(asic_db, self.ASIC_VRF_TABLE) == (len(self.vnet_vr_ids) + 2),\
524+
assert how_many_entries_exist(asic_db, self.ASIC_VRF_TABLE) == (len(self.vnet_vr_ids) + 1),\
525525
"The VR objects are not created"
526526

527-
new_vr_ids = get_created_entries(asic_db, self.ASIC_VRF_TABLE, self.vnet_vr_ids, 2)
527+
new_vr_ids = get_created_entries(asic_db, self.ASIC_VRF_TABLE, self.vnet_vr_ids, 1)
528528

529529
self.vnet_vr_ids.update(new_vr_ids)
530-
self.vr_map[name] = { 'ing':new_vr_ids[0], 'egr':new_vr_ids[1], 'peer':peer_list }
530+
self.vr_map[name] = { 'ing':new_vr_ids[0], 'egr':new_vr_ids[0], 'peer':peer_list }
531531

532532
def check_default_vnet_entry(self, dvs, name):
533533
asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
@@ -544,9 +544,7 @@ def check_del_vnet_entry(self, dvs, name):
544544
def vnet_route_ids(self, dvs, name, local=False):
545545
vr_set = set()
546546

547-
if local:
548-
vr_set.add(self.vr_map[name].get('egr'))
549-
else:
547+
if not local:
550548
vr_set.add(self.vr_map[name].get('ing'))
551549

552550
try:
@@ -599,7 +597,10 @@ def check_vnet_local_routes(self, dvs, name):
599597

600598
new_route = get_created_entries(asic_db, self.ASIC_ROUTE_ENTRY, self.routes, count)
601599

602-
#Check if the route is duplicated to egress VRF
600+
#Routes are not replicated to egress VRF, return if count is 0, else check peering
601+
if not count:
602+
return
603+
603604
asic_vrs = set()
604605
for idx in range(count):
605606
rt_key = json.loads(new_route[idx])

0 commit comments

Comments
 (0)