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

Check resource release or not before removing local vtep. #2082

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,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 @@ -1628,6 +1629,26 @@ 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(); ++it)
{
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;
}
}

if (0 != vxlan_vni_vlan_map_table_.size() )
{
SWSS_LOG_WARN("VTEP %s not deleted as there is vlan vni map still in used", tunnel_name.c_str());
return false;
}

evpn_orch->delEVPNVtep();
}

vxlan_tunnel_table_.erase(tunnel_name);

SWSS_LOG_NOTICE("Vxlan tunnel '%s' was removed", tunnel_name.c_str());
Expand Down Expand Up @@ -2629,6 +2650,9 @@ bool EvpnNvoOrch::addOperation(const Request& request)

source_vtep_ptr = tunnel_orch->getVxlanTunnel(vtep_name);

if (!source_vtep_ptr)
return false;

SWSS_LOG_INFO("evpnnvo: %s vtep : %s \n",nvo_name.c_str(), vtep_name.c_str());

return true;
Expand All @@ -2640,6 +2664,10 @@ bool EvpnNvoOrch::delOperation(const Request& request)

auto nvo_name = request.getKeyString(0);

VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
auto tunnel_size = tunnel_orch->getVxlanTunnelSize();
auto vni_vlan_map_size = tunnel_orch->getVniVlanMapTableSize();

if (!source_vtep_ptr)
{
SWSS_LOG_WARN("NVO Delete failed as VTEP Ptr is NULL");
Expand All @@ -2652,6 +2680,18 @@ bool EvpnNvoOrch::delOperation(const Request& request)
return false;
}

if (tunnel_size != 0)
{
SWSS_LOG_WARN("NVO not deleted as there is user tuunel still in used");
return false;
}

if (vni_vlan_map_size != 0)
{
SWSS_LOG_WARN("NVO not deleted as there is vni vlan map still in used");
return false;
}

source_vtep_ptr = NULL;

SWSS_LOG_INFO("NVO: %s \n",nvo_name.c_str());
Expand Down
15 changes: 15 additions & 0 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ class VxlanTunnelOrch : public Orch2
return vxlan_tunnel_table_.at(tunnelName).get();
}

auto getVxlanTunnelSize()
{
return vxlan_tunnel_table_.size();
}

bool addTunnel(const std::string tunnel_name,VxlanTunnel* tnlptr)
{
vxlan_tunnel_table_[tunnel_name] = (VxlanTunnel_T)tnlptr;
Expand Down Expand Up @@ -342,6 +347,11 @@ class VxlanTunnelOrch : public Orch2
}
}

auto getVniVlanMapTableSize()
{
return vxlan_vni_vlan_map_table_.size();
}

void addVlanMappedToVni(uint32_t vni, uint16_t vlan_id)
{
vxlan_vni_vlan_map_table_[vni] = vlan_id;
Expand Down Expand Up @@ -531,6 +541,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