Skip to content

Commit d8ca31c

Browse files
authored
[vnet/vxlan] Add support of multiple mappers for the VxLAN tunnel (sonic-net#1843)
Added ability to configure VXLAN tunnel with 2 decapsulation mappers (VRF and VLAN mappers) Signed-off-by: Andriy Yurkiv <[email protected]>
1 parent 7280e19 commit d8ca31c

File tree

3 files changed

+64
-14
lines changed

3 files changed

+64
-14
lines changed

orchagent/vxlanorch.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ bool VxlanTunnel::deleteTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src,
863863
//Creation of SAI Tunnel Object with multiple mapper types
864864

865865
bool VxlanTunnel::createTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src,
866-
bool with_term)
866+
bool with_term, sai_uint8_t encap_ttl)
867867
{
868868
bool p2p = false;
869869

@@ -883,7 +883,7 @@ bool VxlanTunnel::createTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src,
883883
SWSS_LOG_WARN("creation src = %d",src_creation_);
884884
}
885885

886-
ids_.tunnel_id = create_tunnel(&ids_, &ips, ip, gUnderlayIfId, p2p);
886+
ids_.tunnel_id = create_tunnel(&ids_, &ips, ip, gUnderlayIfId, p2p, encap_ttl);
887887

888888
if (with_term)
889889
{
@@ -1242,11 +1242,16 @@ bool VxlanTunnelOrch::createVxlanTunnelMap(string tunnelName, tunnel_map_type_t
12421242
{
12431243
if (map == TUNNEL_MAP_T_VIRTUAL_ROUTER)
12441244
{
1245-
tunnel_obj->createTunnel(MAP_T::VRID_TO_VNI, MAP_T::VNI_TO_VRID, encap_ttl);
1245+
uint8_t mapper_list = 0;
1246+
TUNNELMAP_SET_VLAN(mapper_list);
1247+
TUNNELMAP_SET_VRF(mapper_list);
1248+
tunnel_obj->createTunnelHw(mapper_list, TUNNEL_MAP_USE_DEDICATED_ENCAP_DECAP , true, encap_ttl);
12461249
}
12471250
else if (map == TUNNEL_MAP_T_BRIDGE)
12481251
{
1249-
tunnel_obj->createTunnel(MAP_T::BRIDGE_TO_VNI, MAP_T::VNI_TO_BRIDGE, encap_ttl);
1252+
uint8_t mapper_list = 0;
1253+
TUNNELMAP_SET_BRIDGE(mapper_list);
1254+
tunnel_obj->createTunnelHw(mapper_list, TUNNEL_MAP_USE_DEDICATED_ENCAP_DECAP, true, encap_ttl);
12501255
}
12511256
}
12521257

orchagent/vxlanorch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class VxlanTunnel
181181

182182
bool deleteMapperHw(uint8_t mapper_list, tunnel_map_use_t map_src);
183183
bool createMapperHw(uint8_t mapper_list, tunnel_map_use_t map_src);
184-
bool createTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src, bool with_term = true);
184+
bool createTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src, bool with_term = true, sai_uint8_t encap_ttl=0);
185185
bool deleteTunnelHw(uint8_t mapper_list, tunnel_map_use_t map_src, bool with_term = true);
186186
void deletePendingSIPTunnel();
187187
void increment_spurious_imr_add(const std::string remote_vtep);

tests/test_vnet.py

+54-9
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,20 @@ def create_vxlan_tunnel(dvs, name, src_ip):
354354
)
355355

356356

357+
def create_vxlan_tunnel_map(dvs, tunnel_name, tunnel_map_entry_name, vlan, vni_id):
358+
conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0)
359+
360+
# create the VXLAN tunnel map entry in Config DB
361+
create_entry_tbl(
362+
conf_db,
363+
"VXLAN_TUNNEL_MAP", '|', "%s|%s" % (tunnel_name, tunnel_map_entry_name),
364+
[
365+
("vni", vni_id),
366+
("vlan", vlan),
367+
],
368+
)
369+
370+
357371
def get_lo(dvs):
358372
asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
359373
vr_id = get_default_vr_id(dvs)
@@ -451,34 +465,46 @@ def check_vxlan_tunnel(self, dvs, tunnel_name, src_ip):
451465
asic_db = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
452466
global loopback_id, def_vr_id
453467

454-
tunnel_map_id = get_created_entries(asic_db, self.ASIC_TUNNEL_MAP, self.tunnel_map_ids, 2)
468+
tunnel_map_id = get_created_entries(asic_db, self.ASIC_TUNNEL_MAP, self.tunnel_map_ids, 4)
455469
tunnel_id = get_created_entry(asic_db, self.ASIC_TUNNEL_TABLE, self.tunnel_ids)
456470
tunnel_term_id = get_created_entry(asic_db, self.ASIC_TUNNEL_TERM_ENTRY, self.tunnel_term_ids)
457471

458472
# check that the vxlan tunnel termination are there
459-
assert how_many_entries_exist(asic_db, self.ASIC_TUNNEL_MAP) == (len(self.tunnel_map_ids) + 2), "The TUNNEL_MAP wasn't created"
473+
assert how_many_entries_exist(asic_db, self.ASIC_TUNNEL_MAP) == (len(self.tunnel_map_ids) + 4), "The TUNNEL_MAP wasn't created"
460474
assert how_many_entries_exist(asic_db, self.ASIC_TUNNEL_MAP_ENTRY) == len(self.tunnel_map_entry_ids), "The TUNNEL_MAP_ENTRY is created"
461475
assert how_many_entries_exist(asic_db, self.ASIC_TUNNEL_TABLE) == (len(self.tunnel_ids) + 1), "The TUNNEL wasn't created"
462476
assert how_many_entries_exist(asic_db, self.ASIC_TUNNEL_TERM_ENTRY) == (len(self.tunnel_term_ids) + 1), "The TUNNEL_TERM_TABLE_ENTRY wasm't created"
463477

464-
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[0],
478+
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[2],
465479
{
466480
'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_VIRTUAL_ROUTER_ID',
467481
}
468482
)
469483

470-
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[1],
484+
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[3],
471485
{
472486
'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VIRTUAL_ROUTER_ID_TO_VNI',
473487
}
474488
)
475489

490+
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[0],
491+
{
492+
'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_VLAN_ID',
493+
}
494+
)
495+
496+
check_object(asic_db, self.ASIC_TUNNEL_MAP, tunnel_map_id[1],
497+
{
498+
'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VLAN_ID_TO_VNI',
499+
}
500+
)
501+
476502
check_object(asic_db, self.ASIC_TUNNEL_TABLE, tunnel_id,
477503
{
478504
'SAI_TUNNEL_ATTR_TYPE': 'SAI_TUNNEL_TYPE_VXLAN',
479505
'SAI_TUNNEL_ATTR_UNDERLAY_INTERFACE': loopback_id,
480-
'SAI_TUNNEL_ATTR_DECAP_MAPPERS': '1:%s' % tunnel_map_id[0],
481-
'SAI_TUNNEL_ATTR_ENCAP_MAPPERS': '1:%s' % tunnel_map_id[1],
506+
'SAI_TUNNEL_ATTR_DECAP_MAPPERS': '2:%s,%s' % (tunnel_map_id[0], tunnel_map_id[2]),
507+
'SAI_TUNNEL_ATTR_ENCAP_MAPPERS': '2:%s,%s' % (tunnel_map_id[1], tunnel_map_id[3]),
482508
'SAI_TUNNEL_ATTR_ENCAP_SRC_IP': src_ip,
483509
}
484510
)
@@ -506,7 +532,7 @@ def check_vxlan_tunnel_entry(self, dvs, tunnel_name, vnet_name, vni_id):
506532
time.sleep(2)
507533

508534
if (self.tunnel_map_map.get(tunnel_name) is None):
509-
tunnel_map_id = get_created_entries(asic_db, self.ASIC_TUNNEL_MAP, self.tunnel_map_ids, 2)
535+
tunnel_map_id = get_created_entries(asic_db, self.ASIC_TUNNEL_MAP, self.tunnel_map_ids, 4)
510536
else:
511537
tunnel_map_id = self.tunnel_map_map[tunnel_name]
512538

@@ -518,7 +544,7 @@ def check_vxlan_tunnel_entry(self, dvs, tunnel_name, vnet_name, vni_id):
518544
check_object(asic_db, self.ASIC_TUNNEL_MAP_ENTRY, tunnel_map_entry_id[0],
519545
{
520546
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP_TYPE': 'SAI_TUNNEL_MAP_TYPE_VIRTUAL_ROUTER_ID_TO_VNI',
521-
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP': tunnel_map_id[1],
547+
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP': tunnel_map_id[3],
522548
'SAI_TUNNEL_MAP_ENTRY_ATTR_VIRTUAL_ROUTER_ID_KEY': self.vr_map[vnet_name].get('ing'),
523549
'SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_VALUE': vni_id,
524550
}
@@ -527,7 +553,7 @@ def check_vxlan_tunnel_entry(self, dvs, tunnel_name, vnet_name, vni_id):
527553
check_object(asic_db, self.ASIC_TUNNEL_MAP_ENTRY, tunnel_map_entry_id[1],
528554
{
529555
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_VIRTUAL_ROUTER_ID',
530-
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP': tunnel_map_id[0],
556+
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP': tunnel_map_id[2],
531557
'SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_KEY': vni_id,
532558
'SAI_TUNNEL_MAP_ENTRY_ATTR_VIRTUAL_ROUTER_ID_VALUE': self.vr_map[vnet_name].get('egr'),
533559
}
@@ -1080,6 +1106,25 @@ def test_vnet_orch_5(self, dvs, testlog):
10801106
vnet_obj.check_default_vnet_entry(dvs, 'Vnet_5')
10811107
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet_5', '4789')
10821108

1109+
'''
1110+
Test 6 - Test VxLAN tunnel with multiple maps
1111+
'''
1112+
def test_vnet_vxlan_multi_map(self, dvs, testlog):
1113+
vnet_obj = self.get_vnet_obj()
1114+
1115+
tunnel_name = 'tunnel_v4'
1116+
1117+
vnet_obj.fetch_exist_entries(dvs)
1118+
1119+
create_vxlan_tunnel(dvs, tunnel_name, '10.1.0.32')
1120+
create_vnet_entry(dvs, 'Vnet1', tunnel_name, '10001', "")
1121+
1122+
vnet_obj.check_vnet_entry(dvs, 'Vnet1')
1123+
vnet_obj.check_vxlan_tunnel_entry(dvs, tunnel_name, 'Vnet1', '10001')
1124+
vnet_obj.check_vxlan_tunnel(dvs, tunnel_name, '10.1.0.32')
1125+
1126+
create_vxlan_tunnel_map(dvs, tunnel_name, 'map_1', 'Vlan1000', '1000')
1127+
10831128

10841129
# Add Dummy always-pass test at end as workaroud
10851130
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)