Skip to content

Commit

Permalink
[EVPN]Fixing nexthop group delete when multiple routes point to the n…
Browse files Browse the repository at this point in the history
…exthop group (#2744)

* [EVPN]Fixing nexthop group delete when multiple routes point to the nexthop
  • Loading branch information
dgsudharsan authored May 1, 2023
1 parent 6e25014 commit 4c6fc31
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 19 deletions.
50 changes: 32 additions & 18 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2214,15 +2214,22 @@ bool RouteOrch::addRoutePost(const RouteBulkContext& ctx, const NextHopGroupKey
{
decreaseNextHopRefCount(it_route->second.nhg_key);
auto ol_nextHops = it_route->second.nhg_key;
if (ol_nextHops.getSize() > 1
&& m_syncdNextHopGroups[ol_nextHops].ref_count == 0)
if (ol_nextHops.getSize() > 1)
{
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, 0);
if (m_syncdNextHopGroups[ol_nextHops].ref_count == 0)
{
SWSS_LOG_NOTICE("Update Nexthop Group %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, 0);
}
}
else if (ol_nextHops.is_overlay_nexthop())
{
SWSS_LOG_NOTICE("Update overlay Nexthop %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, vrf_id);
const NextHopKey& nexthop = *it_route->second.nhg_key.getNextHops().begin();
if (m_neighOrch->getNextHopRefCount(nexthop) == 0)
{
SWSS_LOG_NOTICE("Update overlay Nexthop %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, vrf_id);
}
}
else if (ol_nextHops.is_srv6_nexthop())
{
Expand Down Expand Up @@ -2475,29 +2482,36 @@ bool RouteOrch::removeRoutePost(const RouteBulkContext& ctx)

auto ol_nextHops = it_route->second.nhg_key;
MuxOrch* mux_orch = gDirectory.get<MuxOrch*>();
if (it_route->second.nhg_key.getSize() > 1
&& m_syncdNextHopGroups[it_route->second.nhg_key].ref_count == 0)
if (it_route->second.nhg_key.getSize() > 1)
{
m_bulkNhgReducedRefCnt.emplace(it_route->second.nhg_key, 0);
if (mux_orch->isMuxNexthops(ol_nextHops))
if (m_syncdNextHopGroups[it_route->second.nhg_key].ref_count == 0)
{
SWSS_LOG_NOTICE("Remove mux Nexthop %s", ol_nextHops.to_string().c_str());
RouteKey routekey = { vrf_id, ipPrefix };
auto nexthop_list = ol_nextHops.getNextHops();
for (auto nh = nexthop_list.begin(); nh != nexthop_list.end(); nh++)
SWSS_LOG_NOTICE("Remove Nexthop Group %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(it_route->second.nhg_key, 0);
if (mux_orch->isMuxNexthops(ol_nextHops))
{
if (!nh->ip_address.isZero())
SWSS_LOG_NOTICE("Remove mux Nexthop %s", ol_nextHops.to_string().c_str());
RouteKey routekey = { vrf_id, ipPrefix };
auto nexthop_list = ol_nextHops.getNextHops();
for (auto nh = nexthop_list.begin(); nh != nexthop_list.end(); nh++)
{
removeNextHopRoute(*nh, routekey);
if (!nh->ip_address.isZero())
{
removeNextHopRoute(*nh, routekey);
}
}
mux_orch->updateRoute(ipPrefix, false);
}
mux_orch->updateRoute(ipPrefix, false);
}
}
else if (ol_nextHops.is_overlay_nexthop())
{
SWSS_LOG_NOTICE("Remove overlay Nexthop %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, vrf_id);
const NextHopKey& nexthop = *it_route->second.nhg_key.getNextHops().begin();
if (m_neighOrch->getNextHopRefCount(nexthop) == 0)
{
SWSS_LOG_NOTICE("Remove overlay Nexthop %s", ol_nextHops.to_string().c_str());
m_bulkNhgReducedRefCnt.emplace(ol_nextHops, vrf_id);
}
}
/*
* Additionally check if the NH has label and its ref count == 0, then
Expand Down
2 changes: 1 addition & 1 deletion tests/evpn_tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ def check_del_vrf_routes(self, dvs, prefix, vrf_name):
assert found_route

self.helper.check_deleted_object(asic_db, self.ASIC_ROUTE_ENTRY, self.route_id[vrf_name + ":" + prefix])
self.route_id.clear()
del self.route_id[vrf_name + ":" + prefix]

return True

Expand Down
38 changes: 38 additions & 0 deletions tests/test_evpn_l3_vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,44 @@ def test_tunnel_ipv4_routes(self, dvs, testlog):
vxlan_obj.check_vrf_routes_ecmp_nexthop_grp_del(dvs, 2)
vxlan_obj.check_del_vrf_routes(dvs, "80.80.1.0/24", 'Vrf-RED')

print ("\n\nTest VRF IPv4 Multiple Route with ECMP Tunnel Nexthop Add and Delete")
vxlan_obj.fetch_exist_entries(dvs)

ecmp_nexthop_attr = [
("nexthop", "7.7.7.7,8.8.8.8"),
("ifname", "Vlan100,Vlan100"),
("vni_label", "1000,1000"),
("router_mac", "00:11:11:11:11:11,00:22:22:22:22:22"),
]

print ("\tTest VRF IPv4 Multiple Route with ECMP Tunnel Nexthop [7.7.7.7 , 8.8.8.8] Add")
vxlan_obj.create_vrf_route_ecmp(dvs, "80.80.1.0/24", 'Vrf-RED', ecmp_nexthop_attr)

nh_count = 2
ecmp_nhid_list = vxlan_obj.check_vrf_routes_ecmp(dvs, "80.80.1.0/24", 'Vrf-RED', tunnel_name, nh_count)
assert nh_count == len(ecmp_nhid_list)
vxlan_obj.check_add_tunnel_nexthop(dvs, ecmp_nhid_list[0], '7.7.7.7', tunnel_name, '00:11:11:11:11:11', '1000')
vxlan_obj.check_add_tunnel_nexthop(dvs, ecmp_nhid_list[1], '8.8.8.8', tunnel_name, '00:22:22:22:22:22', '1000')

nh_count = 2
vxlan_obj.create_vrf_route_ecmp(dvs, "90.90.1.0/24", 'Vrf-RED', ecmp_nexthop_attr)
ecmp_nhid_list = vxlan_obj.check_vrf_routes_ecmp(dvs, "90.90.1.0/24", 'Vrf-RED', tunnel_name, nh_count)
assert nh_count == len(ecmp_nhid_list)
vxlan_obj.check_add_tunnel_nexthop(dvs, ecmp_nhid_list[0], '7.7.7.7', tunnel_name, '00:11:11:11:11:11', '1000')
vxlan_obj.check_add_tunnel_nexthop(dvs, ecmp_nhid_list[1], '8.8.8.8', tunnel_name, '00:22:22:22:22:22', '1000')

print ("\tTest VRF IPv4 Multiple Route with ECMP Tunnel Nexthop [7.7.7.7 , 8.8.8.8] Delete")
vxlan_obj.fetch_exist_entries(dvs)
vxlan_obj.delete_vrf_route(dvs, "80.80.1.0/24", 'Vrf-RED')
vxlan_obj.check_del_vrf_routes(dvs, "80.80.1.0/24", 'Vrf-RED')
vxlan_obj.fetch_exist_entries(dvs)
vxlan_obj.delete_vrf_route(dvs, "90.90.1.0/24", 'Vrf-RED')
vxlan_obj.check_del_vrf_routes(dvs, "90.90.1.0/24", 'Vrf-RED')
helper.check_deleted_object(self.adb, vxlan_obj.ASIC_NEXT_HOP, ecmp_nhid_list[0])
helper.check_deleted_object(self.adb, vxlan_obj.ASIC_NEXT_HOP, ecmp_nhid_list[1])

vxlan_obj.check_vrf_routes_ecmp_nexthop_grp_del(dvs, 2)

print ("\n\nTest VRF IPv4 Route with Tunnel Nexthop update from non-ECMP to ECMP")
print ("\tTest VRF IPv4 Route with Tunnel Nexthop 7.7.7.7 Add")
vxlan_obj.fetch_exist_entries(dvs)
Expand Down

0 comments on commit 4c6fc31

Please sign in to comment.