blob: 1b6d2d4d62cfd21cf39032b90b84af8248bfbe4c [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Flavio Castro05d20bc2015-11-16 15:06:14 -050017"""
Flavio Castro423df652016-05-17 20:14:08 -040018Check README file
Flavio Castro05d20bc2015-11-16 15:06:14 -050019"""
Flavio Castro1c9b1252016-02-04 18:42:58 -050020import Queue
Flavio Castro05d20bc2015-11-16 15:06:14 -050021
Flavio Castro05d20bc2015-11-16 15:06:14 -050022from oftest import config
Flavio Castro67d8bd52016-02-03 14:22:14 -050023import inspect
Flavio Castro167f5bd2015-12-02 19:33:53 -050024import logging
25import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050026import ofp
Saurav Das34992182017-04-14 15:59:48 -070027import time
Flavio Castro05d20bc2015-11-16 15:06:14 -050028from oftest.testutils import *
29from accton_util import *
Pierbbdf3782016-08-22 17:58:26 -070030from utils import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050031
Flavio Castroa7162bb2016-07-25 17:30:30 -070032class PacketInUDP( base_tests.SimpleDataPlane ):
Flavio Castro6d498522015-12-15 14:05:04 -050033 """
Flavio Castro76c5b262016-07-27 19:53:00 -070034 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 -050035 """
36
Flavio Castroa7162bb2016-07-25 17:30:30 -070037 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -070038 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -070039 parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
40 vlan_pkt = str( parsed_vlan_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070041 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -070042 match = ofp.match( )
43 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
44 match.oxm_list.append( ofp.oxm.ip_proto( 2 ) )
45 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
46 ofp.instruction.apply_actions( actions=[
47 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
48 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
49 logging.info( "Inserting packet in flow to controller" )
50 self.controller.message_send( request )
Flavio Castro1c9b1252016-02-04 18:42:58 -050051
Flavio Castroa7162bb2016-07-25 17:30:30 -070052 for of_port in config[ "port_map" ].keys( ):
53 logging.info( "PacketInMiss test, port %d", of_port )
54 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -050055
Flavio Castroa7162bb2016-07-25 17:30:30 -070056 verify_no_packet_in( self, vlan_pkt, of_port )
57 delete_all_flows( self.controller )
58 do_barrier( self.controller )
Flavio Castro6d498522015-12-15 14:05:04 -050059
Flavio Castroa7162bb2016-07-25 17:30:30 -070060 match = ofp.match( )
61 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
62 match.oxm_list.append( ofp.oxm.ip_proto( 17 ) )
63 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
64 ofp.instruction.apply_actions( actions=[
65 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
66 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
67 logging.info( "Inserting packet in flow to controller" )
68 self.controller.message_send( request )
69 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050070
Flavio Castroa7162bb2016-07-25 17:30:30 -070071 for of_port in config[ "port_map" ].keys( ):
72 logging.info( "PacketInMiss test, port %d", of_port )
73 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro6d498522015-12-15 14:05:04 -050074
Flavio Castroa7162bb2016-07-25 17:30:30 -070075 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro6d498522015-12-15 14:05:04 -050076
Flavio Castroa7162bb2016-07-25 17:30:30 -070077 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070078 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -070079 delete_all_flows( self.controller )
80 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050081
Flavio Castroaf2b4502016-02-02 17:41:32 -050082
Flavio Castro67d8bd52016-02-03 14:22:14 -050083@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -070084class ArpNL2( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -070085 """
86 Needs a description, disabled for now. Also needs try/finally
87 """
Flavio Castroa7162bb2016-07-25 17:30:30 -070088 def runTest( self ):
89 delete_all_flows( self.controller )
90 delete_all_groups( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050091
Flavio Castroa7162bb2016-07-25 17:30:30 -070092 ports = sorted( config[ "port_map" ].keys( ) )
93 match = ofp.match( )
94 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
95 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
96 ofp.instruction.apply_actions( actions=[
97 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
98 buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
99 self.controller.message_send( request )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500100 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700101 add_one_l2_interface_group( self.controller, port, 1, False, False )
102 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
103 group_id = encode_l2_interface_group_id( 1, port )
104 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
105 do_barrier( self.controller )
106 parsed_arp_pkt = simple_arp_packet( )
107 arp_pkt = str( parsed_arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500108
109 for out_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700110 self.dataplane.send( out_port, arp_pkt )
111 verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500112 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500113 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500114 for in_port in ports:
115 if in_port == out_port:
116 continue
117 # change source based on port number to avoid packet-ins from learning
Flavio Castro1c9b1252016-02-04 18:42:58 -0500118 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700119 parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
120 pkt = str( parsed_pkt )
121 self.dataplane.send( in_port, pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500122
123 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700124 if ofport in [ out_port ]:
125 verify_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500126 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700127 verify_no_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500128
Flavio Castroa7162bb2016-07-25 17:30:30 -0700129 verify_no_other_packets( self )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500130
Flavio Castroa7162bb2016-07-25 17:30:30 -0700131class PacketInArp( base_tests.SimpleDataPlane ):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500132 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700133 Verify Packet-in message from eth_type 0x806 on ACL table
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500134 """
135
Flavio Castroa7162bb2016-07-25 17:30:30 -0700136 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700137 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700138 parsed_arp_pkt = simple_arp_packet( )
139 arp_pkt = str( parsed_arp_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700140 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -0700141 match = ofp.match( )
142 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
143 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
144 ofp.instruction.apply_actions( actions=[
145 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
146 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500147
Saurav Das34992182017-04-14 15:59:48 -0700148 logging.info( "Inserting arp flow " )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700149 self.controller.message_send( request )
150 do_barrier( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500151
Flavio Castroa7162bb2016-07-25 17:30:30 -0700152 for of_port in config[ "port_map" ].keys( ):
Saurav Das34992182017-04-14 15:59:48 -0700153 logging.info( "PacketInArp test, sending arp packet to port %d", of_port )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700154 self.dataplane.send( of_port, arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500155
Flavio Castroa7162bb2016-07-25 17:30:30 -0700156 verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500157
Flavio Castroa7162bb2016-07-25 17:30:30 -0700158 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700159 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700160 delete_all_flows( self.controller )
161 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500162
Saurav Das34992182017-04-14 15:59:48 -0700163@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700164class PacketInIPTable( base_tests.SimpleDataPlane ):
Flavio Castro91d1a552016-05-17 16:59:44 -0700165 """
Pier265ad5f2017-02-28 17:46:28 +0100166 Verify Packet-in message from IP table when controller action is used
Flavio Castro91d1a552016-05-17 16:59:44 -0700167 Send a packet to each dataplane port and verify that a packet
168 in message is received from the controller for each
169 #todo verify you stop receiving after adding rule
170 """
171
Flavio Castroa7162bb2016-07-25 17:30:30 -0700172 def runTest( self ):
173 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700174 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700175 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
176 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
177 dip = 0xc0a80001
178 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro91d1a552016-05-17 16:59:44 -0700179
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700180 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700181 # add l2 interface group
182 vlan_id = port
183 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
184 send_barrier=False )
185 dst_mac[ 5 ] = vlan_id
186 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
187 src_mac=intf_src_mac, dst_mac=dst_mac )
188 # add vlan flow table
TonyChouaf5505c2017-08-24 09:11:19 +0800189 add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700190 # add termination flow
191 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
192 # add unicast routing flow
193 dst_ip = dip + (vlan_id << 8)
194 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
195 send_ctrl=True )
196 Groups.put( l3_msg.group_id )
Flavio Castro91d1a552016-05-17 16:59:44 -0700197
Flavio Castroa7162bb2016-07-25 17:30:30 -0700198 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700199
Flavio Castroa7162bb2016-07-25 17:30:30 -0700200 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700201 for in_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700202 mac_src = '00:00:00:22:22:%02X' % in_port
203 ip_src = '192.168.%02d.1' % in_port
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700204 for out_port in ports:
205 if in_port == out_port:
206 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700207 ip_dst = '192.168.%02d.1' % out_port
208 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
209 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
210 pkt = str( parsed_pkt )
211 self.dataplane.send( in_port, pkt )
212 verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
213 # verify_no_other_packets(self)
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700214 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700215 delete_all_flows( self.controller )
216 delete_groups( self.controller, Groups )
217 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700218
Flavio Castroa7162bb2016-07-25 17:30:30 -0700219
220class L2FloodQinQ( base_tests.SimpleDataPlane ):
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500221 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700222 Verify Vlan based flooding of QinQ based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500223 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500224
Flavio Castroa7162bb2016-07-25 17:30:30 -0700225 def runTest( self ):
226 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700227 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700228 ports = sorted( config[ "port_map" ].keys( ) )
Saurav Dase94ba572017-04-28 17:47:21 -0700229 vlan_id = 100
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500230
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700231 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700232 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Saurav Das15c2c262017-05-06 18:12:38 -0700233 add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700234 Groups.put( L2gid )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500235
Flavio Castroa7162bb2016-07-25 17:30:30 -0700236 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
237 Groups.put( msg.group_id )
238 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
239 do_barrier( self.controller )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500240
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700241 # verify flood
242 for ofport in ports:
243 # change dest based on port number
244 mac_src = '00:12:34:56:78:%02X' % ofport
Flavio Castroa7162bb2016-07-25 17:30:30 -0700245 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
246 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
247 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
248 pkt = str( parsed_pkt )
249 self.dataplane.send( ofport, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700250 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700251 verify_no_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700252 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700253 tmp_ports = list( ports )
254 tmp_ports.remove( ofport )
255 verify_packets( self, pkt, tmp_ports )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500256
Flavio Castroa7162bb2016-07-25 17:30:30 -0700257 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700258 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700259 delete_all_flows( self.controller )
260 delete_groups( self.controller, Groups )
261 delete_all_groups( self.controller )
262
Flavio Castro1c9b1252016-02-04 18:42:58 -0500263
Saurav Dase94ba572017-04-28 17:47:21 -0700264
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500265@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700266class L2FloodTagged( base_tests.SimpleDataPlane ):
Flavio Castro184cefe2015-11-19 20:52:49 -0500267 """
Saurav Das34992182017-04-14 15:59:48 -0700268 currently disabled; fix with try/finally
Flavio Castro184cefe2015-11-19 20:52:49 -0500269 Test L2 flood to a vlan
270 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 -0500271 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500272
Flavio Castroa7162bb2016-07-25 17:30:30 -0700273 def runTest( self ):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500274 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700275 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500276 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500277
Flavio Castroa7162bb2016-07-25 17:30:30 -0700278 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro34352e72015-12-07 20:01:51 -0500279
Flavio Castroa7162bb2016-07-25 17:30:30 -0700280 delete_all_flows( self.controller )
281 delete_all_groups( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500282
Flavio Castro184cefe2015-11-19 20:52:49 -0500283 # Installing flows to avoid packet-in
284 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700285 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
286 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
287 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
288 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
289 do_barrier( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500290
Flavio Castro1c9b1252016-02-04 18:42:58 -0500291 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500292 for ofport in ports:
293 # change dest based on port number
Flavio Castroa7162bb2016-07-25 17:30:30 -0700294 pkt = str(
295 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
296 self.dataplane.send( ofport, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500297 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700298 verify_no_packet( self, pkt, ofport )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500299 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700300 tmp_ports = list( ports )
301 tmp_ports.remove( ofport )
302 verify_packets( self, pkt, tmp_ports )
303 verify_no_other_packets( self )
Flavio Castroaabb5792015-11-18 19:03:50 -0500304
Flavio Castro1c9b1252016-02-04 18:42:58 -0500305
Flavio Castroa7162bb2016-07-25 17:30:30 -0700306class L2UnicastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700307 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500308
Flavio Castroa7162bb2016-07-25 17:30:30 -0700309 def runTest( self ):
Flavio Castrob01d0aa2016-07-20 16:14:48 -0700310
Flavio Castroa7162bb2016-07-25 17:30:30 -0700311 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700312 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700313 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700314 vlan_id = 1;
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700315 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700316 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
317 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
318 Groups.put( L2gid )
319 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
320 True )
321 do_barrier( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500322
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700323 for out_port in ports:
324 # change dest based on port number
325 mac_dst = '00:12:34:56:78:%02X' % out_port
326 for in_port in ports:
327 if in_port == out_port:
328 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700329 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
330 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700331 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700332 if ofport in [ out_port ]:
333 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700334 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700335 verify_no_packet( self, pkt, ofport )
336 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700337 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700338 delete_all_flows( self.controller )
339 delete_groups( self.controller, Groups )
340 delete_all_groups( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500341
Flavio Castroa7162bb2016-07-25 17:30:30 -0700342
343class Mtu1500( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700344 """
345 Verifies basic mtu limits
346 """
347
Flavio Castroa7162bb2016-07-25 17:30:30 -0700348 def runTest( self ):
349 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700350 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700351 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700352 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700353 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700354 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Pier265ad5f2017-02-28 17:46:28 +0100355 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700356 Groups.put( L2gid )
357 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
358 True )
359 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500360
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700361 for out_port in ports:
362 # change dest based on port number
363 mac_dst = '00:12:34:56:78:%02X' % out_port
364 for in_port in ports:
365 if in_port == out_port:
366 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700367 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
368 eth_dst=mac_dst ) )
369 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700370 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700371 if ofport in [ out_port ]:
372 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700373 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700374 verify_no_packet( self, pkt, ofport )
375 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700376 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700377 delete_all_flows( self.controller )
378 delete_groups( self.controller, Groups )
379 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500380
Flavio Castroa7162bb2016-07-25 17:30:30 -0700381
382class _32UcastTagged( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700383 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500384
Flavio Castroa7162bb2016-07-25 17:30:30 -0700385 def runTest( self ):
386 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700387 try:
388 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700389 if len( config[ "port_map" ] ) < 2:
390 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700391 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700392 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
393 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700394 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700395 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700396 for port in ports:
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700397 vlan_id = port + test_id
Saurav Dase94ba572017-04-28 17:47:21 -0700398 # add l2 interface group and l3 unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700399 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
400 is_tagged=True, send_barrier=False )
401 dst_mac[ 5 ] = vlan_id
402 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
403 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700404 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100405 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700406 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700407 if config["switch_type"] == "qmx":
408 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
409 else:
410 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700411 # add unicast routing flow
412 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700413 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
414 Groups.put( l2gid )
415 Groups.put( l3_msg.group_id )
416 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500417
Flavio Castroa7162bb2016-07-25 17:30:30 -0700418 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700419 for in_port in ports:
420 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
421 ip_src = '192.168.%02d.1' % (test_id + in_port)
422 for out_port in ports:
423 if in_port == out_port:
424 continue
425 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700426 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
427 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
428 ip_src=ip_src, ip_dst=ip_dst )
429 pkt = str( parsed_pkt )
430 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700431 # build expected packet
432 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700433 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
434 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
435 ip_src=ip_src, ip_dst=ip_dst )
436 pkt = str( exp_pkt )
437 verify_packet( self, pkt, out_port )
438 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700439 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700440 delete_all_flows( self.controller )
441 delete_groups( self.controller, Groups )
442 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500443
Saurav Das34992182017-04-14 15:59:48 -0700444@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700445class _32VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700446 """
447 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
448 No ECMP group used
449 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500450
Flavio Castroa7162bb2016-07-25 17:30:30 -0700451 def runTest( self ):
452 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700453 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700454 if len( config[ "port_map" ] ) < 2:
455 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700456 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500457
Flavio Castroa7162bb2016-07-25 17:30:30 -0700458 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
459 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700460 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700461 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700462 for port in ports:
463 # add l2 interface group
464 id = port
465 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700466 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
467 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700468 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700469 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
470 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700471 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700472 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
473 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
474 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700475 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700476 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100477 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700478 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700479 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700480 if config["switch_type"] == "qmx":
481 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
482 else:
483 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700484 # add routing flow
485 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700486 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
487 Groups._put( l2_gid )
488 Groups._put( mpls_gid )
489 Groups._put( mpls_label_gid )
490 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500491
Flavio Castroa7162bb2016-07-25 17:30:30 -0700492 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700493 for in_port in ports:
494 ip_src = '192.168.%02d.1' % (in_port)
495 for out_port in ports:
496 if in_port == out_port:
497 continue
498 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700499 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
500 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
501 pkt = str( parsed_pkt )
502 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700503 # build expect packet
504 mac_dst = '00:00:00:22:22:%02X' % (out_port)
505 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700506 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
507 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
508 label=[ label ] )
509 pkt = str( exp_pkt )
510 verify_packet( self, pkt, out_port )
511 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700512 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700513 delete_all_flows( self.controller )
514 delete_groups( self.controller, Groups )
515 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500516
Saurav Das34992182017-04-14 15:59:48 -0700517@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700518class _32EcmpVpn( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700519 """
520 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
521 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500522
Flavio Castroa7162bb2016-07-25 17:30:30 -0700523 def runTest( self ):
524 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700525 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700526 if len( config[ "port_map" ] ) < 2:
527 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700528 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500529
Flavio Castroa7162bb2016-07-25 17:30:30 -0700530 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
531 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700532 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700533 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700534 for port in ports:
535 # add l2 interface group
536 id = port
537 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700538 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
539 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700540 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700541 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
542 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700543 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700544 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
545 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
546 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
547 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
548 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700549 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100550 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700551 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700552 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700553 if config["switch_type"] == "qmx":
554 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
555 else:
556 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700557 # add routing flow
558 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700559 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
560 Groups._put( l2_gid )
561 Groups._put( mpls_gid )
562 Groups._put( mpls_label_gid )
563 Groups._put( ecmp_msg.group_id )
564 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500565
Flavio Castroa7162bb2016-07-25 17:30:30 -0700566 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700567 for in_port in ports:
568 ip_src = '192.168.%02d.1' % (in_port)
569 for out_port in ports:
570 if in_port == out_port:
571 continue
572 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700573 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
574 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
575 pkt = str( parsed_pkt )
576 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700577 # build expect packet
578 mac_dst = '00:00:00:22:22:%02X' % (out_port)
579 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700580 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
581 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
582 label=[ label ] )
583 pkt = str( exp_pkt )
584 verify_packet( self, pkt, out_port )
585 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -0700586
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700587 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700588 delete_all_flows( self.controller )
589 delete_groups( self.controller, Groups )
590 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500591
Flavio Castroa7162bb2016-07-25 17:30:30 -0700592
Saurav Das34992182017-04-14 15:59:48 -0700593@disabled
594class One_32EcmpVpn( base_tests.SimpleDataPlane ):
595 """
596 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
597 in only one direction
598 """
599
600 def runTest( self ):
601 Groups = Queue.LifoQueue( )
602 try:
603 if len( config[ "port_map" ] ) < 2:
604 logging.info( "Port count less than 2, can't run this case" )
605 return
606
607 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
608 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
609 dip = 0xc0a80001
610 ports = config[ "port_map" ].keys( )
611 # add l2 interface group
612 id = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700613 in_offset = 19
614 out_offset = 20
615 vlan_id = ports[1] + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700616 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
Saurav Das1ab6a142017-04-25 14:42:25 -0700617 dst_mac[ 5 ] = ports[1]
Saurav Das34992182017-04-14 15:59:48 -0700618 # add MPLS interface group
619 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
620 vlan_id, id )
621 # add MPLS L3 VPN group
622 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
623 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
Saurav Das1ab6a142017-04-25 14:42:25 -0700624 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
Saurav Das34992182017-04-14 15:59:48 -0700625 # add ECMP group
626 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
627 do_barrier( self.controller )
628 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700629 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 -0700630 flag=VLAN_TABLE_FLAG_ONLY_TAG )
631 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700632 if config["switch_type"] == "qmx":
633 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
634 else:
635 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700636 # add routing flow
637 dst_ip = dip + (vlan_id << 8)
638 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
639 Groups._put( l2_gid )
640 Groups._put( mpls_gid )
641 Groups._put( mpls_label_gid )
642 Groups._put( ecmp_msg.group_id )
643
644
645 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
646 in_port = ports[0]
647 out_port = ports[1]
648 ip_src = '192.168.%02d.1' % (in_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700649 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
650 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
Saurav Das34992182017-04-14 15:59:48 -0700651 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
652 pkt = str( parsed_pkt )
653 self.dataplane.send( in_port, pkt )
654 # build expect packet
655 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700656 label = (out_port+out_offset, 0, 1, 32)
657 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 -0700658 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
Saurav Das1ab6a142017-04-25 14:42:25 -0700659 label=[ label ] )
Saurav Das34992182017-04-14 15:59:48 -0700660 pkt = str( exp_pkt )
661 verify_packet( self, pkt, out_port )
662 #verify_no_other_packets( self )
663
664 finally:
665 delete_all_flows( self.controller )
666 delete_group(self.controller, ecmp_msg.group_id)
667 delete_group(self.controller, mpls_label_gid)
668 delete_group(self.controller, mpls_gid)
669 delete_group(self.controller, l2_gid)
670
671
Flavio Castroa7162bb2016-07-25 17:30:30 -0700672class _32ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700673 """
674 Verifies /32 IP routing and ECMP with no label push
675 IP -> L3ECMP -> L3Unicast -> L2Interface
676 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500677
Flavio Castroa7162bb2016-07-25 17:30:30 -0700678 def runTest( self ):
679 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700680 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700681 if len( config[ "port_map" ] ) < 2:
682 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700683 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500684
Flavio Castroa7162bb2016-07-25 17:30:30 -0700685 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
686 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700687 dip = 0xc0a80001
688 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700689 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700690 for port in ports:
691 vlan_id = port
692 id = port
693 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700694 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
695 is_tagged=True, send_barrier=False )
696 dst_mac[ 5 ] = vlan_id
697 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
698 src_mac=intf_src_mac, dst_mac=dst_mac )
699 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700700 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100701 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700702 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700703 if config["switch_type"] == "qmx":
704 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
705 else:
706 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700707 # add unicast routing flow
708 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700709 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
710 Groups._put( l2_gid )
711 Groups._put( l3_msg.group_id )
712 Groups._put( ecmp_msg.group_id )
713 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500714
Flavio Castroa7162bb2016-07-25 17:30:30 -0700715 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700716 for in_port in ports:
717 mac_src = '00:00:00:22:22:%02X' % in_port
718 ip_src = '192.168.%02d.1' % in_port
719 for out_port in ports:
720 if in_port == out_port:
721 continue
722 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700723 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
724 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
725 pkt = str( parsed_pkt )
726 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700727 # build expected packet
728 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700729 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
730 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
731 pkt = str( exp_pkt )
732 verify_packet( self, pkt, out_port )
733 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700734 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700735 delete_all_flows( self.controller )
736 delete_groups( self.controller, Groups )
737 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500738
Saurav Das34992182017-04-14 15:59:48 -0700739@disabled
740class One_32ECMPL3( base_tests.SimpleDataPlane ):
741 """
742 Verifies /32 IP routing and ECMP with no label push
743 IP -> L3ECMP -> L3Unicast -> L2Interface
744 in only one direction
745 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700746
Saurav Das34992182017-04-14 15:59:48 -0700747 def runTest( self ):
748 Groups = Queue.LifoQueue( )
749 try:
750 if len( config[ "port_map" ] ) < 2:
751 logging.info( "Port count less than 2, can't run this case" )
752 return
753
754 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
755 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
756 dip = 0xc0a80001
757 # Hashes Test Name and uses it as id for installing unique groups
758 ports = config[ "port_map" ].keys( )
759 inport = ports[0]
760 outport = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700761 in_offset = 19
762 out_offset = 20
763 vlan_id = outport + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700764 id = outport
765 # add l2 interface group, l3 unicast and ecmp group for outport
766 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
767 is_tagged=True, send_barrier=False )
Saurav Das1ab6a142017-04-25 14:42:25 -0700768 dst_mac[ 5 ] = outport
Saurav Das34992182017-04-14 15:59:48 -0700769 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
770 src_mac=intf_src_mac, dst_mac=dst_mac )
771 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
772 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700773 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 -0700774 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700775 if config["switch_type"] == "qmx":
776 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset )
777 else:
778 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 -0700779 # add unicast routing flow
780 dst_ip = dip + (vlan_id << 8)
781 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
782 Groups._put( l2_gid )
783 Groups._put( l3_msg.group_id )
784 Groups._put( ecmp_msg.group_id )
785
786 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
787 mac_src = '00:00:00:22:22:%02X' % inport
788 ip_src = '192.168.%02d.1' % inport
Saurav Das1ab6a142017-04-25 14:42:25 -0700789 ip_dst = '192.168.%02d.1' % (outport+out_offset)
790 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
Saurav Das34992182017-04-14 15:59:48 -0700791 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
792 pkt = str( parsed_pkt )
793 self.dataplane.send( inport, pkt )
794 # build expected packet
795 mac_dst = '00:00:00:22:22:%02X' % outport
Saurav Das1ab6a142017-04-25 14:42:25 -0700796 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
Saurav Das34992182017-04-14 15:59:48 -0700797 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
798 pkt = str( exp_pkt )
799 verify_packet( self, pkt, outport )
800 verify_no_other_packets( self )
801 finally:
802 delete_all_flows( self.controller )
803 delete_groups( self.controller, Groups )
804 delete_all_groups( self.controller )
805
806
807
808
809@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700810class _24VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700811 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500812
Flavio Castroa7162bb2016-07-25 17:30:30 -0700813 def runTest( self ):
814 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700815 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700816 if len( config[ "port_map" ] ) < 2:
817 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700818 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500819
Flavio Castroa7162bb2016-07-25 17:30:30 -0700820 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
821 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700822 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700823 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700824 for port in ports:
825 # add l2 interface group
826 id = port
827 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700828 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
829 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700830 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700831 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
832 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700833 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700834 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
835 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
836 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700837 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700838 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700839 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100840 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700841 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700842 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700843 if config["switch_type"] == "qmx":
844 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
845 else:
846 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700847 # add routing flow
848 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700849 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
850 Groups._put( l2_gid )
851 Groups._put( mpls_gid )
852 Groups._put( mpls_label_gid )
853 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500854
Flavio Castroa7162bb2016-07-25 17:30:30 -0700855 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700856 for in_port in ports:
857 ip_src = '192.168.%02d.1' % (in_port)
858 for out_port in ports:
859 if in_port == out_port:
860 continue
861 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700862 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
863 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
864 pkt = str( parsed_pkt )
865 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700866 # build expect packet
867 mac_dst = '00:00:00:22:22:%02X' % (out_port)
868 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700869 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
870 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
871 label=[ label ] )
872 pkt = str( exp_pkt )
873 verify_packet( self, pkt, out_port )
874 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700875 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700876 delete_all_flows( self.controller )
877 delete_groups( self.controller, Groups )
878 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500879
Saurav Das34992182017-04-14 15:59:48 -0700880@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700881class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700882 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -0500883
Flavio Castroa7162bb2016-07-25 17:30:30 -0700884 def runTest( self ):
885 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700886 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700887 if len( config[ "port_map" ] ) < 2:
888 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700889 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700890 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
891 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700892 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700893 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700894 for port in ports:
895 # add l2 interface group
896 id = port
897 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -0700898 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
899 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700900 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700901 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
902 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700903 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700904 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
905 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
906 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
907 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
908 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700909 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100910 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700911 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700912 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700913 if config["switch_type"] == "qmx":
914 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
915 else:
916 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700917 # add routing flow
918 dst_ip = dip + (vlan_id << 8)
919 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700920 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
921 vrf=0 )
922 Groups._put( l2_gid )
923 Groups._put( mpls_gid )
924 Groups._put( mpls_label_gid )
925 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700926
Flavio Castroa7162bb2016-07-25 17:30:30 -0700927 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -0500928
Flavio Castroa7162bb2016-07-25 17:30:30 -0700929 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700930 for in_port in ports:
931 mac_src = '00:00:00:22:22:%02X' % (in_port)
932 ip_src = '192.168.%02d.1' % (in_port)
933 for out_port in ports:
934 if in_port == out_port:
935 continue
936 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700937 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
938 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
939 pkt = str( parsed_pkt )
940 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700941 # build expect packet
942 mac_dst = '00:00:00:22:22:%02X' % out_port
943 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700944 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
945 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
946 label=[ label ] )
947 pkt = str( exp_pkt )
948 verify_packet( self, pkt, out_port )
949 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700950 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700951 delete_all_flows( self.controller )
952 delete_groups( self.controller, Groups )
953 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500954
Flavio Castroa7162bb2016-07-25 17:30:30 -0700955
956class FloodGroupMod( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700957 """ Modify a referenced flood group """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700958
959 def runTest( self ):
960 Groups = Queue.LifoQueue( )
961 try:
962 ports = sorted( config[ "port_map" ].keys( ) )
963 vlan_id = 1
964
965 for port in ports:
966 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
967 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
968 Groups.put( L2gid )
969
970 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
971 Groups.put( msg.group_id )
972 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
973 do_barrier( self.controller )
974 # verify flood
975 for ofport in ports:
976 # change dest based on port number
977 mac_src = '00:12:34:56:78:%02X' % ofport
978 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
979 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
980 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
981 pkt = str( parsed_pkt )
982 self.dataplane.send( ofport, pkt )
983 # self won't rx packet
984 verify_no_packet( self, pkt, ofport )
985 # others will rx packet
986 tmp_ports = list( ports )
987 tmp_ports.remove( ofport )
988 verify_packets( self, pkt, tmp_ports )
989 verify_no_other_packets( self )
990 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
991 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
992 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
993 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
994 eth_src=mac_src )
995 pkt = str( parsed_pkt )
996 self.dataplane.send( ports[ 1 ], pkt )
997 verify_packets( self, pkt, [ ports[ 0 ] ] )
998 finally:
999 delete_all_flows( self.controller )
1000 delete_groups( self.controller, Groups )
1001 delete_all_groups( self.controller )
1002
1003
1004class _24ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001005 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
Flavio Castro80730822015-12-11 15:38:47 -05001006
Flavio Castroa7162bb2016-07-25 17:30:30 -07001007 def runTest( self ):
1008 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001009 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001010 if len( config[ "port_map" ] ) < 2:
1011 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001012 return
Flavio Castro80730822015-12-11 15:38:47 -05001013
Flavio Castroa7162bb2016-07-25 17:30:30 -07001014 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1015 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001016 dip = 0xc0a80001
1017 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -07001018 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001019 for port in ports:
1020 vlan_id = port
1021 id = port
1022 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001023 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1024 is_tagged=True, send_barrier=False )
1025 dst_mac[ 5 ] = vlan_id
1026 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1027 src_mac=intf_src_mac, dst_mac=dst_mac )
1028 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001029 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001030 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001031 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001032 if config["switch_type"] == "qmx":
1033 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1034 else:
1035 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001036 # add unicast routing flow
1037 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001038 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1039 Groups._put( l2_gid )
1040 Groups._put( l3_msg.group_id )
1041 Groups._put( ecmp_msg.group_id )
1042 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -05001043
Flavio Castroa7162bb2016-07-25 17:30:30 -07001044 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001045 for in_port in ports:
1046 mac_src = '00:00:00:22:22:%02X' % in_port
1047 ip_src = '192.168.%02d.1' % in_port
1048 for out_port in ports:
1049 if in_port == out_port:
1050 continue
1051 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001052 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1053 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1054 pkt = str( parsed_pkt )
1055 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001056 # build expected packet
1057 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001058 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1059 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1060 pkt = str( exp_pkt )
1061 verify_packet( self, pkt, out_port )
1062 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001063 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001064 delete_all_flows( self.controller )
1065 delete_groups( self.controller, Groups )
1066 delete_all_groups( self.controller )
1067
Flavio Castro1c9b1252016-02-04 18:42:58 -05001068
Flavio Castroaba28ff2016-02-03 16:47:48 -05001069@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001070class MPLSBUG( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001071 """
1072 Needs a description or needs to be removed
1073 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001074 def runTest( self ):
1075 if len( config[ "port_map" ] ) < 2:
1076 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -05001077 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001078 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1079 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -05001080 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001081 Groups = Queue.LifoQueue( )
1082 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -05001083 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001084 # add l2 interface group
1085 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001086 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1087 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -05001088 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001089 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1090 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001091 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001092 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001093 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001094 if config["switch_type"] == "qmx":
1095 add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 )
1096 else:
1097 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001098 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001099 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001100 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001101 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001102 # add unicast routing flow
1103 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001104 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1105 Groups._put( l2_gid )
1106 Groups._put( l3_msg.group_id )
1107 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001108
Flavio Castroa7162bb2016-07-25 17:30:30 -07001109 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -05001110 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001111 mac_src = '00:00:00:22:22:%02X' % in_port
1112 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -05001113 for out_port in ports:
1114 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001115 continue
1116 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -05001117 switch_mac = "00:00:00:cc:cc:cc"
1118 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001119 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1120 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1121 pkt = str( parsed_pkt )
1122 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -05001123
Flavio Castro1c9b1252016-02-04 18:42:58 -05001124 # build expect packet
1125 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001126 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1127 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1128 pkt = str( exp_pkt )
1129 verify_packet( self, pkt, out_port )
1130 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001131
Flavio Castroa7162bb2016-07-25 17:30:30 -07001132 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1133 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1134 pkt = str( parsed_pkt )
1135 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001136 # build expected packet
1137 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001138 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1139 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1140 pkt = str( exp_pkt )
1141 verify_packet( self, pkt, out_port )
1142 verify_no_other_packets( self )
1143 delete_all_flows( self.controller )
1144 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001145
Flavio Castroa7162bb2016-07-25 17:30:30 -07001146class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -07001147 """
1148 Mcast routing, in this test case the traffic comes in tagged.
1149 port+1 is used as ingress vlan_id. The packet goes out tagged on
1150 different ports. 4094-port is used as egress vlan_id.
1151 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001152 def runTest( self ):
Pier7b031af2016-08-25 15:00:22 -07001153 """
1154 port1 (vlan 300)-> All Ports (vlan 300)
1155 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001156 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001157 try:
Pierbbdf3782016-08-22 17:58:26 -07001158 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1159 if len( config[ "port_map" ] ) < 1:
1160 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001161 assert (False)
1162 return
Pierbbdf3782016-08-22 17:58:26 -07001163 ports = config[ "port_map" ].keys( )
1164 dst_ip_str = "224.0.0.1"
1165 (
1166 port_to_in_vlan,
1167 port_to_out_vlan,
1168 port_to_src_mac_str,
1169 port_to_dst_mac_str,
1170 port_to_src_ip_str,
1171 port_to_intf_src_mac_str,
1172 Groups) = fill_mcast_pipeline_L3toL3(
1173 self.controller,
1174 logging,
1175 ports,
1176 is_ingress_tagged = True,
1177 is_egress_tagged = True,
1178 is_vlan_translated = True,
1179 is_max_vlan = False
1180 )
Flavio Castro12296312015-12-15 17:48:26 -05001181
Pierbbdf3782016-08-22 17:58:26 -07001182 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001183
Pierbbdf3782016-08-22 17:58:26 -07001184 parsed_pkt = simple_udp_packet(
1185 pktlen = 100,
1186 dl_vlan_enable = True,
1187 vlan_vid = port_to_in_vlan[in_port],
1188 eth_dst = port_to_dst_mac_str[in_port],
1189 eth_src = port_to_src_mac_str[in_port],
1190 ip_ttl = 64,
1191 ip_src = port_to_src_ip_str[in_port],
1192 ip_dst = dst_ip_str
1193 )
1194 pkt = str( parsed_pkt )
1195 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001196
Pierbbdf3782016-08-22 17:58:26 -07001197 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001198
Pierbbdf3782016-08-22 17:58:26 -07001199 parsed_pkt = simple_udp_packet(
1200 pktlen = 100,
1201 dl_vlan_enable = True,
1202 vlan_vid = port_to_out_vlan[out_port],
1203 eth_dst = port_to_dst_mac_str[in_port],
1204 eth_src = port_to_intf_src_mac_str[out_port],
1205 ip_ttl = 63,
1206 ip_src = port_to_src_ip_str[in_port],
1207 ip_dst = dst_ip_str
1208 )
1209 pkt = str( parsed_pkt )
1210 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001211
Pierbbdf3782016-08-22 17:58:26 -07001212 verify_no_other_packets( self )
1213
Pier7b031af2016-08-25 15:00:22 -07001214 finally:
1215 delete_all_flows( self.controller )
1216 delete_groups( self.controller, Groups )
1217 delete_all_groups( self.controller )
1218
1219class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1220 """
1221 Mcast routing, in this test case the traffic is untagged.
1222 4094 is used as internal vlan_id. The packet goes out
1223 untagged.
1224 """
1225 def runTest( self ):
1226 Groups = Queue.LifoQueue( )
1227 try:
1228 if len( config[ "port_map" ] ) < 2:
1229 logging.info( "Port count less than 2, can't run this case" )
1230 assert (False)
1231 return
1232 ports = config[ "port_map" ].keys( )
1233 dst_ip_str = "224.0.0.1"
1234 (
1235 port_to_in_vlan,
1236 port_to_out_vlan,
1237 port_to_src_mac_str,
1238 port_to_dst_mac_str,
1239 port_to_src_ip_str,
1240 Groups) = fill_mcast_pipeline_L3toL2(
1241 self.controller,
1242 logging,
1243 ports,
1244 is_ingress_tagged = False,
1245 is_egress_tagged = False,
1246 is_vlan_translated = False,
1247 is_max_vlan = True
1248 )
1249
1250 for in_port in ports:
1251
1252 parsed_pkt = simple_udp_packet(
1253 pktlen = 96,
1254 eth_dst = port_to_dst_mac_str[in_port],
1255 eth_src = port_to_src_mac_str[in_port],
1256 ip_ttl = 64,
1257 ip_src = port_to_src_ip_str[in_port],
1258 ip_dst = dst_ip_str
1259 )
1260 pkt = str( parsed_pkt )
1261 self.dataplane.send( in_port, pkt )
1262
1263 for out_port in ports:
1264
1265 parsed_pkt = simple_udp_packet(
1266 pktlen = 96,
1267 eth_dst = port_to_dst_mac_str[in_port],
1268 eth_src = port_to_src_mac_str[in_port],
1269 ip_ttl = 64,
1270 ip_src = port_to_src_ip_str[in_port],
1271 ip_dst = dst_ip_str
1272 )
1273 pkt = str( parsed_pkt )
1274 if out_port == in_port:
1275 verify_no_packet( self, pkt, in_port )
1276 continue
1277 verify_packet( self, pkt, out_port )
1278 verify_no_other_packets( self )
1279 finally:
1280 delete_all_flows( self.controller )
1281 delete_groups( self.controller, Groups )
1282 delete_all_groups( self.controller )
1283
1284class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1285 """
1286 Mcast routing, in this test case the traffic is untagged.
1287 300 is used as vlan_id. The packet goes out
1288 tagged.
1289 """
1290 def runTest( self ):
1291 Groups = Queue.LifoQueue( )
1292 try:
1293 if len( config[ "port_map" ] ) < 2:
1294 logging.info( "Port count less than 2, can't run this case" )
1295 assert (False)
1296 return
1297 ports = config[ "port_map" ].keys( )
1298 dst_ip_str = "224.0.0.1"
1299 (
1300 port_to_in_vlan,
1301 port_to_out_vlan,
1302 port_to_src_mac_str,
1303 port_to_dst_mac_str,
1304 port_to_src_ip_str,
1305 Groups) = fill_mcast_pipeline_L3toL2(
1306 self.controller,
1307 logging,
1308 ports,
1309 is_ingress_tagged = False,
1310 is_egress_tagged = True,
1311 is_vlan_translated = False,
1312 is_max_vlan = False
1313 )
1314
1315 for in_port in ports:
1316
1317 parsed_pkt = simple_udp_packet(
1318 pktlen = 96,
1319 eth_dst = port_to_dst_mac_str[in_port],
1320 eth_src = port_to_src_mac_str[in_port],
1321 ip_ttl = 64,
1322 ip_src = port_to_src_ip_str[in_port],
1323 ip_dst = dst_ip_str
1324 )
1325 pkt = str( parsed_pkt )
1326 self.dataplane.send( in_port, pkt )
1327
1328 for out_port in ports:
1329
1330 parsed_pkt = simple_udp_packet(
1331 pktlen = 100,
1332 dl_vlan_enable = True,
1333 vlan_vid = port_to_out_vlan[in_port],
1334 eth_dst = port_to_dst_mac_str[in_port],
1335 eth_src = port_to_src_mac_str[in_port],
1336 ip_ttl = 64,
1337 ip_src = port_to_src_ip_str[in_port],
1338 ip_dst = dst_ip_str
1339 )
1340 pkt = str( parsed_pkt )
1341 if out_port == in_port:
1342 verify_no_packet( self, pkt, in_port )
1343 continue
1344 verify_packet( self, pkt, out_port )
1345 verify_no_other_packets( self )
1346 finally:
1347 delete_all_flows( self.controller )
1348 delete_groups( self.controller, Groups )
1349 delete_all_groups( self.controller )
1350
1351
1352class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1353 """
1354 Mcast routing, in this test case the traffic is tagged.
1355 300 is used as vlan_id. The packet goes out
1356 untagged.
1357 """
1358 def runTest( self ):
1359 Groups = Queue.LifoQueue( )
1360 try:
1361 if len( config[ "port_map" ] ) < 2:
1362 logging.info( "Port count less than 2, can't run this case" )
1363 assert (False)
1364 return
1365 ports = config[ "port_map" ].keys( )
1366 dst_ip_str = "224.0.0.1"
1367 (
1368 port_to_in_vlan,
1369 port_to_out_vlan,
1370 port_to_src_mac_str,
1371 port_to_dst_mac_str,
1372 port_to_src_ip_str,
1373 Groups) = fill_mcast_pipeline_L3toL2(
1374 self.controller,
1375 logging,
1376 ports,
1377 is_ingress_tagged = True,
1378 is_egress_tagged = False,
1379 is_vlan_translated = False,
1380 is_max_vlan = False
1381 )
1382
1383 for in_port in ports:
1384
1385 parsed_pkt = simple_udp_packet(
1386 pktlen = 100,
1387 dl_vlan_enable = True,
1388 vlan_vid = port_to_in_vlan[in_port],
1389 eth_dst = port_to_dst_mac_str[in_port],
1390 eth_src = port_to_src_mac_str[in_port],
1391 ip_ttl = 64,
1392 ip_src = port_to_src_ip_str[in_port],
1393 ip_dst = dst_ip_str
1394 )
1395 pkt = str( parsed_pkt )
1396 self.dataplane.send( in_port, pkt )
1397
1398 for out_port in ports:
1399
1400 parsed_pkt = simple_udp_packet(
1401 pktlen = 96,
1402 eth_dst = port_to_dst_mac_str[in_port],
1403 eth_src = port_to_src_mac_str[in_port],
1404 ip_ttl = 64,
1405 ip_src = port_to_src_ip_str[in_port],
1406 ip_dst = dst_ip_str
1407 )
1408 pkt = str( parsed_pkt )
1409 if out_port == in_port:
1410 verify_no_packet( self, pkt, in_port )
1411 continue
1412 verify_packet( self, pkt, out_port )
1413 verify_no_other_packets( self )
1414 finally:
1415 delete_all_flows( self.controller )
1416 delete_groups( self.controller, Groups )
1417 delete_all_groups( self.controller )
1418
1419class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1420 """
1421 Mcast routing, in this test case the traffic is tagged.
1422 300 is used as vlan_id. The packet goes out tagged.
1423 """
1424 def runTest( self ):
1425 Groups = Queue.LifoQueue( )
1426 try:
1427 if len( config[ "port_map" ] ) < 2:
1428 logging.info( "Port count less than 2, can't run this case" )
1429 assert (False)
1430 return
1431 ports = config[ "port_map" ].keys( )
1432 dst_ip_str = "224.0.0.1"
1433 (
1434 port_to_in_vlan,
1435 port_to_out_vlan,
1436 port_to_src_mac_str,
1437 port_to_dst_mac_str,
1438 port_to_src_ip_str,
1439 Groups) = fill_mcast_pipeline_L3toL2(
1440 self.controller,
1441 logging,
1442 ports,
1443 is_ingress_tagged = True,
1444 is_egress_tagged = True,
1445 is_vlan_translated = False,
1446 is_max_vlan = False
1447 )
1448
1449 for in_port in ports:
1450
1451 parsed_pkt = simple_udp_packet(
1452 pktlen = 100,
1453 dl_vlan_enable = True,
1454 vlan_vid = port_to_in_vlan[in_port],
1455 eth_dst = port_to_dst_mac_str[in_port],
1456 eth_src = port_to_src_mac_str[in_port],
1457 ip_ttl = 64,
1458 ip_src = port_to_src_ip_str[in_port],
1459 ip_dst = dst_ip_str
1460 )
1461 pkt = str( parsed_pkt )
1462 self.dataplane.send( in_port, pkt )
1463
1464 for out_port in ports:
1465
1466 parsed_pkt = simple_udp_packet(
1467 pktlen = 100,
1468 dl_vlan_enable = True,
1469 vlan_vid = port_to_in_vlan[in_port],
1470 eth_dst = port_to_dst_mac_str[in_port],
1471 eth_src = port_to_src_mac_str[in_port],
1472 ip_ttl = 64,
1473 ip_src = port_to_src_ip_str[in_port],
1474 ip_dst = dst_ip_str
1475 )
1476 pkt = str( parsed_pkt )
1477 if out_port == in_port:
1478 verify_no_packet( self, pkt, in_port )
1479 continue
1480 verify_packet( self, pkt, out_port )
1481 verify_no_other_packets( self )
1482 finally:
1483 delete_all_flows( self.controller )
1484 delete_groups( self.controller, Groups )
1485 delete_all_groups( self.controller )
1486
1487class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1488 """
1489 Mcast routing, in this test case the traffic is tagged.
1490 port+1 is used as ingress vlan_id. The packet goes out
1491 tagged. 4094-port is used as egress vlan_id
1492 """
1493 def runTest( self ):
1494 Groups = Queue.LifoQueue( )
1495 try:
1496 if len( config[ "port_map" ] ) < 2:
1497 logging.info( "Port count less than 2, can't run this case" )
1498 assert (False)
1499 return
1500 ports = config[ "port_map" ].keys( )
1501 dst_ip_str = "224.0.0.1"
1502 (
1503 port_to_in_vlan,
1504 port_to_out_vlan,
1505 port_to_src_mac_str,
1506 port_to_dst_mac_str,
1507 port_to_src_ip_str,
1508 Groups) = fill_mcast_pipeline_L3toL2(
1509 self.controller,
1510 logging,
1511 ports,
1512 is_ingress_tagged = True,
1513 is_egress_tagged = True,
1514 is_vlan_translated = True,
1515 is_max_vlan = False
1516 )
1517
1518 for in_port in ports:
1519
1520 parsed_pkt = simple_udp_packet(
1521 pktlen = 100,
1522 dl_vlan_enable = True,
1523 vlan_vid = port_to_in_vlan[in_port],
1524 eth_dst = port_to_dst_mac_str[in_port],
1525 eth_src = port_to_src_mac_str[in_port],
1526 ip_ttl = 64,
1527 ip_src = port_to_src_ip_str[in_port],
1528 ip_dst = dst_ip_str
1529 )
1530 pkt = str( parsed_pkt )
1531 self.dataplane.send( in_port, pkt )
1532
1533 for out_port in ports:
1534
1535 parsed_pkt = simple_udp_packet(
1536 pktlen = 100,
1537 dl_vlan_enable = True,
1538 vlan_vid = port_to_out_vlan[in_port],
1539 eth_dst = port_to_dst_mac_str[in_port],
1540 eth_src = port_to_src_mac_str[in_port],
1541 ip_ttl = 64,
1542 ip_src = port_to_src_ip_str[in_port],
1543 ip_dst = dst_ip_str
1544 )
1545 pkt = str( parsed_pkt )
1546 if out_port == in_port:
1547 verify_no_packet( self, pkt, in_port )
1548 continue
1549 verify_packet( self, pkt, out_port )
1550 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001551 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001552 delete_all_flows( self.controller )
1553 delete_groups( self.controller, Groups )
1554 delete_all_groups( self.controller )
1555
Saurav Das34992182017-04-14 15:59:48 -07001556@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001557class _MplsFwd( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001558 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001559
1560 def runTest( self ):
1561 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001562 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001563 if len( config[ "port_map" ] ) < 2:
1564 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001565 return
1566 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001567 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1568 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001569 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001570 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001571 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001572 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1573 vlan_id = port + 16
1574 mpls_label = port + 16
1575
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001576 # add l2 interface group
1577 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001578 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001579 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001580 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1581 vlan_id, id )
1582 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1583 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001584 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Saurav Das34992182017-04-14 15:59:48 -07001585 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1586 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001587 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001588 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001589 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001590 if config["switch_type"] == "qmx":
1591 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1592 else:
1593 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001594 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Charles Chan53cac542016-08-22 16:03:26 -07001595 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001596 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001597 Groups._put( l2_gid )
1598 Groups._put( mpls_gid )
1599 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001600 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001601 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001602
Flavio Castroa7162bb2016-07-25 17:30:30 -07001603 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001604 for in_port in ports:
1605 ip_src = '192.168.%02d.1' % (in_port)
1606 for out_port in ports:
1607 if in_port == out_port:
1608 continue
Flavio Castro54947942016-02-03 16:05:20 -05001609
Charles Chan53cac542016-08-22 16:03:26 -07001610 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1611 out_mpls_label = out_port + 16
1612 in_vlan_vid = in_port + 16
1613 out_vlan_vid = out_port + 16
1614
1615 ip_dst = '192.168.%02d.1' % (out_port)
1616 label = (out_mpls_label, 0, 1, 32)
1617 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001618 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1619 pkt = str( parsed_pkt )
1620 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001621
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001622 # build expect packet
1623 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001624 label = (out_mpls_label, 0, 1, 31)
1625 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001626 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1627 label=[ label ] )
1628 pkt = str( exp_pkt )
1629 verify_packet( self, pkt, out_port )
1630 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001631 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001632 delete_all_flows( self.controller )
1633 delete_groups( self.controller, Groups )
1634 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001635
Saurav Das34992182017-04-14 15:59:48 -07001636@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001637class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001638 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001639
1640 def runTest( self ):
1641 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001642 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001643 if len( config[ "port_map" ] ) < 2:
1644 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001645 return
1646 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001647 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1648 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001649 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001650 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001651 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001652 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1653 vlan_id = port + 16
1654 mpls_label = port + 16
1655
Flavio Castrod80fbc32016-07-25 15:54:26 -07001656 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001657 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001658 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001659 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001660 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1661 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001662 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001663 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001664 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001665 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001666 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001667 if config["switch_type"] == "qmx":
1668 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1669 else:
1670 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Charles Chan53cac542016-08-22 16:03:26 -07001671 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001672 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001673 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001674 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001675 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001676 Groups._put( l2_gid )
1677 Groups._put( l3_msg.group_id )
1678 Groups._put( ecmp_msg.group_id )
1679 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001680
Flavio Castroa7162bb2016-07-25 17:30:30 -07001681 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001682 for in_port in ports:
1683 ip_src = '192.168.%02d.1' % (in_port)
1684 for out_port in ports:
1685 if in_port == out_port:
1686 continue
Charles Chan53cac542016-08-22 16:03:26 -07001687
1688 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1689 out_mpls_label = out_port + 16
1690 in_vlan_vid = in_port + 16
1691 out_vlan_vid = out_port + 16
1692
Flavio Castrod80fbc32016-07-25 15:54:26 -07001693 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001694 label = (out_mpls_label, 0, 1, 32)
1695 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001696 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1697 pkt = str( parsed_pkt )
1698 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001699 # build expect packet
1700 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001701 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001702 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1703 pkt = str( exp_pkt )
1704 verify_packet( self, pkt, out_port )
1705 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001706 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001707 delete_all_flows( self.controller )
1708 delete_groups( self.controller, Groups )
1709 delete_all_groups( self.controller )
Saurav Das15c2c262017-05-06 18:12:38 -07001710
Saurav Das34992182017-04-14 15:59:48 -07001711
1712@disabled
1713class One_MplsTermination( base_tests.SimpleDataPlane ):
1714 """
1715 Verify MPLS VPN Termination at penultimate hop in only one direction
1716 """
1717
1718 def runTest( self ):
1719 Groups = Queue.LifoQueue( )
1720 try:
1721 if len( config[ "port_map" ] ) < 2:
1722 logging.info( "Port count less than 2, can't run this case" )
1723 return
1724 dip = 0xc0a80001
1725 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1726 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1727 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1728 ports = config[ "port_map" ].keys( )
1729 inport = ports[0]
1730 outport = ports[1]
1731
1732 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1733 invlan_id = inport + 16
1734 outvlan_id = outport + 16
1735 mpls_label = outport + 16
1736
1737 # add l2 interface group
1738 id, dst_mac[ 5 ] = inport, outport
1739 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
1740 # add L3 Unicast group
1741 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
1742 src_mac=intf_src_mac, dst_mac=dst_mac )
1743 # add L3 ecmp group
1744 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1745 # add vlan flow table
1746 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1747 # add tmac flow
Saurav Dase94ba572017-04-28 17:47:21 -07001748 if config["switch_type"] == "qmx":
1749 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
1750 else:
1751 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
Saurav Das34992182017-04-14 15:59:48 -07001752 # add mpls termination flow
1753 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
1754 Groups._put( l2_gid )
1755 Groups._put( l3_msg.group_id )
1756 Groups._put( ecmp_msg.group_id )
1757
1758 time.sleep(0.1)
1759 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1760 ip_src = '192.168.%02d.1' % (inport)
1761 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1762 out_mpls_label = outport + 16
1763 in_vlan_vid = inport + 16
1764 out_vlan_vid = outport + 16
1765
1766 ip_dst = '192.168.%02d.1' % (outport)
1767 label = (out_mpls_label, 0, 1, 32)
1768 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1769 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1770 pkt = str( parsed_pkt )
1771 self.dataplane.send( inport, pkt )
1772 # build expect packet
1773 mac_dst = '00:00:00:22:22:%02X' % (outport)
1774 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1775 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1776 pkt = str( exp_pkt )
1777 verify_packet( self, pkt, outport )
1778 verify_no_other_packets( self )
1779 finally:
1780 delete_all_flows( self.controller )
1781 delete_groups( self.controller, Groups )
1782 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001783
Flavio Castroa7162bb2016-07-25 17:30:30 -07001784
1785class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001786 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001787
Flavio Castroa7162bb2016-07-25 17:30:30 -07001788 def runTest( self ):
1789 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001790 try:
1791 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001792 if len( config[ "port_map" ] ) < 2:
1793 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001794 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001795 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1796 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001797 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001798 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001799 for port in ports:
1800 # add l2 interface group
1801 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001802 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1803 is_tagged=True, send_barrier=False )
1804 dst_mac[ 5 ] = vlan_id
1805 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1806 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001807 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001808 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001809 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001810 if config["switch_type"] == "qmx":
1811 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1812 else:
1813 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001814 # add unicast routing flow
1815 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001816 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1817 Groups.put( l2gid )
1818 Groups.put( l3_msg.group_id )
1819 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001820
Flavio Castroa7162bb2016-07-25 17:30:30 -07001821 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001822 for in_port in ports:
1823 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1824 ip_src = '192.168.%02d.1' % (test_id + in_port)
1825 for out_port in ports:
1826 if in_port == out_port:
1827 continue
1828 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001829 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1830 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1831 ip_src=ip_src, ip_dst=ip_dst )
1832 pkt = str( parsed_pkt )
1833 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001834 # build expected packet
1835 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001836 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1837 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1838 ip_src=ip_src, ip_dst=ip_dst )
1839 pkt = str( exp_pkt )
1840 verify_packet( self, pkt, out_port )
1841 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001842 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001843 delete_all_flows( self.controller )
1844 delete_groups( self.controller, Groups )
1845 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001846
Flavio Castroa7162bb2016-07-25 17:30:30 -07001847
1848class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001849 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07001850
Flavio Castroa7162bb2016-07-25 17:30:30 -07001851 def runTest( self ):
1852 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001853 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001854 if len( config[ "port_map" ] ) < 2:
1855 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001856 return
Flavio Castro91d1a552016-05-17 16:59:44 -07001857
Flavio Castroa7162bb2016-07-25 17:30:30 -07001858 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1859 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001860 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001861 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001862 for port in ports:
1863 # add l2 interface group
1864 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001865 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
1866 is_tagged=True, send_barrier=False )
1867 dst_mac[ 5 ] = vlan_id
1868 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
1869 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001870 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001871 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001872 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001873 if config["switch_type"] == "qmx":
1874 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1875 else:
1876 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001877 # add unicast routing flow
1878 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001879 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1880 Groups.put( l2gid )
1881 Groups.put( l3_msg.group_id )
1882 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001883 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07001884 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
1885 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001886
Flavio Castroa7162bb2016-07-25 17:30:30 -07001887 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001888 for in_port in ports:
1889 mac_src = '00:00:00:22:22:%02X' % (in_port)
1890 ip_src = '192.168.%02d.1' % (in_port)
1891 for out_port in ports:
1892 if in_port == out_port:
1893 continue
1894 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001895 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1896 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1897 pkt = str( parsed_pkt )
1898 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001899 # build expected packet
1900 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001901 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
1902 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1903 pkt = str( exp_pkt )
1904 verify_packet( self, pkt, out_port )
1905 verify_no_other_packets( self )
1906 ip_dst = '1.168.%02d.1' % ports[ 0 ]
1907 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1908 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1909 pkt = str( parsed_pkt )
1910 self.dataplane.send( in_port, pkt )
1911 # build expect packet
1912 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
1913 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
1914 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
1915 pkt = str( exp_pkt )
1916 verify_packet( self, pkt, ports[ 0 ] )
1917 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001918 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001919 delete_all_flows( self.controller )
1920 delete_groups( self.controller, Groups )
1921 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001922
Flavio Castroa7162bb2016-07-25 17:30:30 -07001923
1924class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001925 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001926 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04001927 """
Flavio Castro91d1a552016-05-17 16:59:44 -07001928
Flavio Castroa7162bb2016-07-25 17:30:30 -07001929 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001930 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001931 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001932 vlan_id = 1;
1933 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001934 add_l2_unfiltered_group( self.controller, [ port ], False )
1935 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001936 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001937 delete_all_flows( self.controller )
1938 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001939
Saurav Das34992182017-04-14 15:59:48 -07001940@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001941class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04001942 """
Flavio Castro76c5b262016-07-27 19:53:00 -07001943 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04001944 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001945
1946 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04001947 """
1948 port1 (vlan 1)-> port 2 (vlan 2)
1949 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001950 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001951 delete_all_flows( self.controller )
1952 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04001953
Flavio Castroa7162bb2016-07-25 17:30:30 -07001954 if len( config[ "port_map" ] ) < 3:
1955 logging.info( "Port count less than 3, can't run this case" )
1956 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001957 return
Flavio Castro423df652016-05-17 20:14:08 -04001958
Flavio Castroa7162bb2016-07-25 17:30:30 -07001959 vlan_id = 1
1960 port2_out_vlan = 2
1961 port3_out_vlan = 3
1962 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
1963 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1964 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1965 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
1966 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1967 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
1968 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
1969 src_ip = 0xc0a80101
1970 src_ip_str = "192.168.1.1"
1971 dst_ip = 0xe0010101
1972 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04001973
Flavio Castroa7162bb2016-07-25 17:30:30 -07001974 port1 = config[ "port_map" ].keys( )[ 0 ]
1975 port2 = config[ "port_map" ].keys( )[ 1 ]
1976 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04001977
Flavio Castroa7162bb2016-07-25 17:30:30 -07001978 # add l2 interface group
1979 for port in config[ "port_map" ].keys( ):
1980 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
1981 send_barrier=False )
1982 # add vlan flow table
1983 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1984 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04001985
Flavio Castroa7162bb2016-07-25 17:30:30 -07001986 # add termination flow
1987 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
1988 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04001989
Flavio Castroa7162bb2016-07-25 17:30:30 -07001990 # add MPLS interface group
1991 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
1992 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1993 port2_out_vlan, port2 )
1994 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1995 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1996 # add L3VPN groups
1997 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
1998 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
1999 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
2000 # 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 -07002001 # 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 -04002002
Flavio Castroa7162bb2016-07-25 17:30:30 -07002003 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
2004 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 -04002005
Flavio Castroa7162bb2016-07-25 17:30:30 -07002006 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
2007 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
2008 pkt = str( parsed_pkt )
2009 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002010 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002011 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
2012 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
2013 pkt = str( exp_pkt )
2014 verify_packet( self, pkt, port2 )
2015 # verify_packet(self, pkt, port3)
2016 verify_no_other_packets( self )
2017 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002018 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002019 delete_all_flows( self.controller )
2020 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002021
Saurav Das34992182017-04-14 15:59:48 -07002022@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002023class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002024 """
2025 Test packet in function on a src-mac miss
2026 Send a packet to each dataplane port and verify that a packet
2027 in message is received from the controller for each
2028 #todo verify you stop receiving after adding rule
2029 """
2030
Flavio Castroa7162bb2016-07-25 17:30:30 -07002031 def runTest( self ):
2032 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002033 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002034 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04002035
Flavio Castroa7162bb2016-07-25 17:30:30 -07002036 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002037 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002038 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2039 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2040 Groups.put( L2gid )
2041 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2042 vlan_pkt = str( parsed_vlan_pkt )
2043 for of_port in config[ "port_map" ].keys( ):
2044 logging.info( "PacketInMiss test, port %d", of_port )
2045 self.dataplane.send( of_port, vlan_pkt )
2046 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2047 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002048 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002049 delete_all_flows( self.controller )
2050 delete_all_groups( self.controller )
2051
2052
2053class EcmpGroupMod( base_tests.SimpleDataPlane ):
2054 """
Saurav Das34992182017-04-14 15:59:48 -07002055 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07002056 """
2057
2058 def runTest( self ):
2059 Groups = Queue.LifoQueue( )
2060 try:
2061 if len( config[ "port_map" ] ) < 2:
2062 logging.info( "Port count less than 2, can't run this case" )
2063 return
2064
2065 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2066 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2067 dip = 0xc0a80001
2068 # Hashes Test Name and uses it as id for installing unique groups
2069 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002070 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002071 dst_ips = []
2072 # add flows for all ports but include only the egress switchport (connected to ports[1])
2073 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002074 for port in ports:
2075 vlan_id = port
2076 id = port
2077 # add l2 interface group
2078 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2079 is_tagged=True, send_barrier=False )
2080 dst_mac[ 5 ] = vlan_id
2081 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2082 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002083 if port == ports[1]:
2084 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002085 Groups._put( l2_gid )
2086 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002087 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002088 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002089 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002090 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002091 if config["switch_type"] == "qmx":
2092 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2093 else:
2094 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002095 # add unicast routing flow
2096 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002097 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002098 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002099 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002100 for dst_ip in dst_ips:
2101 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2102 time.sleep(0.1)
2103 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002104 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002105 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002106 in_port = ports[0]
2107 out_port = ports[1]
2108 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2109 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2110 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2111 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2112 tcp = out_port if out_port == 24 else 25
2113 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2114 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2115 ip_dst=ip_dst, tcp_dport=tcp )
2116 pkt = str( parsed_pkt )
2117 self.dataplane.send( ports[ 0 ], pkt )
2118 # build expected packet at egress switchport
2119 mac_dst = '00:00:00:22:22:%02X' % out_port
2120 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2121 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2122 ip_dst=ip_dst, tcp_dport=tcp )
2123 pkt = str( exp_pkt )
2124 verify_packet( self, pkt, out_port )
2125 verify_no_other_packets( self )
2126
2127 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2128 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2129 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002130 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2131 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002132 time.sleep(0.1)
2133 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2134 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2135 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2136 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2137 tcp = port if port == 24 else 25
2138 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2139 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2140 ip_dst=ip_dst,tcp_dport=tcp )
2141 pkt = str( parsed_pkt )
2142 self.dataplane.send( ports[ 0 ], pkt )
2143 # build expected packet
2144 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2145 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2146 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2147 ip_dst=ip_dst,tcp_dport=tcp )
2148 pkt = str( exp_pkt )
2149 verify_packet( self, pkt, ports[ 0 ] )
2150 verify_no_other_packets( self )
2151
2152 # third part of the test - edit the group to completely remove bucket. Packet sent
2153 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002154 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002155 time.sleep(0.1)
2156 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2157 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2158 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2159 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2160 tcp = port if port == 24 else 25
2161 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2162 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2163 ip_dst=ip_dst,tcp_dport=tcp )
2164 pkt = str( parsed_pkt )
2165 self.dataplane.send( ports[ 0 ], pkt )
2166 verify_no_other_packets( self )
2167
2168 # final part of the test - edit the empty group to add back the bucket for the
2169 # original egress port, and verify packet is received on egress switch port
2170 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2171 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2172 time.sleep(0.1)
2173 in_port = ports[0]
2174 out_port = ports[1]
2175 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2176 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2177 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2178 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2179 tcp = out_port if out_port == 24 else 25
2180 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2181 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2182 ip_dst=ip_dst, tcp_dport=tcp )
2183 pkt = str( parsed_pkt )
2184 self.dataplane.send( ports[ 0 ], pkt )
2185 # build expected packet at egress switchport
2186 mac_dst = '00:00:00:22:22:%02X' % out_port
2187 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2188 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2189 ip_dst=ip_dst, tcp_dport=tcp )
2190 pkt = str( exp_pkt )
2191 verify_packet( self, pkt, out_port )
2192 verify_no_other_packets( self )
2193
Flavio Castroa7162bb2016-07-25 17:30:30 -07002194 finally:
2195 delete_all_flows( self.controller )
2196 delete_groups( self.controller, Groups )
2197 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002198
Saurav Das34992182017-04-14 15:59:48 -07002199
Pier8b223022016-08-19 22:47:49 -07002200class Untagged( base_tests.SimpleDataPlane ):
2201 """
2202 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2203 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2204 previous versions of the OFDPA.
2205
2206 Two rules are necessary in VLAN table (10):
2207 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2208 2) Filtering: match 0x100A/0x1FFF, goto 20
2209
2210 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2211 The remaining part of the test is based on the use of the bridging table
2212 """
2213
2214 MAX_INTERNAL_VLAN = 4094
2215
2216 def runTest( self ):
2217 groups = Queue.LifoQueue( )
2218 try:
2219 if len( config[ "port_map" ] ) < 2:
2220 logging.info( "Port count less than 2, can't run this case" )
2221 return
2222
2223 ports = sorted( config[ "port_map" ].keys( ) )
2224 for port in ports:
2225 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002226 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2227 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002228 for other_port in ports:
2229 if other_port == port:
2230 continue
2231 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2232 groups.put( L2gid )
2233 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2234
2235 do_barrier( self.controller )
2236
2237 for out_port in ports:
2238 # change dest based on port number
2239 mac_dst = '00:12:34:56:78:%02X' % out_port
2240 for in_port in ports:
2241 if in_port == out_port:
2242 continue
2243 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2244 self.dataplane.send( in_port, pkt )
2245 for ofport in ports:
2246 if ofport in [ out_port ]:
2247 verify_packet( self, pkt, ofport )
2248 else:
2249 verify_no_packet( self, pkt, ofport )
2250 verify_no_other_packets( self )
2251 finally:
2252 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002253 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002254 delete_all_groups( self.controller )