Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EVPN] Skip EVPN routes with invalid VNI or router mac field #3073

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -197,6 +197,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 @@ -506,4 +510,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);
}
}
Loading