Skip to content

Commit e9931f3

Browse files
authored
[EVPN] Skip EVPN routes with invalid VNI or router mac field (#3073)
* Skip EVPN routes with invalid VNI or router mac field
1 parent 600d5e8 commit e9931f3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

orchagent/routeorch.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,18 @@ void RouteOrch::doTask(Consumer& consumer)
807807
}
808808
else
809809
{
810+
if(ipv.size() != rmacv.size()){
811+
SWSS_LOG_ERROR("Skip route %s, it has an invalid router mac field %s", key.c_str(), remote_macs.c_str());
812+
it = consumer.m_toSync.erase(it);
813+
continue;
814+
}
815+
816+
if(ipv.size() != vni_labelv.size()){
817+
SWSS_LOG_ERROR("Skip route %s, it has an invalid vni label field %s", key.c_str(), vni_labels.c_str());
818+
it = consumer.m_toSync.erase(it);
819+
continue;
820+
}
821+
810822
for (uint32_t i = 0; i < ipv.size(); i++)
811823
{
812824
if (i) nhg_str += NHG_DELIMITER;

tests/mock_tests/routeorch_ut.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ namespace routeorch_test
198198

199199
ASSERT_EQ(gVrfOrch, nullptr);
200200
gVrfOrch = new VRFOrch(m_app_db.get(), APP_VRF_TABLE_NAME, m_state_db.get(), STATE_VRF_OBJECT_TABLE_NAME);
201+
gDirectory.set(gVrfOrch);
202+
203+
EvpnNvoOrch *evpn_orch = new EvpnNvoOrch(m_app_db.get(), APP_VXLAN_EVPN_NVO_TABLE_NAME);
204+
gDirectory.set(evpn_orch);
201205

202206
ASSERT_EQ(gIntfsOrch, nullptr);
203207
gIntfsOrch = new IntfsOrch(m_app_db.get(), APP_INTF_TABLE_NAME, gVrfOrch, m_chassis_app_db.get());
@@ -507,4 +511,32 @@ namespace routeorch_test
507511

508512
gMockResponsePublisher.reset();
509513
}
514+
515+
TEST_F(RouteOrchTest, RouteOrchTestInvalidEvpnRoute)
516+
{
517+
std::deque<KeyOpFieldsValuesTuple> entries;
518+
entries.push_back({"Vrf1", "SET", { {"vni", "500100"}, {"v4", "true"}}});
519+
auto consumer = dynamic_cast<Consumer *>(gVrfOrch->getExecutor(APP_VRF_TABLE_NAME));
520+
consumer->addToSync(entries);
521+
static_cast<Orch *>(gVrfOrch)->doTask();
522+
523+
entries.clear();
524+
entries.push_back({"Vrf1:1.1.1.0/24", "SET", { {"ifname", "Ethernet0,Ethernet0"},
525+
{"nexthop", "10.0.0.2,10.0.0.3"},
526+
{"vni_label", "500100"},
527+
{"router_mac", "7e:f0:c0:e4:b2:5a,7e:f0:c0:e4:b2:5b"}}});
528+
entries.push_back({"Vrf1:2.1.1.0/24", "SET", { {"ifname", "Ethernet0,Ethernet0"},
529+
{"nexthop", "10.0.0.2,10.0.0.3"},
530+
{"vni_label", "500100,500100"},
531+
{"router_mac", "7e:f0:c0:e4:b2:5b"}}});
532+
consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
533+
consumer->addToSync(entries);
534+
535+
auto current_create_count = create_route_count;
536+
auto current_set_count = set_route_count;
537+
538+
static_cast<Orch *>(gRouteOrch)->doTask();
539+
ASSERT_EQ(current_create_count, create_route_count);
540+
ASSERT_EQ(current_set_count, set_route_count);
541+
}
510542
}

0 commit comments

Comments
 (0)