Skip to content

Commit

Permalink
[EVPN] Skip EVPN routes with invalid VNI or router mac field (#3073)
Browse files Browse the repository at this point in the history
* Skip EVPN routes with invalid VNI or router mac field
  • Loading branch information
liorghub authored Mar 11, 2024
1 parent 600d5e8 commit e9931f3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,18 @@ void RouteOrch::doTask(Consumer& consumer)
}
else
{
if(ipv.size() != rmacv.size()){
SWSS_LOG_ERROR("Skip route %s, it has an invalid router mac field %s", key.c_str(), remote_macs.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

if(ipv.size() != vni_labelv.size()){
SWSS_LOG_ERROR("Skip route %s, it has an invalid vni label field %s", key.c_str(), vni_labels.c_str());
it = consumer.m_toSync.erase(it);
continue;
}

for (uint32_t i = 0; i < ipv.size(); i++)
{
if (i) nhg_str += NHG_DELIMITER;
Expand Down
32 changes: 32 additions & 0 deletions tests/mock_tests/routeorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ namespace routeorch_test

ASSERT_EQ(gVrfOrch, nullptr);
gVrfOrch = new VRFOrch(m_app_db.get(), APP_VRF_TABLE_NAME, m_state_db.get(), STATE_VRF_OBJECT_TABLE_NAME);
gDirectory.set(gVrfOrch);

EvpnNvoOrch *evpn_orch = new EvpnNvoOrch(m_app_db.get(), APP_VXLAN_EVPN_NVO_TABLE_NAME);
gDirectory.set(evpn_orch);

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

gMockResponsePublisher.reset();
}

TEST_F(RouteOrchTest, RouteOrchTestInvalidEvpnRoute)
{
std::deque<KeyOpFieldsValuesTuple> entries;
entries.push_back({"Vrf1", "SET", { {"vni", "500100"}, {"v4", "true"}}});
auto consumer = dynamic_cast<Consumer *>(gVrfOrch->getExecutor(APP_VRF_TABLE_NAME));
consumer->addToSync(entries);
static_cast<Orch *>(gVrfOrch)->doTask();

entries.clear();
entries.push_back({"Vrf1:1.1.1.0/24", "SET", { {"ifname", "Ethernet0,Ethernet0"},
{"nexthop", "10.0.0.2,10.0.0.3"},
{"vni_label", "500100"},
{"router_mac", "7e:f0:c0:e4:b2:5a,7e:f0:c0:e4:b2:5b"}}});
entries.push_back({"Vrf1:2.1.1.0/24", "SET", { {"ifname", "Ethernet0,Ethernet0"},
{"nexthop", "10.0.0.2,10.0.0.3"},
{"vni_label", "500100,500100"},
{"router_mac", "7e:f0:c0:e4:b2:5b"}}});
consumer = dynamic_cast<Consumer *>(gRouteOrch->getExecutor(APP_ROUTE_TABLE_NAME));
consumer->addToSync(entries);

auto current_create_count = create_route_count;
auto current_set_count = set_route_count;

static_cast<Orch *>(gRouteOrch)->doTask();
ASSERT_EQ(current_create_count, create_route_count);
ASSERT_EQ(current_set_count, set_route_count);
}
}

0 comments on commit e9931f3

Please sign in to comment.