Skip to content

Commit

Permalink
set remote vtep the netdev down before delete (sonic-net#2075)
Browse files Browse the repository at this point in the history
*set vtep-xxx the netdev down before delete vtep-xxx .
  • Loading branch information
iris00522 authored Apr 26, 2022
1 parent 3d3364f commit 7f53db7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 20 additions & 9 deletions cfgmgr/vxlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ bool VxlanMgr::doVxlanTunnelMapDeleteTask(const KeyOpFieldsValuesTuple & t)
vxlan_dev_name = map_entry.vxlan_dev_name;
vlan = map_entry.vlan;
vni_id = map_entry.vni_id;
downVxlanNetdevice(vxlan_dev_name);
deleteVxlanNetdevice(vxlan_dev_name);

m_vxlanTunnelMapCache.erase(vxlanTunnelMapName);
Expand Down Expand Up @@ -906,11 +907,11 @@ void VxlanMgr::createAppDBTunnelMapTable(const KeyOpFieldsValuesTuple & t)
std::replace(vxlanTunnelMapName.begin(), vxlanTunnelMapName.end(), config_db_key_delimiter, delimiter);

/* Case 1: Entry exist - Erase from cache & return
* Case 2: Entry does not exist - Write to AppDB
* Case 2: Entry does not exist - Write to AppDB
* Case 3: Entry exist but modified - Not taken care. Will address later
*/
if (m_in_reconcile)
{
{
auto it = find(m_appVxlanTunnelMapKeysRecon.begin(), m_appVxlanTunnelMapKeysRecon.end(), vxlanTunnelMapName);
if (it != m_appVxlanTunnelMapKeysRecon.end())
{
Expand Down Expand Up @@ -939,28 +940,28 @@ void VxlanMgr::delAppDBTunnelMapTable(std::string vxlanTunnelMapName)
m_appVxlanTunnelMapTable.del(vxlanTunnelMapName);
}

int VxlanMgr::createVxlanNetdevice(std::string vxlanTunnelName, std::string vni_id,
std::string src_ip, std::string dst_ip,
int VxlanMgr::createVxlanNetdevice(std::string vxlanTunnelName, std::string vni_id,
std::string src_ip, std::string dst_ip,
std::string vlan_id)
{
std::string res, cmds;
std::string link_add_cmd, link_set_master_cmd, link_up_cmd;
std::string link_add_cmd, link_set_master_cmd, link_up_cmd;
std::string bridge_add_cmd, bridge_untagged_add_cmd, bridge_del_vid_cmd;
std::string vxlan_dev_name;

vxlan_dev_name = std::string("") + std::string(vxlanTunnelName) + "-" +
vxlan_dev_name = std::string("") + std::string(vxlanTunnelName) + "-" +
std::string(vlan_id);

SWSS_LOG_INFO("Kernel tnl_name: %s vni_id: %s src_ip: %s dst_ip:%s vlan_id: %s",
vxlanTunnelName.c_str(), vni_id.c_str(), src_ip.c_str(), dst_ip.c_str(),
vxlanTunnelName.c_str(), vni_id.c_str(), src_ip.c_str(), dst_ip.c_str(),
vlan_id.c_str());

// Case 1: Entry exist - Erase from cache & return
// Case 2: Entry does not exist - Create netDevice in Kernel
// Case 3: Entry exist but modified - Not taken care. Will address later

if (m_in_reconcile)
{
{
auto it = m_vxlanNetDevices.find(vxlan_dev_name);
if (it != m_vxlanNetDevices.end())
{
Expand Down Expand Up @@ -1024,6 +1025,15 @@ int VxlanMgr::createVxlanNetdevice(std::string vxlanTunnelName, std::string vni_
return swss::exec(cmds,res);
}

int VxlanMgr::downVxlanNetdevice(std::string vxlan_dev_name)
{
int ret = 0;
std::string res;
const std::string cmd = std::string("") + IP_CMD + " link set dev " + vxlan_dev_name + " down";
exec(cmd, res);
return ret;
}

int VxlanMgr::deleteVxlanNetdevice(std::string vxlan_dev_name)
{
std::string res;
Expand Down Expand Up @@ -1188,6 +1198,7 @@ void VxlanMgr::clearAllVxlanDevices()
if (netdev_type.compare(VXLAN))
{
info.m_vxlan = netdev_name;
downVxlanNetdevice(netdev_name);
cmdDeleteVxlan(info, res);
}
else if(netdev_type.compare(VXLAN_IF))
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/vxlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class VxlanMgr : public Orch
void delAppDBTunnelMapTable(std::string vxlanTunnelMapName);
int createVxlanNetdevice(std::string vxlanTunnelName, std::string vni_id,
std::string src_ip, std::string dst_ip, std::string vlan_id);
int downVxlanNetdevice(std::string vxlan_dev_name);
int deleteVxlanNetdevice(std::string vxlan_dev_name);
std::vector<std::string> parseNetDev(const std::string& stdout);
void getAllVxlanNetDevices();
Expand Down

0 comments on commit 7f53db7

Please sign in to comment.