blob: ac99b9baf2b90f31dd473d368ca28b7d801df86d [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( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700213 vlan_id = 1
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
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500248@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700249class L2FloodTagged( base_tests.SimpleDataPlane ):
Flavio Castro184cefe2015-11-19 20:52:49 -0500250 """
Saurav Das34992182017-04-14 15:59:48 -0700251 currently disabled; fix with try/finally
Flavio Castro184cefe2015-11-19 20:52:49 -0500252 Test L2 flood to a vlan
253 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 -0500254 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500255
Flavio Castroa7162bb2016-07-25 17:30:30 -0700256 def runTest( self ):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500257 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700258 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500259 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500260
Flavio Castroa7162bb2016-07-25 17:30:30 -0700261 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro34352e72015-12-07 20:01:51 -0500262
Flavio Castroa7162bb2016-07-25 17:30:30 -0700263 delete_all_flows( self.controller )
264 delete_all_groups( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500265
Flavio Castro184cefe2015-11-19 20:52:49 -0500266 # Installing flows to avoid packet-in
267 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700268 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
269 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
270 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
271 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
272 do_barrier( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500273
Flavio Castro1c9b1252016-02-04 18:42:58 -0500274 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500275 for ofport in ports:
276 # change dest based on port number
Flavio Castroa7162bb2016-07-25 17:30:30 -0700277 pkt = str(
278 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
279 self.dataplane.send( ofport, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500280 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700281 verify_no_packet( self, pkt, ofport )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500282 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700283 tmp_ports = list( ports )
284 tmp_ports.remove( ofport )
285 verify_packets( self, pkt, tmp_ports )
286 verify_no_other_packets( self )
Flavio Castroaabb5792015-11-18 19:03:50 -0500287
Flavio Castro1c9b1252016-02-04 18:42:58 -0500288
Flavio Castroa7162bb2016-07-25 17:30:30 -0700289class L2UnicastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700290 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500291
Flavio Castroa7162bb2016-07-25 17:30:30 -0700292 def runTest( self ):
Flavio Castrob01d0aa2016-07-20 16:14:48 -0700293
Flavio Castroa7162bb2016-07-25 17:30:30 -0700294 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700295 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700296 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700297 vlan_id = 1;
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700298 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700299 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
300 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
301 Groups.put( L2gid )
302 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
303 True )
304 do_barrier( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500305
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700306 for out_port in ports:
307 # change dest based on port number
308 mac_dst = '00:12:34:56:78:%02X' % out_port
309 for in_port in ports:
310 if in_port == out_port:
311 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700312 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
313 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700314 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700315 if ofport in [ out_port ]:
316 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700317 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700318 verify_no_packet( self, pkt, ofport )
319 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700320 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700321 delete_all_flows( self.controller )
322 delete_groups( self.controller, Groups )
323 delete_all_groups( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500324
Flavio Castroa7162bb2016-07-25 17:30:30 -0700325
326class Mtu1500( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700327 """
328 Verifies basic mtu limits
329 """
330
Flavio Castroa7162bb2016-07-25 17:30:30 -0700331 def runTest( self ):
332 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700333 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700334 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700335 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700336 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700337 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Pier265ad5f2017-02-28 17:46:28 +0100338 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700339 Groups.put( L2gid )
340 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
341 True )
342 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500343
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700344 for out_port in ports:
345 # change dest based on port number
346 mac_dst = '00:12:34:56:78:%02X' % out_port
347 for in_port in ports:
348 if in_port == out_port:
349 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700350 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
351 eth_dst=mac_dst ) )
352 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700353 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700354 if ofport in [ out_port ]:
355 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700356 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700357 verify_no_packet( self, pkt, ofport )
358 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700359 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700360 delete_all_flows( self.controller )
361 delete_groups( self.controller, Groups )
362 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500363
Flavio Castroa7162bb2016-07-25 17:30:30 -0700364
365class _32UcastTagged( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700366 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500367
Flavio Castroa7162bb2016-07-25 17:30:30 -0700368 def runTest( self ):
369 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700370 try:
371 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700372 if len( config[ "port_map" ] ) < 2:
373 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700374 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500375
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:
381 # add l2 interface group
382 vlan_id = port + test_id
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
Flavio Castroa7162bb2016-07-25 17:30:30 -0700391 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700392 # add unicast routing flow
393 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700394 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
395 Groups.put( l2gid )
396 Groups.put( l3_msg.group_id )
397 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500398
Flavio Castroa7162bb2016-07-25 17:30:30 -0700399 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700400 for in_port in ports:
401 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
402 ip_src = '192.168.%02d.1' % (test_id + in_port)
403 for out_port in ports:
404 if in_port == out_port:
405 continue
406 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700407 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
408 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
409 ip_src=ip_src, ip_dst=ip_dst )
410 pkt = str( parsed_pkt )
411 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700412 # build expected packet
413 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700414 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
415 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
416 ip_src=ip_src, ip_dst=ip_dst )
417 pkt = str( exp_pkt )
418 verify_packet( self, pkt, out_port )
419 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700420 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700421 delete_all_flows( self.controller )
422 delete_groups( self.controller, Groups )
423 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500424
Saurav Das34992182017-04-14 15:59:48 -0700425@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700426class _32VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700427 """
428 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
429 No ECMP group used
430 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500431
Flavio Castroa7162bb2016-07-25 17:30:30 -0700432 def runTest( self ):
433 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700434 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700435 if len( config[ "port_map" ] ) < 2:
436 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700437 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500438
Flavio Castroa7162bb2016-07-25 17:30:30 -0700439 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
440 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700441 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700442 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700443 for port in ports:
444 # add l2 interface group
445 id = port
446 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700447 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
448 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700449 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700450 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
451 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700452 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700453 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
454 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
455 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700456 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700457 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100458 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700459 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700460 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700461 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700462 # add routing flow
463 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700464 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
465 Groups._put( l2_gid )
466 Groups._put( mpls_gid )
467 Groups._put( mpls_label_gid )
468 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500469
Flavio Castroa7162bb2016-07-25 17:30:30 -0700470 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700471 for in_port in ports:
472 ip_src = '192.168.%02d.1' % (in_port)
473 for out_port in ports:
474 if in_port == out_port:
475 continue
476 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700477 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
478 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
479 pkt = str( parsed_pkt )
480 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700481 # build expect packet
482 mac_dst = '00:00:00:22:22:%02X' % (out_port)
483 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700484 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
485 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
486 label=[ label ] )
487 pkt = str( exp_pkt )
488 verify_packet( self, pkt, out_port )
489 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700490 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700491 delete_all_flows( self.controller )
492 delete_groups( self.controller, Groups )
493 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500494
Saurav Das34992182017-04-14 15:59:48 -0700495@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700496class _32EcmpVpn( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700497 """
498 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
499 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500500
Flavio Castroa7162bb2016-07-25 17:30:30 -0700501 def runTest( self ):
502 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700503 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700504 if len( config[ "port_map" ] ) < 2:
505 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700506 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500507
Flavio Castroa7162bb2016-07-25 17:30:30 -0700508 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
509 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700510 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700511 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700512 for port in ports:
513 # add l2 interface group
514 id = port
515 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700516 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
517 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700518 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700519 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
520 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700521 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700522 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
523 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
524 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
525 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
526 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700527 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100528 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700529 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700530 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700531 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700532 # add routing flow
533 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700534 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
535 Groups._put( l2_gid )
536 Groups._put( mpls_gid )
537 Groups._put( mpls_label_gid )
538 Groups._put( ecmp_msg.group_id )
539 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500540
Flavio Castroa7162bb2016-07-25 17:30:30 -0700541 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700542 for in_port in ports:
543 ip_src = '192.168.%02d.1' % (in_port)
544 for out_port in ports:
545 if in_port == out_port:
546 continue
547 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700548 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
549 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
550 pkt = str( parsed_pkt )
551 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700552 # build expect packet
553 mac_dst = '00:00:00:22:22:%02X' % (out_port)
554 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700555 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
556 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
557 label=[ label ] )
558 pkt = str( exp_pkt )
559 verify_packet( self, pkt, out_port )
560 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -0700561
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700562 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700563 delete_all_flows( self.controller )
564 delete_groups( self.controller, Groups )
565 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500566
Flavio Castroa7162bb2016-07-25 17:30:30 -0700567
Saurav Das34992182017-04-14 15:59:48 -0700568@disabled
569class One_32EcmpVpn( base_tests.SimpleDataPlane ):
570 """
571 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
572 in only one direction
573 """
574
575 def runTest( self ):
576 Groups = Queue.LifoQueue( )
577 try:
578 if len( config[ "port_map" ] ) < 2:
579 logging.info( "Port count less than 2, can't run this case" )
580 return
581
582 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
583 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
584 dip = 0xc0a80001
585 ports = config[ "port_map" ].keys( )
586 # add l2 interface group
587 id = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700588 in_offset = 19
589 out_offset = 20
590 vlan_id = ports[1] + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700591 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
Saurav Das1ab6a142017-04-25 14:42:25 -0700592 dst_mac[ 5 ] = ports[1]
Saurav Das34992182017-04-14 15:59:48 -0700593 # add MPLS interface group
594 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
595 vlan_id, id )
596 # add MPLS L3 VPN group
597 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
598 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
Saurav Das1ab6a142017-04-25 14:42:25 -0700599 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
Saurav Das34992182017-04-14 15:59:48 -0700600 # add ECMP group
601 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
602 do_barrier( self.controller )
603 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700604 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 -0700605 flag=VLAN_TABLE_FLAG_ONLY_TAG )
606 # add termination flow
Saurav Das1ab6a142017-04-25 14:42:25 -0700607 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700608 # add routing flow
609 dst_ip = dip + (vlan_id << 8)
610 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
611 Groups._put( l2_gid )
612 Groups._put( mpls_gid )
613 Groups._put( mpls_label_gid )
614 Groups._put( ecmp_msg.group_id )
615
616
617 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
618 in_port = ports[0]
619 out_port = ports[1]
620 ip_src = '192.168.%02d.1' % (in_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700621 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
622 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
Saurav Das34992182017-04-14 15:59:48 -0700623 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
624 pkt = str( parsed_pkt )
625 self.dataplane.send( in_port, pkt )
626 # build expect packet
627 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700628 label = (out_port+out_offset, 0, 1, 32)
629 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 -0700630 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
Saurav Das1ab6a142017-04-25 14:42:25 -0700631 label=[ label ] )
Saurav Das34992182017-04-14 15:59:48 -0700632 pkt = str( exp_pkt )
633 verify_packet( self, pkt, out_port )
634 #verify_no_other_packets( self )
635
636 finally:
637 delete_all_flows( self.controller )
638 delete_group(self.controller, ecmp_msg.group_id)
639 delete_group(self.controller, mpls_label_gid)
640 delete_group(self.controller, mpls_gid)
641 delete_group(self.controller, l2_gid)
642
643
Flavio Castroa7162bb2016-07-25 17:30:30 -0700644class _32ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700645 """
646 Verifies /32 IP routing and ECMP with no label push
647 IP -> L3ECMP -> L3Unicast -> L2Interface
648 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500649
Flavio Castroa7162bb2016-07-25 17:30:30 -0700650 def runTest( self ):
651 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700652 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700653 if len( config[ "port_map" ] ) < 2:
654 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700655 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500656
Flavio Castroa7162bb2016-07-25 17:30:30 -0700657 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
658 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700659 dip = 0xc0a80001
660 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700661 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700662 for port in ports:
663 vlan_id = port
664 id = port
665 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700666 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
667 is_tagged=True, send_barrier=False )
668 dst_mac[ 5 ] = vlan_id
669 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
670 src_mac=intf_src_mac, dst_mac=dst_mac )
671 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700672 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100673 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700674 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700675 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700676 # add unicast routing flow
677 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700678 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
679 Groups._put( l2_gid )
680 Groups._put( l3_msg.group_id )
681 Groups._put( ecmp_msg.group_id )
682 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500683
Flavio Castroa7162bb2016-07-25 17:30:30 -0700684 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700685 for in_port in ports:
686 mac_src = '00:00:00:22:22:%02X' % in_port
687 ip_src = '192.168.%02d.1' % in_port
688 for out_port in ports:
689 if in_port == out_port:
690 continue
691 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700692 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
693 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
694 pkt = str( parsed_pkt )
695 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700696 # build expected packet
697 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700698 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
699 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
700 pkt = str( exp_pkt )
701 verify_packet( self, pkt, out_port )
702 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700703 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700704 delete_all_flows( self.controller )
705 delete_groups( self.controller, Groups )
706 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500707
Saurav Das34992182017-04-14 15:59:48 -0700708@disabled
709class One_32ECMPL3( base_tests.SimpleDataPlane ):
710 """
711 Verifies /32 IP routing and ECMP with no label push
712 IP -> L3ECMP -> L3Unicast -> L2Interface
713 in only one direction
714 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700715
Saurav Das34992182017-04-14 15:59:48 -0700716 def runTest( self ):
717 Groups = Queue.LifoQueue( )
718 try:
719 if len( config[ "port_map" ] ) < 2:
720 logging.info( "Port count less than 2, can't run this case" )
721 return
722
723 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
724 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
725 dip = 0xc0a80001
726 # Hashes Test Name and uses it as id for installing unique groups
727 ports = config[ "port_map" ].keys( )
728 inport = ports[0]
729 outport = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700730 in_offset = 19
731 out_offset = 20
732 vlan_id = outport + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700733 id = outport
734 # add l2 interface group, l3 unicast and ecmp group for outport
735 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
736 is_tagged=True, send_barrier=False )
Saurav Das1ab6a142017-04-25 14:42:25 -0700737 dst_mac[ 5 ] = outport
Saurav Das34992182017-04-14 15:59:48 -0700738 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
739 src_mac=intf_src_mac, dst_mac=dst_mac )
740 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
741 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700742 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 -0700743 # add termination flow
Saurav Das1ab6a142017-04-25 14:42:25 -0700744 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 -0700745 # add unicast routing flow
746 dst_ip = dip + (vlan_id << 8)
747 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
748 Groups._put( l2_gid )
749 Groups._put( l3_msg.group_id )
750 Groups._put( ecmp_msg.group_id )
751
752 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
753 mac_src = '00:00:00:22:22:%02X' % inport
754 ip_src = '192.168.%02d.1' % inport
Saurav Das1ab6a142017-04-25 14:42:25 -0700755 ip_dst = '192.168.%02d.1' % (outport+out_offset)
756 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
Saurav Das34992182017-04-14 15:59:48 -0700757 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
758 pkt = str( parsed_pkt )
759 self.dataplane.send( inport, pkt )
760 # build expected packet
761 mac_dst = '00:00:00:22:22:%02X' % outport
Saurav Das1ab6a142017-04-25 14:42:25 -0700762 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
Saurav Das34992182017-04-14 15:59:48 -0700763 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
764 pkt = str( exp_pkt )
765 verify_packet( self, pkt, outport )
766 verify_no_other_packets( self )
767 finally:
768 delete_all_flows( self.controller )
769 delete_groups( self.controller, Groups )
770 delete_all_groups( self.controller )
771
772
773
774
775@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700776class _24VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700777 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500778
Flavio Castroa7162bb2016-07-25 17:30:30 -0700779 def runTest( self ):
780 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700781 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700782 if len( config[ "port_map" ] ) < 2:
783 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700784 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500785
Flavio Castroa7162bb2016-07-25 17:30:30 -0700786 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
787 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700788 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700789 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700790 for port in ports:
791 # add l2 interface group
792 id = port
793 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700794 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
795 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700796 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700797 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
798 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700799 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700800 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
801 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
802 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700803 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700804 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700805 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100806 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700807 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700808 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700809 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700810 # add routing flow
811 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700812 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
813 Groups._put( l2_gid )
814 Groups._put( mpls_gid )
815 Groups._put( mpls_label_gid )
816 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500817
Flavio Castroa7162bb2016-07-25 17:30:30 -0700818 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700819 for in_port in ports:
820 ip_src = '192.168.%02d.1' % (in_port)
821 for out_port in ports:
822 if in_port == out_port:
823 continue
824 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700825 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
826 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
827 pkt = str( parsed_pkt )
828 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700829 # build expect packet
830 mac_dst = '00:00:00:22:22:%02X' % (out_port)
831 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700832 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
833 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
834 label=[ label ] )
835 pkt = str( exp_pkt )
836 verify_packet( self, pkt, out_port )
837 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700838 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700839 delete_all_flows( self.controller )
840 delete_groups( self.controller, Groups )
841 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500842
Saurav Das34992182017-04-14 15:59:48 -0700843@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700844class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700845 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -0500846
Flavio Castroa7162bb2016-07-25 17:30:30 -0700847 def runTest( self ):
848 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700849 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700850 if len( config[ "port_map" ] ) < 2:
851 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700852 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700853 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
854 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700855 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700856 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700857 for port in ports:
858 # add l2 interface group
859 id = port
860 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -0700861 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
862 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700863 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700864 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
865 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700866 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700867 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
868 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
869 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
870 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
871 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700872 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100873 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700874 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700875 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700876 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700877 # add routing flow
878 dst_ip = dip + (vlan_id << 8)
879 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700880 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
881 vrf=0 )
882 Groups._put( l2_gid )
883 Groups._put( mpls_gid )
884 Groups._put( mpls_label_gid )
885 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700886
Flavio Castroa7162bb2016-07-25 17:30:30 -0700887 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -0500888
Flavio Castroa7162bb2016-07-25 17:30:30 -0700889 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700890 for in_port in ports:
891 mac_src = '00:00:00:22:22:%02X' % (in_port)
892 ip_src = '192.168.%02d.1' % (in_port)
893 for out_port in ports:
894 if in_port == out_port:
895 continue
896 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700897 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
898 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
899 pkt = str( parsed_pkt )
900 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700901 # build expect packet
902 mac_dst = '00:00:00:22:22:%02X' % out_port
903 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700904 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
905 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
906 label=[ label ] )
907 pkt = str( exp_pkt )
908 verify_packet( self, pkt, out_port )
909 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700910 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700911 delete_all_flows( self.controller )
912 delete_groups( self.controller, Groups )
913 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500914
Flavio Castroa7162bb2016-07-25 17:30:30 -0700915
916class FloodGroupMod( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700917 """ Modify a referenced flood group """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700918
919 def runTest( self ):
920 Groups = Queue.LifoQueue( )
921 try:
922 ports = sorted( config[ "port_map" ].keys( ) )
923 vlan_id = 1
924
925 for port in ports:
926 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
927 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
928 Groups.put( L2gid )
929
930 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
931 Groups.put( msg.group_id )
932 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
933 do_barrier( self.controller )
934 # verify flood
935 for ofport in ports:
936 # change dest based on port number
937 mac_src = '00:12:34:56:78:%02X' % ofport
938 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
939 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
940 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
941 pkt = str( parsed_pkt )
942 self.dataplane.send( ofport, pkt )
943 # self won't rx packet
944 verify_no_packet( self, pkt, ofport )
945 # others will rx packet
946 tmp_ports = list( ports )
947 tmp_ports.remove( ofport )
948 verify_packets( self, pkt, tmp_ports )
949 verify_no_other_packets( self )
950 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
951 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
952 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
953 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
954 eth_src=mac_src )
955 pkt = str( parsed_pkt )
956 self.dataplane.send( ports[ 1 ], pkt )
957 verify_packets( self, pkt, [ ports[ 0 ] ] )
958 finally:
959 delete_all_flows( self.controller )
960 delete_groups( self.controller, Groups )
961 delete_all_groups( self.controller )
962
963
964class _24ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700965 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
Flavio Castro80730822015-12-11 15:38:47 -0500966
Flavio Castroa7162bb2016-07-25 17:30:30 -0700967 def runTest( self ):
968 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700969 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700970 if len( config[ "port_map" ] ) < 2:
971 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700972 return
Flavio Castro80730822015-12-11 15:38:47 -0500973
Flavio Castroa7162bb2016-07-25 17:30:30 -0700974 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
975 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700976 dip = 0xc0a80001
977 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700978 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700979 for port in ports:
980 vlan_id = port
981 id = port
982 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700983 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
984 is_tagged=True, send_barrier=False )
985 dst_mac[ 5 ] = vlan_id
986 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
987 src_mac=intf_src_mac, dst_mac=dst_mac )
988 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700989 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100990 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700991 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -0700992 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700993 # add unicast routing flow
994 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700995 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
996 Groups._put( l2_gid )
997 Groups._put( l3_msg.group_id )
998 Groups._put( ecmp_msg.group_id )
999 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -05001000
Flavio Castroa7162bb2016-07-25 17:30:30 -07001001 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001002 for in_port in ports:
1003 mac_src = '00:00:00:22:22:%02X' % in_port
1004 ip_src = '192.168.%02d.1' % in_port
1005 for out_port in ports:
1006 if in_port == out_port:
1007 continue
1008 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001009 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1010 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1011 pkt = str( parsed_pkt )
1012 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001013 # build expected packet
1014 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001015 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1016 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1017 pkt = str( exp_pkt )
1018 verify_packet( self, pkt, out_port )
1019 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001020 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001021 delete_all_flows( self.controller )
1022 delete_groups( self.controller, Groups )
1023 delete_all_groups( self.controller )
1024
Flavio Castro1c9b1252016-02-04 18:42:58 -05001025
Flavio Castroaba28ff2016-02-03 16:47:48 -05001026@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001027class MPLSBUG( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001028 """
1029 Needs a description or needs to be removed
1030 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001031 def runTest( self ):
1032 if len( config[ "port_map" ] ) < 2:
1033 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -05001034 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001035 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1036 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -05001037 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001038 Groups = Queue.LifoQueue( )
1039 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -05001040 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001041 # add l2 interface group
1042 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001043 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1044 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -05001045 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001046 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1047 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001048 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001049 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001050 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001051 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001052 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001053 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001054 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001055 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001056 # add unicast routing flow
1057 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001058 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1059 Groups._put( l2_gid )
1060 Groups._put( l3_msg.group_id )
1061 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001062
Flavio Castroa7162bb2016-07-25 17:30:30 -07001063 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -05001064 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001065 mac_src = '00:00:00:22:22:%02X' % in_port
1066 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -05001067 for out_port in ports:
1068 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001069 continue
1070 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -05001071 switch_mac = "00:00:00:cc:cc:cc"
1072 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001073 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1074 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1075 pkt = str( parsed_pkt )
1076 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -05001077
Flavio Castro1c9b1252016-02-04 18:42:58 -05001078 # build expect packet
1079 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001080 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1081 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1082 pkt = str( exp_pkt )
1083 verify_packet( self, pkt, out_port )
1084 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001085
Flavio Castroa7162bb2016-07-25 17:30:30 -07001086 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1087 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1088 pkt = str( parsed_pkt )
1089 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001090 # build expected packet
1091 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001092 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1093 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1094 pkt = str( exp_pkt )
1095 verify_packet( self, pkt, out_port )
1096 verify_no_other_packets( self )
1097 delete_all_flows( self.controller )
1098 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001099
Flavio Castroa7162bb2016-07-25 17:30:30 -07001100class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -07001101 """
1102 Mcast routing, in this test case the traffic comes in tagged.
1103 port+1 is used as ingress vlan_id. The packet goes out tagged on
1104 different ports. 4094-port is used as egress vlan_id.
1105 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001106 def runTest( self ):
Pier7b031af2016-08-25 15:00:22 -07001107 """
1108 port1 (vlan 300)-> All Ports (vlan 300)
1109 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001110 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001111 try:
Pierbbdf3782016-08-22 17:58:26 -07001112 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1113 if len( config[ "port_map" ] ) < 1:
1114 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001115 assert (False)
1116 return
Pierbbdf3782016-08-22 17:58:26 -07001117 ports = config[ "port_map" ].keys( )
1118 dst_ip_str = "224.0.0.1"
1119 (
1120 port_to_in_vlan,
1121 port_to_out_vlan,
1122 port_to_src_mac_str,
1123 port_to_dst_mac_str,
1124 port_to_src_ip_str,
1125 port_to_intf_src_mac_str,
1126 Groups) = fill_mcast_pipeline_L3toL3(
1127 self.controller,
1128 logging,
1129 ports,
1130 is_ingress_tagged = True,
1131 is_egress_tagged = True,
1132 is_vlan_translated = True,
1133 is_max_vlan = False
1134 )
Flavio Castro12296312015-12-15 17:48:26 -05001135
Pierbbdf3782016-08-22 17:58:26 -07001136 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001137
Pierbbdf3782016-08-22 17:58:26 -07001138 parsed_pkt = simple_udp_packet(
1139 pktlen = 100,
1140 dl_vlan_enable = True,
1141 vlan_vid = port_to_in_vlan[in_port],
1142 eth_dst = port_to_dst_mac_str[in_port],
1143 eth_src = port_to_src_mac_str[in_port],
1144 ip_ttl = 64,
1145 ip_src = port_to_src_ip_str[in_port],
1146 ip_dst = dst_ip_str
1147 )
1148 pkt = str( parsed_pkt )
1149 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001150
Pierbbdf3782016-08-22 17:58:26 -07001151 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001152
Pierbbdf3782016-08-22 17:58:26 -07001153 parsed_pkt = simple_udp_packet(
1154 pktlen = 100,
1155 dl_vlan_enable = True,
1156 vlan_vid = port_to_out_vlan[out_port],
1157 eth_dst = port_to_dst_mac_str[in_port],
1158 eth_src = port_to_intf_src_mac_str[out_port],
1159 ip_ttl = 63,
1160 ip_src = port_to_src_ip_str[in_port],
1161 ip_dst = dst_ip_str
1162 )
1163 pkt = str( parsed_pkt )
1164 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001165
Pierbbdf3782016-08-22 17:58:26 -07001166 verify_no_other_packets( self )
1167
Pier7b031af2016-08-25 15:00:22 -07001168 finally:
1169 delete_all_flows( self.controller )
1170 delete_groups( self.controller, Groups )
1171 delete_all_groups( self.controller )
1172
1173class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1174 """
1175 Mcast routing, in this test case the traffic is untagged.
1176 4094 is used as internal vlan_id. The packet goes out
1177 untagged.
1178 """
1179 def runTest( self ):
1180 Groups = Queue.LifoQueue( )
1181 try:
1182 if len( config[ "port_map" ] ) < 2:
1183 logging.info( "Port count less than 2, can't run this case" )
1184 assert (False)
1185 return
1186 ports = config[ "port_map" ].keys( )
1187 dst_ip_str = "224.0.0.1"
1188 (
1189 port_to_in_vlan,
1190 port_to_out_vlan,
1191 port_to_src_mac_str,
1192 port_to_dst_mac_str,
1193 port_to_src_ip_str,
1194 Groups) = fill_mcast_pipeline_L3toL2(
1195 self.controller,
1196 logging,
1197 ports,
1198 is_ingress_tagged = False,
1199 is_egress_tagged = False,
1200 is_vlan_translated = False,
1201 is_max_vlan = True
1202 )
1203
1204 for in_port in ports:
1205
1206 parsed_pkt = simple_udp_packet(
1207 pktlen = 96,
1208 eth_dst = port_to_dst_mac_str[in_port],
1209 eth_src = port_to_src_mac_str[in_port],
1210 ip_ttl = 64,
1211 ip_src = port_to_src_ip_str[in_port],
1212 ip_dst = dst_ip_str
1213 )
1214 pkt = str( parsed_pkt )
1215 self.dataplane.send( in_port, pkt )
1216
1217 for out_port in ports:
1218
1219 parsed_pkt = simple_udp_packet(
1220 pktlen = 96,
1221 eth_dst = port_to_dst_mac_str[in_port],
1222 eth_src = port_to_src_mac_str[in_port],
1223 ip_ttl = 64,
1224 ip_src = port_to_src_ip_str[in_port],
1225 ip_dst = dst_ip_str
1226 )
1227 pkt = str( parsed_pkt )
1228 if out_port == in_port:
1229 verify_no_packet( self, pkt, in_port )
1230 continue
1231 verify_packet( self, pkt, out_port )
1232 verify_no_other_packets( self )
1233 finally:
1234 delete_all_flows( self.controller )
1235 delete_groups( self.controller, Groups )
1236 delete_all_groups( self.controller )
1237
1238class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1239 """
1240 Mcast routing, in this test case the traffic is untagged.
1241 300 is used as vlan_id. The packet goes out
1242 tagged.
1243 """
1244 def runTest( self ):
1245 Groups = Queue.LifoQueue( )
1246 try:
1247 if len( config[ "port_map" ] ) < 2:
1248 logging.info( "Port count less than 2, can't run this case" )
1249 assert (False)
1250 return
1251 ports = config[ "port_map" ].keys( )
1252 dst_ip_str = "224.0.0.1"
1253 (
1254 port_to_in_vlan,
1255 port_to_out_vlan,
1256 port_to_src_mac_str,
1257 port_to_dst_mac_str,
1258 port_to_src_ip_str,
1259 Groups) = fill_mcast_pipeline_L3toL2(
1260 self.controller,
1261 logging,
1262 ports,
1263 is_ingress_tagged = False,
1264 is_egress_tagged = True,
1265 is_vlan_translated = False,
1266 is_max_vlan = False
1267 )
1268
1269 for in_port in ports:
1270
1271 parsed_pkt = simple_udp_packet(
1272 pktlen = 96,
1273 eth_dst = port_to_dst_mac_str[in_port],
1274 eth_src = port_to_src_mac_str[in_port],
1275 ip_ttl = 64,
1276 ip_src = port_to_src_ip_str[in_port],
1277 ip_dst = dst_ip_str
1278 )
1279 pkt = str( parsed_pkt )
1280 self.dataplane.send( in_port, pkt )
1281
1282 for out_port in ports:
1283
1284 parsed_pkt = simple_udp_packet(
1285 pktlen = 100,
1286 dl_vlan_enable = True,
1287 vlan_vid = port_to_out_vlan[in_port],
1288 eth_dst = port_to_dst_mac_str[in_port],
1289 eth_src = port_to_src_mac_str[in_port],
1290 ip_ttl = 64,
1291 ip_src = port_to_src_ip_str[in_port],
1292 ip_dst = dst_ip_str
1293 )
1294 pkt = str( parsed_pkt )
1295 if out_port == in_port:
1296 verify_no_packet( self, pkt, in_port )
1297 continue
1298 verify_packet( self, pkt, out_port )
1299 verify_no_other_packets( self )
1300 finally:
1301 delete_all_flows( self.controller )
1302 delete_groups( self.controller, Groups )
1303 delete_all_groups( self.controller )
1304
1305
1306class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1307 """
1308 Mcast routing, in this test case the traffic is tagged.
1309 300 is used as vlan_id. The packet goes out
1310 untagged.
1311 """
1312 def runTest( self ):
1313 Groups = Queue.LifoQueue( )
1314 try:
1315 if len( config[ "port_map" ] ) < 2:
1316 logging.info( "Port count less than 2, can't run this case" )
1317 assert (False)
1318 return
1319 ports = config[ "port_map" ].keys( )
1320 dst_ip_str = "224.0.0.1"
1321 (
1322 port_to_in_vlan,
1323 port_to_out_vlan,
1324 port_to_src_mac_str,
1325 port_to_dst_mac_str,
1326 port_to_src_ip_str,
1327 Groups) = fill_mcast_pipeline_L3toL2(
1328 self.controller,
1329 logging,
1330 ports,
1331 is_ingress_tagged = True,
1332 is_egress_tagged = False,
1333 is_vlan_translated = False,
1334 is_max_vlan = False
1335 )
1336
1337 for in_port in ports:
1338
1339 parsed_pkt = simple_udp_packet(
1340 pktlen = 100,
1341 dl_vlan_enable = True,
1342 vlan_vid = port_to_in_vlan[in_port],
1343 eth_dst = port_to_dst_mac_str[in_port],
1344 eth_src = port_to_src_mac_str[in_port],
1345 ip_ttl = 64,
1346 ip_src = port_to_src_ip_str[in_port],
1347 ip_dst = dst_ip_str
1348 )
1349 pkt = str( parsed_pkt )
1350 self.dataplane.send( in_port, pkt )
1351
1352 for out_port in ports:
1353
1354 parsed_pkt = simple_udp_packet(
1355 pktlen = 96,
1356 eth_dst = port_to_dst_mac_str[in_port],
1357 eth_src = port_to_src_mac_str[in_port],
1358 ip_ttl = 64,
1359 ip_src = port_to_src_ip_str[in_port],
1360 ip_dst = dst_ip_str
1361 )
1362 pkt = str( parsed_pkt )
1363 if out_port == in_port:
1364 verify_no_packet( self, pkt, in_port )
1365 continue
1366 verify_packet( self, pkt, out_port )
1367 verify_no_other_packets( self )
1368 finally:
1369 delete_all_flows( self.controller )
1370 delete_groups( self.controller, Groups )
1371 delete_all_groups( self.controller )
1372
1373class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1374 """
1375 Mcast routing, in this test case the traffic is tagged.
1376 300 is used as vlan_id. The packet goes out tagged.
1377 """
1378 def runTest( self ):
1379 Groups = Queue.LifoQueue( )
1380 try:
1381 if len( config[ "port_map" ] ) < 2:
1382 logging.info( "Port count less than 2, can't run this case" )
1383 assert (False)
1384 return
1385 ports = config[ "port_map" ].keys( )
1386 dst_ip_str = "224.0.0.1"
1387 (
1388 port_to_in_vlan,
1389 port_to_out_vlan,
1390 port_to_src_mac_str,
1391 port_to_dst_mac_str,
1392 port_to_src_ip_str,
1393 Groups) = fill_mcast_pipeline_L3toL2(
1394 self.controller,
1395 logging,
1396 ports,
1397 is_ingress_tagged = True,
1398 is_egress_tagged = True,
1399 is_vlan_translated = False,
1400 is_max_vlan = False
1401 )
1402
1403 for in_port in ports:
1404
1405 parsed_pkt = simple_udp_packet(
1406 pktlen = 100,
1407 dl_vlan_enable = True,
1408 vlan_vid = port_to_in_vlan[in_port],
1409 eth_dst = port_to_dst_mac_str[in_port],
1410 eth_src = port_to_src_mac_str[in_port],
1411 ip_ttl = 64,
1412 ip_src = port_to_src_ip_str[in_port],
1413 ip_dst = dst_ip_str
1414 )
1415 pkt = str( parsed_pkt )
1416 self.dataplane.send( in_port, pkt )
1417
1418 for out_port in ports:
1419
1420 parsed_pkt = simple_udp_packet(
1421 pktlen = 100,
1422 dl_vlan_enable = True,
1423 vlan_vid = port_to_in_vlan[in_port],
1424 eth_dst = port_to_dst_mac_str[in_port],
1425 eth_src = port_to_src_mac_str[in_port],
1426 ip_ttl = 64,
1427 ip_src = port_to_src_ip_str[in_port],
1428 ip_dst = dst_ip_str
1429 )
1430 pkt = str( parsed_pkt )
1431 if out_port == in_port:
1432 verify_no_packet( self, pkt, in_port )
1433 continue
1434 verify_packet( self, pkt, out_port )
1435 verify_no_other_packets( self )
1436 finally:
1437 delete_all_flows( self.controller )
1438 delete_groups( self.controller, Groups )
1439 delete_all_groups( self.controller )
1440
1441class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1442 """
1443 Mcast routing, in this test case the traffic is tagged.
1444 port+1 is used as ingress vlan_id. The packet goes out
1445 tagged. 4094-port is used as egress vlan_id
1446 """
1447 def runTest( self ):
1448 Groups = Queue.LifoQueue( )
1449 try:
1450 if len( config[ "port_map" ] ) < 2:
1451 logging.info( "Port count less than 2, can't run this case" )
1452 assert (False)
1453 return
1454 ports = config[ "port_map" ].keys( )
1455 dst_ip_str = "224.0.0.1"
1456 (
1457 port_to_in_vlan,
1458 port_to_out_vlan,
1459 port_to_src_mac_str,
1460 port_to_dst_mac_str,
1461 port_to_src_ip_str,
1462 Groups) = fill_mcast_pipeline_L3toL2(
1463 self.controller,
1464 logging,
1465 ports,
1466 is_ingress_tagged = True,
1467 is_egress_tagged = True,
1468 is_vlan_translated = True,
1469 is_max_vlan = False
1470 )
1471
1472 for in_port in ports:
1473
1474 parsed_pkt = simple_udp_packet(
1475 pktlen = 100,
1476 dl_vlan_enable = True,
1477 vlan_vid = port_to_in_vlan[in_port],
1478 eth_dst = port_to_dst_mac_str[in_port],
1479 eth_src = port_to_src_mac_str[in_port],
1480 ip_ttl = 64,
1481 ip_src = port_to_src_ip_str[in_port],
1482 ip_dst = dst_ip_str
1483 )
1484 pkt = str( parsed_pkt )
1485 self.dataplane.send( in_port, pkt )
1486
1487 for out_port in ports:
1488
1489 parsed_pkt = simple_udp_packet(
1490 pktlen = 100,
1491 dl_vlan_enable = True,
1492 vlan_vid = port_to_out_vlan[in_port],
1493 eth_dst = port_to_dst_mac_str[in_port],
1494 eth_src = port_to_src_mac_str[in_port],
1495 ip_ttl = 64,
1496 ip_src = port_to_src_ip_str[in_port],
1497 ip_dst = dst_ip_str
1498 )
1499 pkt = str( parsed_pkt )
1500 if out_port == in_port:
1501 verify_no_packet( self, pkt, in_port )
1502 continue
1503 verify_packet( self, pkt, out_port )
1504 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001505 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001506 delete_all_flows( self.controller )
1507 delete_groups( self.controller, Groups )
1508 delete_all_groups( self.controller )
1509
Saurav Das34992182017-04-14 15:59:48 -07001510@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001511class _MplsFwd( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001512 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001513
1514 def runTest( self ):
1515 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001516 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001517 if len( config[ "port_map" ] ) < 2:
1518 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001519 return
1520 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001521 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1522 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001523 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001524 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001525 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001526 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1527 vlan_id = port + 16
1528 mpls_label = port + 16
1529
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001530 # add l2 interface group
1531 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001532 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001533 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001534 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1535 vlan_id, id )
1536 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1537 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001538 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Saurav Das34992182017-04-14 15:59:48 -07001539 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1540 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001541 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001542 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001543 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001544 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001545 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Charles Chan53cac542016-08-22 16:03:26 -07001546 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001547 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001548 Groups._put( l2_gid )
1549 Groups._put( mpls_gid )
1550 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001551 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001552 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001553
Flavio Castroa7162bb2016-07-25 17:30:30 -07001554 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001555 for in_port in ports:
1556 ip_src = '192.168.%02d.1' % (in_port)
1557 for out_port in ports:
1558 if in_port == out_port:
1559 continue
Flavio Castro54947942016-02-03 16:05:20 -05001560
Charles Chan53cac542016-08-22 16:03:26 -07001561 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1562 out_mpls_label = out_port + 16
1563 in_vlan_vid = in_port + 16
1564 out_vlan_vid = out_port + 16
1565
1566 ip_dst = '192.168.%02d.1' % (out_port)
1567 label = (out_mpls_label, 0, 1, 32)
1568 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001569 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1570 pkt = str( parsed_pkt )
1571 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001572
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001573 # build expect packet
1574 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001575 label = (out_mpls_label, 0, 1, 31)
1576 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001577 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1578 label=[ label ] )
1579 pkt = str( exp_pkt )
1580 verify_packet( self, pkt, out_port )
1581 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001582 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001583 delete_all_flows( self.controller )
1584 delete_groups( self.controller, Groups )
1585 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001586
Saurav Das34992182017-04-14 15:59:48 -07001587@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001588class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001589 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001590
1591 def runTest( self ):
1592 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001593 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001594 if len( config[ "port_map" ] ) < 2:
1595 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001596 return
1597 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001598 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1599 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001600 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001601 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001602 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001603 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1604 vlan_id = port + 16
1605 mpls_label = port + 16
1606
Flavio Castrod80fbc32016-07-25 15:54:26 -07001607 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001608 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001609 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001610 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001611 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1612 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001613 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001614 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001615 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001616 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001617 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001618 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Charles Chan53cac542016-08-22 16:03:26 -07001619 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001620 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001621 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001622 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001623 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001624 Groups._put( l2_gid )
1625 Groups._put( l3_msg.group_id )
1626 Groups._put( ecmp_msg.group_id )
1627 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001628
Flavio Castroa7162bb2016-07-25 17:30:30 -07001629 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001630 for in_port in ports:
1631 ip_src = '192.168.%02d.1' % (in_port)
1632 for out_port in ports:
1633 if in_port == out_port:
1634 continue
Charles Chan53cac542016-08-22 16:03:26 -07001635
1636 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1637 out_mpls_label = out_port + 16
1638 in_vlan_vid = in_port + 16
1639 out_vlan_vid = out_port + 16
1640
Flavio Castrod80fbc32016-07-25 15:54:26 -07001641 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001642 label = (out_mpls_label, 0, 1, 32)
1643 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001644 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1645 pkt = str( parsed_pkt )
1646 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001647 # build expect packet
1648 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001649 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001650 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1651 pkt = str( exp_pkt )
1652 verify_packet( self, pkt, out_port )
1653 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001654 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001655 delete_all_flows( self.controller )
1656 delete_groups( self.controller, Groups )
1657 delete_all_groups( self.controller )
Saurav Das34992182017-04-14 15:59:48 -07001658 print("Done")
1659
1660@disabled
1661class One_MplsTermination( base_tests.SimpleDataPlane ):
1662 """
1663 Verify MPLS VPN Termination at penultimate hop in only one direction
1664 """
1665
1666 def runTest( self ):
1667 Groups = Queue.LifoQueue( )
1668 try:
1669 if len( config[ "port_map" ] ) < 2:
1670 logging.info( "Port count less than 2, can't run this case" )
1671 return
1672 dip = 0xc0a80001
1673 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1674 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1675 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1676 ports = config[ "port_map" ].keys( )
1677 inport = ports[0]
1678 outport = ports[1]
1679
1680 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1681 invlan_id = inport + 16
1682 outvlan_id = outport + 16
1683 mpls_label = outport + 16
1684
1685 # add l2 interface group
1686 id, dst_mac[ 5 ] = inport, outport
1687 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
1688 # add L3 Unicast group
1689 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
1690 src_mac=intf_src_mac, dst_mac=dst_mac )
1691 # add L3 ecmp group
1692 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1693 # add vlan flow table
1694 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1695 # add tmac flow
1696 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
1697 # add mpls termination flow
1698 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
1699 Groups._put( l2_gid )
1700 Groups._put( l3_msg.group_id )
1701 Groups._put( ecmp_msg.group_id )
1702
1703 time.sleep(0.1)
1704 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1705 ip_src = '192.168.%02d.1' % (inport)
1706 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1707 out_mpls_label = outport + 16
1708 in_vlan_vid = inport + 16
1709 out_vlan_vid = outport + 16
1710
1711 ip_dst = '192.168.%02d.1' % (outport)
1712 label = (out_mpls_label, 0, 1, 32)
1713 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1714 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1715 pkt = str( parsed_pkt )
1716 self.dataplane.send( inport, pkt )
1717 # build expect packet
1718 mac_dst = '00:00:00:22:22:%02X' % (outport)
1719 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1720 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1721 pkt = str( exp_pkt )
1722 verify_packet( self, pkt, outport )
1723 verify_no_other_packets( self )
1724 finally:
1725 delete_all_flows( self.controller )
1726 delete_groups( self.controller, Groups )
1727 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001728
Flavio Castroa7162bb2016-07-25 17:30:30 -07001729
1730class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001731 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001732
Flavio Castroa7162bb2016-07-25 17:30:30 -07001733 def runTest( self ):
1734 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001735 try:
1736 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001737 if len( config[ "port_map" ] ) < 2:
1738 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001739 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001740 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1741 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001742 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001743 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001744 for port in ports:
1745 # add l2 interface group
1746 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001747 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1748 is_tagged=True, send_barrier=False )
1749 dst_mac[ 5 ] = vlan_id
1750 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1751 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001752 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001753 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001754 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001755 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001756 # add unicast routing flow
1757 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001758 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1759 Groups.put( l2gid )
1760 Groups.put( l3_msg.group_id )
1761 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001762
Flavio Castroa7162bb2016-07-25 17:30:30 -07001763 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001764 for in_port in ports:
1765 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1766 ip_src = '192.168.%02d.1' % (test_id + in_port)
1767 for out_port in ports:
1768 if in_port == out_port:
1769 continue
1770 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001771 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1772 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1773 ip_src=ip_src, ip_dst=ip_dst )
1774 pkt = str( parsed_pkt )
1775 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001776 # build expected packet
1777 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001778 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1779 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1780 ip_src=ip_src, ip_dst=ip_dst )
1781 pkt = str( exp_pkt )
1782 verify_packet( self, pkt, out_port )
1783 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001784 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001785 delete_all_flows( self.controller )
1786 delete_groups( self.controller, Groups )
1787 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001788
Flavio Castroa7162bb2016-07-25 17:30:30 -07001789
1790class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001791 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07001792
Flavio Castroa7162bb2016-07-25 17:30:30 -07001793 def runTest( self ):
1794 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001795 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001796 if len( config[ "port_map" ] ) < 2:
1797 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001798 return
Flavio Castro91d1a552016-05-17 16:59:44 -07001799
Flavio Castroa7162bb2016-07-25 17:30:30 -07001800 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1801 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001802 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001803 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001804 for port in ports:
1805 # add l2 interface group
1806 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001807 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
1808 is_tagged=True, send_barrier=False )
1809 dst_mac[ 5 ] = vlan_id
1810 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
1811 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001812 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001813 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001814 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001815 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001816 # add unicast routing flow
1817 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001818 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1819 Groups.put( l2gid )
1820 Groups.put( l3_msg.group_id )
1821 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001822 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07001823 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
1824 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001825
Flavio Castroa7162bb2016-07-25 17:30:30 -07001826 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001827 for in_port in ports:
1828 mac_src = '00:00:00:22:22:%02X' % (in_port)
1829 ip_src = '192.168.%02d.1' % (in_port)
1830 for out_port in ports:
1831 if in_port == out_port:
1832 continue
1833 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001834 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1835 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1836 pkt = str( parsed_pkt )
1837 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001838 # build expected packet
1839 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001840 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
1841 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1842 pkt = str( exp_pkt )
1843 verify_packet( self, pkt, out_port )
1844 verify_no_other_packets( self )
1845 ip_dst = '1.168.%02d.1' % ports[ 0 ]
1846 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1847 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1848 pkt = str( parsed_pkt )
1849 self.dataplane.send( in_port, pkt )
1850 # build expect packet
1851 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
1852 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
1853 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
1854 pkt = str( exp_pkt )
1855 verify_packet( self, pkt, ports[ 0 ] )
1856 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001857 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001858 delete_all_flows( self.controller )
1859 delete_groups( self.controller, Groups )
1860 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001861
Flavio Castroa7162bb2016-07-25 17:30:30 -07001862
1863class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001864 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001865 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04001866 """
Flavio Castro91d1a552016-05-17 16:59:44 -07001867
Flavio Castroa7162bb2016-07-25 17:30:30 -07001868 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001869 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001870 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001871 vlan_id = 1;
1872 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001873 add_l2_unfiltered_group( self.controller, [ port ], False )
1874 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001875 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001876 delete_all_flows( self.controller )
1877 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001878
Saurav Das34992182017-04-14 15:59:48 -07001879@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001880class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001881 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001882 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04001883 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001884
1885 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04001886 """
1887 port1 (vlan 1)-> port 2 (vlan 2)
1888 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001889 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001890 delete_all_flows( self.controller )
1891 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04001892
Flavio Castroa7162bb2016-07-25 17:30:30 -07001893 if len( config[ "port_map" ] ) < 3:
1894 logging.info( "Port count less than 3, can't run this case" )
1895 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001896 return
Flavio Castro423df652016-05-17 20:14:08 -04001897
Flavio Castroa7162bb2016-07-25 17:30:30 -07001898 vlan_id = 1
1899 port2_out_vlan = 2
1900 port3_out_vlan = 3
1901 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
1902 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1903 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1904 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
1905 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1906 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
1907 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
1908 src_ip = 0xc0a80101
1909 src_ip_str = "192.168.1.1"
1910 dst_ip = 0xe0010101
1911 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04001912
Flavio Castroa7162bb2016-07-25 17:30:30 -07001913 port1 = config[ "port_map" ].keys( )[ 0 ]
1914 port2 = config[ "port_map" ].keys( )[ 1 ]
1915 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04001916
Flavio Castroa7162bb2016-07-25 17:30:30 -07001917 # add l2 interface group
1918 for port in config[ "port_map" ].keys( ):
1919 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
1920 send_barrier=False )
1921 # add vlan flow table
1922 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1923 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04001924
Flavio Castroa7162bb2016-07-25 17:30:30 -07001925 # add termination flow
1926 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
1927 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04001928
Flavio Castroa7162bb2016-07-25 17:30:30 -07001929 # add MPLS interface group
1930 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
1931 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1932 port2_out_vlan, port2 )
1933 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1934 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1935 # add L3VPN groups
1936 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
1937 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
1938 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
1939 # 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 -07001940 # 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 -04001941
Flavio Castroa7162bb2016-07-25 17:30:30 -07001942 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
1943 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 -04001944
Flavio Castroa7162bb2016-07-25 17:30:30 -07001945 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
1946 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
1947 pkt = str( parsed_pkt )
1948 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001949 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001950 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
1951 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
1952 pkt = str( exp_pkt )
1953 verify_packet( self, pkt, port2 )
1954 # verify_packet(self, pkt, port3)
1955 verify_no_other_packets( self )
1956 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001957 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001958 delete_all_flows( self.controller )
1959 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001960
Saurav Das34992182017-04-14 15:59:48 -07001961@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001962class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001963 """
1964 Test packet in function on a src-mac miss
1965 Send a packet to each dataplane port and verify that a packet
1966 in message is received from the controller for each
1967 #todo verify you stop receiving after adding rule
1968 """
1969
Flavio Castroa7162bb2016-07-25 17:30:30 -07001970 def runTest( self ):
1971 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001972 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001973 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04001974
Flavio Castroa7162bb2016-07-25 17:30:30 -07001975 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001976 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001977 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
1978 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1979 Groups.put( L2gid )
1980 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
1981 vlan_pkt = str( parsed_vlan_pkt )
1982 for of_port in config[ "port_map" ].keys( ):
1983 logging.info( "PacketInMiss test, port %d", of_port )
1984 self.dataplane.send( of_port, vlan_pkt )
1985 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
1986 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001987 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001988 delete_all_flows( self.controller )
1989 delete_all_groups( self.controller )
1990
1991
1992class EcmpGroupMod( base_tests.SimpleDataPlane ):
1993 """
Saurav Das34992182017-04-14 15:59:48 -07001994 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07001995 """
1996
1997 def runTest( self ):
1998 Groups = Queue.LifoQueue( )
1999 try:
2000 if len( config[ "port_map" ] ) < 2:
2001 logging.info( "Port count less than 2, can't run this case" )
2002 return
2003
2004 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2005 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2006 dip = 0xc0a80001
2007 # Hashes Test Name and uses it as id for installing unique groups
2008 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002009 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002010 dst_ips = []
2011 # add flows for all ports but include only the egress switchport (connected to ports[1])
2012 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002013 for port in ports:
2014 vlan_id = port
2015 id = port
2016 # add l2 interface group
2017 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2018 is_tagged=True, send_barrier=False )
2019 dst_mac[ 5 ] = vlan_id
2020 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2021 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002022 if port == ports[1]:
2023 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002024 Groups._put( l2_gid )
2025 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002026 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002027 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002028 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002029 # add termination flow
2030 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2031 # add unicast routing flow
2032 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002033 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002034 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002035 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002036 for dst_ip in dst_ips:
2037 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2038 time.sleep(0.1)
2039 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002040 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002041 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002042 in_port = ports[0]
2043 out_port = ports[1]
2044 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2045 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2046 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2047 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2048 tcp = out_port if out_port == 24 else 25
2049 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2050 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2051 ip_dst=ip_dst, tcp_dport=tcp )
2052 pkt = str( parsed_pkt )
2053 self.dataplane.send( ports[ 0 ], pkt )
2054 # build expected packet at egress switchport
2055 mac_dst = '00:00:00:22:22:%02X' % out_port
2056 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2057 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2058 ip_dst=ip_dst, tcp_dport=tcp )
2059 pkt = str( exp_pkt )
2060 verify_packet( self, pkt, out_port )
2061 verify_no_other_packets( self )
2062
2063 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2064 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2065 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002066 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2067 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002068 time.sleep(0.1)
2069 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2070 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2071 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2072 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2073 tcp = port if port == 24 else 25
2074 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2075 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2076 ip_dst=ip_dst,tcp_dport=tcp )
2077 pkt = str( parsed_pkt )
2078 self.dataplane.send( ports[ 0 ], pkt )
2079 # build expected packet
2080 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2081 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2082 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2083 ip_dst=ip_dst,tcp_dport=tcp )
2084 pkt = str( exp_pkt )
2085 verify_packet( self, pkt, ports[ 0 ] )
2086 verify_no_other_packets( self )
2087
2088 # third part of the test - edit the group to completely remove bucket. Packet sent
2089 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002090 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002091 time.sleep(0.1)
2092 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
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 = port if 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 verify_no_other_packets( self )
2103
2104 # final part of the test - edit the empty group to add back the bucket for the
2105 # original egress port, and verify packet is received on egress switch port
2106 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2107 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2108 time.sleep(0.1)
2109 in_port = ports[0]
2110 out_port = ports[1]
2111 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2112 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2113 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2114 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2115 tcp = out_port if out_port == 24 else 25
2116 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2117 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2118 ip_dst=ip_dst, tcp_dport=tcp )
2119 pkt = str( parsed_pkt )
2120 self.dataplane.send( ports[ 0 ], pkt )
2121 # build expected packet at egress switchport
2122 mac_dst = '00:00:00:22:22:%02X' % out_port
2123 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2124 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2125 ip_dst=ip_dst, tcp_dport=tcp )
2126 pkt = str( exp_pkt )
2127 verify_packet( self, pkt, out_port )
2128 verify_no_other_packets( self )
2129
Flavio Castroa7162bb2016-07-25 17:30:30 -07002130 finally:
2131 delete_all_flows( self.controller )
2132 delete_groups( self.controller, Groups )
2133 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002134
Saurav Das34992182017-04-14 15:59:48 -07002135
Pier8b223022016-08-19 22:47:49 -07002136class Untagged( base_tests.SimpleDataPlane ):
2137 """
2138 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2139 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2140 previous versions of the OFDPA.
2141
2142 Two rules are necessary in VLAN table (10):
2143 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2144 2) Filtering: match 0x100A/0x1FFF, goto 20
2145
2146 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2147 The remaining part of the test is based on the use of the bridging table
2148 """
2149
2150 MAX_INTERNAL_VLAN = 4094
2151
2152 def runTest( self ):
2153 groups = Queue.LifoQueue( )
2154 try:
2155 if len( config[ "port_map" ] ) < 2:
2156 logging.info( "Port count less than 2, can't run this case" )
2157 return
2158
2159 ports = sorted( config[ "port_map" ].keys( ) )
2160 for port in ports:
2161 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002162 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2163 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002164 for other_port in ports:
2165 if other_port == port:
2166 continue
2167 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2168 groups.put( L2gid )
2169 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2170
2171 do_barrier( self.controller )
2172
2173 for out_port in ports:
2174 # change dest based on port number
2175 mac_dst = '00:12:34:56:78:%02X' % out_port
2176 for in_port in ports:
2177 if in_port == out_port:
2178 continue
2179 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2180 self.dataplane.send( in_port, pkt )
2181 for ofport in ports:
2182 if ofport in [ out_port ]:
2183 verify_packet( self, pkt, ofport )
2184 else:
2185 verify_no_packet( self, pkt, ofport )
2186 verify_no_other_packets( self )
2187 finally:
2188 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002189 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002190 delete_all_groups( self.controller )