Skip to content

Commit

Permalink
[vxlanorch] Fix Logic of Vxlan tunnel removal (sonic-net#995)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sdddean authored and lguohan committed Jul 31, 2019
1 parent 5166212 commit a5e6bea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -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.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MAP_T, MAP_T> tunnel_map_ = { MAP_T::MAP_TO_INVALID, MAP_T::MAP_TO_INVALID };

TunnelMapEntries tunnel_map_entries_;
Expand Down

0 comments on commit a5e6bea

Please sign in to comment.