Skip to content

Commit 9b0696e

Browse files
authored
Create vnet tunnel map only if it doesn't exist (sonic-net#1482)
Fix a crash with nullpointer, if a vnet config is pushed that already exist. Code added to check if vnet exists before pushing new config
1 parent 0481e99 commit 9b0696e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

orchagent/vnetorch.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,17 +1461,22 @@ bool VNetOrch::addOperation(const Request& request)
14611461
VNetInfo vnet_info = { tunnel, vni, peer_list, scope };
14621462
obj = createObject<VNetVrfObject>(vnet_name, vnet_info, attrs);
14631463
create = true;
1464-
}
14651464

1466-
VNetVrfObject *vrf_obj = dynamic_cast<VNetVrfObject*>(obj.get());
1467-
if (!vxlan_orch->createVxlanTunnelMap(tunnel, TUNNEL_MAP_T_VIRTUAL_ROUTER, vni,
1468-
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId(), VXLAN_ENCAP_TTL))
1465+
VNetVrfObject *vrf_obj = dynamic_cast<VNetVrfObject*>(obj.get());
1466+
if (!vxlan_orch->createVxlanTunnelMap(tunnel, TUNNEL_MAP_T_VIRTUAL_ROUTER, vni,
1467+
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId(), VXLAN_ENCAP_TTL))
1468+
{
1469+
SWSS_LOG_ERROR("VNET '%s', tunnel '%s', map create failed",
1470+
vnet_name.c_str(), tunnel.c_str());
1471+
return false;
1472+
}
1473+
1474+
SWSS_LOG_NOTICE("VNET '%s' was added ", vnet_name.c_str());
1475+
}
1476+
else
14691477
{
1470-
SWSS_LOG_ERROR("VNET '%s', tunnel '%s', map create failed",
1471-
vnet_name.c_str(), tunnel.c_str());
1478+
SWSS_LOG_NOTICE("VNET '%s' already exists ", vnet_name.c_str());
14721479
}
1473-
1474-
SWSS_LOG_NOTICE("VNET '%s' was added ", vnet_name.c_str());
14751480
}
14761481
else
14771482
{

0 commit comments

Comments
 (0)