blob: b86070bba898da63bcb32c1e2c33d26de73f66ab [file] [log] [blame]
castroflaviobd48e302015-12-15 17:57:38 -05001"""
2The following tests are being done here
31) PacketInSrcMacMiss
42) VlanSupport
53) L2FloodQinQ
64) L2FloodTagged
75) L2Flood Tagged Unknown Src
86) L2 Unicast Tagged
97) MTU 1500
108) MTU 4100
119) MTU 4500
1210) L3UnicastTagged
1311) L3VPNMPLS
1412) MPLS Termination
15"""
16
17from oftest import config
18import logging
19import oftest.base_tests as base_tests
20import ofp
21from oftest.testutils import *
22from accton_util import *
23
24class VlanSupport(base_tests.SimpleDataPlane):
25 """
26 Test L2 forwarding of both, untagged and double-tagged packets
27 Sends a packet and expects the same packet on the other port
28 Repeats for double tagged
29 """
30 def runTest(self):
31 delete_all_flows(self.controller)
32 delete_all_groups(self.controller)
33 ports = sorted(config["port_map"].keys())
34 # group table
35 # set up untag groups for each port
36 add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1)
37 for port in ports:
38 add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
39 group_id = encode_l2_interface_group_id(4093, port)
40 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True)
41 #add flow match for vlan 300
42 add_one_l2_interface_group(self.controller, port, 300, True, False)
43 add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG)
44 msg=add_l2_flood_group(self.controller, ports, 300, 1)
45 add_bridge_flow(self.controller, None, 300, msg.group_id, True)
46 msg=add_l2_flood_group(self.controller, ports, 4093, 1)
47 add_bridge_flow(self.controller, None, 4093, msg.group_id, True)
48 do_barrier(self.controller)
49
50 for out_port in ports:
51 # change dest based on port number
52 mac_dst= '00:12:34:56:78:%02X' % out_port
53
54 for in_port in ports:
55 if in_port == out_port:
56 continue
57 # change source based on port number to avoid packet-ins from learning
58 mac_src= '00:12:34:56:78:%02X' % in_port
59 #sends an untagged packet
60 parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src)
61 pkt = str(parsed_pkt)
62 logging.info("OutputExact test, ports %d to %d", in_port, out_port)
63 self.dataplane.send(in_port, pkt)
64
65 for ofport in ports:
66 if ofport in [out_port]:
67 verify_packet(self, pkt, ofport)
68 else:
69 verify_no_packet(self, pkt, ofport)
70
71 verify_no_other_packets(self)
72 # sends a double tagged packet
73 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300,
74 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
75 pkt = str(parsed_pkt)
76 logging.info("OutputExact test, ports %d to %d", in_port, out_port)
77 self.dataplane.send(in_port, pkt)
78
79 for ofport in ports:
80 if ofport in [out_port]:
81 verify_packet(self, pkt, ofport)
82 else:
83 verify_no_packet(self, pkt, ofport)
84
85 verify_no_other_packets(self)
86
87
88