diff --git a/orchagent/vxlanorch.cpp b/orchagent/vxlanorch.cpp index 543cfe10890..e385c64c20c 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 d4d3a60eea5..008175f92b5 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_;