9
9
CFG_VLAN_SUB_INTF_TABLE_NAME = "VLAN_SUB_INTERFACE"
10
10
CFG_PORT_TABLE_NAME = "PORT"
11
11
CFG_LAG_TABLE_NAME = "PORTCHANNEL"
12
+ CFG_LAG_MEMBER_TABLE_NAME = "PORTCHANNEL_MEMBER"
12
13
13
14
STATE_PORT_TABLE_NAME = "PORT_TABLE"
14
15
STATE_LAG_TABLE_NAME = "LAG_TABLE"
24
25
ASIC_NEXT_HOP_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP"
25
26
ASIC_NEXT_HOP_GROUP_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP_GROUP"
26
27
ASIC_NEXT_HOP_GROUP_MEMBER_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MEMBER"
28
+ ASIC_LAG_MEMBER_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER"
29
+ ASIC_HOSTIF_TABLE = "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF"
27
30
28
31
ADMIN_STATUS = "admin_status"
29
32
36
39
class TestSubPortIntf (object ):
37
40
SUB_PORT_INTERFACE_UNDER_TEST = "Ethernet64.10"
38
41
LAG_SUB_PORT_INTERFACE_UNDER_TEST = "PortChannel1.20"
42
+ LAG_MEMBERS_UNDER_TEST = ["Ethernet68" , "Ethernet72" ]
39
43
40
44
IPV4_ADDR_UNDER_TEST = "10.0.0.33/31"
41
45
IPV4_TOME_UNDER_TEST = "10.0.0.33/32"
@@ -91,6 +95,13 @@ def create_sub_port_intf_profile(self, sub_port_intf_name):
91
95
92
96
self .config_db .create_entry (CFG_VLAN_SUB_INTF_TABLE_NAME , sub_port_intf_name , fvs )
93
97
98
+ def add_lag_members (self , lag , members ):
99
+ fvs = {"NULL" : "NULL" }
100
+
101
+ for member in members :
102
+ key = "{}|{}" .format (lag , member )
103
+ self .config_db .create_entry (CFG_LAG_MEMBER_TABLE_NAME , key , fvs )
104
+
94
105
def add_sub_port_intf_ip_addr (self , sub_port_intf_name , ip_addr ):
95
106
fvs = {"NULL" : "NULL" }
96
107
@@ -102,6 +113,11 @@ def set_sub_port_intf_admin_status(self, sub_port_intf_name, status):
102
113
103
114
self .config_db .create_entry (CFG_VLAN_SUB_INTF_TABLE_NAME , sub_port_intf_name , fvs )
104
115
116
+ def remove_lag_members (self , lag , members ):
117
+ for member in members :
118
+ key = "{}|{}" .format (lag , member )
119
+ self .config_db .delete_entry (CFG_LAG_MEMBER_TABLE_NAME , key )
120
+
105
121
def remove_sub_port_intf_profile (self , sub_port_intf_name ):
106
122
self .config_db .delete_entry (CFG_VLAN_SUB_INTF_TABLE_NAME , sub_port_intf_name )
107
123
@@ -186,13 +202,19 @@ def _test_sub_port_intf_creation(self, dvs, sub_port_intf_name):
186
202
vlan_id = substrs [1 ]
187
203
if parent_port .startswith (ETHERNET_PREFIX ):
188
204
state_tbl_name = STATE_PORT_TABLE_NAME
205
+ phy_ports = [parent_port ]
189
206
else :
190
207
assert parent_port .startswith (LAG_PREFIX )
191
208
state_tbl_name = STATE_LAG_TABLE_NAME
209
+ phy_ports = self .LAG_MEMBERS_UNDER_TEST
192
210
193
211
old_rif_oids = self .get_oids (ASIC_RIF_TABLE )
194
212
195
213
self .set_parent_port_admin_status (dvs , parent_port , "up" )
214
+ # Add lag members to test physical port host interface vlan tag attribute
215
+ if parent_port .startswith (LAG_PREFIX ):
216
+ self .add_lag_members (parent_port , self .LAG_MEMBERS_UNDER_TEST )
217
+ self .asic_db .wait_for_n_keys (ASIC_LAG_MEMBER_TABLE , len (self .LAG_MEMBERS_UNDER_TEST ))
196
218
self .create_sub_port_intf_profile (sub_port_intf_name )
197
219
198
220
# Verify that sub port interface state ok is pushed to STATE_DB by Intfmgrd
@@ -218,10 +240,23 @@ def _test_sub_port_intf_creation(self, dvs, sub_port_intf_name):
218
240
rif_oid = self .get_newly_created_oid (ASIC_RIF_TABLE , old_rif_oids )
219
241
self .check_sub_port_intf_fvs (self .asic_db , ASIC_RIF_TABLE , rif_oid , fv_dict )
220
242
243
+ # Verify physical port host interface vlan tag attribute
244
+ fv_dict = {
245
+ "SAI_HOSTIF_ATTR_VLAN_TAG" : "SAI_HOSTIF_VLAN_TAG_KEEP" ,
246
+ }
247
+ for phy_port in phy_ports :
248
+ hostif_oid = dvs .asicdb .hostifnamemap [phy_port ]
249
+ self .check_sub_port_intf_fvs (self .asic_db , ASIC_HOSTIF_TABLE , hostif_oid , fv_dict )
250
+
221
251
# Remove a sub port interface
222
252
self .remove_sub_port_intf_profile (sub_port_intf_name )
223
253
self .check_sub_port_intf_profile_removal (rif_oid )
224
254
255
+ # Remove lag members from lag parent port
256
+ if parent_port .startswith (LAG_PREFIX ):
257
+ self .remove_lag_members (parent_port , self .LAG_MEMBERS_UNDER_TEST )
258
+ self .asic_db .wait_for_n_keys (ASIC_LAG_MEMBER_TABLE , 0 )
259
+
225
260
def test_sub_port_intf_creation (self , dvs ):
226
261
self .connect_dbs (dvs )
227
262
@@ -427,13 +462,19 @@ def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name):
427
462
parent_port = substrs [0 ]
428
463
if parent_port .startswith (ETHERNET_PREFIX ):
429
464
state_tbl_name = STATE_PORT_TABLE_NAME
465
+ phy_ports = [parent_port ]
430
466
else :
431
467
assert parent_port .startswith (LAG_PREFIX )
432
468
state_tbl_name = STATE_LAG_TABLE_NAME
469
+ phy_ports = self .LAG_MEMBERS_UNDER_TEST
433
470
434
471
old_rif_oids = self .get_oids (ASIC_RIF_TABLE )
435
472
436
473
self .set_parent_port_admin_status (dvs , parent_port , "up" )
474
+ # Add lag members to test physical port host interface vlan tag attribute
475
+ if parent_port .startswith (LAG_PREFIX ):
476
+ self .add_lag_members (parent_port , self .LAG_MEMBERS_UNDER_TEST )
477
+ self .asic_db .wait_for_n_keys (ASIC_LAG_MEMBER_TABLE , len (self .LAG_MEMBERS_UNDER_TEST ))
437
478
self .create_sub_port_intf_profile (sub_port_intf_name )
438
479
439
480
self .add_sub_port_intf_ip_addr (sub_port_intf_name , self .IPV4_ADDR_UNDER_TEST )
@@ -471,6 +512,19 @@ def _test_sub_port_intf_removal(self, dvs, sub_port_intf_name):
471
512
# Verify that sub port router interface entry is removed from ASIC_DB
472
513
self .check_sub_port_intf_key_removal (self .asic_db , ASIC_RIF_TABLE , rif_oid )
473
514
515
+ # Verify physical port host interface vlan tag attribute
516
+ fv_dict = {
517
+ "SAI_HOSTIF_ATTR_VLAN_TAG" : "SAI_HOSTIF_VLAN_TAG_STRIP" ,
518
+ }
519
+ for phy_port in phy_ports :
520
+ hostif_oid = dvs .asicdb .hostifnamemap [phy_port ]
521
+ self .check_sub_port_intf_fvs (self .asic_db , ASIC_HOSTIF_TABLE , hostif_oid , fv_dict )
522
+
523
+ # Remove lag members from lag parent port
524
+ if parent_port .startswith (LAG_PREFIX ):
525
+ self .remove_lag_members (parent_port , self .LAG_MEMBERS_UNDER_TEST )
526
+ self .asic_db .wait_for_n_keys (ASIC_LAG_MEMBER_TABLE , 0 )
527
+
474
528
def test_sub_port_intf_removal (self , dvs ):
475
529
self .connect_dbs (dvs )
476
530
0 commit comments