diff --git a/orchagent/vxlanorch.cpp b/orchagent/vxlanorch.cpp index 6e25454f13e..22cfc75bf00 100644 --- a/orchagent/vxlanorch.cpp +++ b/orchagent/vxlanorch.cpp @@ -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(); if (!isTunnelExists(tunnel_name)) { @@ -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()); diff --git a/orchagent/vxlanorch.h b/orchagent/vxlanorch.h index edc65d97fe2..2800e097ff3 100644 --- a/orchagent/vxlanorch.h +++ b/orchagent/vxlanorch.h @@ -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);