blob: 9c6c5aab6a4042ecdaf9294c339da22f0ed38d48 [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 )
Charles Chan53cac542016-08-22 16:03:26 -07001739 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001740 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001741 Groups._put( l2_gid )
1742 Groups._put( mpls_gid )
1743 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001744 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001745 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001746
Flavio Castroa7162bb2016-07-25 17:30:30 -07001747 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001748 for in_port in ports:
1749 ip_src = '192.168.%02d.1' % (in_port)
1750 for out_port in ports:
1751 if in_port == out_port:
1752 continue
Flavio Castro54947942016-02-03 16:05:20 -05001753
Charles Chan53cac542016-08-22 16:03:26 -07001754 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1755 out_mpls_label = out_port + 16
1756 in_vlan_vid = in_port + 16
1757 out_vlan_vid = out_port + 16
1758
1759 ip_dst = '192.168.%02d.1' % (out_port)
1760 label = (out_mpls_label, 0, 1, 32)
1761 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001762 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1763 pkt = str( parsed_pkt )
1764 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001765
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001766 # build expect packet
1767 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001768 label = (out_mpls_label, 0, 1, 31)
1769 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001770 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1771 label=[ label ] )
1772 pkt = str( exp_pkt )
1773 verify_packet( self, pkt, out_port )
1774 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001775 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001776 delete_all_flows( self.controller )
1777 delete_groups( self.controller, Groups )
1778 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001779
Saurav Das34992182017-04-14 15:59:48 -07001780@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001781class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001782 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001783
1784 def runTest( self ):
1785 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001786 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001787 if len( config[ "port_map" ] ) < 2:
1788 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001789 return
1790 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001791 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1792 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001793 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001794 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001795 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001796 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1797 vlan_id = port + 16
1798 mpls_label = port + 16
1799
Flavio Castrod80fbc32016-07-25 15:54:26 -07001800 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001801 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001802 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001803 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001804 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1805 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001806 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001807 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001808 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001809 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001810 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001811 if config["switch_type"] == "qmx":
1812 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1813 else:
1814 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Charles Chan53cac542016-08-22 16:03:26 -07001815 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001816 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001817 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001818 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001819 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001820 Groups._put( l2_gid )
1821 Groups._put( l3_msg.group_id )
1822 Groups._put( ecmp_msg.group_id )
1823 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001824
Flavio Castroa7162bb2016-07-25 17:30:30 -07001825 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001826 for in_port in ports:
1827 ip_src = '192.168.%02d.1' % (in_port)
1828 for out_port in ports:
1829 if in_port == out_port:
1830 continue
Charles Chan53cac542016-08-22 16:03:26 -07001831
1832 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1833 out_mpls_label = out_port + 16
1834 in_vlan_vid = in_port + 16
1835 out_vlan_vid = out_port + 16
1836
Flavio Castrod80fbc32016-07-25 15:54:26 -07001837 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001838 label = (out_mpls_label, 0, 1, 32)
1839 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001840 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1841 pkt = str( parsed_pkt )
1842 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001843 # build expect packet
1844 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001845 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001846 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1847 pkt = str( exp_pkt )
1848 verify_packet( self, pkt, out_port )
1849 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001850 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001851 delete_all_flows( self.controller )
1852 delete_groups( self.controller, Groups )
1853 delete_all_groups( self.controller )
Saurav Das15c2c262017-05-06 18:12:38 -07001854
Saurav Das34992182017-04-14 15:59:48 -07001855
1856@disabled
1857class One_MplsTermination( base_tests.SimpleDataPlane ):
1858 """
1859 Verify MPLS VPN Termination at penultimate hop in only one direction
1860 """
1861
1862 def runTest( self ):
1863 Groups = Queue.LifoQueue( )
1864 try:
1865 if len( config[ "port_map" ] ) < 2:
1866 logging.info( "Port count less than 2, can't run this case" )
1867 return
1868 dip = 0xc0a80001
1869 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1870 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1871 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1872 ports = config[ "port_map" ].keys( )
1873 inport = ports[0]
1874 outport = ports[1]
1875
1876 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1877 invlan_id = inport + 16
1878 outvlan_id = outport + 16
1879 mpls_label = outport + 16
1880
1881 # add l2 interface group
1882 id, dst_mac[ 5 ] = inport, outport
1883 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
1884 # add L3 Unicast group
1885 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
1886 src_mac=intf_src_mac, dst_mac=dst_mac )
1887 # add L3 ecmp group
1888 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1889 # add vlan flow table
1890 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1891 # add tmac flow
Saurav Dase94ba572017-04-28 17:47:21 -07001892 if config["switch_type"] == "qmx":
1893 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
1894 else:
1895 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
Saurav Das34992182017-04-14 15:59:48 -07001896 # add mpls termination flow
1897 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
1898 Groups._put( l2_gid )
1899 Groups._put( l3_msg.group_id )
1900 Groups._put( ecmp_msg.group_id )
1901
1902 time.sleep(0.1)
1903 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1904 ip_src = '192.168.%02d.1' % (inport)
1905 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1906 out_mpls_label = outport + 16
1907 in_vlan_vid = inport + 16
1908 out_vlan_vid = outport + 16
1909
1910 ip_dst = '192.168.%02d.1' % (outport)
1911 label = (out_mpls_label, 0, 1, 32)
1912 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1913 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1914 pkt = str( parsed_pkt )
1915 self.dataplane.send( inport, pkt )
1916 # build expect packet
1917 mac_dst = '00:00:00:22:22:%02X' % (outport)
1918 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1919 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1920 pkt = str( exp_pkt )
1921 verify_packet( self, pkt, outport )
1922 verify_no_other_packets( self )
1923 finally:
1924 delete_all_flows( self.controller )
1925 delete_groups( self.controller, Groups )
1926 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001927
Flavio Castroa7162bb2016-07-25 17:30:30 -07001928
1929class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001930 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001931
Flavio Castroa7162bb2016-07-25 17:30:30 -07001932 def runTest( self ):
1933 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001934 try:
1935 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07001936 if len( config[ "port_map" ] ) < 2:
1937 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001938 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001939 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1940 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001941 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001942 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001943 for port in ports:
1944 # add l2 interface group
1945 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001946 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1947 is_tagged=True, send_barrier=False )
1948 dst_mac[ 5 ] = vlan_id
1949 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1950 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001951 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001952 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001953 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001954 if config["switch_type"] == "qmx":
1955 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1956 else:
1957 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001958 # add unicast routing flow
1959 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001960 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
1961 Groups.put( l2gid )
1962 Groups.put( l3_msg.group_id )
1963 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001964
Flavio Castroa7162bb2016-07-25 17:30:30 -07001965 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001966 for in_port in ports:
1967 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1968 ip_src = '192.168.%02d.1' % (test_id + in_port)
1969 for out_port in ports:
1970 if in_port == out_port:
1971 continue
1972 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001973 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1974 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
1975 ip_src=ip_src, ip_dst=ip_dst )
1976 pkt = str( parsed_pkt )
1977 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001978 # build expected packet
1979 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001980 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
1981 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
1982 ip_src=ip_src, ip_dst=ip_dst )
1983 pkt = str( exp_pkt )
1984 verify_packet( self, pkt, out_port )
1985 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001986 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001987 delete_all_flows( self.controller )
1988 delete_groups( self.controller, Groups )
1989 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07001990
Flavio Castroa7162bb2016-07-25 17:30:30 -07001991
1992class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001993 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07001994
Flavio Castroa7162bb2016-07-25 17:30:30 -07001995 def runTest( self ):
1996 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001997 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001998 if len( config[ "port_map" ] ) < 2:
1999 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002000 return
Flavio Castro91d1a552016-05-17 16:59:44 -07002001
Flavio Castroa7162bb2016-07-25 17:30:30 -07002002 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2003 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002004 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07002005 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002006 for port in ports:
2007 # add l2 interface group
2008 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07002009 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
2010 is_tagged=True, send_barrier=False )
2011 dst_mac[ 5 ] = vlan_id
2012 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
2013 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002014 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002015 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002016 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002017 if config["switch_type"] == "qmx":
2018 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2019 else:
2020 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002021 # add unicast routing flow
2022 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002023 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
2024 Groups.put( l2gid )
2025 Groups.put( l3_msg.group_id )
2026 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002027 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07002028 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
2029 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002030
Flavio Castroa7162bb2016-07-25 17:30:30 -07002031 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002032 for in_port in ports:
2033 mac_src = '00:00:00:22:22:%02X' % (in_port)
2034 ip_src = '192.168.%02d.1' % (in_port)
2035 for out_port in ports:
2036 if in_port == out_port:
2037 continue
2038 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002039 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
2040 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2041 pkt = str( parsed_pkt )
2042 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002043 # build expected packet
2044 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002045 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
2046 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2047 pkt = str( exp_pkt )
2048 verify_packet( self, pkt, out_port )
2049 verify_no_other_packets( self )
2050 ip_dst = '1.168.%02d.1' % ports[ 0 ]
2051 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 )
2055 # build expect packet
2056 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2057 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
2058 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
2059 pkt = str( exp_pkt )
2060 verify_packet( self, pkt, ports[ 0 ] )
2061 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002062 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002063 delete_all_flows( self.controller )
2064 delete_groups( self.controller, Groups )
2065 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002066
Flavio Castroa7162bb2016-07-25 17:30:30 -07002067
2068class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002069 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002070 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04002071 """
Flavio Castro91d1a552016-05-17 16:59:44 -07002072
Flavio Castroa7162bb2016-07-25 17:30:30 -07002073 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002074 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002075 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002076 vlan_id = 1;
2077 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002078 add_l2_unfiltered_group( self.controller, [ port ], False )
2079 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002080 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002081 delete_all_flows( self.controller )
2082 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002083
Saurav Das34992182017-04-14 15:59:48 -07002084@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002085class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002086 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002087 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04002088 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07002089
2090 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04002091 """
2092 port1 (vlan 1)-> port 2 (vlan 2)
2093 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002094 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002095 delete_all_flows( self.controller )
2096 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04002097
Flavio Castroa7162bb2016-07-25 17:30:30 -07002098 if len( config[ "port_map" ] ) < 3:
2099 logging.info( "Port count less than 3, can't run this case" )
2100 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002101 return
Flavio Castro423df652016-05-17 20:14:08 -04002102
Flavio Castroa7162bb2016-07-25 17:30:30 -07002103 vlan_id = 1
2104 port2_out_vlan = 2
2105 port3_out_vlan = 3
2106 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
2107 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2108 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2109 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2110 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
2111 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
2112 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
2113 src_ip = 0xc0a80101
2114 src_ip_str = "192.168.1.1"
2115 dst_ip = 0xe0010101
2116 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04002117
Flavio Castroa7162bb2016-07-25 17:30:30 -07002118 port1 = config[ "port_map" ].keys( )[ 0 ]
2119 port2 = config[ "port_map" ].keys( )[ 1 ]
2120 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04002121
Flavio Castroa7162bb2016-07-25 17:30:30 -07002122 # add l2 interface group
2123 for port in config[ "port_map" ].keys( ):
2124 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
2125 send_barrier=False )
2126 # add vlan flow table
2127 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2128 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04002129
Flavio Castroa7162bb2016-07-25 17:30:30 -07002130 # add termination flow
2131 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
2132 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04002133
Flavio Castroa7162bb2016-07-25 17:30:30 -07002134 # add MPLS interface group
2135 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
2136 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
2137 port2_out_vlan, port2 )
2138 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
2139 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
2140 # add L3VPN groups
2141 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
2142 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
2143 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
2144 # 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 -07002145 # 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 -04002146
Flavio Castroa7162bb2016-07-25 17:30:30 -07002147 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
2148 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 -04002149
Flavio Castroa7162bb2016-07-25 17:30:30 -07002150 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
2151 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
2152 pkt = str( parsed_pkt )
2153 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002154 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002155 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
2156 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
2157 pkt = str( exp_pkt )
2158 verify_packet( self, pkt, port2 )
2159 # verify_packet(self, pkt, port3)
2160 verify_no_other_packets( self )
2161 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002162 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002163 delete_all_flows( self.controller )
2164 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002165
Saurav Das34992182017-04-14 15:59:48 -07002166@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002167class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002168 """
2169 Test packet in function on a src-mac miss
2170 Send a packet to each dataplane port and verify that a packet
2171 in message is received from the controller for each
2172 #todo verify you stop receiving after adding rule
2173 """
2174
Flavio Castroa7162bb2016-07-25 17:30:30 -07002175 def runTest( self ):
2176 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002177 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002178 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04002179
Flavio Castroa7162bb2016-07-25 17:30:30 -07002180 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002181 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002182 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2183 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2184 Groups.put( L2gid )
2185 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2186 vlan_pkt = str( parsed_vlan_pkt )
2187 for of_port in config[ "port_map" ].keys( ):
2188 logging.info( "PacketInMiss test, port %d", of_port )
2189 self.dataplane.send( of_port, vlan_pkt )
2190 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2191 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002192 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002193 delete_all_flows( self.controller )
2194 delete_all_groups( self.controller )
2195
2196
2197class EcmpGroupMod( base_tests.SimpleDataPlane ):
2198 """
Saurav Das34992182017-04-14 15:59:48 -07002199 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07002200 """
2201
2202 def runTest( self ):
2203 Groups = Queue.LifoQueue( )
2204 try:
2205 if len( config[ "port_map" ] ) < 2:
2206 logging.info( "Port count less than 2, can't run this case" )
2207 return
2208
2209 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2210 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2211 dip = 0xc0a80001
2212 # Hashes Test Name and uses it as id for installing unique groups
2213 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002214 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002215 dst_ips = []
2216 # add flows for all ports but include only the egress switchport (connected to ports[1])
2217 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002218 for port in ports:
2219 vlan_id = port
2220 id = port
2221 # add l2 interface group
2222 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2223 is_tagged=True, send_barrier=False )
2224 dst_mac[ 5 ] = vlan_id
2225 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2226 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002227 if port == ports[1]:
2228 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002229 Groups._put( l2_gid )
2230 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002231 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002232 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002233 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002234 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002235 if config["switch_type"] == "qmx":
2236 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2237 else:
2238 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002239 # add unicast routing flow
2240 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002241 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002242 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002243 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002244 for dst_ip in dst_ips:
2245 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2246 time.sleep(0.1)
2247 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002248 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002249 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002250 in_port = ports[0]
2251 out_port = ports[1]
2252 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2253 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2254 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2255 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2256 tcp = out_port if out_port == 24 else 25
2257 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2258 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2259 ip_dst=ip_dst, tcp_dport=tcp )
2260 pkt = str( parsed_pkt )
2261 self.dataplane.send( ports[ 0 ], pkt )
2262 # build expected packet at egress switchport
2263 mac_dst = '00:00:00:22:22:%02X' % out_port
2264 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2265 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2266 ip_dst=ip_dst, tcp_dport=tcp )
2267 pkt = str( exp_pkt )
2268 verify_packet( self, pkt, out_port )
2269 verify_no_other_packets( self )
2270
2271 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2272 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2273 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002274 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2275 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002276 time.sleep(0.1)
2277 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2278 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2279 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2280 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2281 tcp = port if port == 24 else 25
2282 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2283 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2284 ip_dst=ip_dst,tcp_dport=tcp )
2285 pkt = str( parsed_pkt )
2286 self.dataplane.send( ports[ 0 ], pkt )
2287 # build expected packet
2288 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2289 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2290 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2291 ip_dst=ip_dst,tcp_dport=tcp )
2292 pkt = str( exp_pkt )
2293 verify_packet( self, pkt, ports[ 0 ] )
2294 verify_no_other_packets( self )
2295
2296 # third part of the test - edit the group to completely remove bucket. Packet sent
2297 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002298 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002299 time.sleep(0.1)
2300 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2301 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2302 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2303 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2304 tcp = port if port == 24 else 25
2305 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2306 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2307 ip_dst=ip_dst,tcp_dport=tcp )
2308 pkt = str( parsed_pkt )
2309 self.dataplane.send( ports[ 0 ], pkt )
2310 verify_no_other_packets( self )
2311
2312 # final part of the test - edit the empty group to add back the bucket for the
2313 # original egress port, and verify packet is received on egress switch port
2314 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2315 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2316 time.sleep(0.1)
2317 in_port = ports[0]
2318 out_port = ports[1]
2319 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2320 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2321 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2322 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2323 tcp = out_port if out_port == 24 else 25
2324 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2325 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2326 ip_dst=ip_dst, tcp_dport=tcp )
2327 pkt = str( parsed_pkt )
2328 self.dataplane.send( ports[ 0 ], pkt )
2329 # build expected packet at egress switchport
2330 mac_dst = '00:00:00:22:22:%02X' % out_port
2331 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2332 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2333 ip_dst=ip_dst, tcp_dport=tcp )
2334 pkt = str( exp_pkt )
2335 verify_packet( self, pkt, out_port )
2336 verify_no_other_packets( self )
2337
Flavio Castroa7162bb2016-07-25 17:30:30 -07002338 finally:
2339 delete_all_flows( self.controller )
2340 delete_groups( self.controller, Groups )
2341 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002342
Saurav Das34992182017-04-14 15:59:48 -07002343
Pier8b223022016-08-19 22:47:49 -07002344class Untagged( base_tests.SimpleDataPlane ):
2345 """
2346 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2347 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2348 previous versions of the OFDPA.
2349
2350 Two rules are necessary in VLAN table (10):
2351 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2352 2) Filtering: match 0x100A/0x1FFF, goto 20
2353
2354 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2355 The remaining part of the test is based on the use of the bridging table
2356 """
2357
2358 MAX_INTERNAL_VLAN = 4094
2359
2360 def runTest( self ):
2361 groups = Queue.LifoQueue( )
2362 try:
2363 if len( config[ "port_map" ] ) < 2:
2364 logging.info( "Port count less than 2, can't run this case" )
2365 return
2366
2367 ports = sorted( config[ "port_map" ].keys( ) )
2368 for port in ports:
2369 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002370 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2371 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002372 for other_port in ports:
2373 if other_port == port:
2374 continue
2375 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2376 groups.put( L2gid )
2377 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2378
2379 do_barrier( self.controller )
2380
2381 for out_port in ports:
2382 # change dest based on port number
2383 mac_dst = '00:12:34:56:78:%02X' % out_port
2384 for in_port in ports:
2385 if in_port == out_port:
2386 continue
2387 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2388 self.dataplane.send( in_port, pkt )
2389 for ofport in ports:
2390 if ofport in [ out_port ]:
2391 verify_packet( self, pkt, ofport )
2392 else:
2393 verify_no_packet( self, pkt, ofport )
2394 verify_no_other_packets( self )
2395 finally:
2396 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002397 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002398 delete_all_groups( self.controller )