From bbdf2148c8ffe97043e9734bfae824739ada0c56 Mon Sep 17 00:00:00 2001 From: gord_chen Date: Wed, 3 Mar 2021 09:44:35 +0000 Subject: [PATCH] Fix the EVPN orch may access invalid address 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 --- orchagent/vxlanorch.cpp | 6 ++++++ orchagent/vxlanorch.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/orchagent/vxlanorch.cpp b/orchagent/vxlanorch.cpp index 6e25454f13e..1d86e75c21b 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,11 @@ bool VxlanTunnelOrch::delOperation(const Request& request) return false; } + if (vtep_ptr == evpn_orch->getEVPNVtep()) + { + 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);