Skip to content

Commit

Permalink
[EVPN]Modified tunnel creation logic when creating tunnel in VRF-VNI …
Browse files Browse the repository at this point in the history
…map creation flow

During the configuration phase when VRF-VNI map arrives before VLAN-VNI map, the tunnel is created without a tunnel map for vlan-vni membership. This is problematic when VLAN to VNI map arrives later, tunnel map entry cannot be created since the tunnel map doesn't exist and its a create only attribute in SAI.
Modified the logic of tunnel map creation to create tunnel with tunnel map for vlan-vni map in addition to vrf-vni map
  • Loading branch information
dgsudharsan committed Jul 20, 2022
1 parent 33c420d commit 1d22020
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 67 deletions.
76 changes: 13 additions & 63 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,67 +494,6 @@ VxlanTunnel::~VxlanTunnel()
src_creation_, false);
}

bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap, uint8_t encap_ttl)
{
try
{
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
sai_ip_address_t ips, ipd, *ip=nullptr;
uint8_t mapper_list = 0;
swss::copy(ips, src_ip_);

// Only a single mapper type is created

if (decap == MAP_T::VNI_TO_BRIDGE)
{
TUNNELMAP_SET_BRIDGE(mapper_list);
}
else if (decap == MAP_T::VNI_TO_VLAN_ID)
{
TUNNELMAP_SET_VLAN(mapper_list);
}
else
{
TUNNELMAP_SET_VRF(mapper_list);
}

createMapperHw(mapper_list, (encap == MAP_T::MAP_TO_INVALID) ?
TUNNEL_MAP_USE_DECAP_ONLY: TUNNEL_MAP_USE_DEDICATED_ENCAP_DECAP);

if (encap != MAP_T::MAP_TO_INVALID)
{
ip = &ips;
}

ids_.tunnel_id = create_tunnel(&ids_, ip, NULL, gUnderlayIfId, false, encap_ttl);

if (ids_.tunnel_id != SAI_NULL_OBJECT_ID)
{
tunnel_orch->addTunnelToFlexCounter(ids_.tunnel_id, tunnel_name_);
}

ip = nullptr;
if (!dst_ip_.isZero())
{
swss::copy(ipd, dst_ip_);
ip = &ipd;
}

ids_.tunnel_term_id = create_tunnel_termination(ids_.tunnel_id, ips, ip, gVirtualRouterId);
active_ = true;
tunnel_map_ = { encap, decap };
}
catch (const std::runtime_error& error)
{
SWSS_LOG_ERROR("Error creating tunnel %s: %s", tunnel_name_.c_str(), error.what());
// FIXME: add code to remove already created objects
return false;
}

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

sai_object_id_t VxlanTunnel::addEncapMapperEntry(sai_object_id_t obj, uint32_t vni, tunnel_map_type_t type)
{
const auto encap_id = getEncapMapId(type);
Expand Down Expand Up @@ -2013,7 +1952,6 @@ bool VxlanTunnelMapOrch::addOperation(const Request& request)
if (!tunnel_obj->isActive())
{
//@Todo, currently only decap mapper is allowed
//tunnel_obj->createTunnel(MAP_T::MAP_TO_INVALID, MAP_T::VNI_TO_VLAN_ID);
uint8_t mapper_list = 0;
TUNNELMAP_SET_VLAN(mapper_list);
TUNNELMAP_SET_VRF(mapper_list);
Expand Down Expand Up @@ -2218,7 +2156,19 @@ bool VxlanVrfMapOrch::addOperation(const Request& request)
{
if (!tunnel_obj->isActive())
{
tunnel_obj->createTunnel(MAP_T::VRID_TO_VNI, MAP_T::VNI_TO_VRID);
uint8_t mapper_list = 0;
TUNNELMAP_SET_VLAN(mapper_list);
TUNNELMAP_SET_VRF(mapper_list);
tunnel_obj->createTunnelHw(mapper_list,TUNNEL_MAP_USE_DEDICATED_ENCAP_DECAP);
Port tunPort;
auto src_vtep = tunnel_obj->getSrcIP().to_string();
if (!tunnel_orch->getTunnelPort(src_vtep, tunPort, true))
{
auto port_tunnel_name = tunnel_orch->getTunnelPortName(src_vtep, true);
gPortsOrch->addTunnel(port_tunnel_name, tunnel_obj->getTunnelId(), false);
gPortsOrch->getPort(port_tunnel_name,tunPort);
gPortsOrch->addBridgePort(tunPort);
}
}
vrf_id = vrf_orch->getVRFid(vrf_name);
}
Expand Down
1 change: 0 additions & 1 deletion orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class VxlanTunnel
return active_;
}

bool createTunnel(MAP_T encap, MAP_T decap, uint8_t encap_ttl=0);
sai_object_id_t addEncapMapperEntry(sai_object_id_t obj, uint32_t vni,
tunnel_map_type_t type=TUNNEL_MAP_T_VIRTUAL_ROUTER);
sai_object_id_t addDecapMapperEntry(sai_object_id_t obj, uint32_t vni,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_evpn_l3_vxlan_p2mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def test_sip_tunnel_vrf_vni_map(self, dvs, testlog):
vxlan_obj.create_vxlan_tunnel(dvs, tunnel_name, '6.6.6.6')
vxlan_obj.create_evpn_nvo(dvs, 'nvo1', tunnel_name)

print ("\tCreate Vlan-VNI map and VRF-VNI map")
vxlan_obj.create_vxlan_tunnel_map(dvs, tunnel_name, map_name, '1000', 'Vlan100')

vxlan_obj.create_vrf(dvs, "Vrf-RED")
vxlan_obj.create_vxlan_vrf_tunnel_map(dvs, 'Vrf-RED', '1000')

print ("\tCreate Vlan-VNI map and VRF-VNI map")
vxlan_obj.create_vxlan_tunnel_map(dvs, tunnel_name, map_name, '1000', 'Vlan100')

print ("\tTesting VRF-VNI map in APP DB")
vlanlist = ['100']
vnilist = ['1000']
Expand Down

0 comments on commit 1d22020

Please sign in to comment.