From a5e6bea1d690bf503e77e274a0a68efd9f77d5f8 Mon Sep 17 00:00:00 2001 From: sdddean <50697155+sdddean@users.noreply.github.com> Date: Thu, 1 Aug 2019 06:14:25 +0800 Subject: [PATCH] [vxlanorch] Fix Logic of Vxlan tunnel removal (#995) As the vxlan tunnel_id and tunnel_term_id are not created until the map entrys are added, in case of configuring the vxlan tunnel without map entry, and then it is invalid to remove it without validity checking. Signed-off-by: sundandan --- orchagent/vxlanorch.cpp | 26 ++++++++++++++++++++------ orchagent/vxlanorch.h | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/orchagent/vxlanorch.cpp b/orchagent/vxlanorch.cpp index 543cfe1089..e385c64c20 100644 --- a/orchagent/vxlanorch.cpp +++ b/orchagent/vxlanorch.cpp @@ -295,10 +295,17 @@ create_tunnel( void remove_tunnel(sai_object_id_t tunnel_id) { - sai_status_t status = sai_tunnel_api->remove_tunnel(tunnel_id); - if (status != SAI_STATUS_SUCCESS) + if (tunnel_id != SAI_NULL_OBJECT_ID) + { + sai_status_t status = sai_tunnel_api->remove_tunnel(tunnel_id); + if (status != SAI_STATUS_SUCCESS) + { + throw std::runtime_error("Can't remove a tunnel object"); + } + } + else { - throw std::runtime_error("Can't remove a tunnel object"); + SWSS_LOG_DEBUG("Tunnel id is NULL."); } } @@ -364,10 +371,17 @@ create_tunnel_termination( void remove_tunnel_termination(sai_object_id_t term_table_id) { - sai_status_t status = sai_tunnel_api->remove_tunnel_term_table_entry(term_table_id); - if (status != SAI_STATUS_SUCCESS) + if (term_table_id != SAI_NULL_OBJECT_ID) + { + sai_status_t status = sai_tunnel_api->remove_tunnel_term_table_entry(term_table_id); + if (status != SAI_STATUS_SUCCESS) + { + throw std::runtime_error("Can't remove a tunnel term table object"); + } + } + else { - throw std::runtime_error("Can't remove a tunnel term table object"); + SWSS_LOG_DEBUG("Tunnel term table id is NULL."); } } diff --git a/orchagent/vxlanorch.h b/orchagent/vxlanorch.h index d4d3a60eea..008175f92b 100644 --- a/orchagent/vxlanorch.h +++ b/orchagent/vxlanorch.h @@ -121,7 +121,7 @@ class VxlanTunnel string tunnel_name_; bool active_ = false; - tunnel_ids_t ids_; + tunnel_ids_t ids_ = {0, 0, 0, 0}; std::pair tunnel_map_ = { MAP_T::MAP_TO_INVALID, MAP_T::MAP_TO_INVALID }; TunnelMapEntries tunnel_map_entries_;