7
7
"""
8
8
# The test checks vxlan decapsulation for the dataplane.
9
9
# The test runs three tests for each vlan on the DUT:
10
- # 1. 'Vxlan' : Sends encapsulated packets to PortChannel interfaces and expects to see
10
+ # 1. 'Vxlan' : Sends encapsulated packets to DUT interfaces and expects to see
11
11
# the decapsulated inner packets on the corresponding vlan interface.
12
- # 2. 'RegularLAGtoVLAN ' : Sends regular packets to PortChannel interfaces and expects to see
12
+ # 2. 'RegularDUTtoVLAN ' : Sends regular packets to DUT interfaces and expects to see
13
13
# the packets on the corresponding vlan interface.
14
- # 3. 'RegularVLANtoLAG ' : Sends regular packets to Vlan member interfaces and expects to see
15
- # the packets on the one of PortChannel interfaces.
14
+ # 3. 'RegularVLANtoDUT ' : Sends regular packets to Vlan member interfaces and expects to see
15
+ # the packets on the one of DUT interfaces.
16
16
#
17
17
# The test has 6 parameters:
18
18
# 1. 'config_file' is a filename of a file which contains all necessary information to run the test.
37
37
import socket
38
38
import struct
39
39
import re
40
+ import ipaddress
40
41
41
42
import ptf
42
43
import ptf .packet as scapy
48
49
from device_connection import DeviceConnection
49
50
50
51
52
+ def is_valid_ipv4 (ip_str ):
53
+ try :
54
+ ipaddress .IPv4Address (ip_str )
55
+ return True
56
+ except ipaddress .AddressValueError :
57
+ return False
58
+
59
+
51
60
def count_matched_packets_helper (test , exp_packet , exp_packet_number , port = None , device_number = 0 , timeout = 1 ):
52
61
"""
53
62
Add exp_packet_number to original ptf interface in order to
@@ -217,9 +226,10 @@ def setUp(self):
217
226
with open (config ) as fp :
218
227
graph = json .load (fp )
219
228
220
- self .pc_info = []
229
+ self .intf_info = []
221
230
self .net_ports = []
222
231
self .all_active_net_ports = []
232
+ # To portchannels interfaces
223
233
for name , val in graph ['minigraph_portchannels' ].items ():
224
234
members = [graph ['minigraph_port_indices' ][member ]
225
235
for member in val ['members' ]]
@@ -239,7 +249,18 @@ def setUp(self):
239
249
raise Exception (
240
250
"Portchannel '%s' ip address is not found" % name )
241
251
242
- self .pc_info .append ((ip , members ))
252
+ self .intf_info .append ((ip , members ))
253
+
254
+ # To non portchannels interfaces
255
+ for d in graph ['minigraph_interfaces' ]:
256
+ intf = d ['attachto' ]
257
+ if (intf in graph ['minigraph_portchannels' ] or
258
+ intf not in graph ['minigraph_port_indices' ] or
259
+ 'peer_addr' not in d or
260
+ not is_valid_ipv4 (d ['peer_addr' ])):
261
+ continue
262
+ self .intf_info .append ((d ['peer_addr' ], [graph ['minigraph_port_indices' ][intf ]]))
263
+ self .net_ports .append (graph ['minigraph_port_indices' ][intf ])
243
264
244
265
self .tests = []
245
266
vni_base = 336
@@ -248,7 +269,7 @@ def setUp(self):
248
269
test ['name' ] = name
249
270
test ['intf_alias' ] = data ['members' ]
250
271
test ['acc_ports' ] = [graph ['minigraph_port_indices' ][member ]
251
- for member in data ['members' ]]
272
+ for member in data ['members' ] if member in graph [ 'minigraph_port_indices' ] ]
252
273
vlan_id = int (name .replace ('Vlan' , '' ))
253
274
test ['vni' ] = vni_base + vlan_id
254
275
test ['src_ip' ] = "8.8.8.8"
@@ -344,10 +365,10 @@ def warmup(self):
344
365
err = ''
345
366
trace = ''
346
367
ret = 0
347
- TIMEOUT = 60
368
+ TIMEOUT = 300
348
369
try :
349
370
for test in self .tests :
350
- self .RegularLAGtoVLAN (test , True )
371
+ self .RegularDUTtoVLAN (test , True )
351
372
# wait sometime for DUT to build FDB and ARP table
352
373
res = self .wait_dut (test , TIMEOUT )
353
374
self .log_dut_status ()
@@ -390,19 +411,19 @@ def work_test(self):
390
411
for test in self .tests :
391
412
self .log (test ['name' ])
392
413
393
- res_f , out_f = self .RegularLAGtoVLAN (test )
394
- self .log ("RegularLAGtoVLAN = {} {}" .format (res_f , out_f ))
414
+ res_f , out_f = self .RegularDUTtoVLAN (test )
415
+ self .log ("RegularDUTtoVLAN = {} {}" .format (res_f , out_f ))
395
416
if not res_f :
396
417
self .log_dut_status ()
397
418
self .assertTrue (
398
- res_f , "RegularLAGtoVLAN test failed:\n %s\n " % (out_f ))
419
+ res_f , "RegularDUTtoVLAN test failed:\n %s\n " % (out_f ))
399
420
400
- res_t , out_t = self .RegularVLANtoLAG (test )
401
- self .log ("RegularVLANtoLAG = {} {}" .format (res_t , out_t ))
421
+ res_t , out_t = self .RegularVLANtoDUT (test )
422
+ self .log ("RegularVLANtoDUT = {} {}" .format (res_t , out_t ))
402
423
if not res_t :
403
424
self .log_dut_status ()
404
425
self .assertTrue (
405
- res_t , "RegularVLANtoLAG test failed:\n %s\n " % (out_t ))
426
+ res_t , "RegularVLANtoDUT test failed:\n %s\n " % (out_t ))
406
427
407
428
res_v , out_v = self .Vxlan (test )
408
429
self .log ("Vxlan = {} {}" .format (res_v , out_v ))
@@ -453,10 +474,10 @@ def Vxlan(self, test):
453
474
return False , out + " | net_port_rel=%d acc_port_rel=%d" % (i , j )
454
475
return True , ""
455
476
456
- def RegularLAGtoVLAN (self , test , wu = False ):
477
+ def RegularDUTtoVLAN (self , test , wu = False ):
457
478
for i , n in enumerate (self .net_ports ):
458
479
for j , a in enumerate (test ['acc_ports' ]):
459
- res , out = self .checkRegularRegularLAGtoVLAN (a , n , test , wu )
480
+ res , out = self .checkRegularRegularDUTtoVLAN (a , n , test , wu )
460
481
if wu :
461
482
# Wait a short time for building FDB and ARP table
462
483
time .sleep (0.5 )
@@ -467,16 +488,16 @@ def RegularLAGtoVLAN(self, test, wu=False):
467
488
break
468
489
return True , ""
469
490
470
- def RegularVLANtoLAG (self , test ):
471
- for i , (dst , ports ) in enumerate (self .pc_info ):
491
+ def RegularVLANtoDUT (self , test ):
492
+ for i , (dst , ports ) in enumerate (self .intf_info ):
472
493
for j , a in enumerate (test ['acc_ports' ]):
473
- res , out = self .checkRegularRegularVLANtoLAG (
494
+ res , out = self .checkRegularRegularVLANtoDUT (
474
495
a , ports , dst , test )
475
496
if not res :
476
- return False , out + " | pc_info_rel =%d acc_port_rel=%d" % (i , j )
497
+ return False , out + " | intf_info_rel =%d acc_port_rel=%d" % (i , j )
477
498
return True , ""
478
499
479
- def checkRegularRegularVLANtoLAG (self , acc_port , pc_ports , dst_ip , test ):
500
+ def checkRegularRegularVLANtoDUT (self , acc_port , pc_ports , dst_ip , test ):
480
501
src_mac = self .ptf_mac_addrs ['eth%d' % acc_port ]
481
502
dst_mac = self .vlan_mac
482
503
src_ip = test ['vlan_ip_prefixes' ][acc_port ]
@@ -522,7 +543,7 @@ def checkRegularRegularVLANtoLAG(self, acc_port, pc_ports, dst_ip, test):
522
543
out = "sent = %d rcvd = %d | src_port=%s dst_ports=%s | src_mac=%s dst_mac=%s src_ip=%s dst_ip=%s" % arg
523
544
return rv , out
524
545
525
- def checkRegularRegularLAGtoVLAN (self , acc_port , net_port , test , wu ):
546
+ def checkRegularRegularDUTtoVLAN (self , acc_port , net_port , test , wu ):
526
547
src_mac = self .random_mac
527
548
dst_mac = self .dut_mac
528
549
src_ip = test ['src_ip' ]
0 commit comments