Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of VXLAN tunnel removal #931

Merged
merged 16 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a5b0a88
Pospone QueueMap initialization until activation of counters
pavel-shirshov Jun 25, 2018
1d54717
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Jun 29, 2018
b767c2e
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Jun 29, 2018
5e96d67
Generate queue maps only for front panel ports
pavel-shirshov Jul 2, 2018
21c072c
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Jul 4, 2018
00192a4
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Aug 22, 2018
1a71c39
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Aug 29, 2018
6bc8091
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Sep 5, 2018
83efbee
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Sep 11, 2018
c2f4fdf
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Sep 15, 2018
c4094b0
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Nov 7, 2018
fc6185a
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Nov 10, 2018
4e5d73d
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Nov 13, 2018
cc57c96
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Dec 4, 2018
3e879f0
Merge branch 'master' of https://github.com/Azure/sonic-swss
pavel-shirshov Apr 1, 2019
383b514
Add support of vxlan removal
pavel-shirshov Jun 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 91 additions & 4 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ create_tunnel_map(MAP_T map_t)
return tunnel_map_id;
}

void
remove_tunnel_map(sai_object_id_t tunnel_map_id)
{
sai_status_t status = sai_tunnel_api->remove_tunnel_map(tunnel_map_id);
if (status != SAI_STATUS_SUCCESS)
{
throw std::runtime_error("Can't remove a tunnel map object");
}
}

static sai_object_id_t create_tunnel_map_entry(
MAP_T map_t,
sai_object_id_t tunnel_map_id,
Expand Down Expand Up @@ -269,6 +279,16 @@ create_tunnel(
return tunnel_id;
}

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)
{
throw std::runtime_error("Can't remove a tunnel object");
}
}

// Create tunnel termination
static sai_object_id_t
create_tunnel_termination(
Expand Down Expand Up @@ -328,6 +348,16 @@ create_tunnel_termination(
return term_table_id;
}

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)
{
throw std::runtime_error("Can't remove a tunnel term table object");
}
}

bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap)
{
try
Expand Down Expand Up @@ -368,7 +398,7 @@ bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap)
return false;
}

SWSS_LOG_INFO("Vxlan tunnel '%s' was created", tunnel_name_.c_str());
SWSS_LOG_NOTICE("Vxlan tunnel '%s' was created", tunnel_name_.c_str());
return true;
}

Expand Down Expand Up @@ -658,15 +688,47 @@ bool VxlanTunnelOrch::addOperation(const Request& request)

vxlan_tunnel_table_[tunnel_name] = std::unique_ptr<VxlanTunnel>(new VxlanTunnel(tunnel_name, src_ip, dst_ip));

SWSS_LOG_INFO("Vxlan tunnel '%s' was added", tunnel_name.c_str());
SWSS_LOG_NOTICE("Vxlan tunnel '%s' was added", tunnel_name.c_str());
return true;
}

bool VxlanTunnelOrch::delOperation(const Request& request)
{
SWSS_LOG_ENTER();

SWSS_LOG_ERROR("DEL operation is not implemented");
const auto& tunnel_name = request.getKeyString(0);

if(!isTunnelExists(tunnel_name))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd address it in separate PR

{
SWSS_LOG_ERROR("Vxlan tunnel '%s' doesn't exist", tunnel_name.c_str());
return true;
}

auto tunnel_term_id = vxlan_tunnel_table_[tunnel_name].get()->getTunnelTermId();
try
{
remove_tunnel_termination(tunnel_term_id);
}
catch(const std::runtime_error& error)
pavel-shirshov marked this conversation as resolved.
Show resolved Hide resolved
{
SWSS_LOG_ERROR("Error removing tunnel term entry. Tunnel: %s. Error: %s", tunnel_name.c_str(), error.what());
return false;
}

auto tunnel_id = vxlan_tunnel_table_[tunnel_name].get()->getTunnelId();
try
{
remove_tunnel(tunnel_id);
}
catch(const std::runtime_error& error)
{
SWSS_LOG_ERROR("Error removing tunnel entry. Tunnel: %s. Error: %s", tunnel_name.c_str(), error.what());
return false;
}

vxlan_tunnel_table_.erase(tunnel_name);

SWSS_LOG_NOTICE("Vxlan tunnel '%s' was removed", tunnel_name.c_str());

return true;
}
Expand Down Expand Up @@ -738,7 +800,32 @@ bool VxlanTunnelMapOrch::delOperation(const Request& request)
{
SWSS_LOG_ENTER();

SWSS_LOG_ERROR("DEL operation is not implemented");
const auto& tunnel_name = request.getKeyString(0);
const auto& tunnel_map_entry_name = request.getKeyString(1);
const auto& full_tunnel_map_entry_name = request.getFullKey();


if (!isTunnelMapExists(full_tunnel_map_entry_name))
{
SWSS_LOG_WARN("Vxlan tunnel map '%s' doesn't exist", full_tunnel_map_entry_name.c_str());
return true;
}

auto tunnel_map_entry_id = vxlan_tunnel_map_table_[full_tunnel_map_entry_name];
try
{
remove_tunnel_map_entry(tunnel_map_entry_id);
}
catch (const std::runtime_error& error)
{
SWSS_LOG_ERROR("Error removing tunnel map %s: %s", full_tunnel_map_entry_name.c_str(), error.what());
return false;
}

vxlan_tunnel_map_table_.erase(full_tunnel_map_entry_name);

SWSS_LOG_NOTICE("Vxlan tunnel map entry '%s' for tunnel '%s' was removed",
tunnel_map_entry_name.c_str(), tunnel_name.c_str());

return true;
}
Expand Down
6 changes: 6 additions & 0 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class VxlanTunnel
return ids_.tunnel_encap_id;
}

sai_object_id_t getTunnelTermId() const
{
return ids_.tunnel_term_id;
}


void updateNextHop(IpAddress& ipAddr, MacAddress macAddress, uint32_t vni, sai_object_id_t nhId);
bool removeNextHop(IpAddress& ipAddr, MacAddress macAddress, uint32_t vni);
sai_object_id_t getNextHop(IpAddress& ipAddr, MacAddress macAddress, uint32_t vni) const;
Expand Down