Skip to content

Commit

Permalink
Create vnet tunnel map only if it doesn't exist (sonic-net#1482)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
prsunny authored Oct 29, 2020
1 parent 0481e99 commit 9b0696e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,17 +1461,22 @@ bool VNetOrch::addOperation(const Request& request)
VNetInfo vnet_info = { tunnel, vni, peer_list, scope };
obj = createObject<VNetVrfObject>(vnet_name, vnet_info, attrs);
create = true;
}

VNetVrfObject *vrf_obj = dynamic_cast<VNetVrfObject*>(obj.get());
if (!vxlan_orch->createVxlanTunnelMap(tunnel, TUNNEL_MAP_T_VIRTUAL_ROUTER, vni,
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId(), VXLAN_ENCAP_TTL))
VNetVrfObject *vrf_obj = dynamic_cast<VNetVrfObject*>(obj.get());
if (!vxlan_orch->createVxlanTunnelMap(tunnel, TUNNEL_MAP_T_VIRTUAL_ROUTER, vni,
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId(), VXLAN_ENCAP_TTL))
{
SWSS_LOG_ERROR("VNET '%s', tunnel '%s', map create failed",
vnet_name.c_str(), tunnel.c_str());
return false;
}

SWSS_LOG_NOTICE("VNET '%s' was added ", vnet_name.c_str());
}
else
{
SWSS_LOG_ERROR("VNET '%s', tunnel '%s', map create failed",
vnet_name.c_str(), tunnel.c_str());
SWSS_LOG_NOTICE("VNET '%s' already exists ", vnet_name.c_str());
}

SWSS_LOG_NOTICE("VNET '%s' was added ", vnet_name.c_str());
}
else
{
Expand Down

0 comments on commit 9b0696e

Please sign in to comment.