blob: 6e416de9ad7a2c1c0dc14e8900bec194008f9183 [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
Saurav Das34992182017-04-14 15:59:48 -070011import time
Flavio Castro05d20bc2015-11-16 15:06:14 -050012from oftest.testutils import *
13from accton_util import *
Pierbbdf3782016-08-22 17:58:26 -070014from utils import *
Flavio Castrod8f8af22015-12-02 18:19:26 -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 ):
Saurav Das34992182017-04-14 15:59:48 -070069 """
70 Needs a description, disabled for now. Also needs try/finally
71 """
Flavio Castroa7162bb2016-07-25 17:30:30 -070072 def runTest( self ):
73 delete_all_flows( self.controller )
74 delete_all_groups( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050075
Flavio Castroa7162bb2016-07-25 17:30:30 -070076 ports = sorted( config[ "port_map" ].keys( ) )
77 match = ofp.match( )
78 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
79 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
80 ofp.instruction.apply_actions( actions=[
81 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
82 buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
83 self.controller.message_send( request )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050084 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -070085 add_one_l2_interface_group( self.controller, port, 1, False, False )
86 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
87 group_id = encode_l2_interface_group_id( 1, port )
88 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
89 do_barrier( self.controller )
90 parsed_arp_pkt = simple_arp_packet( )
91 arp_pkt = str( parsed_arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050092
93 for out_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -070094 self.dataplane.send( out_port, arp_pkt )
95 verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050096 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -050097 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -050098 for in_port in ports:
99 if in_port == out_port:
100 continue
101 # change source based on port number to avoid packet-ins from learning
Flavio Castro1c9b1252016-02-04 18:42:58 -0500102 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700103 parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
104 pkt = str( parsed_pkt )
105 self.dataplane.send( in_port, pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500106
107 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700108 if ofport in [ out_port ]:
109 verify_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500110 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700111 verify_no_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500112
Flavio Castroa7162bb2016-07-25 17:30:30 -0700113 verify_no_other_packets( self )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500114
Flavio Castroa7162bb2016-07-25 17:30:30 -0700115class PacketInArp( base_tests.SimpleDataPlane ):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500116 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700117 Verify Packet-in message from eth_type 0x806 on ACL table
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500118 """
119
Flavio Castroa7162bb2016-07-25 17:30:30 -0700120 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700121 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700122 parsed_arp_pkt = simple_arp_packet( )
123 arp_pkt = str( parsed_arp_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700124 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -0700125 match = ofp.match( )
126 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
127 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
128 ofp.instruction.apply_actions( actions=[
129 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
130 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500131
Saurav Das34992182017-04-14 15:59:48 -0700132 logging.info( "Inserting arp flow " )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700133 self.controller.message_send( request )
134 do_barrier( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500135
Flavio Castroa7162bb2016-07-25 17:30:30 -0700136 for of_port in config[ "port_map" ].keys( ):
Saurav Das34992182017-04-14 15:59:48 -0700137 logging.info( "PacketInArp test, sending arp packet to port %d", of_port )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700138 self.dataplane.send( of_port, arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500139
Flavio Castroa7162bb2016-07-25 17:30:30 -0700140 verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500141
Flavio Castroa7162bb2016-07-25 17:30:30 -0700142 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700143 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700144 delete_all_flows( self.controller )
145 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500146
Saurav Das34992182017-04-14 15:59:48 -0700147@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700148class PacketInIPTable( base_tests.SimpleDataPlane ):
Flavio Castro91d1a552016-05-17 16:59:44 -0700149 """
Pier265ad5f2017-02-28 17:46:28 +0100150 Verify Packet-in message from IP table when controller action is used
Flavio Castro91d1a552016-05-17 16:59:44 -0700151 Send a packet to each dataplane port and verify that a packet
152 in message is received from the controller for each
153 #todo verify you stop receiving after adding rule
154 """
155
Flavio Castroa7162bb2016-07-25 17:30:30 -0700156 def runTest( self ):
157 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700158 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700159 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
160 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
161 dip = 0xc0a80001
162 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro91d1a552016-05-17 16:59:44 -0700163
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700164 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700165 # add l2 interface group
166 vlan_id = port
167 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
168 send_barrier=False )
169 dst_mac[ 5 ] = vlan_id
170 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
171 src_mac=intf_src_mac, dst_mac=dst_mac )
172 # add vlan flow table
173 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
174 # add termination flow
175 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
176 # add unicast routing flow
177 dst_ip = dip + (vlan_id << 8)
178 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
179 send_ctrl=True )
180 Groups.put( l3_msg.group_id )
Flavio Castro91d1a552016-05-17 16:59:44 -0700181
Flavio Castroa7162bb2016-07-25 17:30:30 -0700182 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700183
Flavio Castroa7162bb2016-07-25 17:30:30 -0700184 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700185 for in_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700186 mac_src = '00:00:00:22:22:%02X' % in_port
187 ip_src = '192.168.%02d.1' % in_port
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700188 for out_port in ports:
189 if in_port == out_port:
190 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700191 ip_dst = '192.168.%02d.1' % out_port
192 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
193 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
194 pkt = str( parsed_pkt )
195 self.dataplane.send( in_port, pkt )
196 verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
197 # verify_no_other_packets(self)
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700198 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700199 delete_all_flows( self.controller )
200 delete_groups( self.controller, Groups )
201 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700202
Flavio Castroa7162bb2016-07-25 17:30:30 -0700203
204class L2FloodQinQ( base_tests.SimpleDataPlane ):
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500205 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700206 Verify Vlan based flooding of QinQ based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500207 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500208
Flavio Castroa7162bb2016-07-25 17:30:30 -0700209 def runTest( self ):
210 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700211 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700212 ports = sorted( config[ "port_map" ].keys( ) )
Saurav Dase94ba572017-04-28 17:47:21 -0700213 vlan_id = 100
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500214
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700215 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700216 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
217 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
218 Groups.put( L2gid )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500219
Flavio Castroa7162bb2016-07-25 17:30:30 -0700220 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
221 Groups.put( msg.group_id )
222 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
223 do_barrier( self.controller )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500224
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700225 # verify flood
226 for ofport in ports:
227 # change dest based on port number
228 mac_src = '00:12:34:56:78:%02X' % ofport
Flavio Castroa7162bb2016-07-25 17:30:30 -0700229 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
230 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
231 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
232 pkt = str( parsed_pkt )
233 self.dataplane.send( ofport, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700234 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700235 verify_no_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700236 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700237 tmp_ports = list( ports )
238 tmp_ports.remove( ofport )
239 verify_packets( self, pkt, tmp_ports )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500240
Flavio Castroa7162bb2016-07-25 17:30:30 -0700241 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700242 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700243 delete_all_flows( self.controller )
244 delete_groups( self.controller, Groups )
245 delete_all_groups( self.controller )
246
Flavio Castro1c9b1252016-02-04 18:42:58 -0500247
Saurav Dase94ba572017-04-28 17:47:21 -0700248
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500249@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700250class L2FloodTagged( base_tests.SimpleDataPlane ):
Flavio Castro184cefe2015-11-19 20:52:49 -0500251 """
Saurav Das34992182017-04-14 15:59:48 -0700252 currently disabled; fix with try/finally
Flavio Castro184cefe2015-11-19 20:52:49 -0500253 Test L2 flood to a vlan
254 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 -0500255 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500256
Flavio Castroa7162bb2016-07-25 17:30:30 -0700257 def runTest( self ):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500258 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700259 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500260 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500261
Flavio Castroa7162bb2016-07-25 17:30:30 -0700262 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro34352e72015-12-07 20:01:51 -0500263
Flavio Castroa7162bb2016-07-25 17:30:30 -0700264 delete_all_flows( self.controller )
265 delete_all_groups( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500266
Flavio Castro184cefe2015-11-19 20:52:49 -0500267 # Installing flows to avoid packet-in
268 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700269 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
270 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
271 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
272 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
273 do_barrier( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500274
Flavio Castro1c9b1252016-02-04 18:42:58 -0500275 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500276 for ofport in ports:
277 # change dest based on port number
Flavio Castroa7162bb2016-07-25 17:30:30 -0700278 pkt = str(
279 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
280 self.dataplane.send( ofport, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500281 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700282 verify_no_packet( self, pkt, ofport )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500283 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700284 tmp_ports = list( ports )
285 tmp_ports.remove( ofport )
286 verify_packets( self, pkt, tmp_ports )
287 verify_no_other_packets( self )
Flavio Castroaabb5792015-11-18 19:03:50 -0500288
Flavio Castro1c9b1252016-02-04 18:42:58 -0500289
Flavio Castroa7162bb2016-07-25 17:30:30 -0700290class L2UnicastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700291 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500292
Flavio Castroa7162bb2016-07-25 17:30:30 -0700293 def runTest( self ):
Flavio Castrob01d0aa2016-07-20 16:14:48 -0700294
Flavio Castroa7162bb2016-07-25 17:30:30 -0700295 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700296 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700297 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700298 vlan_id = 1;
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700299 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700300 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
301 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
302 Groups.put( L2gid )
303 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
304 True )
305 do_barrier( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500306
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700307 for out_port in ports:
308 # change dest based on port number
309 mac_dst = '00:12:34:56:78:%02X' % out_port
310 for in_port in ports:
311 if in_port == out_port:
312 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700313 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
314 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700315 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700316 if ofport in [ out_port ]:
317 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700318 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700319 verify_no_packet( self, pkt, ofport )
320 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700321 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700322 delete_all_flows( self.controller )
323 delete_groups( self.controller, Groups )
324 delete_all_groups( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500325
Flavio Castroa7162bb2016-07-25 17:30:30 -0700326
327class Mtu1500( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700328 """
329 Verifies basic mtu limits
330 """
331
Flavio Castroa7162bb2016-07-25 17:30:30 -0700332 def runTest( self ):
333 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700334 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700335 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700336 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700337 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700338 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Pier265ad5f2017-02-28 17:46:28 +0100339 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700340 Groups.put( L2gid )
341 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
342 True )
343 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500344
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700345 for out_port in ports:
346 # change dest based on port number
347 mac_dst = '00:12:34:56:78:%02X' % out_port
348 for in_port in ports:
349 if in_port == out_port:
350 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700351 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
352 eth_dst=mac_dst ) )
353 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700354 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700355 if ofport in [ out_port ]:
356 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700357 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700358 verify_no_packet( self, pkt, ofport )
359 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700360 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700361 delete_all_flows( self.controller )
362 delete_groups( self.controller, Groups )
363 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500364
Flavio Castroa7162bb2016-07-25 17:30:30 -0700365
366class _32UcastTagged( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700367 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500368
Flavio Castroa7162bb2016-07-25 17:30:30 -0700369 def runTest( self ):
370 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700371 try:
372 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700373 if len( config[ "port_map" ] ) < 2:
374 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700375 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700376 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
377 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700378 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700379 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700380 for port in ports:
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700381 vlan_id = port + test_id
Saurav Dase94ba572017-04-28 17:47:21 -0700382 # add l2 interface group and l3 unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700383 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
384 is_tagged=True, send_barrier=False )
385 dst_mac[ 5 ] = vlan_id
386 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
387 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700388 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100389 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700390 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700391 if config["switch_type"] == "qmx":
392 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
393 else:
394 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700395 # add unicast routing flow
396 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700397 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
398 Groups.put( l2gid )
399 Groups.put( l3_msg.group_id )
400 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500401
Flavio Castroa7162bb2016-07-25 17:30:30 -0700402 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700403 for in_port in ports:
404 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
405 ip_src = '192.168.%02d.1' % (test_id + in_port)
406 for out_port in ports:
407 if in_port == out_port:
408 continue
409 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700410 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
411 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
412 ip_src=ip_src, ip_dst=ip_dst )
413 pkt = str( parsed_pkt )
414 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700415 # build expected packet
416 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700417 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
418 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
419 ip_src=ip_src, ip_dst=ip_dst )
420 pkt = str( exp_pkt )
421 verify_packet( self, pkt, out_port )
422 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700423 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700424 delete_all_flows( self.controller )
425 delete_groups( self.controller, Groups )
426 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500427
Saurav Das34992182017-04-14 15:59:48 -0700428@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700429class _32VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700430 """
431 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
432 No ECMP group used
433 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500434
Flavio Castroa7162bb2016-07-25 17:30:30 -0700435 def runTest( self ):
436 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700437 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700438 if len( config[ "port_map" ] ) < 2:
439 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700440 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500441
Flavio Castroa7162bb2016-07-25 17:30:30 -0700442 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
443 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700444 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700445 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700446 for port in ports:
447 # add l2 interface group
448 id = port
449 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700450 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
451 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700452 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700453 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
454 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700455 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700456 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
457 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
458 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700459 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700460 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100461 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700462 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700463 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700464 if config["switch_type"] == "qmx":
465 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
466 else:
467 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700468 # add routing flow
469 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700470 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
471 Groups._put( l2_gid )
472 Groups._put( mpls_gid )
473 Groups._put( mpls_label_gid )
474 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500475
Flavio Castroa7162bb2016-07-25 17:30:30 -0700476 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700477 for in_port in ports:
478 ip_src = '192.168.%02d.1' % (in_port)
479 for out_port in ports:
480 if in_port == out_port:
481 continue
482 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700483 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
484 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
485 pkt = str( parsed_pkt )
486 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700487 # build expect packet
488 mac_dst = '00:00:00:22:22:%02X' % (out_port)
489 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700490 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
491 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
492 label=[ label ] )
493 pkt = str( exp_pkt )
494 verify_packet( self, pkt, out_port )
495 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700496 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700497 delete_all_flows( self.controller )
498 delete_groups( self.controller, Groups )
499 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500500
Saurav Das34992182017-04-14 15:59:48 -0700501@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700502class _32EcmpVpn( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700503 """
504 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
505 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500506
Flavio Castroa7162bb2016-07-25 17:30:30 -0700507 def runTest( self ):
508 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700509 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700510 if len( config[ "port_map" ] ) < 2:
511 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700512 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500513
Flavio Castroa7162bb2016-07-25 17:30:30 -0700514 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
515 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700516 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700517 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700518 for port in ports:
519 # add l2 interface group
520 id = port
521 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700522 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
523 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700524 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700525 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
526 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700527 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700528 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
529 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
530 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
531 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
532 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700533 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100534 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700535 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700536 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700537 if config["switch_type"] == "qmx":
538 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
539 else:
540 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700541 # add routing flow
542 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700543 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
544 Groups._put( l2_gid )
545 Groups._put( mpls_gid )
546 Groups._put( mpls_label_gid )
547 Groups._put( ecmp_msg.group_id )
548 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500549
Flavio Castroa7162bb2016-07-25 17:30:30 -0700550 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700551 for in_port in ports:
552 ip_src = '192.168.%02d.1' % (in_port)
553 for out_port in ports:
554 if in_port == out_port:
555 continue
556 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700557 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
558 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
559 pkt = str( parsed_pkt )
560 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700561 # build expect packet
562 mac_dst = '00:00:00:22:22:%02X' % (out_port)
563 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700564 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
565 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
566 label=[ label ] )
567 pkt = str( exp_pkt )
568 verify_packet( self, pkt, out_port )
569 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -0700570
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700571 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700572 delete_all_flows( self.controller )
573 delete_groups( self.controller, Groups )
574 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500575
Flavio Castroa7162bb2016-07-25 17:30:30 -0700576
Saurav Das34992182017-04-14 15:59:48 -0700577@disabled
578class One_32EcmpVpn( base_tests.SimpleDataPlane ):
579 """
580 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
581 in only one direction
582 """
583
584 def runTest( self ):
585 Groups = Queue.LifoQueue( )
586 try:
587 if len( config[ "port_map" ] ) < 2:
588 logging.info( "Port count less than 2, can't run this case" )
589 return
590
591 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
592 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
593 dip = 0xc0a80001
594 ports = config[ "port_map" ].keys( )
595 # add l2 interface group
596 id = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700597 in_offset = 19
598 out_offset = 20
599 vlan_id = ports[1] + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700600 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
Saurav Das1ab6a142017-04-25 14:42:25 -0700601 dst_mac[ 5 ] = ports[1]
Saurav Das34992182017-04-14 15:59:48 -0700602 # add MPLS interface group
603 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
604 vlan_id, id )
605 # add MPLS L3 VPN group
606 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
607 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
Saurav Das1ab6a142017-04-25 14:42:25 -0700608 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
Saurav Das34992182017-04-14 15:59:48 -0700609 # add ECMP group
610 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
611 do_barrier( self.controller )
612 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700613 add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0,
Saurav Das34992182017-04-14 15:59:48 -0700614 flag=VLAN_TABLE_FLAG_ONLY_TAG )
615 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700616 if config["switch_type"] == "qmx":
617 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
618 else:
619 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700620 # add routing flow
621 dst_ip = dip + (vlan_id << 8)
622 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
623 Groups._put( l2_gid )
624 Groups._put( mpls_gid )
625 Groups._put( mpls_label_gid )
626 Groups._put( ecmp_msg.group_id )
627
628
629 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
630 in_port = ports[0]
631 out_port = ports[1]
632 ip_src = '192.168.%02d.1' % (in_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700633 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
634 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
Saurav Das34992182017-04-14 15:59:48 -0700635 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
636 pkt = str( parsed_pkt )
637 self.dataplane.send( in_port, pkt )
638 # build expect packet
639 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700640 label = (out_port+out_offset, 0, 1, 32)
641 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63,
Saurav Das34992182017-04-14 15:59:48 -0700642 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
Saurav Das1ab6a142017-04-25 14:42:25 -0700643 label=[ label ] )
Saurav Das34992182017-04-14 15:59:48 -0700644 pkt = str( exp_pkt )
645 verify_packet( self, pkt, out_port )
646 #verify_no_other_packets( self )
647
648 finally:
649 delete_all_flows( self.controller )
650 delete_group(self.controller, ecmp_msg.group_id)
651 delete_group(self.controller, mpls_label_gid)
652 delete_group(self.controller, mpls_gid)
653 delete_group(self.controller, l2_gid)
654
655
Flavio Castroa7162bb2016-07-25 17:30:30 -0700656class _32ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700657 """
658 Verifies /32 IP routing and ECMP with no label push
659 IP -> L3ECMP -> L3Unicast -> L2Interface
660 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500661
Flavio Castroa7162bb2016-07-25 17:30:30 -0700662 def runTest( self ):
663 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700664 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700665 if len( config[ "port_map" ] ) < 2:
666 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700667 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500668
Flavio Castroa7162bb2016-07-25 17:30:30 -0700669 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
670 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700671 dip = 0xc0a80001
672 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700673 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700674 for port in ports:
675 vlan_id = port
676 id = port
677 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700678 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
679 is_tagged=True, send_barrier=False )
680 dst_mac[ 5 ] = vlan_id
681 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
682 src_mac=intf_src_mac, dst_mac=dst_mac )
683 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700684 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100685 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700686 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700687 if config["switch_type"] == "qmx":
688 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
689 else:
690 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700691 # add unicast routing flow
692 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700693 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
694 Groups._put( l2_gid )
695 Groups._put( l3_msg.group_id )
696 Groups._put( ecmp_msg.group_id )
697 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500698
Flavio Castroa7162bb2016-07-25 17:30:30 -0700699 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700700 for in_port in ports:
701 mac_src = '00:00:00:22:22:%02X' % in_port
702 ip_src = '192.168.%02d.1' % in_port
703 for out_port in ports:
704 if in_port == out_port:
705 continue
706 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700707 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
708 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
709 pkt = str( parsed_pkt )
710 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700711 # build expected packet
712 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700713 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
714 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
715 pkt = str( exp_pkt )
716 verify_packet( self, pkt, out_port )
717 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700718 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700719 delete_all_flows( self.controller )
720 delete_groups( self.controller, Groups )
721 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500722
Saurav Das34992182017-04-14 15:59:48 -0700723@disabled
724class One_32ECMPL3( base_tests.SimpleDataPlane ):
725 """
726 Verifies /32 IP routing and ECMP with no label push
727 IP -> L3ECMP -> L3Unicast -> L2Interface
728 in only one direction
729 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700730
Saurav Das34992182017-04-14 15:59:48 -0700731 def runTest( self ):
732 Groups = Queue.LifoQueue( )
733 try:
734 if len( config[ "port_map" ] ) < 2:
735 logging.info( "Port count less than 2, can't run this case" )
736 return
737
738 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
739 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
740 dip = 0xc0a80001
741 # Hashes Test Name and uses it as id for installing unique groups
742 ports = config[ "port_map" ].keys( )
743 inport = ports[0]
744 outport = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700745 in_offset = 19
746 out_offset = 20
747 vlan_id = outport + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700748 id = outport
749 # add l2 interface group, l3 unicast and ecmp group for outport
750 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
751 is_tagged=True, send_barrier=False )
Saurav Das1ab6a142017-04-25 14:42:25 -0700752 dst_mac[ 5 ] = outport
Saurav Das34992182017-04-14 15:59:48 -0700753 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
754 src_mac=intf_src_mac, dst_mac=dst_mac )
755 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
756 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700757 add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Saurav Das34992182017-04-14 15:59:48 -0700758 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700759 if config["switch_type"] == "qmx":
760 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset )
761 else:
762 add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700763 # add unicast routing flow
764 dst_ip = dip + (vlan_id << 8)
765 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
766 Groups._put( l2_gid )
767 Groups._put( l3_msg.group_id )
768 Groups._put( ecmp_msg.group_id )
769
770 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
771 mac_src = '00:00:00:22:22:%02X' % inport
772 ip_src = '192.168.%02d.1' % inport
Saurav Das1ab6a142017-04-25 14:42:25 -0700773 ip_dst = '192.168.%02d.1' % (outport+out_offset)
774 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
Saurav Das34992182017-04-14 15:59:48 -0700775 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
776 pkt = str( parsed_pkt )
777 self.dataplane.send( inport, pkt )
778 # build expected packet
779 mac_dst = '00:00:00:22:22:%02X' % outport
Saurav Das1ab6a142017-04-25 14:42:25 -0700780 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
Saurav Das34992182017-04-14 15:59:48 -0700781 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
782 pkt = str( exp_pkt )
783 verify_packet( self, pkt, outport )
784 verify_no_other_packets( self )
785 finally:
786 delete_all_flows( self.controller )
787 delete_groups( self.controller, Groups )
788 delete_all_groups( self.controller )
789
790
791
792
793@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700794class _24VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700795 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500796
Flavio Castroa7162bb2016-07-25 17:30:30 -0700797 def runTest( self ):
798 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700799 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700800 if len( config[ "port_map" ] ) < 2:
801 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700802 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500803
Flavio Castroa7162bb2016-07-25 17:30:30 -0700804 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
805 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700806 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700807 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700808 for port in ports:
809 # add l2 interface group
810 id = port
811 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700812 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
813 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700814 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700815 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
816 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700817 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700818 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
819 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
820 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700821 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700822 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700823 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100824 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700825 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700826 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700827 if config["switch_type"] == "qmx":
828 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
829 else:
830 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700831 # add routing flow
832 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700833 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
834 Groups._put( l2_gid )
835 Groups._put( mpls_gid )
836 Groups._put( mpls_label_gid )
837 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500838
Flavio Castroa7162bb2016-07-25 17:30:30 -0700839 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700840 for in_port in ports:
841 ip_src = '192.168.%02d.1' % (in_port)
842 for out_port in ports:
843 if in_port == out_port:
844 continue
845 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700846 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
847 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
848 pkt = str( parsed_pkt )
849 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700850 # build expect packet
851 mac_dst = '00:00:00:22:22:%02X' % (out_port)
852 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700853 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
854 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
855 label=[ label ] )
856 pkt = str( exp_pkt )
857 verify_packet( self, pkt, out_port )
858 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700859 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700860 delete_all_flows( self.controller )
861 delete_groups( self.controller, Groups )
862 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500863
Saurav Das34992182017-04-14 15:59:48 -0700864@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700865class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700866 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -0500867
Flavio Castroa7162bb2016-07-25 17:30:30 -0700868 def runTest( self ):
869 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700870 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700871 if len( config[ "port_map" ] ) < 2:
872 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700873 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 Castro8c37e1c2016-07-19 18:26:33 -0700876 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700877 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700878 for port in ports:
879 # add l2 interface group
880 id = port
881 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -0700882 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
883 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700884 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700885 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
886 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700887 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700888 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
889 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
890 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
891 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
892 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700893 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100894 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700895 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700896 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700897 if config["switch_type"] == "qmx":
898 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
899 else:
900 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700901 # add routing flow
902 dst_ip = dip + (vlan_id << 8)
903 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700904 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
905 vrf=0 )
906 Groups._put( l2_gid )
907 Groups._put( mpls_gid )
908 Groups._put( mpls_label_gid )
909 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700910
Flavio Castroa7162bb2016-07-25 17:30:30 -0700911 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -0500912
Flavio Castroa7162bb2016-07-25 17:30:30 -0700913 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700914 for in_port in ports:
915 mac_src = '00:00:00:22:22:%02X' % (in_port)
916 ip_src = '192.168.%02d.1' % (in_port)
917 for out_port in ports:
918 if in_port == out_port:
919 continue
920 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700921 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
922 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
923 pkt = str( parsed_pkt )
924 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700925 # build expect packet
926 mac_dst = '00:00:00:22:22:%02X' % out_port
927 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700928 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
929 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
930 label=[ label ] )
931 pkt = str( exp_pkt )
932 verify_packet( self, pkt, out_port )
933 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700934 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700935 delete_all_flows( self.controller )
936 delete_groups( self.controller, Groups )
937 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500938
Flavio Castroa7162bb2016-07-25 17:30:30 -0700939
940class FloodGroupMod( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700941 """ Modify a referenced flood group """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700942
943 def runTest( self ):
944 Groups = Queue.LifoQueue( )
945 try:
946 ports = sorted( config[ "port_map" ].keys( ) )
947 vlan_id = 1
948
949 for port in ports:
950 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
951 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
952 Groups.put( L2gid )
953
954 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
955 Groups.put( msg.group_id )
956 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
957 do_barrier( self.controller )
958 # verify flood
959 for ofport in ports:
960 # change dest based on port number
961 mac_src = '00:12:34:56:78:%02X' % ofport
962 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
963 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
964 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
965 pkt = str( parsed_pkt )
966 self.dataplane.send( ofport, pkt )
967 # self won't rx packet
968 verify_no_packet( self, pkt, ofport )
969 # others will rx packet
970 tmp_ports = list( ports )
971 tmp_ports.remove( ofport )
972 verify_packets( self, pkt, tmp_ports )
973 verify_no_other_packets( self )
974 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
975 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
976 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
977 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
978 eth_src=mac_src )
979 pkt = str( parsed_pkt )
980 self.dataplane.send( ports[ 1 ], pkt )
981 verify_packets( self, pkt, [ ports[ 0 ] ] )
982 finally:
983 delete_all_flows( self.controller )
984 delete_groups( self.controller, Groups )
985 delete_all_groups( self.controller )
986
987
988class _24ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700989 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
Flavio Castro80730822015-12-11 15:38:47 -0500990
Flavio Castroa7162bb2016-07-25 17:30:30 -0700991 def runTest( self ):
992 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700993 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700994 if len( config[ "port_map" ] ) < 2:
995 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700996 return
Flavio Castro80730822015-12-11 15:38:47 -0500997
Flavio Castroa7162bb2016-07-25 17:30:30 -0700998 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
999 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001000 dip = 0xc0a80001
1001 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -07001002 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001003 for port in ports:
1004 vlan_id = port
1005 id = port
1006 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001007 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1008 is_tagged=True, send_barrier=False )
1009 dst_mac[ 5 ] = vlan_id
1010 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1011 src_mac=intf_src_mac, dst_mac=dst_mac )
1012 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001013 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001014 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001015 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001016 if config["switch_type"] == "qmx":
1017 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1018 else:
1019 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001020 # add unicast routing flow
1021 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001022 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1023 Groups._put( l2_gid )
1024 Groups._put( l3_msg.group_id )
1025 Groups._put( ecmp_msg.group_id )
1026 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -05001027
Flavio Castroa7162bb2016-07-25 17:30:30 -07001028 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001029 for in_port in ports:
1030 mac_src = '00:00:00:22:22:%02X' % in_port
1031 ip_src = '192.168.%02d.1' % in_port
1032 for out_port in ports:
1033 if in_port == out_port:
1034 continue
1035 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001036 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1037 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1038 pkt = str( parsed_pkt )
1039 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001040 # build expected packet
1041 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001042 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1043 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1044 pkt = str( exp_pkt )
1045 verify_packet( self, pkt, out_port )
1046 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001047 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001048 delete_all_flows( self.controller )
1049 delete_groups( self.controller, Groups )
1050 delete_all_groups( self.controller )
1051
Flavio Castro1c9b1252016-02-04 18:42:58 -05001052
Flavio Castroaba28ff2016-02-03 16:47:48 -05001053@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001054class MPLSBUG( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001055 """
1056 Needs a description or needs to be removed
1057 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001058 def runTest( self ):
1059 if len( config[ "port_map" ] ) < 2:
1060 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -05001061 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001062 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1063 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -05001064 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001065 Groups = Queue.LifoQueue( )
1066 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -05001067 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001068 # add l2 interface group
1069 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001070 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1071 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -05001072 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001073 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1074 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001075 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001076 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001077 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001078 if config["switch_type"] == "qmx":
1079 add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 )
1080 else:
1081 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001082 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001083 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001084 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001085 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001086 # add unicast routing flow
1087 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001088 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1089 Groups._put( l2_gid )
1090 Groups._put( l3_msg.group_id )
1091 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001092
Flavio Castroa7162bb2016-07-25 17:30:30 -07001093 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -05001094 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001095 mac_src = '00:00:00:22:22:%02X' % in_port
1096 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -05001097 for out_port in ports:
1098 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001099 continue
1100 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -05001101 switch_mac = "00:00:00:cc:cc:cc"
1102 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001103 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1104 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1105 pkt = str( parsed_pkt )
1106 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -05001107
Flavio Castro1c9b1252016-02-04 18:42:58 -05001108 # build expect packet
1109 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001110 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1111 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1112 pkt = str( exp_pkt )
1113 verify_packet( self, pkt, out_port )
1114 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001115
Flavio Castroa7162bb2016-07-25 17:30:30 -07001116 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1117 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1118 pkt = str( parsed_pkt )
1119 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001120 # build expected packet
1121 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001122 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1123 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1124 pkt = str( exp_pkt )
1125 verify_packet( self, pkt, out_port )
1126 verify_no_other_packets( self )
1127 delete_all_flows( self.controller )
1128 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001129
Flavio Castroa7162bb2016-07-25 17:30:30 -07001130class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -07001131 """
1132 Mcast routing, in this test case the traffic comes in tagged.
1133 port+1 is used as ingress vlan_id. The packet goes out tagged on
1134 different ports. 4094-port is used as egress vlan_id.
1135 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001136 def runTest( self ):
Pier7b031af2016-08-25 15:00:22 -07001137 """
1138 port1 (vlan 300)-> All Ports (vlan 300)
1139 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001140 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001141 try:
Pierbbdf3782016-08-22 17:58:26 -07001142 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1143 if len( config[ "port_map" ] ) < 1:
1144 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001145 assert (False)
1146 return
Pierbbdf3782016-08-22 17:58:26 -07001147 ports = config[ "port_map" ].keys( )
1148 dst_ip_str = "224.0.0.1"
1149 (
1150 port_to_in_vlan,
1151 port_to_out_vlan,
1152 port_to_src_mac_str,
1153 port_to_dst_mac_str,
1154 port_to_src_ip_str,
1155 port_to_intf_src_mac_str,
1156 Groups) = fill_mcast_pipeline_L3toL3(
1157 self.controller,
1158 logging,
1159 ports,
1160 is_ingress_tagged = True,
1161 is_egress_tagged = True,
1162 is_vlan_translated = True,
1163 is_max_vlan = False
1164 )
Flavio Castro12296312015-12-15 17:48:26 -05001165
Pierbbdf3782016-08-22 17:58:26 -07001166 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001167
Pierbbdf3782016-08-22 17:58:26 -07001168 parsed_pkt = simple_udp_packet(
1169 pktlen = 100,
1170 dl_vlan_enable = True,
1171 vlan_vid = port_to_in_vlan[in_port],
1172 eth_dst = port_to_dst_mac_str[in_port],
1173 eth_src = port_to_src_mac_str[in_port],
1174 ip_ttl = 64,
1175 ip_src = port_to_src_ip_str[in_port],
1176 ip_dst = dst_ip_str
1177 )
1178 pkt = str( parsed_pkt )
1179 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001180
Pierbbdf3782016-08-22 17:58:26 -07001181 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001182
Pierbbdf3782016-08-22 17:58:26 -07001183 parsed_pkt = simple_udp_packet(
1184 pktlen = 100,
1185 dl_vlan_enable = True,
1186 vlan_vid = port_to_out_vlan[out_port],
1187 eth_dst = port_to_dst_mac_str[in_port],
1188 eth_src = port_to_intf_src_mac_str[out_port],
1189 ip_ttl = 63,
1190 ip_src = port_to_src_ip_str[in_port],
1191 ip_dst = dst_ip_str
1192 )
1193 pkt = str( parsed_pkt )
1194 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001195
Pierbbdf3782016-08-22 17:58:26 -07001196 verify_no_other_packets( self )
1197
Pier7b031af2016-08-25 15:00:22 -07001198 finally:
1199 delete_all_flows( self.controller )
1200 delete_groups( self.controller, Groups )
1201 delete_all_groups( self.controller )
1202
1203class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1204 """
1205 Mcast routing, in this test case the traffic is untagged.
1206 4094 is used as internal vlan_id. The packet goes out
1207 untagged.
1208 """
1209 def runTest( self ):
1210 Groups = Queue.LifoQueue( )
1211 try:
1212 if len( config[ "port_map" ] ) < 2:
1213 logging.info( "Port count less than 2, can't run this case" )
1214 assert (False)
1215 return
1216 ports = config[ "port_map" ].keys( )
1217 dst_ip_str = "224.0.0.1"
1218 (
1219 port_to_in_vlan,
1220 port_to_out_vlan,
1221 port_to_src_mac_str,
1222 port_to_dst_mac_str,
1223 port_to_src_ip_str,
1224 Groups) = fill_mcast_pipeline_L3toL2(
1225 self.controller,
1226 logging,
1227 ports,
1228 is_ingress_tagged = False,
1229 is_egress_tagged = False,
1230 is_vlan_translated = False,
1231 is_max_vlan = True
1232 )
1233
1234 for in_port in ports:
1235
1236 parsed_pkt = simple_udp_packet(
1237 pktlen = 96,
1238 eth_dst = port_to_dst_mac_str[in_port],
1239 eth_src = port_to_src_mac_str[in_port],
1240 ip_ttl = 64,
1241 ip_src = port_to_src_ip_str[in_port],
1242 ip_dst = dst_ip_str
1243 )
1244 pkt = str( parsed_pkt )
1245 self.dataplane.send( in_port, pkt )
1246
1247 for out_port in ports:
1248
1249 parsed_pkt = simple_udp_packet(
1250 pktlen = 96,
1251 eth_dst = port_to_dst_mac_str[in_port],
1252 eth_src = port_to_src_mac_str[in_port],
1253 ip_ttl = 64,
1254 ip_src = port_to_src_ip_str[in_port],
1255 ip_dst = dst_ip_str
1256 )
1257 pkt = str( parsed_pkt )
1258 if out_port == in_port:
1259 verify_no_packet( self, pkt, in_port )
1260 continue
1261 verify_packet( self, pkt, out_port )
1262 verify_no_other_packets( self )
1263 finally:
1264 delete_all_flows( self.controller )
1265 delete_groups( self.controller, Groups )
1266 delete_all_groups( self.controller )
1267
1268class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1269 """
1270 Mcast routing, in this test case the traffic is untagged.
1271 300 is used as vlan_id. The packet goes out
1272 tagged.
1273 """
1274 def runTest( self ):
1275 Groups = Queue.LifoQueue( )
1276 try:
1277 if len( config[ "port_map" ] ) < 2:
1278 logging.info( "Port count less than 2, can't run this case" )
1279 assert (False)
1280 return
1281 ports = config[ "port_map" ].keys( )
1282 dst_ip_str = "224.0.0.1"
1283 (
1284 port_to_in_vlan,
1285 port_to_out_vlan,
1286 port_to_src_mac_str,
1287 port_to_dst_mac_str,
1288 port_to_src_ip_str,
1289 Groups) = fill_mcast_pipeline_L3toL2(
1290 self.controller,
1291 logging,
1292 ports,
1293 is_ingress_tagged = False,
1294 is_egress_tagged = True,
1295 is_vlan_translated = False,
1296 is_max_vlan = False
1297 )
1298
1299 for in_port in ports:
1300
1301 parsed_pkt = simple_udp_packet(
1302 pktlen = 96,
1303 eth_dst = port_to_dst_mac_str[in_port],
1304 eth_src = port_to_src_mac_str[in_port],
1305 ip_ttl = 64,
1306 ip_src = port_to_src_ip_str[in_port],
1307 ip_dst = dst_ip_str
1308 )
1309 pkt = str( parsed_pkt )
1310 self.dataplane.send( in_port, pkt )
1311
1312 for out_port in ports:
1313
1314 parsed_pkt = simple_udp_packet(
1315 pktlen = 100,
1316 dl_vlan_enable = True,
1317 vlan_vid = port_to_out_vlan[in_port],
1318 eth_dst = port_to_dst_mac_str[in_port],
1319 eth_src = port_to_src_mac_str[in_port],
1320 ip_ttl = 64,
1321 ip_src = port_to_src_ip_str[in_port],
1322 ip_dst = dst_ip_str
1323 )
1324 pkt = str( parsed_pkt )
1325 if out_port == in_port:
1326 verify_no_packet( self, pkt, in_port )
1327 continue
1328 verify_packet( self, pkt, out_port )
1329 verify_no_other_packets( self )
1330 finally:
1331 delete_all_flows( self.controller )
1332 delete_groups( self.controller, Groups )
1333 delete_all_groups( self.controller )
1334
1335
1336class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1337 """
1338 Mcast routing, in this test case the traffic is tagged.
1339 300 is used as vlan_id. The packet goes out
1340 untagged.
1341 """
1342 def runTest( self ):
1343 Groups = Queue.LifoQueue( )
1344 try:
1345 if len( config[ "port_map" ] ) < 2:
1346 logging.info( "Port count less than 2, can't run this case" )
1347 assert (False)
1348 return
1349 ports = config[ "port_map" ].keys( )
1350 dst_ip_str = "224.0.0.1"
1351 (
1352 port_to_in_vlan,
1353 port_to_out_vlan,
1354 port_to_src_mac_str,
1355 port_to_dst_mac_str,
1356 port_to_src_ip_str,
1357 Groups) = fill_mcast_pipeline_L3toL2(
1358 self.controller,
1359 logging,
1360 ports,
1361 is_ingress_tagged = True,
1362 is_egress_tagged = False,
1363 is_vlan_translated = False,
1364 is_max_vlan = False
1365 )
1366
1367 for in_port in ports:
1368
1369 parsed_pkt = simple_udp_packet(
1370 pktlen = 100,
1371 dl_vlan_enable = True,
1372 vlan_vid = port_to_in_vlan[in_port],
1373 eth_dst = port_to_dst_mac_str[in_port],
1374 eth_src = port_to_src_mac_str[in_port],
1375 ip_ttl = 64,
1376 ip_src = port_to_src_ip_str[in_port],
1377 ip_dst = dst_ip_str
1378 )
1379 pkt = str( parsed_pkt )
1380 self.dataplane.send( in_port, pkt )
1381
1382 for out_port in ports:
1383
1384 parsed_pkt = simple_udp_packet(
1385 pktlen = 96,
1386 eth_dst = port_to_dst_mac_str[in_port],
1387 eth_src = port_to_src_mac_str[in_port],
1388 ip_ttl = 64,
1389 ip_src = port_to_src_ip_str[in_port],
1390 ip_dst = dst_ip_str
1391 )
1392 pkt = str( parsed_pkt )
1393 if out_port == in_port:
1394 verify_no_packet( self, pkt, in_port )
1395 continue
1396 verify_packet( self, pkt, out_port )
1397 verify_no_other_packets( self )
1398 finally:
1399 delete_all_flows( self.controller )
1400 delete_groups( self.controller, Groups )
1401 delete_all_groups( self.controller )
1402
1403class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1404 """
1405 Mcast routing, in this test case the traffic is tagged.
1406 300 is used as vlan_id. The packet goes out tagged.
1407 """
1408 def runTest( self ):
1409 Groups = Queue.LifoQueue( )
1410 try:
1411 if len( config[ "port_map" ] ) < 2:
1412 logging.info( "Port count less than 2, can't run this case" )
1413 assert (False)
1414 return
1415 ports = config[ "port_map" ].keys( )
1416 dst_ip_str = "224.0.0.1"
1417 (
1418 port_to_in_vlan,
1419 port_to_out_vlan,
1420 port_to_src_mac_str,
1421 port_to_dst_mac_str,
1422 port_to_src_ip_str,
1423 Groups) = fill_mcast_pipeline_L3toL2(
1424 self.controller,
1425 logging,
1426 ports,
1427 is_ingress_tagged = True,
1428 is_egress_tagged = True,
1429 is_vlan_translated = False,
1430 is_max_vlan = False
1431 )
1432
1433 for in_port in ports:
1434
1435 parsed_pkt = simple_udp_packet(
1436 pktlen = 100,
1437 dl_vlan_enable = True,
1438 vlan_vid = port_to_in_vlan[in_port],
1439 eth_dst = port_to_dst_mac_str[in_port],
1440 eth_src = port_to_src_mac_str[in_port],
1441 ip_ttl = 64,
1442 ip_src = port_to_src_ip_str[in_port],
1443 ip_dst = dst_ip_str
1444 )
1445 pkt = str( parsed_pkt )
1446 self.dataplane.send( in_port, pkt )
1447
1448 for out_port in ports:
1449
1450 parsed_pkt = simple_udp_packet(
1451 pktlen = 100,
1452 dl_vlan_enable = True,
1453 vlan_vid = port_to_in_vlan[in_port],
1454 eth_dst = port_to_dst_mac_str[in_port],
1455 eth_src = port_to_src_mac_str[in_port],
1456 ip_ttl = 64,
1457 ip_src = port_to_src_ip_str[in_port],
1458 ip_dst = dst_ip_str
1459 )
1460 pkt = str( parsed_pkt )
1461 if out_port == in_port:
1462 verify_no_packet( self, pkt, in_port )
1463 continue
1464 verify_packet( self, pkt, out_port )
1465 verify_no_other_packets( self )
1466 finally:
1467 delete_all_flows( self.controller )
1468 delete_groups( self.controller, Groups )
1469 delete_all_groups( self.controller )
1470
1471class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1472 """
1473 Mcast routing, in this test case the traffic is tagged.
1474 port+1 is used as ingress vlan_id. The packet goes out
1475 tagged. 4094-port is used as egress vlan_id
1476 """
1477 def runTest( self ):
1478 Groups = Queue.LifoQueue( )
1479 try:
1480 if len( config[ "port_map" ] ) < 2:
1481 logging.info( "Port count less than 2, can't run this case" )
1482 assert (False)
1483 return
1484 ports = config[ "port_map" ].keys( )
1485 dst_ip_str = "224.0.0.1"
1486 (
1487 port_to_in_vlan,
1488 port_to_out_vlan,
1489 port_to_src_mac_str,
1490 port_to_dst_mac_str,
1491 port_to_src_ip_str,
1492 Groups) = fill_mcast_pipeline_L3toL2(
1493 self.controller,
1494 logging,
1495 ports,
1496 is_ingress_tagged = True,
1497 is_egress_tagged = True,
1498 is_vlan_translated = True,
1499 is_max_vlan = False
1500 )
1501
1502 for in_port in ports:
1503
1504 parsed_pkt = simple_udp_packet(
1505 pktlen = 100,
1506 dl_vlan_enable = True,
1507 vlan_vid = port_to_in_vlan[in_port],
1508 eth_dst = port_to_dst_mac_str[in_port],
1509 eth_src = port_to_src_mac_str[in_port],
1510 ip_ttl = 64,
1511 ip_src = port_to_src_ip_str[in_port],
1512 ip_dst = dst_ip_str
1513 )
1514 pkt = str( parsed_pkt )
1515 self.dataplane.send( in_port, pkt )
1516
1517 for out_port in ports:
1518
1519 parsed_pkt = simple_udp_packet(
1520 pktlen = 100,
1521 dl_vlan_enable = True,
1522 vlan_vid = port_to_out_vlan[in_port],
1523 eth_dst = port_to_dst_mac_str[in_port],
1524 eth_src = port_to_src_mac_str[in_port],
1525 ip_ttl = 64,
1526 ip_src = port_to_src_ip_str[in_port],
1527 ip_dst = dst_ip_str
1528 )
1529 pkt = str( parsed_pkt )
1530 if out_port == in_port:
1531 verify_no_packet( self, pkt, in_port )
1532 continue
1533 verify_packet( self, pkt, out_port )
1534 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001535 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001536 delete_all_flows( self.controller )
1537 delete_groups( self.controller, Groups )
1538 delete_all_groups( self.controller )
1539
Saurav Das34992182017-04-14 15:59:48 -07001540@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001541class _MplsFwd( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001542 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001543
1544 def runTest( self ):
1545 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001546 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001547 if len( config[ "port_map" ] ) < 2:
1548 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001549 return
1550 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001551 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1552 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001553 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001554 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001555 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001556 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1557 vlan_id = port + 16
1558 mpls_label = port + 16
1559
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001560 # add l2 interface group
1561 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001562 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001563 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001564 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1565 vlan_id, id )
1566 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1567 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001568 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Saurav Das34992182017-04-14 15:59:48 -07001569 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1570 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001571 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001572 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001573 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001574 if config["switch_type"] == "qmx":
1575 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1576 else:
1577 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001578 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Charles Chan53cac542016-08-22 16:03:26 -07001579 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001580 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001581 Groups._put( l2_gid )
1582 Groups._put( mpls_gid )
1583 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001584 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001585 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001586
Flavio Castroa7162bb2016-07-25 17:30:30 -07001587 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001588 for in_port in ports:
1589 ip_src = '192.168.%02d.1' % (in_port)
1590 for out_port in ports:
1591 if in_port == out_port:
1592 continue
Flavio Castro54947942016-02-03 16:05:20 -05001593
Charles Chan53cac542016-08-22 16:03:26 -07001594 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1595 out_mpls_label = out_port + 16
1596 in_vlan_vid = in_port + 16
1597 out_vlan_vid = out_port + 16
1598
1599 ip_dst = '192.168.%02d.1' % (out_port)
1600 label = (out_mpls_label, 0, 1, 32)
1601 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001602 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1603 pkt = str( parsed_pkt )
1604 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001605
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001606 # build expect packet
1607 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001608 label = (out_mpls_label, 0, 1, 31)
1609 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001610 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1611 label=[ label ] )
1612 pkt = str( exp_pkt )
1613 verify_packet( self, pkt, out_port )
1614 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001615 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001616 delete_all_flows( self.controller )
1617 delete_groups( self.controller, Groups )
1618 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001619
Saurav Das34992182017-04-14 15:59:48 -07001620@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001621class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001622 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001623
1624 def runTest( self ):
1625 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001626 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001627 if len( config[ "port_map" ] ) < 2:
1628 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001629 return
1630 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001631 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1632 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001633 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001634 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001635 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001636 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1637 vlan_id = port + 16
1638 mpls_label = port + 16
1639
Flavio Castrod80fbc32016-07-25 15:54:26 -07001640 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001641 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001642 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001643 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001644 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1645 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001646 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001647 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001648 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001649 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001650 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001651 if config["switch_type"] == "qmx":
1652 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1653 else:
1654 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Charles Chan53cac542016-08-22 16:03:26 -07001655 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001656 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001657 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001658 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001659 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001660 Groups._put( l2_gid )
1661 Groups._put( l3_msg.group_id )
1662 Groups._put( ecmp_msg.group_id )
1663 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001664
Flavio Castroa7162bb2016-07-25 17:30:30 -07001665 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001666 for in_port in ports:
1667 ip_src = '192.168.%02d.1' % (in_port)
1668 for out_port in ports:
1669 if in_port == out_port:
1670 continue
Charles Chan53cac542016-08-22 16:03:26 -07001671
1672 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1673 out_mpls_label = out_port + 16
1674 in_vlan_vid = in_port + 16
1675 out_vlan_vid = out_port + 16
1676
Flavio Castrod80fbc32016-07-25 15:54:26 -07001677 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001678 label = (out_mpls_label, 0, 1, 32)
1679 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001680 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1681 pkt = str( parsed_pkt )
1682 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001683 # build expect packet
1684 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001685 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001686 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1687 pkt = str( exp_pkt )
1688 verify_packet( self, pkt, out_port )
1689 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001690 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001691 delete_all_flows( self.controller )
1692 delete_groups( self.controller, Groups )
1693 delete_all_groups( self.controller )
Saurav Das34992182017-04-14 15:59:48 -07001694 print("Done")
1695
1696@disabled
1697class One_MplsTermination( base_tests.SimpleDataPlane ):
1698 """
1699 Verify MPLS VPN Termination at penultimate hop in only one direction
1700 """
1701
1702 def runTest( self ):
1703 Groups = Queue.LifoQueue( )
1704 try:
1705 if len( config[ "port_map" ] ) < 2:
1706 logging.info( "Port count less than 2, can't run this case" )
1707 return
1708 dip = 0xc0a80001
1709 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1710 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1711 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1712 ports = config[ "port_map" ].keys( )
1713 inport = ports[0]
1714 outport = ports[1]
1715
1716 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1717 invlan_id = inport + 16
1718 outvlan_id = outport + 16
1719 mpls_label = outport + 16
1720
1721 # add l2 interface group
1722 id, dst_mac[ 5 ] = inport, outport
1723 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
1724 # add L3 Unicast group
1725 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
1726 src_mac=intf_src_mac, dst_mac=dst_mac )
1727 # add L3 ecmp group
1728 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1729 # add vlan flow table
1730 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1731 # add tmac flow
Saurav Dase94ba572017-04-28 17:47:21 -07001732 if config["switch_type"] == "qmx":
1733 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
1734 else:
1735 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
Saurav Das34992182017-04-14 15:59:48 -07001736 # add mpls termination flow
1737 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
1738 Groups._put( l2_gid )
1739 Groups._put( l3_msg.group_id )
1740 Groups._put( ecmp_msg.group_id )
1741
1742 time.sleep(0.1)
1743 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1744 ip_src = '192.168.%02d.1' % (inport)
1745 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1746 out_mpls_label = outport + 16
1747 in_vlan_vid = inport + 16
1748 out_vlan_vid = outport + 16
1749
1750 ip_dst = '192.168.%02d.1' % (outport)
1751 label = (out_mpls_label, 0, 1, 32)
1752 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1753 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1754 pkt = str( parsed_pkt )
1755 self.dataplane.send( inport, pkt )
1756 # build expect packet
1757 mac_dst = '00:00:00:22:22:%02X' % (outport)
1758 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1759 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1760 pkt = str( exp_pkt )
1761 verify_packet( self, pkt, outport )
1762 verify_no_other_packets( self )
1763 finally:
1764 delete_all_flows( self.controller )
1765 delete_groups( self.controller, Groups )
1766 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001767
Flavio Castroa7162bb2016-07-25 17:30:30 -07001768
1769class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001770 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001771
Flavio Castroa7162bb2016-07-25 17:30:30 -07001772 def runTest( self ):
1773 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001774 try:
1775 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001776 if len( config[ "port_map" ] ) < 2:
1777 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001778 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001779 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1780 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001781 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001782 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001783 for port in ports:
1784 # add l2 interface group
1785 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001786 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1787 is_tagged=True, send_barrier=False )
1788 dst_mac[ 5 ] = vlan_id
1789 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1790 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001791 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001792 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001793 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001794 if config["switch_type"] == "qmx":
1795 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1796 else:
1797 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001798 # add unicast routing flow
1799 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001800 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1801 Groups.put( l2gid )
1802 Groups.put( l3_msg.group_id )
1803 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001804
Flavio Castroa7162bb2016-07-25 17:30:30 -07001805 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001806 for in_port in ports:
1807 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1808 ip_src = '192.168.%02d.1' % (test_id + in_port)
1809 for out_port in ports:
1810 if in_port == out_port:
1811 continue
1812 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001813 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1814 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1815 ip_src=ip_src, ip_dst=ip_dst )
1816 pkt = str( parsed_pkt )
1817 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001818 # build expected packet
1819 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001820 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1821 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1822 ip_src=ip_src, ip_dst=ip_dst )
1823 pkt = str( exp_pkt )
1824 verify_packet( self, pkt, out_port )
1825 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001826 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001827 delete_all_flows( self.controller )
1828 delete_groups( self.controller, Groups )
1829 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001830
Flavio Castroa7162bb2016-07-25 17:30:30 -07001831
1832class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001833 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07001834
Flavio Castroa7162bb2016-07-25 17:30:30 -07001835 def runTest( self ):
1836 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001837 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001838 if len( config[ "port_map" ] ) < 2:
1839 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001840 return
Flavio Castro91d1a552016-05-17 16:59:44 -07001841
Flavio Castroa7162bb2016-07-25 17:30:30 -07001842 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1843 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001844 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001845 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001846 for port in ports:
1847 # add l2 interface group
1848 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001849 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
1850 is_tagged=True, send_barrier=False )
1851 dst_mac[ 5 ] = vlan_id
1852 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
1853 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001854 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001855 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001856 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001857 if config["switch_type"] == "qmx":
1858 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1859 else:
1860 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001861 # add unicast routing flow
1862 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001863 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1864 Groups.put( l2gid )
1865 Groups.put( l3_msg.group_id )
1866 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001867 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07001868 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
1869 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001870
Flavio Castroa7162bb2016-07-25 17:30:30 -07001871 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001872 for in_port in ports:
1873 mac_src = '00:00:00:22:22:%02X' % (in_port)
1874 ip_src = '192.168.%02d.1' % (in_port)
1875 for out_port in ports:
1876 if in_port == out_port:
1877 continue
1878 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001879 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1880 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1881 pkt = str( parsed_pkt )
1882 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001883 # build expected packet
1884 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001885 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
1886 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1887 pkt = str( exp_pkt )
1888 verify_packet( self, pkt, out_port )
1889 verify_no_other_packets( self )
1890 ip_dst = '1.168.%02d.1' % ports[ 0 ]
1891 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1892 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1893 pkt = str( parsed_pkt )
1894 self.dataplane.send( in_port, pkt )
1895 # build expect packet
1896 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
1897 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
1898 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
1899 pkt = str( exp_pkt )
1900 verify_packet( self, pkt, ports[ 0 ] )
1901 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001902 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001903 delete_all_flows( self.controller )
1904 delete_groups( self.controller, Groups )
1905 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001906
Flavio Castroa7162bb2016-07-25 17:30:30 -07001907
1908class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001909 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001910 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04001911 """
Flavio Castro91d1a552016-05-17 16:59:44 -07001912
Flavio Castroa7162bb2016-07-25 17:30:30 -07001913 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001914 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001915 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001916 vlan_id = 1;
1917 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001918 add_l2_unfiltered_group( self.controller, [ port ], False )
1919 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001920 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001921 delete_all_flows( self.controller )
1922 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001923
Saurav Das34992182017-04-14 15:59:48 -07001924@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001925class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001926 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001927 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04001928 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001929
1930 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04001931 """
1932 port1 (vlan 1)-> port 2 (vlan 2)
1933 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001934 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001935 delete_all_flows( self.controller )
1936 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04001937
Flavio Castroa7162bb2016-07-25 17:30:30 -07001938 if len( config[ "port_map" ] ) < 3:
1939 logging.info( "Port count less than 3, can't run this case" )
1940 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001941 return
Flavio Castro423df652016-05-17 20:14:08 -04001942
Flavio Castroa7162bb2016-07-25 17:30:30 -07001943 vlan_id = 1
1944 port2_out_vlan = 2
1945 port3_out_vlan = 3
1946 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
1947 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1948 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1949 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
1950 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1951 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
1952 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
1953 src_ip = 0xc0a80101
1954 src_ip_str = "192.168.1.1"
1955 dst_ip = 0xe0010101
1956 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04001957
Flavio Castroa7162bb2016-07-25 17:30:30 -07001958 port1 = config[ "port_map" ].keys( )[ 0 ]
1959 port2 = config[ "port_map" ].keys( )[ 1 ]
1960 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04001961
Flavio Castroa7162bb2016-07-25 17:30:30 -07001962 # add l2 interface group
1963 for port in config[ "port_map" ].keys( ):
1964 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
1965 send_barrier=False )
1966 # add vlan flow table
1967 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1968 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04001969
Flavio Castroa7162bb2016-07-25 17:30:30 -07001970 # add termination flow
1971 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
1972 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04001973
Flavio Castroa7162bb2016-07-25 17:30:30 -07001974 # add MPLS interface group
1975 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
1976 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1977 port2_out_vlan, port2 )
1978 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1979 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1980 # add L3VPN groups
1981 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
1982 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
1983 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
1984 # 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 -07001985 # 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 -04001986
Flavio Castroa7162bb2016-07-25 17:30:30 -07001987 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
1988 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 -04001989
Flavio Castroa7162bb2016-07-25 17:30:30 -07001990 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
1991 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
1992 pkt = str( parsed_pkt )
1993 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001994 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001995 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
1996 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
1997 pkt = str( exp_pkt )
1998 verify_packet( self, pkt, port2 )
1999 # verify_packet(self, pkt, port3)
2000 verify_no_other_packets( self )
2001 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002002 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002003 delete_all_flows( self.controller )
2004 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002005
Saurav Das34992182017-04-14 15:59:48 -07002006@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002007class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002008 """
2009 Test packet in function on a src-mac miss
2010 Send a packet to each dataplane port and verify that a packet
2011 in message is received from the controller for each
2012 #todo verify you stop receiving after adding rule
2013 """
2014
Flavio Castroa7162bb2016-07-25 17:30:30 -07002015 def runTest( self ):
2016 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002017 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002018 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04002019
Flavio Castroa7162bb2016-07-25 17:30:30 -07002020 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002021 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002022 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2023 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2024 Groups.put( L2gid )
2025 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2026 vlan_pkt = str( parsed_vlan_pkt )
2027 for of_port in config[ "port_map" ].keys( ):
2028 logging.info( "PacketInMiss test, port %d", of_port )
2029 self.dataplane.send( of_port, vlan_pkt )
2030 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2031 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002032 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002033 delete_all_flows( self.controller )
2034 delete_all_groups( self.controller )
2035
2036
2037class EcmpGroupMod( base_tests.SimpleDataPlane ):
2038 """
Saurav Das34992182017-04-14 15:59:48 -07002039 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07002040 """
2041
2042 def runTest( self ):
2043 Groups = Queue.LifoQueue( )
2044 try:
2045 if len( config[ "port_map" ] ) < 2:
2046 logging.info( "Port count less than 2, can't run this case" )
2047 return
2048
2049 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2050 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2051 dip = 0xc0a80001
2052 # Hashes Test Name and uses it as id for installing unique groups
2053 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002054 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002055 dst_ips = []
2056 # add flows for all ports but include only the egress switchport (connected to ports[1])
2057 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002058 for port in ports:
2059 vlan_id = port
2060 id = port
2061 # add l2 interface group
2062 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2063 is_tagged=True, send_barrier=False )
2064 dst_mac[ 5 ] = vlan_id
2065 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2066 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002067 if port == ports[1]:
2068 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002069 Groups._put( l2_gid )
2070 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002071 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002072 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002073 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002074 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002075 if config["switch_type"] == "qmx":
2076 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2077 else:
2078 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002079 # add unicast routing flow
2080 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002081 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002082 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002083 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002084 for dst_ip in dst_ips:
2085 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2086 time.sleep(0.1)
2087 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002088 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002089 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002090 in_port = ports[0]
2091 out_port = ports[1]
2092 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2093 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2094 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2095 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2096 tcp = out_port if out_port == 24 else 25
2097 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2098 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2099 ip_dst=ip_dst, tcp_dport=tcp )
2100 pkt = str( parsed_pkt )
2101 self.dataplane.send( ports[ 0 ], pkt )
2102 # build expected packet at egress switchport
2103 mac_dst = '00:00:00:22:22:%02X' % out_port
2104 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2105 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2106 ip_dst=ip_dst, tcp_dport=tcp )
2107 pkt = str( exp_pkt )
2108 verify_packet( self, pkt, out_port )
2109 verify_no_other_packets( self )
2110
2111 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2112 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2113 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002114 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2115 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002116 time.sleep(0.1)
2117 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2118 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2119 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2120 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2121 tcp = port if port == 24 else 25
2122 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2123 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2124 ip_dst=ip_dst,tcp_dport=tcp )
2125 pkt = str( parsed_pkt )
2126 self.dataplane.send( ports[ 0 ], pkt )
2127 # build expected packet
2128 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2129 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2130 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2131 ip_dst=ip_dst,tcp_dport=tcp )
2132 pkt = str( exp_pkt )
2133 verify_packet( self, pkt, ports[ 0 ] )
2134 verify_no_other_packets( self )
2135
2136 # third part of the test - edit the group to completely remove bucket. Packet sent
2137 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002138 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002139 time.sleep(0.1)
2140 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2141 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2142 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2143 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2144 tcp = port if port == 24 else 25
2145 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2146 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2147 ip_dst=ip_dst,tcp_dport=tcp )
2148 pkt = str( parsed_pkt )
2149 self.dataplane.send( ports[ 0 ], pkt )
2150 verify_no_other_packets( self )
2151
2152 # final part of the test - edit the empty group to add back the bucket for the
2153 # original egress port, and verify packet is received on egress switch port
2154 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2155 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2156 time.sleep(0.1)
2157 in_port = ports[0]
2158 out_port = ports[1]
2159 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2160 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2161 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2162 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2163 tcp = out_port if out_port == 24 else 25
2164 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2165 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2166 ip_dst=ip_dst, tcp_dport=tcp )
2167 pkt = str( parsed_pkt )
2168 self.dataplane.send( ports[ 0 ], pkt )
2169 # build expected packet at egress switchport
2170 mac_dst = '00:00:00:22:22:%02X' % out_port
2171 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2172 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2173 ip_dst=ip_dst, tcp_dport=tcp )
2174 pkt = str( exp_pkt )
2175 verify_packet( self, pkt, out_port )
2176 verify_no_other_packets( self )
2177
Flavio Castroa7162bb2016-07-25 17:30:30 -07002178 finally:
2179 delete_all_flows( self.controller )
2180 delete_groups( self.controller, Groups )
2181 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002182
Saurav Das34992182017-04-14 15:59:48 -07002183
Pier8b223022016-08-19 22:47:49 -07002184class Untagged( base_tests.SimpleDataPlane ):
2185 """
2186 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2187 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2188 previous versions of the OFDPA.
2189
2190 Two rules are necessary in VLAN table (10):
2191 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2192 2) Filtering: match 0x100A/0x1FFF, goto 20
2193
2194 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2195 The remaining part of the test is based on the use of the bridging table
2196 """
2197
2198 MAX_INTERNAL_VLAN = 4094
2199
2200 def runTest( self ):
2201 groups = Queue.LifoQueue( )
2202 try:
2203 if len( config[ "port_map" ] ) < 2:
2204 logging.info( "Port count less than 2, can't run this case" )
2205 return
2206
2207 ports = sorted( config[ "port_map" ].keys( ) )
2208 for port in ports:
2209 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002210 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2211 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002212 for other_port in ports:
2213 if other_port == port:
2214 continue
2215 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2216 groups.put( L2gid )
2217 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2218
2219 do_barrier( self.controller )
2220
2221 for out_port in ports:
2222 # change dest based on port number
2223 mac_dst = '00:12:34:56:78:%02X' % out_port
2224 for in_port in ports:
2225 if in_port == out_port:
2226 continue
2227 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2228 self.dataplane.send( in_port, pkt )
2229 for ofport in ports:
2230 if ofport in [ out_port ]:
2231 verify_packet( self, pkt, ofport )
2232 else:
2233 verify_no_packet( self, pkt, ofport )
2234 verify_no_other_packets( self )
2235 finally:
2236 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002237 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002238 delete_all_groups( self.controller )