blob: 28261d9a6d5408d694e7872c17424690a4bb4f3e [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
Saurav Das59fae5e2017-12-07 12:02:02 -0800343class Bridging( base_tests.SimpleDataPlane ):
344 """
345 Verify bridging works including flooding with different vlans
346 ports[0] has vlan 31 untagged
347 ports[1] has vlan 31 untagged (native) and vlan 41 tagged
348 ARP request should be flooded
349 ARP reply should be forwarded by bridging rule
350 Both arp messages should also be copied to controller
351 """
352
353 def runTest( self ):
354 Groupd = Queue.LifoQueue()
355 try:
356 if len( config[ "port_map" ] ) < 2:
357 logging.info( "Port count less than 2, can't run this case" )
358 return
359 ports = sorted( config[ "port_map" ].keys() )
360 vlan_p0_untagged = 31
361 vlan_p1_tagged = 31
362 vlan_p1_native = 41
363
364 #l2 interface groups and table 10 flows
365 L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged,
366 is_tagged=False, send_barrier=False )
367 add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
368 send_barrier=True)
369 L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged,
370 is_tagged=True, send_barrier=False )
371 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG,
372 send_barrier=True)
373 L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native,
374 is_tagged=False, send_barrier=False )
375 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
376 send_barrier=True)
377 #flooding groups
378 Floodmsg31 = add_l2_flood_group( self.controller, ports, vlan_p0_untagged, id=0 )
379 Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 )
380
381 #add bridging flows for flooding groups
382 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id )
383 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id )
384 do_barrier( self.controller )
385
386 # add bridging flows for dstMac+vlan
387 add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True )
388 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True )
389 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True )
390
391 # add terminationMac flow
392 router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
393 if config["switch_type"] == "qmx":
394 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged )
395 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native )
396 else:
397 add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged )
398 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged )
399 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native )
400
401 # add acl rule for arp
402 match = ofp.match( )
403 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
404 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
405 ofp.instruction.apply_actions( actions=[
406 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
407 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
408 self.controller.message_send( request )
409 do_barrier( self.controller )
410
411 #acl rule for gateway ip
412 match = ofp.match( )
413 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
414 match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) )
415 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
416 ofp.instruction.apply_actions( actions=[
417 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ),
418 ofp.instruction.clear_actions() ],
419 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
420 self.controller.message_send( request )
421 do_barrier( self.controller )
422
423 # send ARP request
424 parsed_arp_pkt = simple_arp_packet(pktlen=80,
425 eth_dst='ff:ff:ff:ff:ff:ff',
426 eth_src='00:66:77:88:99:aa',
427 vlan_vid=vlan_p1_tagged,
428 vlan_pcp=0,
429 arp_op=1,
430 ip_snd='192.168.0.2',
431 ip_tgt='192.168.0.1',
432 hw_snd='00:66:77:88:99:aa',
433 hw_tgt='00:00:00:00:00:00')
434 arp_pkt_to_send = str( parsed_arp_pkt )
435 logging.info( "sending arp request to port %d", ports[1] )
436 self.dataplane.send( ports[1], arp_pkt_to_send )
437 verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION )
438 parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76,
439 eth_dst='ff:ff:ff:ff:ff:ff',
440 eth_src='00:66:77:88:99:aa',
441 vlan_vid=0,
442 vlan_pcp=0,
443 arp_op=1,
444 ip_snd='192.168.0.2',
445 ip_tgt='192.168.0.1',
446 hw_snd='00:66:77:88:99:aa',
447 hw_tgt='00:00:00:00:00:00')
448 arp_pkt_dest = str( parsed_arp_pkt_untagged )
449 verify_packet( self, arp_pkt_dest, ports[0] )
450 #verify_no_other_packets( self )
451
452 # send ARP reply
453 parsed_arp_pkt = simple_arp_packet(pktlen=76,
454 eth_dst='00:66:77:88:99:aa',
455 eth_src='00:11:22:33:44:55',
456 vlan_vid=0,
457 vlan_pcp=0,
458 arp_op=2,
459 ip_snd='192.168.0.1',
460 ip_tgt='192.168.0.2',
461 hw_snd='00:11:22:33:44:55',
462 hw_tgt='00:66:77:88:99:aa')
463 arp_pkt_to_send = str( parsed_arp_pkt )
464 logging.info( "sending arp reply to port %d", ports[0] )
465 self.dataplane.send( ports[0], arp_pkt_to_send )
466 verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION )
467 parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80,
468 eth_dst='00:66:77:88:99:aa',
469 eth_src='00:11:22:33:44:55',
470 vlan_vid=vlan_p1_tagged,
471 vlan_pcp=0,
472 arp_op=2,
473 ip_snd='192.168.0.1',
474 ip_tgt='192.168.0.2',
475 hw_snd='00:11:22:33:44:55',
476 hw_tgt='00:66:77:88:99:aa')
477 arp_pkt_dest = str( parsed_arp_pkt_tagged )
478 verify_packet( self, arp_pkt_dest, ports[1] )
479
480 finally:
481 delete_all_flows( self.controller )
482 delete_all_groups( self.controller )
483 print("done")
484
485
486
Flavio Castroa7162bb2016-07-25 17:30:30 -0700487class Mtu1500( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700488 """
489 Verifies basic mtu limits
490 """
491
Flavio Castroa7162bb2016-07-25 17:30:30 -0700492 def runTest( self ):
493 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700494 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700495 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700496 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700497 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700498 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Pier265ad5f2017-02-28 17:46:28 +0100499 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700500 Groups.put( L2gid )
501 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
502 True )
503 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500504
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700505 for out_port in ports:
506 # change dest based on port number
507 mac_dst = '00:12:34:56:78:%02X' % out_port
508 for in_port in ports:
509 if in_port == out_port:
510 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700511 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
512 eth_dst=mac_dst ) )
513 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700514 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700515 if ofport in [ out_port ]:
516 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700517 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700518 verify_no_packet( self, pkt, ofport )
519 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700520 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700521 delete_all_flows( self.controller )
522 delete_groups( self.controller, Groups )
523 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500524
Flavio Castroa7162bb2016-07-25 17:30:30 -0700525
526class _32UcastTagged( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700527 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500528
Flavio Castroa7162bb2016-07-25 17:30:30 -0700529 def runTest( self ):
530 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700531 try:
532 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700533 if len( config[ "port_map" ] ) < 2:
534 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700535 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700536 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
537 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700538 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700539 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700540 for port in ports:
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700541 vlan_id = port + test_id
Saurav Dase94ba572017-04-28 17:47:21 -0700542 # add l2 interface group and l3 unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700543 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
544 is_tagged=True, send_barrier=False )
545 dst_mac[ 5 ] = vlan_id
546 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
547 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700548 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100549 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700550 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700551 if config["switch_type"] == "qmx":
552 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
553 else:
554 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700555 # add unicast routing flow
556 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700557 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
558 Groups.put( l2gid )
559 Groups.put( l3_msg.group_id )
560 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500561
Flavio Castroa7162bb2016-07-25 17:30:30 -0700562 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700563 for in_port in ports:
564 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
565 ip_src = '192.168.%02d.1' % (test_id + in_port)
566 for out_port in ports:
567 if in_port == out_port:
568 continue
569 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700570 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
571 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
572 ip_src=ip_src, ip_dst=ip_dst )
573 pkt = str( parsed_pkt )
574 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700575 # build expected packet
576 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700577 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
578 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
579 ip_src=ip_src, ip_dst=ip_dst )
580 pkt = str( exp_pkt )
581 verify_packet( self, pkt, out_port )
582 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700583 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700584 delete_all_flows( self.controller )
585 delete_groups( self.controller, Groups )
586 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500587
Saurav Das34992182017-04-14 15:59:48 -0700588@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700589class _32VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700590 """
591 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
592 No ECMP group used
593 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500594
Flavio Castroa7162bb2016-07-25 17:30:30 -0700595 def runTest( self ):
596 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700597 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700598 if len( config[ "port_map" ] ) < 2:
599 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700600 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500601
Flavio Castroa7162bb2016-07-25 17:30:30 -0700602 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
603 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700604 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700605 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700606 for port in ports:
607 # add l2 interface group
608 id = port
609 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700610 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
611 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700612 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700613 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
614 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700615 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700616 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
617 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
618 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700619 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700620 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100621 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700622 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700623 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700624 if config["switch_type"] == "qmx":
625 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
626 else:
627 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700628 # add routing flow
629 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700630 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
631 Groups._put( l2_gid )
632 Groups._put( mpls_gid )
633 Groups._put( mpls_label_gid )
634 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500635
Flavio Castroa7162bb2016-07-25 17:30:30 -0700636 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700637 for in_port in ports:
638 ip_src = '192.168.%02d.1' % (in_port)
639 for out_port in ports:
640 if in_port == out_port:
641 continue
642 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700643 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
644 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
645 pkt = str( parsed_pkt )
646 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700647 # build expect packet
648 mac_dst = '00:00:00:22:22:%02X' % (out_port)
649 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700650 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
651 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
652 label=[ label ] )
653 pkt = str( exp_pkt )
654 verify_packet( self, pkt, out_port )
655 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700656 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700657 delete_all_flows( self.controller )
658 delete_groups( self.controller, Groups )
659 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500660
Saurav Das34992182017-04-14 15:59:48 -0700661@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700662class _32EcmpVpn( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700663 """
664 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
665 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500666
Flavio Castroa7162bb2016-07-25 17:30:30 -0700667 def runTest( self ):
668 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700669 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700670 if len( config[ "port_map" ] ) < 2:
671 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700672 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500673
Flavio Castroa7162bb2016-07-25 17:30:30 -0700674 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
675 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700676 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700677 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700678 for port in ports:
679 # add l2 interface group
680 id = port
681 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700682 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
683 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700684 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700685 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
686 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700687 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700688 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
689 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
690 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
691 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
692 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700693 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100694 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700695 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700696 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700697 if config["switch_type"] == "qmx":
698 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
699 else:
700 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700701 # add routing flow
702 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700703 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
704 Groups._put( l2_gid )
705 Groups._put( mpls_gid )
706 Groups._put( mpls_label_gid )
707 Groups._put( ecmp_msg.group_id )
708 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500709
Flavio Castroa7162bb2016-07-25 17:30:30 -0700710 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700711 for in_port in ports:
712 ip_src = '192.168.%02d.1' % (in_port)
713 for out_port in ports:
714 if in_port == out_port:
715 continue
716 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700717 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
718 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
719 pkt = str( parsed_pkt )
720 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700721 # build expect packet
722 mac_dst = '00:00:00:22:22:%02X' % (out_port)
723 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700724 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
725 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
726 label=[ label ] )
727 pkt = str( exp_pkt )
728 verify_packet( self, pkt, out_port )
729 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -0700730
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700731 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700732 delete_all_flows( self.controller )
733 delete_groups( self.controller, Groups )
734 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500735
Flavio Castroa7162bb2016-07-25 17:30:30 -0700736
Saurav Das34992182017-04-14 15:59:48 -0700737@disabled
738class One_32EcmpVpn( base_tests.SimpleDataPlane ):
739 """
740 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
741 in only one direction
742 """
743
744 def runTest( self ):
745 Groups = Queue.LifoQueue( )
746 try:
747 if len( config[ "port_map" ] ) < 2:
748 logging.info( "Port count less than 2, can't run this case" )
749 return
750
751 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
752 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
753 dip = 0xc0a80001
754 ports = config[ "port_map" ].keys( )
755 # add l2 interface group
756 id = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700757 in_offset = 19
758 out_offset = 20
759 vlan_id = ports[1] + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700760 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
Saurav Das1ab6a142017-04-25 14:42:25 -0700761 dst_mac[ 5 ] = ports[1]
Saurav Das34992182017-04-14 15:59:48 -0700762 # add MPLS interface group
763 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
764 vlan_id, id )
765 # add MPLS L3 VPN group
766 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
767 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
Saurav Das1ab6a142017-04-25 14:42:25 -0700768 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
Saurav Das34992182017-04-14 15:59:48 -0700769 # add ECMP group
770 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
771 do_barrier( self.controller )
772 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700773 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 -0700774 flag=VLAN_TABLE_FLAG_ONLY_TAG )
775 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700776 if config["switch_type"] == "qmx":
777 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
778 else:
779 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700780 # add routing flow
781 dst_ip = dip + (vlan_id << 8)
782 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
783 Groups._put( l2_gid )
784 Groups._put( mpls_gid )
785 Groups._put( mpls_label_gid )
786 Groups._put( ecmp_msg.group_id )
787
788
789 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
790 in_port = ports[0]
791 out_port = ports[1]
792 ip_src = '192.168.%02d.1' % (in_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700793 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
794 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
Saurav Das34992182017-04-14 15:59:48 -0700795 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
796 pkt = str( parsed_pkt )
797 self.dataplane.send( in_port, pkt )
798 # build expect packet
799 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700800 label = (out_port+out_offset, 0, 1, 32)
801 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 -0700802 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
Saurav Das1ab6a142017-04-25 14:42:25 -0700803 label=[ label ] )
Saurav Das34992182017-04-14 15:59:48 -0700804 pkt = str( exp_pkt )
805 verify_packet( self, pkt, out_port )
806 #verify_no_other_packets( self )
807
808 finally:
809 delete_all_flows( self.controller )
810 delete_group(self.controller, ecmp_msg.group_id)
811 delete_group(self.controller, mpls_label_gid)
812 delete_group(self.controller, mpls_gid)
813 delete_group(self.controller, l2_gid)
814
815
Flavio Castroa7162bb2016-07-25 17:30:30 -0700816class _32ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700817 """
818 Verifies /32 IP routing and ECMP with no label push
819 IP -> L3ECMP -> L3Unicast -> L2Interface
820 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500821
Flavio Castroa7162bb2016-07-25 17:30:30 -0700822 def runTest( self ):
823 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700824 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700825 if len( config[ "port_map" ] ) < 2:
826 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700827 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500828
Flavio Castroa7162bb2016-07-25 17:30:30 -0700829 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
830 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700831 dip = 0xc0a80001
832 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700833 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700834 for port in ports:
835 vlan_id = port
836 id = port
837 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700838 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
839 is_tagged=True, send_barrier=False )
840 dst_mac[ 5 ] = vlan_id
841 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
842 src_mac=intf_src_mac, dst_mac=dst_mac )
843 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700844 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100845 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700846 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700847 if config["switch_type"] == "qmx":
848 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
849 else:
850 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700851 # add unicast routing flow
852 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700853 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
854 Groups._put( l2_gid )
855 Groups._put( l3_msg.group_id )
856 Groups._put( ecmp_msg.group_id )
857 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500858
Flavio Castroa7162bb2016-07-25 17:30:30 -0700859 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700860 for in_port in ports:
861 mac_src = '00:00:00:22:22:%02X' % in_port
862 ip_src = '192.168.%02d.1' % in_port
863 for out_port in ports:
864 if in_port == out_port:
865 continue
866 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700867 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
868 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
869 pkt = str( parsed_pkt )
870 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700871 # build expected packet
872 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700873 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
874 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
875 pkt = str( exp_pkt )
876 verify_packet( self, pkt, out_port )
877 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700878 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700879 delete_all_flows( self.controller )
880 delete_groups( self.controller, Groups )
881 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500882
Saurav Das34992182017-04-14 15:59:48 -0700883@disabled
884class One_32ECMPL3( base_tests.SimpleDataPlane ):
885 """
886 Verifies /32 IP routing and ECMP with no label push
887 IP -> L3ECMP -> L3Unicast -> L2Interface
888 in only one direction
889 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700890
Saurav Das34992182017-04-14 15:59:48 -0700891 def runTest( self ):
892 Groups = Queue.LifoQueue( )
893 try:
894 if len( config[ "port_map" ] ) < 2:
895 logging.info( "Port count less than 2, can't run this case" )
896 return
897
898 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
899 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
900 dip = 0xc0a80001
901 # Hashes Test Name and uses it as id for installing unique groups
902 ports = config[ "port_map" ].keys( )
903 inport = ports[0]
904 outport = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700905 in_offset = 19
906 out_offset = 20
907 vlan_id = outport + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700908 id = outport
909 # add l2 interface group, l3 unicast and ecmp group for outport
910 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
911 is_tagged=True, send_barrier=False )
Saurav Das1ab6a142017-04-25 14:42:25 -0700912 dst_mac[ 5 ] = outport
Saurav Das34992182017-04-14 15:59:48 -0700913 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
914 src_mac=intf_src_mac, dst_mac=dst_mac )
915 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
916 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700917 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 -0700918 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700919 if config["switch_type"] == "qmx":
920 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset )
921 else:
922 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 -0700923 # add unicast routing flow
924 dst_ip = dip + (vlan_id << 8)
925 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
926 Groups._put( l2_gid )
927 Groups._put( l3_msg.group_id )
928 Groups._put( ecmp_msg.group_id )
929
930 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
931 mac_src = '00:00:00:22:22:%02X' % inport
932 ip_src = '192.168.%02d.1' % inport
Saurav Das1ab6a142017-04-25 14:42:25 -0700933 ip_dst = '192.168.%02d.1' % (outport+out_offset)
934 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
Saurav Das34992182017-04-14 15:59:48 -0700935 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
936 pkt = str( parsed_pkt )
937 self.dataplane.send( inport, pkt )
938 # build expected packet
939 mac_dst = '00:00:00:22:22:%02X' % outport
Saurav Das1ab6a142017-04-25 14:42:25 -0700940 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
Saurav Das34992182017-04-14 15:59:48 -0700941 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
942 pkt = str( exp_pkt )
943 verify_packet( self, pkt, outport )
944 verify_no_other_packets( self )
945 finally:
946 delete_all_flows( self.controller )
947 delete_groups( self.controller, Groups )
948 delete_all_groups( self.controller )
949
950
951
952
953@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700954class _24VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700955 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500956
Flavio Castroa7162bb2016-07-25 17:30:30 -0700957 def runTest( self ):
958 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700959 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700960 if len( config[ "port_map" ] ) < 2:
961 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700962 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500963
Flavio Castroa7162bb2016-07-25 17:30:30 -0700964 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
965 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700966 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700967 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700968 for port in ports:
969 # add l2 interface group
970 id = port
971 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700972 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
973 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700974 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700975 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
976 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700977 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700978 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
979 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
980 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700981 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700982 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700983 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100984 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700985 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700986 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700987 if config["switch_type"] == "qmx":
988 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
989 else:
990 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700991 # add routing flow
992 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700993 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
994 Groups._put( l2_gid )
995 Groups._put( mpls_gid )
996 Groups._put( mpls_label_gid )
997 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500998
Flavio Castroa7162bb2016-07-25 17:30:30 -0700999 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001000 for in_port in ports:
1001 ip_src = '192.168.%02d.1' % (in_port)
1002 for out_port in ports:
1003 if in_port == out_port:
1004 continue
1005 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001006 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1007 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1008 pkt = str( parsed_pkt )
1009 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001010 # build expect packet
1011 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1012 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001013 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1014 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1015 label=[ label ] )
1016 pkt = str( exp_pkt )
1017 verify_packet( self, pkt, out_port )
1018 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001019 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001020 delete_all_flows( self.controller )
1021 delete_groups( self.controller, Groups )
1022 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -05001023
Saurav Das34992182017-04-14 15:59:48 -07001024@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001025class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001026 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -05001027
Flavio Castroa7162bb2016-07-25 17:30:30 -07001028 def runTest( self ):
1029 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001030 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001031 if len( config[ "port_map" ] ) < 2:
1032 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001033 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001034 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1035 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001036 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001037 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001038 for port in ports:
1039 # add l2 interface group
1040 id = port
1041 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001042 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
1043 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001044 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001045 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1046 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001047 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001048 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1049 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
1050 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
1051 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
1052 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001053 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001054 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -07001055 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001056 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001057 if config["switch_type"] == "qmx":
1058 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1059 else:
1060 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001061 # add routing flow
1062 dst_ip = dip + (vlan_id << 8)
1063 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001064 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
1065 vrf=0 )
1066 Groups._put( l2_gid )
1067 Groups._put( mpls_gid )
1068 Groups._put( mpls_label_gid )
1069 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001070
Flavio Castroa7162bb2016-07-25 17:30:30 -07001071 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001072
Flavio Castroa7162bb2016-07-25 17:30:30 -07001073 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001074 for in_port in ports:
1075 mac_src = '00:00:00:22:22:%02X' % (in_port)
1076 ip_src = '192.168.%02d.1' % (in_port)
1077 for out_port in ports:
1078 if in_port == out_port:
1079 continue
1080 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001081 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1082 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1083 pkt = str( parsed_pkt )
1084 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001085 # build expect packet
1086 mac_dst = '00:00:00:22:22:%02X' % out_port
1087 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001088 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1089 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1090 label=[ label ] )
1091 pkt = str( exp_pkt )
1092 verify_packet( self, pkt, out_port )
1093 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001094 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001095 delete_all_flows( self.controller )
1096 delete_groups( self.controller, Groups )
1097 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001098
Flavio Castroa7162bb2016-07-25 17:30:30 -07001099
1100class FloodGroupMod( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001101 """ Modify a referenced flood group """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001102
1103 def runTest( self ):
1104 Groups = Queue.LifoQueue( )
1105 try:
1106 ports = sorted( config[ "port_map" ].keys( ) )
1107 vlan_id = 1
1108
1109 for port in ports:
1110 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1111 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1112 Groups.put( L2gid )
1113
1114 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
1115 Groups.put( msg.group_id )
1116 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
1117 do_barrier( self.controller )
1118 # verify flood
1119 for ofport in ports:
1120 # change dest based on port number
1121 mac_src = '00:12:34:56:78:%02X' % ofport
1122 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1123 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
1124 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
1125 pkt = str( parsed_pkt )
1126 self.dataplane.send( ofport, pkt )
1127 # self won't rx packet
1128 verify_no_packet( self, pkt, ofport )
1129 # others will rx packet
1130 tmp_ports = list( ports )
1131 tmp_ports.remove( ofport )
1132 verify_packets( self, pkt, tmp_ports )
1133 verify_no_other_packets( self )
1134 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
1135 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
1136 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1137 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
1138 eth_src=mac_src )
1139 pkt = str( parsed_pkt )
1140 self.dataplane.send( ports[ 1 ], pkt )
1141 verify_packets( self, pkt, [ ports[ 0 ] ] )
1142 finally:
1143 delete_all_flows( self.controller )
1144 delete_groups( self.controller, Groups )
1145 delete_all_groups( self.controller )
1146
1147
1148class _24ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001149 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
Flavio Castro80730822015-12-11 15:38:47 -05001150
Flavio Castroa7162bb2016-07-25 17:30:30 -07001151 def runTest( self ):
1152 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001153 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001154 if len( config[ "port_map" ] ) < 2:
1155 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001156 return
Flavio Castro80730822015-12-11 15:38:47 -05001157
Flavio Castroa7162bb2016-07-25 17:30:30 -07001158 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1159 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001160 dip = 0xc0a80001
1161 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -07001162 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001163 for port in ports:
1164 vlan_id = port
1165 id = port
1166 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001167 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1168 is_tagged=True, send_barrier=False )
1169 dst_mac[ 5 ] = vlan_id
1170 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1171 src_mac=intf_src_mac, dst_mac=dst_mac )
1172 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001173 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001174 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001175 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001176 if config["switch_type"] == "qmx":
1177 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1178 else:
1179 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001180 # add unicast routing flow
1181 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001182 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1183 Groups._put( l2_gid )
1184 Groups._put( l3_msg.group_id )
1185 Groups._put( ecmp_msg.group_id )
1186 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -05001187
Flavio Castroa7162bb2016-07-25 17:30:30 -07001188 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001189 for in_port in ports:
1190 mac_src = '00:00:00:22:22:%02X' % in_port
1191 ip_src = '192.168.%02d.1' % in_port
1192 for out_port in ports:
1193 if in_port == out_port:
1194 continue
1195 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001196 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1197 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1198 pkt = str( parsed_pkt )
1199 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001200 # build expected packet
1201 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001202 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1203 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1204 pkt = str( exp_pkt )
1205 verify_packet( self, pkt, out_port )
1206 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001207 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001208 delete_all_flows( self.controller )
1209 delete_groups( self.controller, Groups )
1210 delete_all_groups( self.controller )
1211
Flavio Castro1c9b1252016-02-04 18:42:58 -05001212
Flavio Castroaba28ff2016-02-03 16:47:48 -05001213@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001214class MPLSBUG( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001215 """
1216 Needs a description or needs to be removed
1217 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001218 def runTest( self ):
1219 if len( config[ "port_map" ] ) < 2:
1220 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -05001221 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001222 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1223 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -05001224 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001225 Groups = Queue.LifoQueue( )
1226 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -05001227 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001228 # add l2 interface group
1229 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001230 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1231 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -05001232 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001233 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1234 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001235 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001236 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001237 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001238 if config["switch_type"] == "qmx":
1239 add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 )
1240 else:
1241 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001242 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001243 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001244 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001245 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001246 # add unicast routing flow
1247 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001248 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1249 Groups._put( l2_gid )
1250 Groups._put( l3_msg.group_id )
1251 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001252
Flavio Castroa7162bb2016-07-25 17:30:30 -07001253 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -05001254 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001255 mac_src = '00:00:00:22:22:%02X' % in_port
1256 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -05001257 for out_port in ports:
1258 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001259 continue
1260 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -05001261 switch_mac = "00:00:00:cc:cc:cc"
1262 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001263 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1264 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1265 pkt = str( parsed_pkt )
1266 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -05001267
Flavio Castro1c9b1252016-02-04 18:42:58 -05001268 # build expect packet
1269 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001270 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1271 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1272 pkt = str( exp_pkt )
1273 verify_packet( self, pkt, out_port )
1274 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001275
Flavio Castroa7162bb2016-07-25 17:30:30 -07001276 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1277 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1278 pkt = str( parsed_pkt )
1279 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001280 # build expected packet
1281 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001282 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1283 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1284 pkt = str( exp_pkt )
1285 verify_packet( self, pkt, out_port )
1286 verify_no_other_packets( self )
1287 delete_all_flows( self.controller )
1288 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001289
Flavio Castroa7162bb2016-07-25 17:30:30 -07001290class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -07001291 """
1292 Mcast routing, in this test case the traffic comes in tagged.
1293 port+1 is used as ingress vlan_id. The packet goes out tagged on
1294 different ports. 4094-port is used as egress vlan_id.
1295 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001296 def runTest( self ):
Pier7b031af2016-08-25 15:00:22 -07001297 """
1298 port1 (vlan 300)-> All Ports (vlan 300)
1299 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001300 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001301 try:
Pierbbdf3782016-08-22 17:58:26 -07001302 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1303 if len( config[ "port_map" ] ) < 1:
1304 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001305 assert (False)
1306 return
Pierbbdf3782016-08-22 17:58:26 -07001307 ports = config[ "port_map" ].keys( )
1308 dst_ip_str = "224.0.0.1"
1309 (
1310 port_to_in_vlan,
1311 port_to_out_vlan,
1312 port_to_src_mac_str,
1313 port_to_dst_mac_str,
1314 port_to_src_ip_str,
1315 port_to_intf_src_mac_str,
1316 Groups) = fill_mcast_pipeline_L3toL3(
1317 self.controller,
1318 logging,
1319 ports,
1320 is_ingress_tagged = True,
1321 is_egress_tagged = True,
1322 is_vlan_translated = True,
1323 is_max_vlan = False
1324 )
Flavio Castro12296312015-12-15 17:48:26 -05001325
Pierbbdf3782016-08-22 17:58:26 -07001326 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001327
Pierbbdf3782016-08-22 17:58:26 -07001328 parsed_pkt = simple_udp_packet(
1329 pktlen = 100,
1330 dl_vlan_enable = True,
1331 vlan_vid = port_to_in_vlan[in_port],
1332 eth_dst = port_to_dst_mac_str[in_port],
1333 eth_src = port_to_src_mac_str[in_port],
1334 ip_ttl = 64,
1335 ip_src = port_to_src_ip_str[in_port],
1336 ip_dst = dst_ip_str
1337 )
1338 pkt = str( parsed_pkt )
1339 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001340
Pierbbdf3782016-08-22 17:58:26 -07001341 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001342
Pierbbdf3782016-08-22 17:58:26 -07001343 parsed_pkt = simple_udp_packet(
1344 pktlen = 100,
1345 dl_vlan_enable = True,
1346 vlan_vid = port_to_out_vlan[out_port],
1347 eth_dst = port_to_dst_mac_str[in_port],
1348 eth_src = port_to_intf_src_mac_str[out_port],
1349 ip_ttl = 63,
1350 ip_src = port_to_src_ip_str[in_port],
1351 ip_dst = dst_ip_str
1352 )
1353 pkt = str( parsed_pkt )
1354 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001355
Pierbbdf3782016-08-22 17:58:26 -07001356 verify_no_other_packets( self )
1357
Pier7b031af2016-08-25 15:00:22 -07001358 finally:
1359 delete_all_flows( self.controller )
1360 delete_groups( self.controller, Groups )
1361 delete_all_groups( self.controller )
1362
1363class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1364 """
1365 Mcast routing, in this test case the traffic is untagged.
1366 4094 is used as internal vlan_id. The packet goes out
1367 untagged.
1368 """
1369 def runTest( self ):
1370 Groups = Queue.LifoQueue( )
1371 try:
1372 if len( config[ "port_map" ] ) < 2:
1373 logging.info( "Port count less than 2, can't run this case" )
1374 assert (False)
1375 return
1376 ports = config[ "port_map" ].keys( )
1377 dst_ip_str = "224.0.0.1"
1378 (
1379 port_to_in_vlan,
1380 port_to_out_vlan,
1381 port_to_src_mac_str,
1382 port_to_dst_mac_str,
1383 port_to_src_ip_str,
1384 Groups) = fill_mcast_pipeline_L3toL2(
1385 self.controller,
1386 logging,
1387 ports,
1388 is_ingress_tagged = False,
1389 is_egress_tagged = False,
1390 is_vlan_translated = False,
1391 is_max_vlan = True
1392 )
1393
1394 for in_port in ports:
1395
1396 parsed_pkt = simple_udp_packet(
1397 pktlen = 96,
1398 eth_dst = port_to_dst_mac_str[in_port],
1399 eth_src = port_to_src_mac_str[in_port],
1400 ip_ttl = 64,
1401 ip_src = port_to_src_ip_str[in_port],
1402 ip_dst = dst_ip_str
1403 )
1404 pkt = str( parsed_pkt )
1405 self.dataplane.send( in_port, pkt )
1406
1407 for out_port in ports:
1408
1409 parsed_pkt = simple_udp_packet(
1410 pktlen = 96,
1411 eth_dst = port_to_dst_mac_str[in_port],
1412 eth_src = port_to_src_mac_str[in_port],
1413 ip_ttl = 64,
1414 ip_src = port_to_src_ip_str[in_port],
1415 ip_dst = dst_ip_str
1416 )
1417 pkt = str( parsed_pkt )
1418 if out_port == in_port:
1419 verify_no_packet( self, pkt, in_port )
1420 continue
1421 verify_packet( self, pkt, out_port )
1422 verify_no_other_packets( self )
1423 finally:
1424 delete_all_flows( self.controller )
1425 delete_groups( self.controller, Groups )
1426 delete_all_groups( self.controller )
1427
1428class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1429 """
1430 Mcast routing, in this test case the traffic is untagged.
1431 300 is used as vlan_id. The packet goes out
1432 tagged.
1433 """
1434 def runTest( self ):
1435 Groups = Queue.LifoQueue( )
1436 try:
1437 if len( config[ "port_map" ] ) < 2:
1438 logging.info( "Port count less than 2, can't run this case" )
1439 assert (False)
1440 return
1441 ports = config[ "port_map" ].keys( )
1442 dst_ip_str = "224.0.0.1"
1443 (
1444 port_to_in_vlan,
1445 port_to_out_vlan,
1446 port_to_src_mac_str,
1447 port_to_dst_mac_str,
1448 port_to_src_ip_str,
1449 Groups) = fill_mcast_pipeline_L3toL2(
1450 self.controller,
1451 logging,
1452 ports,
1453 is_ingress_tagged = False,
1454 is_egress_tagged = True,
1455 is_vlan_translated = False,
1456 is_max_vlan = False
1457 )
1458
1459 for in_port in ports:
1460
1461 parsed_pkt = simple_udp_packet(
1462 pktlen = 96,
1463 eth_dst = port_to_dst_mac_str[in_port],
1464 eth_src = port_to_src_mac_str[in_port],
1465 ip_ttl = 64,
1466 ip_src = port_to_src_ip_str[in_port],
1467 ip_dst = dst_ip_str
1468 )
1469 pkt = str( parsed_pkt )
1470 self.dataplane.send( in_port, pkt )
1471
1472 for out_port in ports:
1473
1474 parsed_pkt = simple_udp_packet(
1475 pktlen = 100,
1476 dl_vlan_enable = True,
1477 vlan_vid = port_to_out_vlan[in_port],
1478 eth_dst = port_to_dst_mac_str[in_port],
1479 eth_src = port_to_src_mac_str[in_port],
1480 ip_ttl = 64,
1481 ip_src = port_to_src_ip_str[in_port],
1482 ip_dst = dst_ip_str
1483 )
1484 pkt = str( parsed_pkt )
1485 if out_port == in_port:
1486 verify_no_packet( self, pkt, in_port )
1487 continue
1488 verify_packet( self, pkt, out_port )
1489 verify_no_other_packets( self )
1490 finally:
1491 delete_all_flows( self.controller )
1492 delete_groups( self.controller, Groups )
1493 delete_all_groups( self.controller )
1494
1495
1496class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1497 """
1498 Mcast routing, in this test case the traffic is tagged.
1499 300 is used as vlan_id. The packet goes out
1500 untagged.
1501 """
1502 def runTest( self ):
1503 Groups = Queue.LifoQueue( )
1504 try:
1505 if len( config[ "port_map" ] ) < 2:
1506 logging.info( "Port count less than 2, can't run this case" )
1507 assert (False)
1508 return
1509 ports = config[ "port_map" ].keys( )
1510 dst_ip_str = "224.0.0.1"
1511 (
1512 port_to_in_vlan,
1513 port_to_out_vlan,
1514 port_to_src_mac_str,
1515 port_to_dst_mac_str,
1516 port_to_src_ip_str,
1517 Groups) = fill_mcast_pipeline_L3toL2(
1518 self.controller,
1519 logging,
1520 ports,
1521 is_ingress_tagged = True,
1522 is_egress_tagged = False,
1523 is_vlan_translated = False,
1524 is_max_vlan = False
1525 )
1526
1527 for in_port in ports:
1528
1529 parsed_pkt = simple_udp_packet(
1530 pktlen = 100,
1531 dl_vlan_enable = True,
1532 vlan_vid = port_to_in_vlan[in_port],
1533 eth_dst = port_to_dst_mac_str[in_port],
1534 eth_src = port_to_src_mac_str[in_port],
1535 ip_ttl = 64,
1536 ip_src = port_to_src_ip_str[in_port],
1537 ip_dst = dst_ip_str
1538 )
1539 pkt = str( parsed_pkt )
1540 self.dataplane.send( in_port, pkt )
1541
1542 for out_port in ports:
1543
1544 parsed_pkt = simple_udp_packet(
1545 pktlen = 96,
1546 eth_dst = port_to_dst_mac_str[in_port],
1547 eth_src = port_to_src_mac_str[in_port],
1548 ip_ttl = 64,
1549 ip_src = port_to_src_ip_str[in_port],
1550 ip_dst = dst_ip_str
1551 )
1552 pkt = str( parsed_pkt )
1553 if out_port == in_port:
1554 verify_no_packet( self, pkt, in_port )
1555 continue
1556 verify_packet( self, pkt, out_port )
1557 verify_no_other_packets( self )
1558 finally:
1559 delete_all_flows( self.controller )
1560 delete_groups( self.controller, Groups )
1561 delete_all_groups( self.controller )
1562
1563class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1564 """
1565 Mcast routing, in this test case the traffic is tagged.
1566 300 is used as vlan_id. The packet goes out tagged.
1567 """
1568 def runTest( self ):
1569 Groups = Queue.LifoQueue( )
1570 try:
1571 if len( config[ "port_map" ] ) < 2:
1572 logging.info( "Port count less than 2, can't run this case" )
1573 assert (False)
1574 return
1575 ports = config[ "port_map" ].keys( )
1576 dst_ip_str = "224.0.0.1"
1577 (
1578 port_to_in_vlan,
1579 port_to_out_vlan,
1580 port_to_src_mac_str,
1581 port_to_dst_mac_str,
1582 port_to_src_ip_str,
1583 Groups) = fill_mcast_pipeline_L3toL2(
1584 self.controller,
1585 logging,
1586 ports,
1587 is_ingress_tagged = True,
1588 is_egress_tagged = True,
1589 is_vlan_translated = False,
1590 is_max_vlan = False
1591 )
1592
1593 for in_port in ports:
1594
1595 parsed_pkt = simple_udp_packet(
1596 pktlen = 100,
1597 dl_vlan_enable = True,
1598 vlan_vid = port_to_in_vlan[in_port],
1599 eth_dst = port_to_dst_mac_str[in_port],
1600 eth_src = port_to_src_mac_str[in_port],
1601 ip_ttl = 64,
1602 ip_src = port_to_src_ip_str[in_port],
1603 ip_dst = dst_ip_str
1604 )
1605 pkt = str( parsed_pkt )
1606 self.dataplane.send( in_port, pkt )
1607
1608 for out_port in ports:
1609
1610 parsed_pkt = simple_udp_packet(
1611 pktlen = 100,
1612 dl_vlan_enable = True,
1613 vlan_vid = port_to_in_vlan[in_port],
1614 eth_dst = port_to_dst_mac_str[in_port],
1615 eth_src = port_to_src_mac_str[in_port],
1616 ip_ttl = 64,
1617 ip_src = port_to_src_ip_str[in_port],
1618 ip_dst = dst_ip_str
1619 )
1620 pkt = str( parsed_pkt )
1621 if out_port == in_port:
1622 verify_no_packet( self, pkt, in_port )
1623 continue
1624 verify_packet( self, pkt, out_port )
1625 verify_no_other_packets( self )
1626 finally:
1627 delete_all_flows( self.controller )
1628 delete_groups( self.controller, Groups )
1629 delete_all_groups( self.controller )
1630
1631class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1632 """
1633 Mcast routing, in this test case the traffic is tagged.
1634 port+1 is used as ingress vlan_id. The packet goes out
1635 tagged. 4094-port is used as egress vlan_id
1636 """
1637 def runTest( self ):
1638 Groups = Queue.LifoQueue( )
1639 try:
1640 if len( config[ "port_map" ] ) < 2:
1641 logging.info( "Port count less than 2, can't run this case" )
1642 assert (False)
1643 return
1644 ports = config[ "port_map" ].keys( )
1645 dst_ip_str = "224.0.0.1"
1646 (
1647 port_to_in_vlan,
1648 port_to_out_vlan,
1649 port_to_src_mac_str,
1650 port_to_dst_mac_str,
1651 port_to_src_ip_str,
1652 Groups) = fill_mcast_pipeline_L3toL2(
1653 self.controller,
1654 logging,
1655 ports,
1656 is_ingress_tagged = True,
1657 is_egress_tagged = True,
1658 is_vlan_translated = True,
1659 is_max_vlan = False
1660 )
1661
1662 for in_port in ports:
1663
1664 parsed_pkt = simple_udp_packet(
1665 pktlen = 100,
1666 dl_vlan_enable = True,
1667 vlan_vid = port_to_in_vlan[in_port],
1668 eth_dst = port_to_dst_mac_str[in_port],
1669 eth_src = port_to_src_mac_str[in_port],
1670 ip_ttl = 64,
1671 ip_src = port_to_src_ip_str[in_port],
1672 ip_dst = dst_ip_str
1673 )
1674 pkt = str( parsed_pkt )
1675 self.dataplane.send( in_port, pkt )
1676
1677 for out_port in ports:
1678
1679 parsed_pkt = simple_udp_packet(
1680 pktlen = 100,
1681 dl_vlan_enable = True,
1682 vlan_vid = port_to_out_vlan[in_port],
1683 eth_dst = port_to_dst_mac_str[in_port],
1684 eth_src = port_to_src_mac_str[in_port],
1685 ip_ttl = 64,
1686 ip_src = port_to_src_ip_str[in_port],
1687 ip_dst = dst_ip_str
1688 )
1689 pkt = str( parsed_pkt )
1690 if out_port == in_port:
1691 verify_no_packet( self, pkt, in_port )
1692 continue
1693 verify_packet( self, pkt, out_port )
1694 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001695 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001696 delete_all_flows( self.controller )
1697 delete_groups( self.controller, Groups )
1698 delete_all_groups( self.controller )
1699
Saurav Das34992182017-04-14 15:59:48 -07001700@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001701class _MplsFwd( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001702 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001703
1704 def runTest( self ):
1705 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001706 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001707 if len( config[ "port_map" ] ) < 2:
1708 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001709 return
1710 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001711 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1712 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001713 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001714 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001715 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001716 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1717 vlan_id = port + 16
1718 mpls_label = port + 16
1719
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001720 # add l2 interface group
1721 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001722 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001723 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001724 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1725 vlan_id, id )
1726 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1727 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001728 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Saurav Das34992182017-04-14 15:59:48 -07001729 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1730 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001731 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001732 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001733 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001734 if config["switch_type"] == "qmx":
1735 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1736 else:
1737 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001738 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Alex Yashchuk9f449462017-12-09 18:27:19 +02001739 if config["switch_type"] != 'xpliant':
1740 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
1741 else:
1742 xpliant_add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001743 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001744 Groups._put( l2_gid )
1745 Groups._put( mpls_gid )
1746 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001747 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001748 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001749
Flavio Castroa7162bb2016-07-25 17:30:30 -07001750 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001751 for in_port in ports:
1752 ip_src = '192.168.%02d.1' % (in_port)
1753 for out_port in ports:
1754 if in_port == out_port:
1755 continue
Flavio Castro54947942016-02-03 16:05:20 -05001756
Charles Chan53cac542016-08-22 16:03:26 -07001757 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1758 out_mpls_label = out_port + 16
1759 in_vlan_vid = in_port + 16
1760 out_vlan_vid = out_port + 16
1761
1762 ip_dst = '192.168.%02d.1' % (out_port)
1763 label = (out_mpls_label, 0, 1, 32)
1764 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001765 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1766 pkt = str( parsed_pkt )
1767 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001768
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001769 # build expect packet
1770 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001771 label = (out_mpls_label, 0, 1, 31)
1772 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001773 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1774 label=[ label ] )
1775 pkt = str( exp_pkt )
1776 verify_packet( self, pkt, out_port )
1777 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001778 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001779 delete_all_flows( self.controller )
1780 delete_groups( self.controller, Groups )
1781 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001782
Saurav Das34992182017-04-14 15:59:48 -07001783@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001784class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001785 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001786
1787 def runTest( self ):
1788 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001789 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001790 if len( config[ "port_map" ] ) < 2:
1791 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001792 return
1793 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001794 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1795 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001796 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001797 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001798 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001799 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1800 vlan_id = port + 16
1801 mpls_label = port + 16
1802
Flavio Castrod80fbc32016-07-25 15:54:26 -07001803 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001804 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001805 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001806 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001807 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1808 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001809 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001810 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001811 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001812 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001813 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001814 if config["switch_type"] == "qmx":
1815 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1816 else:
1817 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Alex Yashchuk9f449462017-12-09 18:27:19 +02001818
1819 if config["switch_type"] != 'xpliant':
1820 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1821 else:
1822 xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1823
Flavio Castroa7162bb2016-07-25 17:30:30 -07001824 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001825 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001826 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001827 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001828 Groups._put( l2_gid )
1829 Groups._put( l3_msg.group_id )
1830 Groups._put( ecmp_msg.group_id )
1831 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001832
Flavio Castroa7162bb2016-07-25 17:30:30 -07001833 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001834 for in_port in ports:
1835 ip_src = '192.168.%02d.1' % (in_port)
1836 for out_port in ports:
1837 if in_port == out_port:
1838 continue
Charles Chan53cac542016-08-22 16:03:26 -07001839
1840 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1841 out_mpls_label = out_port + 16
1842 in_vlan_vid = in_port + 16
1843 out_vlan_vid = out_port + 16
1844
Flavio Castrod80fbc32016-07-25 15:54:26 -07001845 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001846 label = (out_mpls_label, 0, 1, 32)
1847 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001848 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1849 pkt = str( parsed_pkt )
1850 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001851 # build expect packet
1852 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Alex Yashchuk9f449462017-12-09 18:27:19 +02001853 if config["switch_type"] != 'xpliant':
1854 ip_ttl=31
1855 else:
1856 ip_ttl=64
Charles Chan53cac542016-08-22 16:03:26 -07001857 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Alex Yashchuk9f449462017-12-09 18:27:19 +02001858 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=ip_ttl, ip_src=ip_src, ip_dst=ip_dst )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001859 pkt = str( exp_pkt )
1860 verify_packet( self, pkt, out_port )
1861 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001862 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001863 delete_all_flows( self.controller )
1864 delete_groups( self.controller, Groups )
1865 delete_all_groups( self.controller )
Saurav Das15c2c262017-05-06 18:12:38 -07001866
Saurav Das34992182017-04-14 15:59:48 -07001867
1868@disabled
1869class One_MplsTermination( base_tests.SimpleDataPlane ):
1870 """
1871 Verify MPLS VPN Termination at penultimate hop in only one direction
1872 """
1873
1874 def runTest( self ):
1875 Groups = Queue.LifoQueue( )
1876 try:
1877 if len( config[ "port_map" ] ) < 2:
1878 logging.info( "Port count less than 2, can't run this case" )
1879 return
1880 dip = 0xc0a80001
1881 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1882 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1883 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1884 ports = config[ "port_map" ].keys( )
1885 inport = ports[0]
1886 outport = ports[1]
1887
1888 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1889 invlan_id = inport + 16
1890 outvlan_id = outport + 16
1891 mpls_label = outport + 16
1892
1893 # add l2 interface group
1894 id, dst_mac[ 5 ] = inport, outport
1895 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
1896 # add L3 Unicast group
1897 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
1898 src_mac=intf_src_mac, dst_mac=dst_mac )
1899 # add L3 ecmp group
1900 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1901 # add vlan flow table
1902 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1903 # add tmac flow
Saurav Dase94ba572017-04-28 17:47:21 -07001904 if config["switch_type"] == "qmx":
1905 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
1906 else:
1907 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
Saurav Das34992182017-04-14 15:59:48 -07001908 # add mpls termination flow
1909 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
1910 Groups._put( l2_gid )
1911 Groups._put( l3_msg.group_id )
1912 Groups._put( ecmp_msg.group_id )
1913
1914 time.sleep(0.1)
1915 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1916 ip_src = '192.168.%02d.1' % (inport)
1917 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1918 out_mpls_label = outport + 16
1919 in_vlan_vid = inport + 16
1920 out_vlan_vid = outport + 16
1921
1922 ip_dst = '192.168.%02d.1' % (outport)
1923 label = (out_mpls_label, 0, 1, 32)
1924 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1925 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1926 pkt = str( parsed_pkt )
1927 self.dataplane.send( inport, pkt )
1928 # build expect packet
1929 mac_dst = '00:00:00:22:22:%02X' % (outport)
1930 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1931 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1932 pkt = str( exp_pkt )
1933 verify_packet( self, pkt, outport )
1934 verify_no_other_packets( self )
1935 finally:
1936 delete_all_flows( self.controller )
1937 delete_groups( self.controller, Groups )
1938 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001939
Flavio Castroa7162bb2016-07-25 17:30:30 -07001940
1941class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001942 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001943
Flavio Castroa7162bb2016-07-25 17:30:30 -07001944 def runTest( self ):
1945 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001946 try:
1947 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001948 if len( config[ "port_map" ] ) < 2:
1949 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001950 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001951 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1952 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001953 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001954 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001955 for port in ports:
1956 # add l2 interface group
1957 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001958 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1959 is_tagged=True, send_barrier=False )
1960 dst_mac[ 5 ] = vlan_id
1961 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1962 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001963 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001964 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001965 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001966 if config["switch_type"] == "qmx":
1967 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1968 else:
1969 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001970 # add unicast routing flow
1971 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001972 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1973 Groups.put( l2gid )
1974 Groups.put( l3_msg.group_id )
1975 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001976
Flavio Castroa7162bb2016-07-25 17:30:30 -07001977 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001978 for in_port in ports:
1979 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1980 ip_src = '192.168.%02d.1' % (test_id + in_port)
1981 for out_port in ports:
1982 if in_port == out_port:
1983 continue
1984 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001985 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1986 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1987 ip_src=ip_src, ip_dst=ip_dst )
1988 pkt = str( parsed_pkt )
1989 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001990 # build expected packet
1991 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001992 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1993 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1994 ip_src=ip_src, ip_dst=ip_dst )
1995 pkt = str( exp_pkt )
1996 verify_packet( self, pkt, out_port )
1997 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001998 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001999 delete_all_flows( self.controller )
2000 delete_groups( self.controller, Groups )
2001 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002002
Flavio Castroa7162bb2016-07-25 17:30:30 -07002003
2004class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07002005 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07002006
Flavio Castroa7162bb2016-07-25 17:30:30 -07002007 def runTest( self ):
2008 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002009 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002010 if len( config[ "port_map" ] ) < 2:
2011 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002012 return
Flavio Castro91d1a552016-05-17 16:59:44 -07002013
Flavio Castroa7162bb2016-07-25 17:30:30 -07002014 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2015 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002016 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07002017 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002018 for port in ports:
2019 # add l2 interface group
2020 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07002021 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
2022 is_tagged=True, send_barrier=False )
2023 dst_mac[ 5 ] = vlan_id
2024 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
2025 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002026 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002027 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002028 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002029 if config["switch_type"] == "qmx":
2030 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2031 else:
2032 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002033 # add unicast routing flow
2034 dst_ip = dip + (vlan_id << 8)
Alex Yashchuk9f449462017-12-09 18:27:19 +02002035 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id, priority=2 )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002036 Groups.put( l2gid )
2037 Groups.put( l3_msg.group_id )
2038 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002039 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07002040 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
2041 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002042
Flavio Castroa7162bb2016-07-25 17:30:30 -07002043 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002044 for in_port in ports:
2045 mac_src = '00:00:00:22:22:%02X' % (in_port)
2046 ip_src = '192.168.%02d.1' % (in_port)
2047 for out_port in ports:
2048 if in_port == out_port:
2049 continue
2050 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002051 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
2052 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2053 pkt = str( parsed_pkt )
2054 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002055 # build expected packet
2056 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002057 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
2058 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2059 pkt = str( exp_pkt )
2060 verify_packet( self, pkt, out_port )
2061 verify_no_other_packets( self )
2062 ip_dst = '1.168.%02d.1' % ports[ 0 ]
2063 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
2064 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2065 pkt = str( parsed_pkt )
2066 self.dataplane.send( in_port, pkt )
2067 # build expect packet
2068 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2069 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
2070 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
2071 pkt = str( exp_pkt )
2072 verify_packet( self, pkt, ports[ 0 ] )
2073 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002074 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002075 delete_all_flows( self.controller )
2076 delete_groups( self.controller, Groups )
2077 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002078
Flavio Castroa7162bb2016-07-25 17:30:30 -07002079
2080class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002081 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002082 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04002083 """
Flavio Castro91d1a552016-05-17 16:59:44 -07002084
Flavio Castroa7162bb2016-07-25 17:30:30 -07002085 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002086 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002087 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002088 vlan_id = 1;
2089 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002090 add_l2_unfiltered_group( self.controller, [ port ], False )
2091 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002092 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002093 delete_all_flows( self.controller )
2094 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002095
Saurav Das34992182017-04-14 15:59:48 -07002096@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002097class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002098 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002099 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04002100 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07002101
2102 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04002103 """
2104 port1 (vlan 1)-> port 2 (vlan 2)
2105 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002106 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002107 delete_all_flows( self.controller )
2108 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04002109
Flavio Castroa7162bb2016-07-25 17:30:30 -07002110 if len( config[ "port_map" ] ) < 3:
2111 logging.info( "Port count less than 3, can't run this case" )
2112 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002113 return
Flavio Castro423df652016-05-17 20:14:08 -04002114
Flavio Castroa7162bb2016-07-25 17:30:30 -07002115 vlan_id = 1
2116 port2_out_vlan = 2
2117 port3_out_vlan = 3
2118 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
2119 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2120 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2121 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2122 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
2123 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
2124 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
2125 src_ip = 0xc0a80101
2126 src_ip_str = "192.168.1.1"
2127 dst_ip = 0xe0010101
2128 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04002129
Flavio Castroa7162bb2016-07-25 17:30:30 -07002130 port1 = config[ "port_map" ].keys( )[ 0 ]
2131 port2 = config[ "port_map" ].keys( )[ 1 ]
2132 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04002133
Flavio Castroa7162bb2016-07-25 17:30:30 -07002134 # add l2 interface group
2135 for port in config[ "port_map" ].keys( ):
2136 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
2137 send_barrier=False )
2138 # add vlan flow table
2139 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2140 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04002141
Flavio Castroa7162bb2016-07-25 17:30:30 -07002142 # add termination flow
2143 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
2144 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04002145
Flavio Castroa7162bb2016-07-25 17:30:30 -07002146 # add MPLS interface group
2147 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
2148 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
2149 port2_out_vlan, port2 )
2150 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
2151 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
2152 # add L3VPN groups
2153 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
2154 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
2155 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
2156 # 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 -07002157 # 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 -04002158
Flavio Castroa7162bb2016-07-25 17:30:30 -07002159 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
2160 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 -04002161
Flavio Castroa7162bb2016-07-25 17:30:30 -07002162 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
2163 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
2164 pkt = str( parsed_pkt )
2165 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002166 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002167 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
2168 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
2169 pkt = str( exp_pkt )
2170 verify_packet( self, pkt, port2 )
2171 # verify_packet(self, pkt, port3)
2172 verify_no_other_packets( self )
2173 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002174 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002175 delete_all_flows( self.controller )
2176 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002177
Saurav Das34992182017-04-14 15:59:48 -07002178@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002179class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002180 """
2181 Test packet in function on a src-mac miss
2182 Send a packet to each dataplane port and verify that a packet
2183 in message is received from the controller for each
2184 #todo verify you stop receiving after adding rule
2185 """
2186
Flavio Castroa7162bb2016-07-25 17:30:30 -07002187 def runTest( self ):
2188 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002189 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002190 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04002191
Flavio Castroa7162bb2016-07-25 17:30:30 -07002192 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002193 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002194 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2195 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2196 Groups.put( L2gid )
2197 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2198 vlan_pkt = str( parsed_vlan_pkt )
2199 for of_port in config[ "port_map" ].keys( ):
2200 logging.info( "PacketInMiss test, port %d", of_port )
2201 self.dataplane.send( of_port, vlan_pkt )
2202 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2203 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002204 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002205 delete_all_flows( self.controller )
2206 delete_all_groups( self.controller )
2207
2208
2209class EcmpGroupMod( base_tests.SimpleDataPlane ):
2210 """
Saurav Das34992182017-04-14 15:59:48 -07002211 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07002212 """
2213
2214 def runTest( self ):
2215 Groups = Queue.LifoQueue( )
2216 try:
2217 if len( config[ "port_map" ] ) < 2:
2218 logging.info( "Port count less than 2, can't run this case" )
2219 return
2220
2221 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2222 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2223 dip = 0xc0a80001
2224 # Hashes Test Name and uses it as id for installing unique groups
2225 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002226 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002227 dst_ips = []
2228 # add flows for all ports but include only the egress switchport (connected to ports[1])
2229 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002230 for port in ports:
2231 vlan_id = port
2232 id = port
2233 # add l2 interface group
2234 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2235 is_tagged=True, send_barrier=False )
2236 dst_mac[ 5 ] = vlan_id
2237 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2238 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002239 if port == ports[1]:
2240 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002241 Groups._put( l2_gid )
2242 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002243 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002244 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002245 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002246 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002247 if config["switch_type"] == "qmx":
2248 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2249 else:
2250 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002251 # add unicast routing flow
2252 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002253 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002254 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002255 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002256 for dst_ip in dst_ips:
2257 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2258 time.sleep(0.1)
2259 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002260 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002261 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002262 in_port = ports[0]
2263 out_port = ports[1]
2264 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2265 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2266 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2267 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2268 tcp = out_port if out_port == 24 else 25
2269 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2270 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2271 ip_dst=ip_dst, tcp_dport=tcp )
2272 pkt = str( parsed_pkt )
2273 self.dataplane.send( ports[ 0 ], pkt )
2274 # build expected packet at egress switchport
2275 mac_dst = '00:00:00:22:22:%02X' % out_port
2276 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2277 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2278 ip_dst=ip_dst, tcp_dport=tcp )
2279 pkt = str( exp_pkt )
2280 verify_packet( self, pkt, out_port )
2281 verify_no_other_packets( self )
2282
2283 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2284 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2285 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002286 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2287 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002288 time.sleep(0.1)
2289 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2290 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2291 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2292 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2293 tcp = port if port == 24 else 25
2294 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2295 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2296 ip_dst=ip_dst,tcp_dport=tcp )
2297 pkt = str( parsed_pkt )
2298 self.dataplane.send( ports[ 0 ], pkt )
2299 # build expected packet
2300 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2301 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2302 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2303 ip_dst=ip_dst,tcp_dport=tcp )
Alex Yashchuk9f449462017-12-09 18:27:19 +02002304 # Expects packet on the input port
2305 if config["switch_type"] != 'xpliant':
2306 pkt = str( exp_pkt )
2307 verify_packet( self, pkt, ports[ 0 ] )
2308 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -07002309
2310 # third part of the test - edit the group to completely remove bucket. Packet sent
2311 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002312 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002313 time.sleep(0.1)
2314 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2315 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2316 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2317 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2318 tcp = port if port == 24 else 25
2319 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2320 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2321 ip_dst=ip_dst,tcp_dport=tcp )
2322 pkt = str( parsed_pkt )
2323 self.dataplane.send( ports[ 0 ], pkt )
2324 verify_no_other_packets( self )
2325
2326 # final part of the test - edit the empty group to add back the bucket for the
2327 # original egress port, and verify packet is received on egress switch port
2328 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2329 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Alex Yashchuk9f449462017-12-09 18:27:19 +02002330 do_barrier(self.controller)
Saurav Das34992182017-04-14 15:59:48 -07002331 in_port = ports[0]
2332 out_port = ports[1]
2333 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2334 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2335 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2336 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2337 tcp = out_port if out_port == 24 else 25
2338 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2339 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2340 ip_dst=ip_dst, tcp_dport=tcp )
2341 pkt = str( parsed_pkt )
2342 self.dataplane.send( ports[ 0 ], pkt )
2343 # build expected packet at egress switchport
2344 mac_dst = '00:00:00:22:22:%02X' % out_port
2345 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2346 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2347 ip_dst=ip_dst, tcp_dport=tcp )
2348 pkt = str( exp_pkt )
2349 verify_packet( self, pkt, out_port )
2350 verify_no_other_packets( self )
2351
Flavio Castroa7162bb2016-07-25 17:30:30 -07002352 finally:
2353 delete_all_flows( self.controller )
2354 delete_groups( self.controller, Groups )
2355 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002356
Saurav Das34992182017-04-14 15:59:48 -07002357
Pier8b223022016-08-19 22:47:49 -07002358class Untagged( base_tests.SimpleDataPlane ):
2359 """
2360 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2361 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2362 previous versions of the OFDPA.
2363
2364 Two rules are necessary in VLAN table (10):
2365 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2366 2) Filtering: match 0x100A/0x1FFF, goto 20
2367
2368 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2369 The remaining part of the test is based on the use of the bridging table
2370 """
2371
2372 MAX_INTERNAL_VLAN = 4094
2373
2374 def runTest( self ):
2375 groups = Queue.LifoQueue( )
2376 try:
2377 if len( config[ "port_map" ] ) < 2:
2378 logging.info( "Port count less than 2, can't run this case" )
2379 return
2380
2381 ports = sorted( config[ "port_map" ].keys( ) )
2382 for port in ports:
2383 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002384 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2385 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002386 for other_port in ports:
2387 if other_port == port:
2388 continue
2389 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2390 groups.put( L2gid )
2391 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2392
2393 do_barrier( self.controller )
2394
2395 for out_port in ports:
2396 # change dest based on port number
2397 mac_dst = '00:12:34:56:78:%02X' % out_port
2398 for in_port in ports:
2399 if in_port == out_port:
2400 continue
2401 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2402 self.dataplane.send( in_port, pkt )
2403 for ofport in ports:
2404 if ofport in [ out_port ]:
2405 verify_packet( self, pkt, ofport )
2406 else:
2407 verify_no_packet( self, pkt, ofport )
2408 verify_no_other_packets( self )
2409 finally:
2410 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002411 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002412 delete_all_groups( self.controller )
Andreas Pantelopoulos6c76b942018-01-22 10:03:02 -08002413
2414class MPLSSwapTest( base_tests.SimpleDataPlane ):
2415 """
2416 MPLS switching with the same label used.
2417 Used for interconnecting spines between different fabrics where
2418 the label should not be popped, but swapepd with the same label.
2419 """
2420
2421 def runTest( self ):
2422 try:
2423 delete_all_flows( self.controller )
2424 delete_all_groups( self.controller )
2425
2426 if len( config[ "port_map" ] ) < 2:
2427 logging.info( "Port count less than 3, can't run this case" )
2428 assert (False)
2429 return
2430
2431 input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2432 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2433
2434 input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ]
2435 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2436
2437 output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ]
2438 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2439
2440 mpls_label = 1000
2441
2442 src_ip = 0xc0a80101
2443 src_ip_str = "192.168.1.1"
2444 dst_ip = 0xe0010101
2445 dst_ip_str = "224.1.1.1"
2446
2447 src_port = config[ "port_map" ].keys( )[ 0 ]
2448 dst_port = config[ "port_map" ].keys( )[ 1 ]
2449
2450 out_vlan = 4094
2451
2452 add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False,
2453 send_barrier=True )
2454
2455 # add vlan flow table
2456 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2457 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2458
2459 # add termination flow
2460
2461 if config["switch_type"] == "qmx":
2462 logging.debug("MPLSSwitching : Adding flow for qmx, without input port")
2463 add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2464 else:
2465 add_termination_flow( self.controller, in_port=src_port,
2466 eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2467
2468 # add groups that will be used now
2469 l2_gid = encode_l2_interface_group_id( out_vlan, dst_port)
2470 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid,
2471 output_dst_mac, input_dst_mac,
2472 out_vlan, dst_port, send_barrier=True)
2473 index = 60
2474 mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid,
2475 5, index, mpls_label)
2476
2477 # add flow to mpls table
2478 add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True)
2479
2480 # we generate the packet which carries a single label
2481 label = (mpls_label, 0, 1, 63)
2482 parsed_pkt = mpls_packet(
2483 pktlen=104,
2484 label=[label],
2485 eth_src=input_src_mac_str,
2486 eth_dst=input_dst_mac_str,
2487 )
2488 pkt = str( parsed_pkt )
2489 self.dataplane.send( src_port, pkt )
2490
2491 label = (mpls_label, 0, 1, 62)
2492 parsed_pkt = mpls_packet(
2493 pktlen=104,
2494 label=[label],
2495 eth_src=input_dst_mac_str,
2496 eth_dst=output_dst_mac_str,
2497 )
2498 pkt = str( parsed_pkt )
2499
2500 verify_packet( self, pkt, dst_port )
2501 verify_no_packet( self, pkt, src_port )
2502 verify_no_other_packets( self )
2503
2504 delete_all_flows( self.controller )
2505 delete_all_groups( self.controller )
2506
2507 finally:
2508 delete_all_flows( self.controller )
2509 delete_all_groups( self.controller )
2510
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07002511class DoubleToUntagged( base_tests.SimpleDataPlane ):
2512 """
2513 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2514 where we receive double tagged packets and output untagged
2515 packets.
2516
2517 Each double tagged packet represents a subscriber where Outer tag is pon
2518 and inner tag is the subrscriber tag.
2519 """
2520
2521 def runTest( self ):
2522 Groups = Queue.LifoQueue( )
2523 try:
2524 if len( config[ "port_map" ] ) < 2:
2525 logging.info( "Port count less than 2, can't run this case" )
2526 return
2527
2528 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2529 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2530
2531 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2532 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2533
2534 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2535 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2536
2537 dip = 0xc0a80001
2538 ports = config[ "port_map" ].keys( )
2539
2540 inner_vlan = 66
2541 outer_vlan = 77
2542 id = 10
2543 mpls_label = 152
2544
2545 port = ports[0]
2546 out_port = ports[1]
2547
2548 # add l2 interface group
2549 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2550
2551 # add MPLS interface group
2552 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2553 inner_vlan, id )
2554
2555 # add MPLS L3 VPN group
2556 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2557 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2558 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2559 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2560
2561 do_barrier( self.controller )
2562
2563 # add vlan flow table
2564 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2565 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2566
2567 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2568 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2569
2570 # add termination flow
2571 if config["switch_type"] == "qmx":
2572 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2573 else:
2574 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2575
2576 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2577 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2578 vrf=0 )
2579 Groups._put( l2_gid )
2580 Groups._put( mpls_gid )
2581 Groups._put( mpls_label_gid )
2582 Groups._put( ecmp_msg.group_id )
2583
2584 do_barrier( self.controller )
2585
2586 ip_src = '192.168.5.5'
2587 ip_dst = '192.168.0.5'
2588 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2589 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2590 pkt = str( parsed_pkt )
2591
2592 # print("Expected %s" % format_packet(pkt))
2593
2594 self.dataplane.send( port, pkt )
2595
2596 # build expect packet
2597 label = (mpls_label, 0, 1, 32)
2598 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2599 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2600 label=[ label ] )
2601 pkt = str( exp_pkt )
2602 verify_packet( self, pkt, out_port )
2603 verify_no_other_packets( self )
2604
2605 finally:
2606 delete_all_flows( self.controller )
2607 delete_groups( self.controller, Groups )
2608 delete_all_groups( self.controller )
2609
2610class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ):
2611 """
2612 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2613 where we receive double tagged packets and output untagged
2614 packets.
2615
2616 Each double tagged packet represents a subscriber where Outer tag is pon
2617 and inner tag is the subrscriber tag.
2618 """
2619
2620 def runTest( self ):
2621 Groups = Queue.LifoQueue( )
2622 try:
2623 if len( config[ "port_map" ] ) < 2:
2624 logging.info( "Port count less than 2, can't run this case" )
2625 return
2626
2627 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
2628 subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"],
2629 [20, 0xc0a80002, 10, 101, "192.168.0.2"],
2630 [30, 0xc0a80003, 11, 100, "192.168.0.3"],
2631 [40, 0xc0a80004, 11, 101, "192.168.0.4"]]
2632
2633 print("")
2634
2635 for sub_info in subscriber_info:
2636
2637 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
2638
2639 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2640 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2641
2642 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2643 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2644
2645 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2646 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2647
2648 dip = sub_info[1]
2649 ports = config[ "port_map" ].keys( )
2650
2651 inner_vlan = sub_info[2]
2652 outer_vlan = sub_info[3]
2653 id = 10
2654 mpls_label = 152
2655
2656 port = ports[0]
2657 out_port = ports[1]
2658
2659 # add l2 interface group
2660 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2661
2662 # add MPLS interface group
2663 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2664 inner_vlan, id )
2665
2666 # add MPLS L3 VPN group
2667 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2668 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2669 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2670 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2671
2672 do_barrier( self.controller )
2673
2674 # add vlan flow table
2675 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2676 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2677
2678 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2679 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2680
2681 # add termination flow
2682 if config["switch_type"] == "qmx":
2683 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2684 else:
2685 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2686
2687 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2688 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2689 vrf=0 )
2690 Groups._put( l2_gid )
2691 Groups._put( mpls_gid )
2692 Groups._put( mpls_label_gid )
2693 Groups._put( ecmp_msg.group_id )
2694
2695 do_barrier( self.controller )
2696
2697 for sub_info in subscriber_info:
2698
2699 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
2700
2701 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2702 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2703
2704 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2705 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2706
2707 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2708 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2709
2710 dip = sub_info[1]
2711 ports = config[ "port_map" ].keys( )
2712
2713 inner_vlan = sub_info[2]
2714 outer_vlan = sub_info[3]
2715 id = 10
2716 mpls_label = 152
2717
2718 port = ports[0]
2719 out_port = ports[1]
2720
2721 ip_src = sub_info[4]
2722 ip_dst = '192.168.0.{}'.format(sub_info[0])
2723 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2724 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2725 pkt = str( parsed_pkt )
2726
2727 # print("Sent %s" % format_packet(pkt))
2728
2729 self.dataplane.send( port, pkt )
2730
2731 # build expect packet
2732 label = (mpls_label, 0, 1, 32)
2733 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2734 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2735 label=[ label ] )
2736 pkt = str( exp_pkt )
2737 verify_packet( self, pkt, out_port )
2738 verify_no_other_packets( self )
2739
2740 finally:
2741 delete_all_flows( self.controller )
2742 delete_groups( self.controller, Groups )
2743 delete_all_groups( self.controller )
2744
2745
2746class UntaggedToDouble ( base_tests.SimpleDataPlane ):
2747 """
2748 Verify google senario where we need to go from
2749 an untagged packet to a double tagged packet.
2750
2751 This is used for a single subscriber.
2752 """
2753
2754 def runTest( self ):
2755 Groups = Queue.LifoQueue( )
2756 try:
2757 if len( config[ "port_map" ] ) < 2:
2758 logging.info( "Port count less than 2, can't run this case" )
2759 return
2760
2761 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2762 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2763
2764 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2765 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2766
2767 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2768 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2769
2770 dip = 0xc0a80001
2771 ports = config[ "port_map" ].keys( )
2772
2773 inner_vlan = 66
2774 outer_vlan = 77
2775 id = 10
2776 mpls_label = 152
2777
2778 port = ports[0]
2779 out_port = ports[1]
2780
2781 # add l2 unfiltered interface group
2782 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
2783
2784 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id,
2785 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
2786
2787 do_barrier( self.controller )
2788
2789 # add vlan flow table
2790 add_one_vlan_table_flow( self.controller, port, 1, 4094,
2791 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
2792
2793 # add termination flow
2794 if config["switch_type"] == "qmx":
2795 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
2796 else:
2797 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
2798
2799 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
2800 vrf=0 )
2801
2802 add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan)
2803
2804 Groups._put( l2_gid )
2805 Groups._put( l3_msg.group_id )
2806
2807 do_barrier( self.controller )
2808
2809 ip_src = '192.168.5.5'
2810 ip_dst = '192.168.0.1'
2811 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
2812 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2813 pkt = str( parsed_pkt )
2814
2815 # print("Input Packet %s" % format_packet(pkt))
2816
2817 self.dataplane.send( port, pkt )
2818
2819 # build expect packet
2820 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2821 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2822 pkt = str( exp_pkt )
2823
2824 # print("Expected Packet %s" % format_packet(pkt))
2825
2826 verify_packet( self, pkt, out_port )
2827 verify_no_other_packets( self )
2828 finally:
2829 delete_all_flows( self.controller )
2830 delete_groups( self.controller, Groups )
2831 delete_all_groups( self.controller )
2832
2833class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ):
2834 """
2835 Verify google senario where we need to go from
2836 an untagged packet to a double tagged packet.
2837
2838 This is used for multiple subscribers.
2839
2840 However, this solution does not scale, since we assign an internal vlan to each subscriber
2841 used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table.
2842 """
2843
2844 def runTest( self ):
2845 Groups = Queue.LifoQueue( )
2846 try:
2847 if len( config[ "port_map" ] ) < 2:
2848 logging.info( "Port count less than 2, can't run this case" )
2849 return
2850
2851 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan]
2852 subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000],
2853 [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001],
2854 [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002],
2855 [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]]
2856
2857 print("")
2858
2859 for sub_info in subscriber_info:
2860
2861 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
2862
2863 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2864 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2865
2866 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2867 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2868
2869 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2870 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2871
2872 dip = sub_info[1]
2873 ports = config[ "port_map" ].keys( )
2874
2875 inner_vlan = sub_info[2]
2876 outer_vlan = sub_info[3]
2877 internal_vlan = sub_info[5]
2878 id = sub_info[0] + 10
2879
2880 port = ports[0]
2881 out_port = ports[1]
2882
2883 # add l2 unfiltered interface group
2884 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
2885
2886 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id,
2887 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
2888
2889 do_barrier( self.controller )
2890
2891 # add vlan flow table
2892 add_one_vlan_table_flow( self.controller, port, 1, 4094,
2893 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
2894
2895 # add termination flow
2896 if config["switch_type"] == "qmx":
2897 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
2898 else:
2899 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
2900
2901 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
2902 vrf=0 )
2903
2904 add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan)
2905
2906 Groups._put( l2_gid )
2907 Groups._put( l3_msg.group_id )
2908 do_barrier( self.controller )
2909
2910 for sub_info in subscriber_info:
2911
2912 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
2913
2914 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2915 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2916
2917 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2918 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2919
2920 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2921 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2922
2923 dip = sub_info[1]
2924 ports = config[ "port_map" ].keys( )
2925
2926 inner_vlan = sub_info[2]
2927 outer_vlan = sub_info[3]
2928 internal_vlan = sub_info[5]
2929
2930 id = sub_info[0] + 10
2931 ip_src = '192.168.5.5'
2932 ip_dst = '192.168.0.{}'.format(sub_info[0])
2933 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
2934 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2935 pkt = str( parsed_pkt )
2936
2937 # print("Input Packet %s" % format_packet(pkt))
2938
2939 self.dataplane.send( port, pkt )
2940
2941 # build expect packet
2942 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2943 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2944 pkt = str( exp_pkt )
2945
2946 # print("Expected Packet %s" % format_packet(pkt))
2947
2948 verify_packet( self, pkt, out_port )
2949 verify_no_other_packets( self )
2950 finally:
2951 delete_all_flows( self.controller )
2952 delete_groups( self.controller, Groups )
2953 delete_all_groups( self.controller )
Andreas Pantelopoulos6c76b942018-01-22 10:03:02 -08002954