blob: dc5d2e934d772ab1db6f7e944baa6f23d062a45c [file] [log] [blame]
Flavio Castro05d20bc2015-11-16 15:06:14 -05001"""
Flavio Castro423df652016-05-17 20:14:08 -04002Check README file
Flavio Castro05d20bc2015-11-16 15:06:14 -05003"""
Flavio Castro1c9b1252016-02-04 18:42:58 -05004import Queue
Flavio Castro05d20bc2015-11-16 15:06:14 -05005
Flavio Castro05d20bc2015-11-16 15:06:14 -05006from oftest import config
Flavio Castro67d8bd52016-02-03 14:22:14 -05007import inspect
Flavio Castro167f5bd2015-12-02 19:33:53 -05008import logging
9import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050010import ofp
11from oftest.testutils import *
12from accton_util import *
Pierbbdf3782016-08-22 17:58:26 -070013from utils import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050014
Flavio Castro1c9b1252016-02-04 18:42:58 -050015
Flavio Castroa7162bb2016-07-25 17:30:30 -070016class PacketInUDP( base_tests.SimpleDataPlane ):
Flavio Castro6d498522015-12-15 14:05:04 -050017 """
Flavio Castro76c5b262016-07-27 19:53:00 -070018 Verify ACL rule for IP_PROTO=2 wont match a UDP packet and a rule for IP_PROTO=17 WILL match a UDP packet.
Flavio Castro6d498522015-12-15 14:05:04 -050019 """
20
Flavio Castroa7162bb2016-07-25 17:30:30 -070021 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -070022 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -070023 parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
24 vlan_pkt = str( parsed_vlan_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070025 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -070026 match = ofp.match( )
27 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
28 match.oxm_list.append( ofp.oxm.ip_proto( 2 ) )
29 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
30 ofp.instruction.apply_actions( actions=[
31 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
32 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
33 logging.info( "Inserting packet in flow to controller" )
34 self.controller.message_send( request )
Flavio Castro1c9b1252016-02-04 18:42:58 -050035
Flavio Castroa7162bb2016-07-25 17:30:30 -070036 for of_port in config[ "port_map" ].keys( ):
37 logging.info( "PacketInMiss test, port %d", of_port )
38 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -050039
Flavio Castroa7162bb2016-07-25 17:30:30 -070040 verify_no_packet_in( self, vlan_pkt, of_port )
41 delete_all_flows( self.controller )
42 do_barrier( self.controller )
Flavio Castro6d498522015-12-15 14:05:04 -050043
Flavio Castroa7162bb2016-07-25 17:30:30 -070044 match = ofp.match( )
45 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
46 match.oxm_list.append( ofp.oxm.ip_proto( 17 ) )
47 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
48 ofp.instruction.apply_actions( actions=[
49 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
50 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
51 logging.info( "Inserting packet in flow to controller" )
52 self.controller.message_send( request )
53 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050054
Flavio Castroa7162bb2016-07-25 17:30:30 -070055 for of_port in config[ "port_map" ].keys( ):
56 logging.info( "PacketInMiss test, port %d", of_port )
57 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro6d498522015-12-15 14:05:04 -050058
Flavio Castroa7162bb2016-07-25 17:30:30 -070059 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro6d498522015-12-15 14:05:04 -050060
Flavio Castroa7162bb2016-07-25 17:30:30 -070061 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070062 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -070063 delete_all_flows( self.controller )
64 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050065
Flavio Castroaf2b4502016-02-02 17:41:32 -050066
Flavio Castro67d8bd52016-02-03 14:22:14 -050067@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -070068class ArpNL2( base_tests.SimpleDataPlane ):
69 def runTest( self ):
70 delete_all_flows( self.controller )
71 delete_all_groups( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050072
Flavio Castroa7162bb2016-07-25 17:30:30 -070073 ports = sorted( config[ "port_map" ].keys( ) )
74 match = ofp.match( )
75 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
76 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
77 ofp.instruction.apply_actions( actions=[
78 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
79 buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
80 self.controller.message_send( request )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050081 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -070082 add_one_l2_interface_group( self.controller, port, 1, False, False )
83 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
84 group_id = encode_l2_interface_group_id( 1, port )
85 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
86 do_barrier( self.controller )
87 parsed_arp_pkt = simple_arp_packet( )
88 arp_pkt = str( parsed_arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050089
90 for out_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -070091 self.dataplane.send( out_port, arp_pkt )
92 verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050093 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -050094 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -050095 for in_port in ports:
96 if in_port == out_port:
97 continue
98 # change source based on port number to avoid packet-ins from learning
Flavio Castro1c9b1252016-02-04 18:42:58 -050099 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700100 parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
101 pkt = str( parsed_pkt )
102 self.dataplane.send( in_port, pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500103
104 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700105 if ofport in [ out_port ]:
106 verify_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500107 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700108 verify_no_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500109
Flavio Castroa7162bb2016-07-25 17:30:30 -0700110 verify_no_other_packets( self )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500111
Flavio Castroa7162bb2016-07-25 17:30:30 -0700112class PacketInArp( base_tests.SimpleDataPlane ):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500113 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700114 Verify Packet-in message from eth_type 0x806 on ACL table
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500115 """
116
Flavio Castroa7162bb2016-07-25 17:30:30 -0700117 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700118 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700119 parsed_arp_pkt = simple_arp_packet( )
120 arp_pkt = str( parsed_arp_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700121 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -0700122 match = ofp.match( )
123 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
124 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
125 ofp.instruction.apply_actions( actions=[
126 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
127 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500128
Flavio Castroa7162bb2016-07-25 17:30:30 -0700129 logging.info( "Inserting packet in flow to controller" )
130 self.controller.message_send( request )
131 do_barrier( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500132
Flavio Castroa7162bb2016-07-25 17:30:30 -0700133 for of_port in config[ "port_map" ].keys( ):
134 logging.info( "PacketInMiss test, port %d", of_port )
135 self.dataplane.send( of_port, arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500136
Flavio Castroa7162bb2016-07-25 17:30:30 -0700137 verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500138
Flavio Castroa7162bb2016-07-25 17:30:30 -0700139 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700140 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700141 delete_all_flows( self.controller )
142 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500143
Flavio Castroa7162bb2016-07-25 17:30:30 -0700144
145class PacketInIPTable( base_tests.SimpleDataPlane ):
Flavio Castro91d1a552016-05-17 16:59:44 -0700146 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700147 Verify Packet-in message from IP table when controller action is used
Flavio Castro91d1a552016-05-17 16:59:44 -0700148 Send a packet to each dataplane port and verify that a packet
149 in message is received from the controller for each
150 #todo verify you stop receiving after adding rule
151 """
152
Flavio Castroa7162bb2016-07-25 17:30:30 -0700153 def runTest( self ):
154 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700155 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700156 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
157 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
158 dip = 0xc0a80001
159 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro91d1a552016-05-17 16:59:44 -0700160
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700161 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700162 # add l2 interface group
163 vlan_id = port
164 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
165 send_barrier=False )
166 dst_mac[ 5 ] = vlan_id
167 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
168 src_mac=intf_src_mac, dst_mac=dst_mac )
169 # add vlan flow table
170 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
171 # add termination flow
172 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
173 # add unicast routing flow
174 dst_ip = dip + (vlan_id << 8)
175 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
176 send_ctrl=True )
177 Groups.put( l3_msg.group_id )
Flavio Castro91d1a552016-05-17 16:59:44 -0700178
Flavio Castroa7162bb2016-07-25 17:30:30 -0700179 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700180
Flavio Castroa7162bb2016-07-25 17:30:30 -0700181 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700182 for in_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700183 mac_src = '00:00:00:22:22:%02X' % in_port
184 ip_src = '192.168.%02d.1' % in_port
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700185 for out_port in ports:
186 if in_port == out_port:
187 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700188 ip_dst = '192.168.%02d.1' % out_port
189 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
190 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
191 pkt = str( parsed_pkt )
192 self.dataplane.send( in_port, pkt )
193 verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
194 # verify_no_other_packets(self)
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700195 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700196 delete_all_flows( self.controller )
197 delete_groups( self.controller, Groups )
198 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700199
Flavio Castroa7162bb2016-07-25 17:30:30 -0700200
201class L2FloodQinQ( base_tests.SimpleDataPlane ):
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500202 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700203 Verify Vlan based flooding of QinQ based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500204 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500205
Flavio Castroa7162bb2016-07-25 17:30:30 -0700206 def runTest( self ):
207 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700208 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700209 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700210 vlan_id = 1
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500211
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700212 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700213 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
214 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
215 Groups.put( L2gid )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500216
Flavio Castroa7162bb2016-07-25 17:30:30 -0700217 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
218 Groups.put( msg.group_id )
219 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
220 do_barrier( self.controller )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500221
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700222 # verify flood
223 for ofport in ports:
224 # change dest based on port number
225 mac_src = '00:12:34:56:78:%02X' % ofport
Flavio Castroa7162bb2016-07-25 17:30:30 -0700226 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
227 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
228 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
229 pkt = str( parsed_pkt )
230 self.dataplane.send( ofport, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700231 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700232 verify_no_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700233 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700234 tmp_ports = list( ports )
235 tmp_ports.remove( ofport )
236 verify_packets( self, pkt, tmp_ports )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500237
Flavio Castroa7162bb2016-07-25 17:30:30 -0700238 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700239 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700240 delete_all_flows( self.controller )
241 delete_groups( self.controller, Groups )
242 delete_all_groups( self.controller )
243
Flavio Castro1c9b1252016-02-04 18:42:58 -0500244
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500245@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700246class L2FloodTagged( base_tests.SimpleDataPlane ):
Flavio Castro184cefe2015-11-19 20:52:49 -0500247 """
248 Test L2 flood to a vlan
249 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
Flavio Castro184cefe2015-11-19 20:52:49 -0500250 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500251
Flavio Castroa7162bb2016-07-25 17:30:30 -0700252 def runTest( self ):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500253 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700254 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500255 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500256
Flavio Castroa7162bb2016-07-25 17:30:30 -0700257 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro34352e72015-12-07 20:01:51 -0500258
Flavio Castroa7162bb2016-07-25 17:30:30 -0700259 delete_all_flows( self.controller )
260 delete_all_groups( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500261
Flavio Castro184cefe2015-11-19 20:52:49 -0500262 # Installing flows to avoid packet-in
263 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700264 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
265 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
266 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
267 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
268 do_barrier( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500269
Flavio Castro1c9b1252016-02-04 18:42:58 -0500270 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500271 for ofport in ports:
272 # change dest based on port number
Flavio Castroa7162bb2016-07-25 17:30:30 -0700273 pkt = str(
274 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
275 self.dataplane.send( ofport, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500276 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700277 verify_no_packet( self, pkt, ofport )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500278 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700279 tmp_ports = list( ports )
280 tmp_ports.remove( ofport )
281 verify_packets( self, pkt, tmp_ports )
282 verify_no_other_packets( self )
Flavio Castroaabb5792015-11-18 19:03:50 -0500283
Flavio Castro1c9b1252016-02-04 18:42:58 -0500284
Flavio Castroa7162bb2016-07-25 17:30:30 -0700285class L2UnicastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700286 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500287
Flavio Castroa7162bb2016-07-25 17:30:30 -0700288 def runTest( self ):
Flavio Castrob01d0aa2016-07-20 16:14:48 -0700289
Flavio Castroa7162bb2016-07-25 17:30:30 -0700290 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700291 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700292 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700293 vlan_id = 1;
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700294 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700295 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
296 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
297 Groups.put( L2gid )
298 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
299 True )
300 do_barrier( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500301
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700302 for out_port in ports:
303 # change dest based on port number
304 mac_dst = '00:12:34:56:78:%02X' % out_port
305 for in_port in ports:
306 if in_port == out_port:
307 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700308 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
309 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700310 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700311 if ofport in [ out_port ]:
312 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700313 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700314 verify_no_packet( self, pkt, ofport )
315 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700316 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700317 delete_all_flows( self.controller )
318 delete_groups( self.controller, Groups )
319 delete_all_groups( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500320
Flavio Castroa7162bb2016-07-25 17:30:30 -0700321
322class Mtu1500( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700323 """V erifies basic mtu limits"""
Flavio Castroa7162bb2016-07-25 17:30:30 -0700324 def runTest( self ):
325 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700326 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700327 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700328 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700329 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700330 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
331 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
332 Groups.put( L2gid )
333 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
334 True )
335 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500336
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700337 for out_port in ports:
338 # change dest based on port number
339 mac_dst = '00:12:34:56:78:%02X' % out_port
340 for in_port in ports:
341 if in_port == out_port:
342 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700343 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
344 eth_dst=mac_dst ) )
345 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700346 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700347 if ofport in [ out_port ]:
348 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700349 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700350 verify_no_packet( self, pkt, ofport )
351 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700352 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700353 delete_all_flows( self.controller )
354 delete_groups( self.controller, Groups )
355 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500356
Flavio Castroa7162bb2016-07-25 17:30:30 -0700357
358class _32UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700359 """ Verify /32 IP forwarding to L3 Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500360
Flavio Castroa7162bb2016-07-25 17:30:30 -0700361 def runTest( self ):
362 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700363 try:
364 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700365 if len( config[ "port_map" ] ) < 2:
366 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700367 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500368
Flavio Castroa7162bb2016-07-25 17:30:30 -0700369 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
370 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700371 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700372 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700373 for port in ports:
374 # add l2 interface group
375 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -0700376 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
377 is_tagged=True, send_barrier=False )
378 dst_mac[ 5 ] = vlan_id
379 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
380 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700381 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700382 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700383 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700384 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700385 # add unicast routing flow
386 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700387 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
388 Groups.put( l2gid )
389 Groups.put( l3_msg.group_id )
390 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500391
Flavio Castroa7162bb2016-07-25 17:30:30 -0700392 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700393 for in_port in ports:
394 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
395 ip_src = '192.168.%02d.1' % (test_id + in_port)
396 for out_port in ports:
397 if in_port == out_port:
398 continue
399 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700400 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
401 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
402 ip_src=ip_src, ip_dst=ip_dst )
403 pkt = str( parsed_pkt )
404 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700405 # build expected packet
406 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700407 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
408 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
409 ip_src=ip_src, ip_dst=ip_dst )
410 pkt = str( exp_pkt )
411 verify_packet( self, pkt, out_port )
412 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700413 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700414 delete_all_flows( self.controller )
415 delete_groups( self.controller, Groups )
416 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500417
Flavio Castroa7162bb2016-07-25 17:30:30 -0700418
419class _32VPN( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700420 """ Verify MPLS IP VPN Initiation from /32 rule """
Flavio Castro2262fd42016-02-04 19:03:36 -0500421
Flavio Castroa7162bb2016-07-25 17:30:30 -0700422 def runTest( self ):
423 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700424 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700425 if len( config[ "port_map" ] ) < 2:
426 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700427 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500428
Flavio Castroa7162bb2016-07-25 17:30:30 -0700429 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
430 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700431 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700432 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700433 for port in ports:
434 # add l2 interface group
435 id = port
436 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700437 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
438 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700439 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700440 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
441 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700442 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700443 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
444 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
445 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700446 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700447 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700448 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700449 add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=2,
450 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700451 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700452 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700453 # add routing flow
454 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700455 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
456 Groups._put( l2_gid )
457 Groups._put( mpls_gid )
458 Groups._put( mpls_label_gid )
459 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500460
Flavio Castroa7162bb2016-07-25 17:30:30 -0700461 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700462 for in_port in ports:
463 ip_src = '192.168.%02d.1' % (in_port)
464 for out_port in ports:
465 if in_port == out_port:
466 continue
467 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700468 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
469 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
470 pkt = str( parsed_pkt )
471 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700472 # build expect packet
473 mac_dst = '00:00:00:22:22:%02X' % (out_port)
474 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700475 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
476 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
477 label=[ label ] )
478 pkt = str( exp_pkt )
479 verify_packet( self, pkt, out_port )
480 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700481 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700482 delete_all_flows( self.controller )
483 delete_groups( self.controller, Groups )
484 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500485
Flavio Castroa7162bb2016-07-25 17:30:30 -0700486
487class _32EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700488 """ Verify MPLS IP VPN Initiation from /32 rule using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500489
Flavio Castroa7162bb2016-07-25 17:30:30 -0700490 def runTest( self ):
491 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700492 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700493 if len( config[ "port_map" ] ) < 2:
494 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700495 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500496
Flavio Castroa7162bb2016-07-25 17:30:30 -0700497 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
498 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700499 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700500 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700501 for port in ports:
502 # add l2 interface group
503 id = port
504 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700505 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
506 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700507 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700508 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
509 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700510 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700511 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
512 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
513 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
514 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
515 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700516 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700517 add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
518 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700519 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700520 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700521 # add routing flow
522 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700523 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
524 Groups._put( l2_gid )
525 Groups._put( mpls_gid )
526 Groups._put( mpls_label_gid )
527 Groups._put( ecmp_msg.group_id )
528 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500529
Flavio Castroa7162bb2016-07-25 17:30:30 -0700530 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700531 for in_port in ports:
532 ip_src = '192.168.%02d.1' % (in_port)
533 for out_port in ports:
534 if in_port == out_port:
535 continue
536 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700537 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
538 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
539 pkt = str( parsed_pkt )
540 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700541 # build expect packet
542 mac_dst = '00:00:00:22:22:%02X' % (out_port)
543 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700544 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
545 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
546 label=[ label ] )
547 pkt = str( exp_pkt )
548 verify_packet( self, pkt, out_port )
549 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700550 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700551 delete_all_flows( self.controller )
552 delete_groups( self.controller, Groups )
553 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500554
Flavio Castroa7162bb2016-07-25 17:30:30 -0700555
556class _32ECMPL3( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700557 """ Verifies /32 IP routing and ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500558
Flavio Castroa7162bb2016-07-25 17:30:30 -0700559 def runTest( self ):
560 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700561 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700562 if len( config[ "port_map" ] ) < 2:
563 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700564 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500565
Flavio Castroa7162bb2016-07-25 17:30:30 -0700566 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
567 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700568 dip = 0xc0a80001
569 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700570 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700571 for port in ports:
572 vlan_id = port
573 id = port
574 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700575 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
576 is_tagged=True, send_barrier=False )
577 dst_mac[ 5 ] = vlan_id
578 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
579 src_mac=intf_src_mac, dst_mac=dst_mac )
580 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700581 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700582 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700583 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700584 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700585 # add unicast routing flow
586 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700587 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
588 Groups._put( l2_gid )
589 Groups._put( l3_msg.group_id )
590 Groups._put( ecmp_msg.group_id )
591 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500592
Flavio Castroa7162bb2016-07-25 17:30:30 -0700593 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700594 for in_port in ports:
595 mac_src = '00:00:00:22:22:%02X' % in_port
596 ip_src = '192.168.%02d.1' % in_port
597 for out_port in ports:
598 if in_port == out_port:
599 continue
600 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700601 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
602 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
603 pkt = str( parsed_pkt )
604 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700605 # build expected packet
606 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700607 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
608 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
609 pkt = str( exp_pkt )
610 verify_packet( self, pkt, out_port )
611 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700612 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700613 delete_all_flows( self.controller )
614 delete_groups( self.controller, Groups )
615 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500616
Flavio Castroa7162bb2016-07-25 17:30:30 -0700617
618class _24VPN( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700619 """ Verify MPLS IP VPN Initiation from /32 rule using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500620
Flavio Castroa7162bb2016-07-25 17:30:30 -0700621 def runTest( self ):
622 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700623 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700624 if len( config[ "port_map" ] ) < 2:
625 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700626 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500627
Flavio Castroa7162bb2016-07-25 17:30:30 -0700628 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
629 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700630 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700631 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700632 for port in ports:
633 # add l2 interface group
634 id = port
635 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700636 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
637 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700638 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700639 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
640 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700641 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700642 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
643 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
644 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700645 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700646 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700647 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700648 add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
649 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700650 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700651 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700652 # add routing flow
653 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700654 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
655 Groups._put( l2_gid )
656 Groups._put( mpls_gid )
657 Groups._put( mpls_label_gid )
658 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500659
Flavio Castroa7162bb2016-07-25 17:30:30 -0700660 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700661 for in_port in ports:
662 ip_src = '192.168.%02d.1' % (in_port)
663 for out_port in ports:
664 if in_port == out_port:
665 continue
666 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700667 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
668 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
669 pkt = str( parsed_pkt )
670 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700671 # build expect packet
672 mac_dst = '00:00:00:22:22:%02X' % (out_port)
673 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700674 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
675 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
676 label=[ label ] )
677 pkt = str( exp_pkt )
678 verify_packet( self, pkt, out_port )
679 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700680 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700681 delete_all_flows( self.controller )
682 delete_groups( self.controller, Groups )
683 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500684
Flavio Castroa7162bb2016-07-25 17:30:30 -0700685
686class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700687 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -0500688
Flavio Castroa7162bb2016-07-25 17:30:30 -0700689 def runTest( self ):
690 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700691 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700692 if len( config[ "port_map" ] ) < 2:
693 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700694 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700695 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
696 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700697 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700698 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700699 for port in ports:
700 # add l2 interface group
701 id = port
702 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -0700703 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
704 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700705 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700706 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
707 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700708 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700709 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
710 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
711 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
712 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
713 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700714 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700715 add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0,
716 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700717 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700718 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700719 # add routing flow
720 dst_ip = dip + (vlan_id << 8)
721 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700722 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
723 vrf=0 )
724 Groups._put( l2_gid )
725 Groups._put( mpls_gid )
726 Groups._put( mpls_label_gid )
727 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700728
Flavio Castroa7162bb2016-07-25 17:30:30 -0700729 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -0500730
Flavio Castroa7162bb2016-07-25 17:30:30 -0700731 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700732 for in_port in ports:
733 mac_src = '00:00:00:22:22:%02X' % (in_port)
734 ip_src = '192.168.%02d.1' % (in_port)
735 for out_port in ports:
736 if in_port == out_port:
737 continue
738 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700739 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
740 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
741 pkt = str( parsed_pkt )
742 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700743 # build expect packet
744 mac_dst = '00:00:00:22:22:%02X' % out_port
745 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700746 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
747 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
748 label=[ label ] )
749 pkt = str( exp_pkt )
750 verify_packet( self, pkt, out_port )
751 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700752 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700753 delete_all_flows( self.controller )
754 delete_groups( self.controller, Groups )
755 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500756
Flavio Castroa7162bb2016-07-25 17:30:30 -0700757
758class FloodGroupMod( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700759 """ Modify referenced group test """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700760
761 def runTest( self ):
762 Groups = Queue.LifoQueue( )
763 try:
764 ports = sorted( config[ "port_map" ].keys( ) )
765 vlan_id = 1
766
767 for port in ports:
768 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
769 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
770 Groups.put( L2gid )
771
772 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
773 Groups.put( msg.group_id )
774 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
775 do_barrier( self.controller )
776 # verify flood
777 for ofport in ports:
778 # change dest based on port number
779 mac_src = '00:12:34:56:78:%02X' % ofport
780 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
781 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
782 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
783 pkt = str( parsed_pkt )
784 self.dataplane.send( ofport, pkt )
785 # self won't rx packet
786 verify_no_packet( self, pkt, ofport )
787 # others will rx packet
788 tmp_ports = list( ports )
789 tmp_ports.remove( ofport )
790 verify_packets( self, pkt, tmp_ports )
791 verify_no_other_packets( self )
792 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
793 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
794 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
795 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
796 eth_src=mac_src )
797 pkt = str( parsed_pkt )
798 self.dataplane.send( ports[ 1 ], pkt )
799 verify_packets( self, pkt, [ ports[ 0 ] ] )
800 finally:
801 delete_all_flows( self.controller )
802 delete_groups( self.controller, Groups )
803 delete_all_groups( self.controller )
804
805
806class _24ECMPL3( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700807 """ Verifies /24 IP routing using ECMP """
Flavio Castro80730822015-12-11 15:38:47 -0500808
Flavio Castroa7162bb2016-07-25 17:30:30 -0700809 def runTest( self ):
810 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700811 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700812 if len( config[ "port_map" ] ) < 2:
813 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700814 return
Flavio Castro80730822015-12-11 15:38:47 -0500815
Flavio Castroa7162bb2016-07-25 17:30:30 -0700816 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
817 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700818 dip = 0xc0a80001
819 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700820 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700821 for port in ports:
822 vlan_id = port
823 id = port
824 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700825 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
826 is_tagged=True, send_barrier=False )
827 dst_mac[ 5 ] = vlan_id
828 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
829 src_mac=intf_src_mac, dst_mac=dst_mac )
830 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700831 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700832 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700833 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700834 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700835 # add unicast routing flow
836 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700837 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
838 Groups._put( l2_gid )
839 Groups._put( l3_msg.group_id )
840 Groups._put( ecmp_msg.group_id )
841 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -0500842
Flavio Castroa7162bb2016-07-25 17:30:30 -0700843 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700844 for in_port in ports:
845 mac_src = '00:00:00:22:22:%02X' % in_port
846 ip_src = '192.168.%02d.1' % in_port
847 for out_port in ports:
848 if in_port == out_port:
849 continue
850 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700851 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
852 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
853 pkt = str( parsed_pkt )
854 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700855 # build expected packet
856 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700857 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
858 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
859 pkt = str( exp_pkt )
860 verify_packet( self, pkt, out_port )
861 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700862 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700863 delete_all_flows( self.controller )
864 delete_groups( self.controller, Groups )
865 delete_all_groups( self.controller )
866
Flavio Castro1c9b1252016-02-04 18:42:58 -0500867
Flavio Castroaba28ff2016-02-03 16:47:48 -0500868@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700869class MPLSBUG( base_tests.SimpleDataPlane ):
870 def runTest( self ):
871 if len( config[ "port_map" ] ) < 2:
872 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -0500873 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700874 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
875 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -0500876 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700877 Groups = Queue.LifoQueue( )
878 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -0500879 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500880 # add l2 interface group
881 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700882 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
883 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -0500884 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700885 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
886 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500887 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -0700888 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500889 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700890 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500891 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700892 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500893 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700894 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500895 # add unicast routing flow
896 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700897 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
898 Groups._put( l2_gid )
899 Groups._put( l3_msg.group_id )
900 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -0500901
Flavio Castroa7162bb2016-07-25 17:30:30 -0700902 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -0500903 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500904 mac_src = '00:00:00:22:22:%02X' % in_port
905 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -0500906 for out_port in ports:
907 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500908 continue
909 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -0500910 switch_mac = "00:00:00:cc:cc:cc"
911 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700912 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
913 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
914 pkt = str( parsed_pkt )
915 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -0500916
Flavio Castro1c9b1252016-02-04 18:42:58 -0500917 # build expect packet
918 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700919 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
920 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
921 pkt = str( exp_pkt )
922 verify_packet( self, pkt, out_port )
923 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500924
Flavio Castroa7162bb2016-07-25 17:30:30 -0700925 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
926 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
927 pkt = str( parsed_pkt )
928 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500929 # build expected packet
930 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700931 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
932 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
933 pkt = str( exp_pkt )
934 verify_packet( self, pkt, out_port )
935 verify_no_other_packets( self )
936 delete_all_flows( self.controller )
937 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500938
Flavio Castroa7162bb2016-07-25 17:30:30 -0700939class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -0700940 """
941 Mcast routing, in this test case the traffic comes in tagged.
942 port+1 is used as ingress vlan_id. The packet goes out tagged on
943 different ports. 4094-port is used as egress vlan_id.
944 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700945 def runTest( self ):
Flavio Castroa7162bb2016-07-25 17:30:30 -0700946 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700947 try:
Pierbbdf3782016-08-22 17:58:26 -0700948 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
949 if len( config[ "port_map" ] ) < 1:
950 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700951 assert (False)
952 return
Pierbbdf3782016-08-22 17:58:26 -0700953 ports = config[ "port_map" ].keys( )
954 dst_ip_str = "224.0.0.1"
955 (
956 port_to_in_vlan,
957 port_to_out_vlan,
958 port_to_src_mac_str,
959 port_to_dst_mac_str,
960 port_to_src_ip_str,
961 port_to_intf_src_mac_str,
962 Groups) = fill_mcast_pipeline_L3toL3(
963 self.controller,
964 logging,
965 ports,
966 is_ingress_tagged = True,
967 is_egress_tagged = True,
968 is_vlan_translated = True,
969 is_max_vlan = False
970 )
Flavio Castro12296312015-12-15 17:48:26 -0500971
Pierbbdf3782016-08-22 17:58:26 -0700972 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -0500973
Pierbbdf3782016-08-22 17:58:26 -0700974 parsed_pkt = simple_udp_packet(
975 pktlen = 100,
976 dl_vlan_enable = True,
977 vlan_vid = port_to_in_vlan[in_port],
978 eth_dst = port_to_dst_mac_str[in_port],
979 eth_src = port_to_src_mac_str[in_port],
980 ip_ttl = 64,
981 ip_src = port_to_src_ip_str[in_port],
982 ip_dst = dst_ip_str
983 )
984 pkt = str( parsed_pkt )
985 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -0500986
Pierbbdf3782016-08-22 17:58:26 -0700987 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -0500988
Pierbbdf3782016-08-22 17:58:26 -0700989 parsed_pkt = simple_udp_packet(
990 pktlen = 100,
991 dl_vlan_enable = True,
992 vlan_vid = port_to_out_vlan[out_port],
993 eth_dst = port_to_dst_mac_str[in_port],
994 eth_src = port_to_intf_src_mac_str[out_port],
995 ip_ttl = 63,
996 ip_src = port_to_src_ip_str[in_port],
997 ip_dst = dst_ip_str
998 )
999 pkt = str( parsed_pkt )
1000 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001001
Pierbbdf3782016-08-22 17:58:26 -07001002 verify_no_other_packets( self )
1003
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001004 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001005 delete_all_flows( self.controller )
1006 delete_groups( self.controller, Groups )
1007 delete_all_groups( self.controller )
1008
Pierbbdf3782016-08-22 17:58:26 -07001009
Flavio Castroa7162bb2016-07-25 17:30:30 -07001010class _MplsFwd( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001011 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001012
1013 def runTest( self ):
1014 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001015 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001016 if len( config[ "port_map" ] ) < 2:
1017 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001018 return
1019 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001020 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1021 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001022 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001023 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001024 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001025 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1026 vlan_id = port + 16
1027 mpls_label = port + 16
1028
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001029 # add l2 interface group
1030 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001031 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001032 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001033 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1034 vlan_id, id )
1035 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1036 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001037 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Pierf3504f82016-08-19 15:32:53 -07001038 ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1039 subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001040 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001041 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001042 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001043 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001044 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Charles Chan53cac542016-08-22 16:03:26 -07001045 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001046 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001047 Groups._put( l2_gid )
1048 Groups._put( mpls_gid )
1049 Groups._put( mpls_label_gid )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001050 Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001051 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001052
Flavio Castroa7162bb2016-07-25 17:30:30 -07001053 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001054 for in_port in ports:
1055 ip_src = '192.168.%02d.1' % (in_port)
1056 for out_port in ports:
1057 if in_port == out_port:
1058 continue
Flavio Castro54947942016-02-03 16:05:20 -05001059
Charles Chan53cac542016-08-22 16:03:26 -07001060 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1061 out_mpls_label = out_port + 16
1062 in_vlan_vid = in_port + 16
1063 out_vlan_vid = out_port + 16
1064
1065 ip_dst = '192.168.%02d.1' % (out_port)
1066 label = (out_mpls_label, 0, 1, 32)
1067 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001068 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1069 pkt = str( parsed_pkt )
1070 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001071
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001072 # build expect packet
1073 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001074 label = (out_mpls_label, 0, 1, 31)
1075 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001076 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1077 label=[ label ] )
1078 pkt = str( exp_pkt )
1079 verify_packet( self, pkt, out_port )
1080 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001081 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001082 delete_all_flows( self.controller )
1083 delete_groups( self.controller, Groups )
1084 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001085
Flavio Castroa7162bb2016-07-25 17:30:30 -07001086
1087class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001088 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001089
1090 def runTest( self ):
1091 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001092 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001093 if len( config[ "port_map" ] ) < 2:
1094 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001095 return
1096 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001097 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1098 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001099 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001100 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001101 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001102 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1103 vlan_id = port + 16
1104 mpls_label = port + 16
1105
Flavio Castrod80fbc32016-07-25 15:54:26 -07001106 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001107 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001108 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001109 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001110 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1111 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001112 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001113 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001114 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001115 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001116 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001117 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Charles Chan53cac542016-08-22 16:03:26 -07001118 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001119 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001120 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001121 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001122 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001123 Groups._put( l2_gid )
1124 Groups._put( l3_msg.group_id )
1125 Groups._put( ecmp_msg.group_id )
1126 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001127
Flavio Castroa7162bb2016-07-25 17:30:30 -07001128 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001129 for in_port in ports:
1130 ip_src = '192.168.%02d.1' % (in_port)
1131 for out_port in ports:
1132 if in_port == out_port:
1133 continue
Charles Chan53cac542016-08-22 16:03:26 -07001134
1135 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1136 out_mpls_label = out_port + 16
1137 in_vlan_vid = in_port + 16
1138 out_vlan_vid = out_port + 16
1139
Flavio Castrod80fbc32016-07-25 15:54:26 -07001140 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001141 label = (out_mpls_label, 0, 1, 32)
1142 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001143 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1144 pkt = str( parsed_pkt )
1145 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001146 # build expect packet
1147 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001148 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001149 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1150 pkt = str( exp_pkt )
1151 verify_packet( self, pkt, out_port )
1152 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001153 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001154 delete_all_flows( self.controller )
1155 delete_groups( self.controller, Groups )
1156 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001157
Flavio Castroa7162bb2016-07-25 17:30:30 -07001158
1159class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001160 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001161
Flavio Castroa7162bb2016-07-25 17:30:30 -07001162 def runTest( self ):
1163 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001164 try:
1165 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001166 if len( config[ "port_map" ] ) < 2:
1167 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001168 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001169 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1170 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001171 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001172 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001173 for port in ports:
1174 # add l2 interface group
1175 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001176 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1177 is_tagged=True, send_barrier=False )
1178 dst_mac[ 5 ] = vlan_id
1179 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1180 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001181 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001182 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001183 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001184 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001185 # add unicast routing flow
1186 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001187 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1188 Groups.put( l2gid )
1189 Groups.put( l3_msg.group_id )
1190 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001191
Flavio Castroa7162bb2016-07-25 17:30:30 -07001192 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001193 for in_port in ports:
1194 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1195 ip_src = '192.168.%02d.1' % (test_id + in_port)
1196 for out_port in ports:
1197 if in_port == out_port:
1198 continue
1199 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001200 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1201 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1202 ip_src=ip_src, ip_dst=ip_dst )
1203 pkt = str( parsed_pkt )
1204 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001205 # build expected packet
1206 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001207 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1208 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1209 ip_src=ip_src, ip_dst=ip_dst )
1210 pkt = str( exp_pkt )
1211 verify_packet( self, pkt, out_port )
1212 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001213 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001214 delete_all_flows( self.controller )
1215 delete_groups( self.controller, Groups )
1216 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001217
Flavio Castroa7162bb2016-07-25 17:30:30 -07001218
1219class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001220 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07001221
Flavio Castroa7162bb2016-07-25 17:30:30 -07001222 def runTest( self ):
1223 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001224 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001225 if len( config[ "port_map" ] ) < 2:
1226 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001227 return
Flavio Castro91d1a552016-05-17 16:59:44 -07001228
Flavio Castroa7162bb2016-07-25 17:30:30 -07001229 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1230 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001231 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001232 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001233 for port in ports:
1234 # add l2 interface group
1235 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001236 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
1237 is_tagged=True, send_barrier=False )
1238 dst_mac[ 5 ] = vlan_id
1239 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
1240 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001241 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001242 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001243 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001244 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001245 # add unicast routing flow
1246 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001247 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1248 Groups.put( l2gid )
1249 Groups.put( l3_msg.group_id )
1250 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001251 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07001252 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
1253 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001254
Flavio Castroa7162bb2016-07-25 17:30:30 -07001255 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001256 for in_port in ports:
1257 mac_src = '00:00:00:22:22:%02X' % (in_port)
1258 ip_src = '192.168.%02d.1' % (in_port)
1259 for out_port in ports:
1260 if in_port == out_port:
1261 continue
1262 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001263 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1264 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1265 pkt = str( parsed_pkt )
1266 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001267 # build expected packet
1268 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001269 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
1270 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1271 pkt = str( exp_pkt )
1272 verify_packet( self, pkt, out_port )
1273 verify_no_other_packets( self )
1274 ip_dst = '1.168.%02d.1' % ports[ 0 ]
1275 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1276 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1277 pkt = str( parsed_pkt )
1278 self.dataplane.send( in_port, pkt )
1279 # build expect packet
1280 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
1281 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
1282 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
1283 pkt = str( exp_pkt )
1284 verify_packet( self, pkt, ports[ 0 ] )
1285 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001286 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001287 delete_all_flows( self.controller )
1288 delete_groups( self.controller, Groups )
1289 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001290
Flavio Castroa7162bb2016-07-25 17:30:30 -07001291
1292class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001293 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001294 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04001295 """
Flavio Castro91d1a552016-05-17 16:59:44 -07001296
Flavio Castroa7162bb2016-07-25 17:30:30 -07001297 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001298 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001299 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001300 vlan_id = 1;
1301 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001302 add_l2_unfiltered_group( self.controller, [ port ], False )
1303 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001304 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001305 delete_all_flows( self.controller )
1306 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001307
Flavio Castroa7162bb2016-07-25 17:30:30 -07001308
1309class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001310 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001311 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04001312 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001313
1314 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04001315 """
1316 port1 (vlan 1)-> port 2 (vlan 2)
1317 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001318 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001319 delete_all_flows( self.controller )
1320 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04001321
Flavio Castroa7162bb2016-07-25 17:30:30 -07001322 if len( config[ "port_map" ] ) < 3:
1323 logging.info( "Port count less than 3, can't run this case" )
1324 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001325 return
Flavio Castro423df652016-05-17 20:14:08 -04001326
Flavio Castroa7162bb2016-07-25 17:30:30 -07001327 vlan_id = 1
1328 port2_out_vlan = 2
1329 port3_out_vlan = 3
1330 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
1331 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1332 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1333 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
1334 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1335 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
1336 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
1337 src_ip = 0xc0a80101
1338 src_ip_str = "192.168.1.1"
1339 dst_ip = 0xe0010101
1340 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04001341
Flavio Castroa7162bb2016-07-25 17:30:30 -07001342 port1 = config[ "port_map" ].keys( )[ 0 ]
1343 port2 = config[ "port_map" ].keys( )[ 1 ]
1344 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04001345
Flavio Castroa7162bb2016-07-25 17:30:30 -07001346 # add l2 interface group
1347 for port in config[ "port_map" ].keys( ):
1348 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
1349 send_barrier=False )
1350 # add vlan flow table
1351 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1352 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04001353
Flavio Castroa7162bb2016-07-25 17:30:30 -07001354 # add termination flow
1355 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
1356 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04001357
Flavio Castroa7162bb2016-07-25 17:30:30 -07001358 # add MPLS interface group
1359 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
1360 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1361 port2_out_vlan, port2 )
1362 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1363 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1364 # add L3VPN groups
1365 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
1366 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
1367 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
1368 # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001369 # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
Flavio Castro423df652016-05-17 20:14:08 -04001370
Flavio Castroa7162bb2016-07-25 17:30:30 -07001371 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
1372 add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id )
Flavio Castro423df652016-05-17 20:14:08 -04001373
Flavio Castroa7162bb2016-07-25 17:30:30 -07001374 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
1375 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
1376 pkt = str( parsed_pkt )
1377 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001378 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001379 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
1380 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
1381 pkt = str( exp_pkt )
1382 verify_packet( self, pkt, port2 )
1383 # verify_packet(self, pkt, port3)
1384 verify_no_other_packets( self )
1385 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001386 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001387 delete_all_flows( self.controller )
1388 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001389
Flavio Castro423df652016-05-17 20:14:08 -04001390
Flavio Castroa7162bb2016-07-25 17:30:30 -07001391class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001392 """
1393 Test packet in function on a src-mac miss
1394 Send a packet to each dataplane port and verify that a packet
1395 in message is received from the controller for each
1396 #todo verify you stop receiving after adding rule
1397 """
1398
Flavio Castroa7162bb2016-07-25 17:30:30 -07001399 def runTest( self ):
1400 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001401 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001402 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04001403
Flavio Castroa7162bb2016-07-25 17:30:30 -07001404 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001405 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001406 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
1407 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1408 Groups.put( L2gid )
1409 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
1410 vlan_pkt = str( parsed_vlan_pkt )
1411 for of_port in config[ "port_map" ].keys( ):
1412 logging.info( "PacketInMiss test, port %d", of_port )
1413 self.dataplane.send( of_port, vlan_pkt )
1414 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
1415 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001416 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001417 delete_all_flows( self.controller )
1418 delete_all_groups( self.controller )
1419
1420
1421class EcmpGroupMod( base_tests.SimpleDataPlane ):
1422 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001423 Verify referenced group can be modified adding or removing buckets
1424 Attention the hashing behavior may vary according to your porting assigment
1425 Current values are hardcoded for our topology
Flavio Castroa7162bb2016-07-25 17:30:30 -07001426 """
1427
1428 def runTest( self ):
1429 Groups = Queue.LifoQueue( )
1430 try:
1431 if len( config[ "port_map" ] ) < 2:
1432 logging.info( "Port count less than 2, can't run this case" )
1433 return
1434
1435 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1436 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1437 dip = 0xc0a80001
1438 # Hashes Test Name and uses it as id for installing unique groups
1439 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001440 ecmp = [ ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07001441 for port in ports:
1442 vlan_id = port
1443 id = port
1444 # add l2 interface group
1445 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1446 is_tagged=True, send_barrier=False )
1447 dst_mac[ 5 ] = vlan_id
1448 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1449 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001450 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07001451 Groups._put( l2_gid )
1452 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001453 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001454 # add vlan flow table
1455 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1456 # add termination flow
1457 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
1458 # add unicast routing flow
1459 dst_ip = dip + (vlan_id << 8)
1460 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1461 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001462 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001463
1464 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001465 parsed_pkt = exp_pkt = 0
Flavio Castroa7162bb2016-07-25 17:30:30 -07001466 for out_port in ports:
Flavio Castro9debaaa2016-07-26 19:37:50 -07001467 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
1468 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
1469 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
1470 tcp = out_port if out_port == 24 else 25
1471 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
1472 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst,
1473 tcp_dport=tcp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001474 pkt = str( parsed_pkt )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001475 self.dataplane.send( ports[ 0 ], pkt )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001476 # build expected packet
1477 mac_dst = '00:00:00:22:22:%02X' % out_port
1478 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castro9debaaa2016-07-26 19:37:50 -07001479 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst,
1480 tcp_dport=tcp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001481 pkt = str( exp_pkt )
1482 verify_packet( self, pkt, out_port )
1483 verify_no_other_packets( self )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001484 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
1485 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001486 for port in ports:
Flavio Castro9debaaa2016-07-26 19:37:50 -07001487 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
1488 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
1489 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
1490 tcp = port if port == 24 else 25
1491 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
1492 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst,
1493 tcp_dport=tcp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001494 pkt = str( parsed_pkt )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001495 self.dataplane.send( ports[ 0 ], pkt )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001496 # build expected packet
Flavio Castro9debaaa2016-07-26 19:37:50 -07001497 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
1498 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
1499 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst,
1500 tcp_dport=tcp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001501 pkt = str( exp_pkt )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001502 verify_packet( self, pkt, ports[ 0 ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001503 verify_no_other_packets( self )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001504 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001505 for port in ports:
Flavio Castro9debaaa2016-07-26 19:37:50 -07001506 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
1507 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
1508 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
1509 tcp = port if port == 24 else 25
1510 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
1511 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst,
1512 tcp_dport=tcp )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001513 pkt = str( parsed_pkt )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001514 self.dataplane.send( ports[ 0 ], pkt )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001515 verify_no_other_packets( self )
1516 finally:
1517 delete_all_flows( self.controller )
1518 delete_groups( self.controller, Groups )
1519 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07001520
1521class Untagged( base_tests.SimpleDataPlane ):
1522 """
1523 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
1524 This should be fixed in OFDPA 2.0 GA and above, the test fails with
1525 previous versions of the OFDPA.
1526
1527 Two rules are necessary in VLAN table (10):
1528 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
1529 2) Filtering: match 0x100A/0x1FFF, goto 20
1530
1531 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
1532 The remaining part of the test is based on the use of the bridging table
1533 """
1534
1535 MAX_INTERNAL_VLAN = 4094
1536
1537 def runTest( self ):
1538 groups = Queue.LifoQueue( )
1539 try:
1540 if len( config[ "port_map" ] ) < 2:
1541 logging.info( "Port count less than 2, can't run this case" )
1542 return
1543
1544 ports = sorted( config[ "port_map" ].keys( ) )
1545 for port in ports:
1546 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
1547 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1548 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
1549 for other_port in ports:
1550 if other_port == port:
1551 continue
1552 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
1553 groups.put( L2gid )
1554 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
1555
1556 do_barrier( self.controller )
1557
1558 for out_port in ports:
1559 # change dest based on port number
1560 mac_dst = '00:12:34:56:78:%02X' % out_port
1561 for in_port in ports:
1562 if in_port == out_port:
1563 continue
1564 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
1565 self.dataplane.send( in_port, pkt )
1566 for ofport in ports:
1567 if ofport in [ out_port ]:
1568 verify_packet( self, pkt, ofport )
1569 else:
1570 verify_no_packet( self, pkt, ofport )
1571 verify_no_other_packets( self )
1572 finally:
1573 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07001574 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07001575 delete_all_groups( self.controller )
1576