Skip to content

Commit

Permalink
Fix the EVPN orch may access invalid address
Browse files Browse the repository at this point in the history
There is an private pointer in the EVPN orch which is used save the local
vtep. But the local vtep is add/removed in the vxlan tunnel orch, the
vxlan tunnel orch did not notify EVPN orch when remove the vtep and cause
EVPN orch may access invalid address
  • Loading branch information
gord1306 committed Mar 4, 2021
1 parent 721f47d commit 267243c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ bool VxlanTunnelOrch::delOperation(const Request& request)
SWSS_LOG_ENTER();

const auto& tunnel_name = request.getKeyString(0);
EvpnNvoOrch* evpn_orch = gDirectory.get<EvpnNvoOrch*>();

if (!isTunnelExists(tunnel_name))
{
Expand All @@ -1405,6 +1406,21 @@ bool VxlanTunnelOrch::delOperation(const Request& request)
return false;
}

if (vtep_ptr == evpn_orch->getEVPNVtep())
{
for (auto it = vxlan_tunnel_table_.begin(); it != vxlan_tunnel_table_.end(); )
{
if ((it->second.get() != vtep_ptr) || (it->second->getDipTunnelCnt() != 0) )
{
SWSS_LOG_WARN("VTEP %s not deleted as there is user tuunel still in used", tunnel_name.c_str());
return false;
}

++it;
}
evpn_orch->delEVPNVtep();
}

vxlan_tunnel_table_.erase(tunnel_name);

SWSS_LOG_NOTICE("Vxlan tunnel '%s' was removed", tunnel_name.c_str());
Expand Down
5 changes: 5 additions & 0 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ class EvpnNvoOrch : public Orch2
return source_vtep_ptr;
}

void delEVPNVtep()
{
source_vtep_ptr = NULL;
}

private:
virtual bool addOperation(const Request& request);
virtual bool delOperation(const Request& request);
Expand Down

0 comments on commit 267243c

Please sign in to comment.