Skip to content

Commit a5e6bea

Browse files
sdddeanlguohan
authored andcommitted
[vxlanorch] Fix Logic of Vxlan tunnel removal (sonic-net#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 <[email protected]>
1 parent 5166212 commit a5e6bea

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

orchagent/vxlanorch.cpp

+20-6
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,17 @@ create_tunnel(
295295
void
296296
remove_tunnel(sai_object_id_t tunnel_id)
297297
{
298-
sai_status_t status = sai_tunnel_api->remove_tunnel(tunnel_id);
299-
if (status != SAI_STATUS_SUCCESS)
298+
if (tunnel_id != SAI_NULL_OBJECT_ID)
299+
{
300+
sai_status_t status = sai_tunnel_api->remove_tunnel(tunnel_id);
301+
if (status != SAI_STATUS_SUCCESS)
302+
{
303+
throw std::runtime_error("Can't remove a tunnel object");
304+
}
305+
}
306+
else
300307
{
301-
throw std::runtime_error("Can't remove a tunnel object");
308+
SWSS_LOG_DEBUG("Tunnel id is NULL.");
302309
}
303310
}
304311

@@ -364,10 +371,17 @@ create_tunnel_termination(
364371
void
365372
remove_tunnel_termination(sai_object_id_t term_table_id)
366373
{
367-
sai_status_t status = sai_tunnel_api->remove_tunnel_term_table_entry(term_table_id);
368-
if (status != SAI_STATUS_SUCCESS)
374+
if (term_table_id != SAI_NULL_OBJECT_ID)
375+
{
376+
sai_status_t status = sai_tunnel_api->remove_tunnel_term_table_entry(term_table_id);
377+
if (status != SAI_STATUS_SUCCESS)
378+
{
379+
throw std::runtime_error("Can't remove a tunnel term table object");
380+
}
381+
}
382+
else
369383
{
370-
throw std::runtime_error("Can't remove a tunnel term table object");
384+
SWSS_LOG_DEBUG("Tunnel term table id is NULL.");
371385
}
372386
}
373387

orchagent/vxlanorch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class VxlanTunnel
121121
string tunnel_name_;
122122
bool active_ = false;
123123

124-
tunnel_ids_t ids_;
124+
tunnel_ids_t ids_ = {0, 0, 0, 0};
125125
std::pair<MAP_T, MAP_T> tunnel_map_ = { MAP_T::MAP_TO_INVALID, MAP_T::MAP_TO_INVALID };
126126

127127
TunnelMapEntries tunnel_map_entries_;

0 commit comments

Comments
 (0)