blob: 004edd97966df331c4a7c286968d4472aa34932f [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
Andrea Campanella0ea96322018-04-19 19:11:49 +020028from oftest.oft12.testutils import delete_all_flows_one_table
Flavio Castro05d20bc2015-11-16 15:06:14 -050029from oftest.testutils import *
30from accton_util import *
Pierbbdf3782016-08-22 17:58:26 -070031from utils import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050032
Flavio Castroa7162bb2016-07-25 17:30:30 -070033class PacketInUDP( base_tests.SimpleDataPlane ):
Flavio Castro6d498522015-12-15 14:05:04 -050034 """
Flavio Castro76c5b262016-07-27 19:53:00 -070035 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 -050036 """
37
Flavio Castroa7162bb2016-07-25 17:30:30 -070038 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -070039 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -070040 parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
41 vlan_pkt = str( parsed_vlan_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070042 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -070043 match = ofp.match( )
44 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
45 match.oxm_list.append( ofp.oxm.ip_proto( 2 ) )
46 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
47 ofp.instruction.apply_actions( actions=[
48 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
49 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
50 logging.info( "Inserting packet in flow to controller" )
51 self.controller.message_send( request )
Flavio Castro1c9b1252016-02-04 18:42:58 -050052
Flavio Castroa7162bb2016-07-25 17:30:30 -070053 for of_port in config[ "port_map" ].keys( ):
54 logging.info( "PacketInMiss test, port %d", of_port )
55 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -050056
Flavio Castroa7162bb2016-07-25 17:30:30 -070057 verify_no_packet_in( self, vlan_pkt, of_port )
58 delete_all_flows( self.controller )
59 do_barrier( self.controller )
Flavio Castro6d498522015-12-15 14:05:04 -050060
Flavio Castroa7162bb2016-07-25 17:30:30 -070061 match = ofp.match( )
62 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
63 match.oxm_list.append( ofp.oxm.ip_proto( 17 ) )
64 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
65 ofp.instruction.apply_actions( actions=[
66 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
67 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
68 logging.info( "Inserting packet in flow to controller" )
69 self.controller.message_send( request )
70 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050071
Flavio Castroa7162bb2016-07-25 17:30:30 -070072 for of_port in config[ "port_map" ].keys( ):
73 logging.info( "PacketInMiss test, port %d", of_port )
74 self.dataplane.send( of_port, vlan_pkt )
Flavio Castro6d498522015-12-15 14:05:04 -050075
Flavio Castroa7162bb2016-07-25 17:30:30 -070076 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro6d498522015-12-15 14:05:04 -050077
Flavio Castroa7162bb2016-07-25 17:30:30 -070078 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -070079 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -070080 delete_all_flows( self.controller )
81 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -050082
Flavio Castroaf2b4502016-02-02 17:41:32 -050083
Flavio Castro67d8bd52016-02-03 14:22:14 -050084@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -070085class ArpNL2( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -070086 """
87 Needs a description, disabled for now. Also needs try/finally
88 """
Flavio Castroa7162bb2016-07-25 17:30:30 -070089 def runTest( self ):
90 delete_all_flows( self.controller )
91 delete_all_groups( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -050092
Flavio Castroa7162bb2016-07-25 17:30:30 -070093 ports = sorted( config[ "port_map" ].keys( ) )
94 match = ofp.match( )
95 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
96 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
97 ofp.instruction.apply_actions( actions=[
98 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
99 buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
100 self.controller.message_send( request )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500101 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700102 add_one_l2_interface_group( self.controller, port, 1, False, False )
103 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
104 group_id = encode_l2_interface_group_id( 1, port )
105 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
106 do_barrier( self.controller )
107 parsed_arp_pkt = simple_arp_packet( )
108 arp_pkt = str( parsed_arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500109
110 for out_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700111 self.dataplane.send( out_port, arp_pkt )
112 verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500113 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500114 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500115 for in_port in ports:
116 if in_port == out_port:
117 continue
118 # change source based on port number to avoid packet-ins from learning
Flavio Castro1c9b1252016-02-04 18:42:58 -0500119 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700120 parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
121 pkt = str( parsed_pkt )
122 self.dataplane.send( in_port, pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500123
124 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700125 if ofport in [ out_port ]:
126 verify_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500127 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700128 verify_no_packet( self, pkt, ofport )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500129
Flavio Castroa7162bb2016-07-25 17:30:30 -0700130 verify_no_other_packets( self )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500131
Flavio Castroa7162bb2016-07-25 17:30:30 -0700132class PacketInArp( base_tests.SimpleDataPlane ):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500133 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700134 Verify Packet-in message from eth_type 0x806 on ACL table
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500135 """
136
Flavio Castroa7162bb2016-07-25 17:30:30 -0700137 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700138 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700139 parsed_arp_pkt = simple_arp_packet( )
140 arp_pkt = str( parsed_arp_pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700141 # create match
Flavio Castroa7162bb2016-07-25 17:30:30 -0700142 match = ofp.match( )
143 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
144 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
145 ofp.instruction.apply_actions( actions=[
146 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
147 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500148
Saurav Das34992182017-04-14 15:59:48 -0700149 logging.info( "Inserting arp flow " )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700150 self.controller.message_send( request )
151 do_barrier( self.controller )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500152
Flavio Castroa7162bb2016-07-25 17:30:30 -0700153 for of_port in config[ "port_map" ].keys( ):
Saurav Das34992182017-04-14 15:59:48 -0700154 logging.info( "PacketInArp test, sending arp packet to port %d", of_port )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700155 self.dataplane.send( of_port, arp_pkt )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500156
Flavio Castroa7162bb2016-07-25 17:30:30 -0700157 verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500158
Flavio Castroa7162bb2016-07-25 17:30:30 -0700159 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700160 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700161 delete_all_flows( self.controller )
162 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500163
Saurav Das34992182017-04-14 15:59:48 -0700164@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700165class PacketInIPTable( base_tests.SimpleDataPlane ):
Flavio Castro91d1a552016-05-17 16:59:44 -0700166 """
Pier265ad5f2017-02-28 17:46:28 +0100167 Verify Packet-in message from IP table when controller action is used
Flavio Castro91d1a552016-05-17 16:59:44 -0700168 Send a packet to each dataplane port and verify that a packet
169 in message is received from the controller for each
170 #todo verify you stop receiving after adding rule
171 """
172
Flavio Castroa7162bb2016-07-25 17:30:30 -0700173 def runTest( self ):
174 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700175 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700176 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
177 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
178 dip = 0xc0a80001
179 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro91d1a552016-05-17 16:59:44 -0700180
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700181 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700182 # add l2 interface group
183 vlan_id = port
184 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
185 send_barrier=False )
186 dst_mac[ 5 ] = vlan_id
187 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
188 src_mac=intf_src_mac, dst_mac=dst_mac )
189 # add vlan flow table
TonyChouaf5505c2017-08-24 09:11:19 +0800190 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 -0700191 # add termination flow
192 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
193 # add unicast routing flow
194 dst_ip = dip + (vlan_id << 8)
195 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
196 send_ctrl=True )
197 Groups.put( l3_msg.group_id )
Flavio Castro91d1a552016-05-17 16:59:44 -0700198
Flavio Castroa7162bb2016-07-25 17:30:30 -0700199 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700200
Flavio Castroa7162bb2016-07-25 17:30:30 -0700201 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700202 for in_port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700203 mac_src = '00:00:00:22:22:%02X' % in_port
204 ip_src = '192.168.%02d.1' % in_port
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700205 for out_port in ports:
206 if in_port == out_port:
207 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700208 ip_dst = '192.168.%02d.1' % out_port
209 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
210 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
211 pkt = str( parsed_pkt )
212 self.dataplane.send( in_port, pkt )
213 verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
214 # verify_no_other_packets(self)
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700215 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700216 delete_all_flows( self.controller )
217 delete_groups( self.controller, Groups )
218 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -0700219
Flavio Castroa7162bb2016-07-25 17:30:30 -0700220
221class L2FloodQinQ( base_tests.SimpleDataPlane ):
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500222 """
Flavio Castro76c5b262016-07-27 19:53:00 -0700223 Verify Vlan based flooding of QinQ based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500224 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500225
Flavio Castroa7162bb2016-07-25 17:30:30 -0700226 def runTest( self ):
227 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700228 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700229 ports = sorted( config[ "port_map" ].keys( ) )
Saurav Dase94ba572017-04-28 17:47:21 -0700230 vlan_id = 100
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500231
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700232 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700233 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Saurav Das15c2c262017-05-06 18:12:38 -0700234 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 -0700235 Groups.put( L2gid )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500236
Flavio Castroa7162bb2016-07-25 17:30:30 -0700237 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
238 Groups.put( msg.group_id )
239 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
240 do_barrier( self.controller )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500241
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700242 # verify flood
243 for ofport in ports:
244 # change dest based on port number
245 mac_src = '00:12:34:56:78:%02X' % ofport
Flavio Castroa7162bb2016-07-25 17:30:30 -0700246 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
247 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
248 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
249 pkt = str( parsed_pkt )
250 self.dataplane.send( ofport, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700251 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700252 verify_no_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700253 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700254 tmp_ports = list( ports )
255 tmp_ports.remove( ofport )
256 verify_packets( self, pkt, tmp_ports )
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500257
Flavio Castroa7162bb2016-07-25 17:30:30 -0700258 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700259 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700260 delete_all_flows( self.controller )
261 delete_groups( self.controller, Groups )
262 delete_all_groups( self.controller )
263
Flavio Castro1c9b1252016-02-04 18:42:58 -0500264
Saurav Dase94ba572017-04-28 17:47:21 -0700265
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500266@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700267class L2FloodTagged( base_tests.SimpleDataPlane ):
Flavio Castro184cefe2015-11-19 20:52:49 -0500268 """
Saurav Das34992182017-04-14 15:59:48 -0700269 currently disabled; fix with try/finally
Flavio Castro184cefe2015-11-19 20:52:49 -0500270 Test L2 flood to a vlan
271 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 -0500272 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500273
Flavio Castroa7162bb2016-07-25 17:30:30 -0700274 def runTest( self ):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500275 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700276 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500277 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500278
Flavio Castroa7162bb2016-07-25 17:30:30 -0700279 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro34352e72015-12-07 20:01:51 -0500280
Flavio Castroa7162bb2016-07-25 17:30:30 -0700281 delete_all_flows( self.controller )
282 delete_all_groups( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500283
Flavio Castro184cefe2015-11-19 20:52:49 -0500284 # Installing flows to avoid packet-in
285 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700286 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
287 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
288 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
289 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
290 do_barrier( self.controller )
Flavio Castro184cefe2015-11-19 20:52:49 -0500291
Flavio Castro1c9b1252016-02-04 18:42:58 -0500292 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500293 for ofport in ports:
294 # change dest based on port number
Flavio Castroa7162bb2016-07-25 17:30:30 -0700295 pkt = str(
296 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
297 self.dataplane.send( ofport, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500298 # self won't rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700299 verify_no_packet( self, pkt, ofport )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500300 # others will rx packet
Flavio Castroa7162bb2016-07-25 17:30:30 -0700301 tmp_ports = list( ports )
302 tmp_ports.remove( ofport )
303 verify_packets( self, pkt, tmp_ports )
304 verify_no_other_packets( self )
Flavio Castroaabb5792015-11-18 19:03:50 -0500305
Flavio Castro1c9b1252016-02-04 18:42:58 -0500306
Flavio Castroa7162bb2016-07-25 17:30:30 -0700307class L2UnicastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -0700308 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500309
Flavio Castroa7162bb2016-07-25 17:30:30 -0700310 def runTest( self ):
Flavio Castrob01d0aa2016-07-20 16:14:48 -0700311
Flavio Castroa7162bb2016-07-25 17:30:30 -0700312 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700313 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700314 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700315 vlan_id = 1;
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700316 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700317 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
318 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
319 Groups.put( L2gid )
320 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
321 True )
322 do_barrier( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500323
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700324 for out_port in ports:
325 # change dest based on port number
326 mac_dst = '00:12:34:56:78:%02X' % out_port
327 for in_port in ports:
328 if in_port == out_port:
329 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700330 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
331 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700332 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700333 if ofport in [ out_port ]:
334 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700335 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700336 verify_no_packet( self, pkt, ofport )
337 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700338 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700339 delete_all_flows( self.controller )
340 delete_groups( self.controller, Groups )
341 delete_all_groups( self.controller )
Flavio Castro6efe1862015-11-18 16:28:06 -0500342
Flavio Castroa7162bb2016-07-25 17:30:30 -0700343
Saurav Das59fae5e2017-12-07 12:02:02 -0800344class Bridging( base_tests.SimpleDataPlane ):
345 """
346 Verify bridging works including flooding with different vlans
347 ports[0] has vlan 31 untagged
348 ports[1] has vlan 31 untagged (native) and vlan 41 tagged
349 ARP request should be flooded
350 ARP reply should be forwarded by bridging rule
351 Both arp messages should also be copied to controller
352 """
353
354 def runTest( self ):
355 Groupd = Queue.LifoQueue()
356 try:
357 if len( config[ "port_map" ] ) < 2:
358 logging.info( "Port count less than 2, can't run this case" )
359 return
360 ports = sorted( config[ "port_map" ].keys() )
361 vlan_p0_untagged = 31
362 vlan_p1_tagged = 31
363 vlan_p1_native = 41
364
365 #l2 interface groups and table 10 flows
366 L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged,
367 is_tagged=False, send_barrier=False )
368 add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
369 send_barrier=True)
370 L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged,
371 is_tagged=True, send_barrier=False )
372 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG,
373 send_barrier=True)
374 L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native,
375 is_tagged=False, send_barrier=False )
376 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
377 send_barrier=True)
378 #flooding groups
379 Floodmsg31 = add_l2_flood_group( self.controller, ports, vlan_p0_untagged, id=0 )
380 Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 )
381
382 #add bridging flows for flooding groups
383 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id )
384 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id )
385 do_barrier( self.controller )
386
387 # add bridging flows for dstMac+vlan
388 add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True )
389 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True )
390 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True )
391
392 # add terminationMac flow
393 router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
394 if config["switch_type"] == "qmx":
395 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged )
396 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native )
397 else:
398 add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged )
399 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged )
400 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native )
401
402 # add acl rule for arp
403 match = ofp.match( )
404 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
405 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
406 ofp.instruction.apply_actions( actions=[
407 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
408 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
409 self.controller.message_send( request )
410 do_barrier( self.controller )
411
412 #acl rule for gateway ip
413 match = ofp.match( )
414 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
415 match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) )
416 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
417 ofp.instruction.apply_actions( actions=[
418 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ),
419 ofp.instruction.clear_actions() ],
420 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
421 self.controller.message_send( request )
422 do_barrier( self.controller )
423
424 # send ARP request
425 parsed_arp_pkt = simple_arp_packet(pktlen=80,
426 eth_dst='ff:ff:ff:ff:ff:ff',
427 eth_src='00:66:77:88:99:aa',
428 vlan_vid=vlan_p1_tagged,
429 vlan_pcp=0,
430 arp_op=1,
431 ip_snd='192.168.0.2',
432 ip_tgt='192.168.0.1',
433 hw_snd='00:66:77:88:99:aa',
434 hw_tgt='00:00:00:00:00:00')
435 arp_pkt_to_send = str( parsed_arp_pkt )
436 logging.info( "sending arp request to port %d", ports[1] )
437 self.dataplane.send( ports[1], arp_pkt_to_send )
438 verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION )
439 parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76,
440 eth_dst='ff:ff:ff:ff:ff:ff',
441 eth_src='00:66:77:88:99:aa',
442 vlan_vid=0,
443 vlan_pcp=0,
444 arp_op=1,
445 ip_snd='192.168.0.2',
446 ip_tgt='192.168.0.1',
447 hw_snd='00:66:77:88:99:aa',
448 hw_tgt='00:00:00:00:00:00')
449 arp_pkt_dest = str( parsed_arp_pkt_untagged )
450 verify_packet( self, arp_pkt_dest, ports[0] )
451 #verify_no_other_packets( self )
452
453 # send ARP reply
454 parsed_arp_pkt = simple_arp_packet(pktlen=76,
455 eth_dst='00:66:77:88:99:aa',
456 eth_src='00:11:22:33:44:55',
457 vlan_vid=0,
458 vlan_pcp=0,
459 arp_op=2,
460 ip_snd='192.168.0.1',
461 ip_tgt='192.168.0.2',
462 hw_snd='00:11:22:33:44:55',
463 hw_tgt='00:66:77:88:99:aa')
464 arp_pkt_to_send = str( parsed_arp_pkt )
465 logging.info( "sending arp reply to port %d", ports[0] )
466 self.dataplane.send( ports[0], arp_pkt_to_send )
467 verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION )
468 parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80,
469 eth_dst='00:66:77:88:99:aa',
470 eth_src='00:11:22:33:44:55',
471 vlan_vid=vlan_p1_tagged,
472 vlan_pcp=0,
473 arp_op=2,
474 ip_snd='192.168.0.1',
475 ip_tgt='192.168.0.2',
476 hw_snd='00:11:22:33:44:55',
477 hw_tgt='00:66:77:88:99:aa')
478 arp_pkt_dest = str( parsed_arp_pkt_tagged )
479 verify_packet( self, arp_pkt_dest, ports[1] )
480
481 finally:
482 delete_all_flows( self.controller )
483 delete_all_groups( self.controller )
Saurav Das5d1473d2018-07-12 11:02:56 -0700484 #print("done")
Saurav Das59fae5e2017-12-07 12:02:02 -0800485
486
487
Flavio Castroa7162bb2016-07-25 17:30:30 -0700488class Mtu1500( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700489 """
490 Verifies basic mtu limits
491 """
492
Flavio Castroa7162bb2016-07-25 17:30:30 -0700493 def runTest( self ):
494 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700495 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700496 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700497 vlan_id = 18
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700498 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700499 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Pier265ad5f2017-02-28 17:46:28 +0100500 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700501 Groups.put( L2gid )
502 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
503 True )
504 do_barrier( self.controller )
Flavio Castrob6773032015-11-19 22:49:24 -0500505
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700506 for out_port in ports:
507 # change dest based on port number
508 mac_dst = '00:12:34:56:78:%02X' % out_port
509 for in_port in ports:
510 if in_port == out_port:
511 continue
Flavio Castroa7162bb2016-07-25 17:30:30 -0700512 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
513 eth_dst=mac_dst ) )
514 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700515 for ofport in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700516 if ofport in [ out_port ]:
517 verify_packet( self, pkt, ofport )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700518 else:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700519 verify_no_packet( self, pkt, ofport )
520 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700521 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700522 delete_all_flows( self.controller )
523 delete_groups( self.controller, Groups )
524 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -0500525
Flavio Castroa7162bb2016-07-25 17:30:30 -0700526
527class _32UcastTagged( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700528 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
Flavio Castro1c9b1252016-02-04 18:42:58 -0500529
Flavio Castroa7162bb2016-07-25 17:30:30 -0700530 def runTest( self ):
531 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700532 try:
533 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -0700534 if len( config[ "port_map" ] ) < 2:
535 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700536 return
Flavio Castroa7162bb2016-07-25 17:30:30 -0700537 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
538 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700539 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700540 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700541 for port in ports:
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700542 vlan_id = port + test_id
Saurav Dase94ba572017-04-28 17:47:21 -0700543 # add l2 interface group and l3 unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700544 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
545 is_tagged=True, send_barrier=False )
546 dst_mac[ 5 ] = vlan_id
547 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
548 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700549 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100550 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700551 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700552 if config["switch_type"] == "qmx":
553 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
554 else:
555 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700556 # add unicast routing flow
557 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700558 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
559 Groups.put( l2gid )
560 Groups.put( l3_msg.group_id )
561 do_barrier( self.controller )
Flavio Castrod8f8af22015-12-02 18:19:26 -0500562
Flavio Castroa7162bb2016-07-25 17:30:30 -0700563 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700564 for in_port in ports:
565 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
566 ip_src = '192.168.%02d.1' % (test_id + in_port)
567 for out_port in ports:
568 if in_port == out_port:
569 continue
570 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700571 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
572 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
573 ip_src=ip_src, ip_dst=ip_dst )
574 pkt = str( parsed_pkt )
575 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700576 # build expected packet
577 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700578 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
579 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
580 ip_src=ip_src, ip_dst=ip_dst )
581 pkt = str( exp_pkt )
582 verify_packet( self, pkt, out_port )
583 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700584 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700585 delete_all_flows( self.controller )
586 delete_groups( self.controller, Groups )
587 delete_all_groups( self.controller )
Flavio Castro05d20bc2015-11-16 15:06:14 -0500588
Saurav Das34992182017-04-14 15:59:48 -0700589@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700590class _32VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700591 """
592 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
593 No ECMP group used
594 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500595
Flavio Castroa7162bb2016-07-25 17:30:30 -0700596 def runTest( self ):
597 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700598 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700599 if len( config[ "port_map" ] ) < 2:
600 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700601 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500602
Flavio Castroa7162bb2016-07-25 17:30:30 -0700603 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
604 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700605 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700606 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700607 for port in ports:
608 # add l2 interface group
609 id = port
610 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700611 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
612 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700613 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700614 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
615 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700616 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700617 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
618 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
619 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castroa7162bb2016-07-25 17:30:30 -0700620 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700621 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100622 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700623 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700624 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700625 if config["switch_type"] == "qmx":
626 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
627 else:
628 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700629 # add routing flow
630 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700631 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
632 Groups._put( l2_gid )
633 Groups._put( mpls_gid )
634 Groups._put( mpls_label_gid )
635 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500636
Flavio Castroa7162bb2016-07-25 17:30:30 -0700637 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700638 for in_port in ports:
639 ip_src = '192.168.%02d.1' % (in_port)
640 for out_port in ports:
641 if in_port == out_port:
642 continue
643 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700644 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
645 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
646 pkt = str( parsed_pkt )
647 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700648 # build expect packet
649 mac_dst = '00:00:00:22:22:%02X' % (out_port)
650 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700651 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
652 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
653 label=[ label ] )
654 pkt = str( exp_pkt )
655 verify_packet( self, pkt, out_port )
656 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700657 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700658 delete_all_flows( self.controller )
659 delete_groups( self.controller, Groups )
660 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500661
Saurav Das34992182017-04-14 15:59:48 -0700662@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700663class _32EcmpVpn( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700664 """
665 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
666 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500667
Flavio Castroa7162bb2016-07-25 17:30:30 -0700668 def runTest( self ):
669 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700670 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700671 if len( config[ "port_map" ] ) < 2:
672 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700673 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500674
Flavio Castroa7162bb2016-07-25 17:30:30 -0700675 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
676 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700677 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700678 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700679 for port in ports:
680 # add l2 interface group
681 id = port
682 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700683 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
684 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700685 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700686 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
687 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700688 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700689 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
690 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
691 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
692 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
693 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700694 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100695 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700696 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700697 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700698 if config["switch_type"] == "qmx":
699 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
700 else:
701 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700702 # add routing flow
703 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700704 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
705 Groups._put( l2_gid )
706 Groups._put( mpls_gid )
707 Groups._put( mpls_label_gid )
708 Groups._put( ecmp_msg.group_id )
709 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500710
Flavio Castroa7162bb2016-07-25 17:30:30 -0700711 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700712 for in_port in ports:
713 ip_src = '192.168.%02d.1' % (in_port)
714 for out_port in ports:
715 if in_port == out_port:
716 continue
717 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700718 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
719 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
720 pkt = str( parsed_pkt )
721 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700722 # build expect packet
723 mac_dst = '00:00:00:22:22:%02X' % (out_port)
724 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700725 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
726 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
727 label=[ label ] )
728 pkt = str( exp_pkt )
729 verify_packet( self, pkt, out_port )
730 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -0700731
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700732 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700733 delete_all_flows( self.controller )
734 delete_groups( self.controller, Groups )
735 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500736
Flavio Castroa7162bb2016-07-25 17:30:30 -0700737
Saurav Das34992182017-04-14 15:59:48 -0700738@disabled
739class One_32EcmpVpn( base_tests.SimpleDataPlane ):
740 """
741 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
742 in only one direction
743 """
744
745 def runTest( self ):
746 Groups = Queue.LifoQueue( )
747 try:
748 if len( config[ "port_map" ] ) < 2:
749 logging.info( "Port count less than 2, can't run this case" )
750 return
751
752 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
753 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
754 dip = 0xc0a80001
755 ports = config[ "port_map" ].keys( )
756 # add l2 interface group
757 id = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700758 in_offset = 19
759 out_offset = 20
760 vlan_id = ports[1] + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700761 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
Saurav Das1ab6a142017-04-25 14:42:25 -0700762 dst_mac[ 5 ] = ports[1]
Saurav Das34992182017-04-14 15:59:48 -0700763 # add MPLS interface group
764 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
765 vlan_id, id )
766 # add MPLS L3 VPN group
767 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
768 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
Saurav Das1ab6a142017-04-25 14:42:25 -0700769 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
Saurav Das34992182017-04-14 15:59:48 -0700770 # add ECMP group
771 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
772 do_barrier( self.controller )
773 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700774 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 -0700775 flag=VLAN_TABLE_FLAG_ONLY_TAG )
776 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700777 if config["switch_type"] == "qmx":
778 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
779 else:
780 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
Saurav Das34992182017-04-14 15:59:48 -0700781 # add routing flow
782 dst_ip = dip + (vlan_id << 8)
783 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
784 Groups._put( l2_gid )
785 Groups._put( mpls_gid )
786 Groups._put( mpls_label_gid )
787 Groups._put( ecmp_msg.group_id )
788
789
790 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
791 in_port = ports[0]
792 out_port = ports[1]
793 ip_src = '192.168.%02d.1' % (in_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700794 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
795 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
Saurav Das34992182017-04-14 15:59:48 -0700796 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
797 pkt = str( parsed_pkt )
798 self.dataplane.send( in_port, pkt )
799 # build expect packet
800 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Saurav Das1ab6a142017-04-25 14:42:25 -0700801 label = (out_port+out_offset, 0, 1, 32)
802 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 -0700803 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
Saurav Das1ab6a142017-04-25 14:42:25 -0700804 label=[ label ] )
Saurav Das34992182017-04-14 15:59:48 -0700805 pkt = str( exp_pkt )
806 verify_packet( self, pkt, out_port )
807 #verify_no_other_packets( self )
808
809 finally:
810 delete_all_flows( self.controller )
811 delete_group(self.controller, ecmp_msg.group_id)
812 delete_group(self.controller, mpls_label_gid)
813 delete_group(self.controller, mpls_gid)
814 delete_group(self.controller, l2_gid)
815
816
Flavio Castroa7162bb2016-07-25 17:30:30 -0700817class _32ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700818 """
819 Verifies /32 IP routing and ECMP with no label push
820 IP -> L3ECMP -> L3Unicast -> L2Interface
821 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500822
Flavio Castroa7162bb2016-07-25 17:30:30 -0700823 def runTest( self ):
824 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700825 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700826 if len( config[ "port_map" ] ) < 2:
827 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700828 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500829
Flavio Castroa7162bb2016-07-25 17:30:30 -0700830 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
831 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700832 dip = 0xc0a80001
833 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -0700834 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700835 for port in ports:
836 vlan_id = port
837 id = port
838 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700839 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
840 is_tagged=True, send_barrier=False )
841 dst_mac[ 5 ] = vlan_id
842 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
843 src_mac=intf_src_mac, dst_mac=dst_mac )
844 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700845 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100846 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700847 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700848 if config["switch_type"] == "qmx":
849 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
850 else:
851 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700852 # add unicast routing flow
853 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700854 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
855 Groups._put( l2_gid )
856 Groups._put( l3_msg.group_id )
857 Groups._put( ecmp_msg.group_id )
858 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500859
Flavio Castroa7162bb2016-07-25 17:30:30 -0700860 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700861 for in_port in ports:
862 mac_src = '00:00:00:22:22:%02X' % in_port
863 ip_src = '192.168.%02d.1' % in_port
864 for out_port in ports:
865 if in_port == out_port:
866 continue
867 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700868 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
869 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
870 pkt = str( parsed_pkt )
871 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700872 # build expected packet
873 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700874 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
875 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
876 pkt = str( exp_pkt )
877 verify_packet( self, pkt, out_port )
878 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700879 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700880 delete_all_flows( self.controller )
881 delete_groups( self.controller, Groups )
882 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500883
Saurav Das34992182017-04-14 15:59:48 -0700884@disabled
885class One_32ECMPL3( base_tests.SimpleDataPlane ):
886 """
887 Verifies /32 IP routing and ECMP with no label push
888 IP -> L3ECMP -> L3Unicast -> L2Interface
889 in only one direction
890 """
Flavio Castroa7162bb2016-07-25 17:30:30 -0700891
Saurav Das34992182017-04-14 15:59:48 -0700892 def runTest( self ):
893 Groups = Queue.LifoQueue( )
894 try:
895 if len( config[ "port_map" ] ) < 2:
896 logging.info( "Port count less than 2, can't run this case" )
897 return
898
899 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
900 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
901 dip = 0xc0a80001
902 # Hashes Test Name and uses it as id for installing unique groups
903 ports = config[ "port_map" ].keys( )
904 inport = ports[0]
905 outport = ports[1]
Saurav Das1ab6a142017-04-25 14:42:25 -0700906 in_offset = 19
907 out_offset = 20
908 vlan_id = outport + out_offset
Saurav Das34992182017-04-14 15:59:48 -0700909 id = outport
910 # add l2 interface group, l3 unicast and ecmp group for outport
911 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
912 is_tagged=True, send_barrier=False )
Saurav Das1ab6a142017-04-25 14:42:25 -0700913 dst_mac[ 5 ] = outport
Saurav Das34992182017-04-14 15:59:48 -0700914 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
915 src_mac=intf_src_mac, dst_mac=dst_mac )
916 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
917 # add vlan flow table
Saurav Das1ab6a142017-04-25 14:42:25 -0700918 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 -0700919 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700920 if config["switch_type"] == "qmx":
921 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset )
922 else:
923 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 -0700924 # add unicast routing flow
925 dst_ip = dip + (vlan_id << 8)
926 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
927 Groups._put( l2_gid )
928 Groups._put( l3_msg.group_id )
929 Groups._put( ecmp_msg.group_id )
930
931 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
932 mac_src = '00:00:00:22:22:%02X' % inport
933 ip_src = '192.168.%02d.1' % inport
Saurav Das1ab6a142017-04-25 14:42:25 -0700934 ip_dst = '192.168.%02d.1' % (outport+out_offset)
935 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
Saurav Das34992182017-04-14 15:59:48 -0700936 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
937 pkt = str( parsed_pkt )
938 self.dataplane.send( inport, pkt )
939 # build expected packet
940 mac_dst = '00:00:00:22:22:%02X' % outport
Saurav Das1ab6a142017-04-25 14:42:25 -0700941 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
Saurav Das34992182017-04-14 15:59:48 -0700942 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
943 pkt = str( exp_pkt )
944 verify_packet( self, pkt, outport )
945 verify_no_other_packets( self )
946 finally:
947 delete_all_flows( self.controller )
948 delete_groups( self.controller, Groups )
949 delete_all_groups( self.controller )
950
951
952
953
954@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -0700955class _24VPN( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -0700956 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
Flavio Castro2262fd42016-02-04 19:03:36 -0500957
Flavio Castroa7162bb2016-07-25 17:30:30 -0700958 def runTest( self ):
959 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700960 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -0700961 if len( config[ "port_map" ] ) < 2:
962 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700963 return
Flavio Castro2262fd42016-02-04 19:03:36 -0500964
Flavio Castroa7162bb2016-07-25 17:30:30 -0700965 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
966 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700967 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -0700968 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700969 for port in ports:
970 # add l2 interface group
971 id = port
972 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -0700973 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
974 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700975 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700976 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
977 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700978 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -0700979 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
980 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
981 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700982 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castroa7162bb2016-07-25 17:30:30 -0700983 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700984 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +0100985 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -0700986 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700987 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -0700988 if config["switch_type"] == "qmx":
989 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
990 else:
991 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -0700992 # add routing flow
993 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -0700994 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
995 Groups._put( l2_gid )
996 Groups._put( mpls_gid )
997 Groups._put( mpls_label_gid )
998 do_barrier( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -0500999
Flavio Castroa7162bb2016-07-25 17:30:30 -07001000 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001001 for in_port in ports:
1002 ip_src = '192.168.%02d.1' % (in_port)
1003 for out_port in ports:
1004 if in_port == out_port:
1005 continue
1006 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001007 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1008 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1009 pkt = str( parsed_pkt )
1010 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001011 # build expect packet
1012 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1013 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001014 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1015 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1016 label=[ label ] )
1017 pkt = str( exp_pkt )
1018 verify_packet( self, pkt, out_port )
1019 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001020 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001021 delete_all_flows( self.controller )
1022 delete_groups( self.controller, Groups )
1023 delete_all_groups( self.controller )
Flavio Castro2262fd42016-02-04 19:03:36 -05001024
Saurav Das34992182017-04-14 15:59:48 -07001025@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001026class _24EcmpVpn( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001027 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
Flavio Castro72a45d52015-12-02 16:37:05 -05001028
Flavio Castroa7162bb2016-07-25 17:30:30 -07001029 def runTest( self ):
1030 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001031 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001032 if len( config[ "port_map" ] ) < 2:
1033 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001034 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001035 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1036 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001037 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001038 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001039 for port in ports:
1040 # add l2 interface group
1041 id = port
1042 vlan_id = id
Flavio Castroa7162bb2016-07-25 17:30:30 -07001043 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
1044 dst_mac[ 5 ] = vlan_id
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001045 # add MPLS interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001046 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1047 vlan_id, id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001048 # add MPLS L3 VPN group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001049 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1050 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
1051 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
1052 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
1053 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001054 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001055 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
Flavio Castroa7162bb2016-07-25 17:30:30 -07001056 flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001057 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001058 if config["switch_type"] == "qmx":
1059 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1060 else:
1061 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001062 # add routing flow
1063 dst_ip = dip + (vlan_id << 8)
1064 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001065 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
1066 vrf=0 )
1067 Groups._put( l2_gid )
1068 Groups._put( mpls_gid )
1069 Groups._put( mpls_label_gid )
1070 Groups._put( ecmp_msg.group_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001071
Flavio Castroa7162bb2016-07-25 17:30:30 -07001072 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001073
Flavio Castroa7162bb2016-07-25 17:30:30 -07001074 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001075 for in_port in ports:
1076 mac_src = '00:00:00:22:22:%02X' % (in_port)
1077 ip_src = '192.168.%02d.1' % (in_port)
1078 for out_port in ports:
1079 if in_port == out_port:
1080 continue
1081 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001082 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1083 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1084 pkt = str( parsed_pkt )
1085 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001086 # build expect packet
1087 mac_dst = '00:00:00:22:22:%02X' % out_port
1088 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001089 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1090 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1091 label=[ label ] )
1092 pkt = str( exp_pkt )
1093 verify_packet( self, pkt, out_port )
1094 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001095 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001096 delete_all_flows( self.controller )
1097 delete_groups( self.controller, Groups )
1098 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001099
Flavio Castroa7162bb2016-07-25 17:30:30 -07001100
1101class FloodGroupMod( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001102 """ Modify a referenced flood group """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001103
1104 def runTest( self ):
1105 Groups = Queue.LifoQueue( )
1106 try:
1107 ports = sorted( config[ "port_map" ].keys( ) )
1108 vlan_id = 1
1109
1110 for port in ports:
1111 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1112 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1113 Groups.put( L2gid )
1114
1115 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
1116 Groups.put( msg.group_id )
1117 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
1118 do_barrier( self.controller )
1119 # verify flood
1120 for ofport in ports:
1121 # change dest based on port number
1122 mac_src = '00:12:34:56:78:%02X' % ofport
1123 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1124 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
1125 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
1126 pkt = str( parsed_pkt )
1127 self.dataplane.send( ofport, pkt )
1128 # self won't rx packet
1129 verify_no_packet( self, pkt, ofport )
1130 # others will rx packet
1131 tmp_ports = list( ports )
1132 tmp_ports.remove( ofport )
1133 verify_packets( self, pkt, tmp_ports )
1134 verify_no_other_packets( self )
1135 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
1136 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
1137 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1138 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
1139 eth_src=mac_src )
1140 pkt = str( parsed_pkt )
1141 self.dataplane.send( ports[ 1 ], pkt )
1142 verify_packets( self, pkt, [ ports[ 0 ] ] )
1143 finally:
1144 delete_all_flows( self.controller )
1145 delete_groups( self.controller, Groups )
1146 delete_all_groups( self.controller )
1147
1148
1149class _24ECMPL3( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001150 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
Flavio Castro80730822015-12-11 15:38:47 -05001151
Flavio Castroa7162bb2016-07-25 17:30:30 -07001152 def runTest( self ):
1153 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001154 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001155 if len( config[ "port_map" ] ) < 2:
1156 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001157 return
Flavio Castro80730822015-12-11 15:38:47 -05001158
Flavio Castroa7162bb2016-07-25 17:30:30 -07001159 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1160 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001161 dip = 0xc0a80001
1162 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castroa7162bb2016-07-25 17:30:30 -07001163 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001164 for port in ports:
1165 vlan_id = port
1166 id = port
1167 # add l2 interface group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001168 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1169 is_tagged=True, send_barrier=False )
1170 dst_mac[ 5 ] = vlan_id
1171 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1172 src_mac=intf_src_mac, dst_mac=dst_mac )
1173 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001174 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001175 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001176 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001177 if config["switch_type"] == "qmx":
1178 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1179 else:
1180 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001181 # add unicast routing flow
1182 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001183 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1184 Groups._put( l2_gid )
1185 Groups._put( l3_msg.group_id )
1186 Groups._put( ecmp_msg.group_id )
1187 do_barrier( self.controller )
Flavio Castro72a45d52015-12-02 16:37:05 -05001188
Flavio Castroa7162bb2016-07-25 17:30:30 -07001189 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001190 for in_port in ports:
1191 mac_src = '00:00:00:22:22:%02X' % in_port
1192 ip_src = '192.168.%02d.1' % in_port
1193 for out_port in ports:
1194 if in_port == out_port:
1195 continue
1196 ip_dst = '192.168.%02d.1' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001197 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1198 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1199 pkt = str( parsed_pkt )
1200 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001201 # build expected packet
1202 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001203 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1204 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1205 pkt = str( exp_pkt )
1206 verify_packet( self, pkt, out_port )
1207 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001208 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001209 delete_all_flows( self.controller )
1210 delete_groups( self.controller, Groups )
1211 delete_all_groups( self.controller )
1212
Flavio Castro1c9b1252016-02-04 18:42:58 -05001213
Flavio Castroaba28ff2016-02-03 16:47:48 -05001214@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001215class MPLSBUG( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001216 """
1217 Needs a description or needs to be removed
1218 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001219 def runTest( self ):
1220 if len( config[ "port_map" ] ) < 2:
1221 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro80730822015-12-11 15:38:47 -05001222 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07001223 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1224 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro1c9b1252016-02-04 18:42:58 -05001225 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001226 Groups = Queue.LifoQueue( )
1227 ports = config[ "port_map" ].keys( )
Flavio Castro80730822015-12-11 15:38:47 -05001228 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001229 # add l2 interface group
1230 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001231 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1232 dst_mac[ 5 ] = vlan_id
Flavio Castro1c9b1252016-02-04 18:42:58 -05001233 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001234 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1235 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001236 # add vlan flow table
Flavio Castroa7162bb2016-07-25 17:30:30 -07001237 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001238 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001239 if config["switch_type"] == "qmx":
1240 add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 )
1241 else:
1242 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001243 # add mpls flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001244 add_mpls_flow( self.controller, l3_msg.group_id, port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001245 # add termination flow
Flavio Castroa7162bb2016-07-25 17:30:30 -07001246 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001247 # add unicast routing flow
1248 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001249 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1250 Groups._put( l2_gid )
1251 Groups._put( l3_msg.group_id )
1252 do_barrier( self.controller )
Flavio Castro80730822015-12-11 15:38:47 -05001253
Flavio Castroa7162bb2016-07-25 17:30:30 -07001254 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro80730822015-12-11 15:38:47 -05001255 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001256 mac_src = '00:00:00:22:22:%02X' % in_port
1257 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -05001258 for out_port in ports:
1259 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001260 continue
1261 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -05001262 switch_mac = "00:00:00:cc:cc:cc"
1263 label = (out_port, 0, 1, 32)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001264 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1265 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1266 pkt = str( parsed_pkt )
1267 self.dataplane.send( in_port, pkt )
Flavio Castro80730822015-12-11 15:38:47 -05001268
Flavio Castro1c9b1252016-02-04 18:42:58 -05001269 # build expect packet
1270 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001271 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1272 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1273 pkt = str( exp_pkt )
1274 verify_packet( self, pkt, out_port )
1275 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001276
Flavio Castroa7162bb2016-07-25 17:30:30 -07001277 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1278 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1279 pkt = str( parsed_pkt )
1280 self.dataplane.send( in_port, pkt )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001281 # build expected packet
1282 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001283 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1284 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1285 pkt = str( exp_pkt )
1286 verify_packet( self, pkt, out_port )
1287 verify_no_other_packets( self )
1288 delete_all_flows( self.controller )
1289 delete_groups( self.controller, Groups )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001290
Flavio Castroa7162bb2016-07-25 17:30:30 -07001291class L3McastToL3( base_tests.SimpleDataPlane ):
Pierbbdf3782016-08-22 17:58:26 -07001292 """
1293 Mcast routing, in this test case the traffic comes in tagged.
1294 port+1 is used as ingress vlan_id. The packet goes out tagged on
1295 different ports. 4094-port is used as egress vlan_id.
1296 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001297 def runTest( self ):
Pier7b031af2016-08-25 15:00:22 -07001298 """
1299 port1 (vlan 300)-> All Ports (vlan 300)
1300 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001301 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001302 try:
Pierbbdf3782016-08-22 17:58:26 -07001303 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1304 if len( config[ "port_map" ] ) < 1:
1305 logging.info( "Port count less than 1, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001306 assert (False)
1307 return
Pierbbdf3782016-08-22 17:58:26 -07001308 ports = config[ "port_map" ].keys( )
1309 dst_ip_str = "224.0.0.1"
1310 (
1311 port_to_in_vlan,
1312 port_to_out_vlan,
1313 port_to_src_mac_str,
1314 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001315 port_to_src_ip,
Pierbbdf3782016-08-22 17:58:26 -07001316 port_to_src_ip_str,
1317 port_to_intf_src_mac_str,
1318 Groups) = fill_mcast_pipeline_L3toL3(
1319 self.controller,
1320 logging,
1321 ports,
1322 is_ingress_tagged = True,
1323 is_egress_tagged = True,
1324 is_vlan_translated = True,
1325 is_max_vlan = False
1326 )
Flavio Castro12296312015-12-15 17:48:26 -05001327
Pierbbdf3782016-08-22 17:58:26 -07001328 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001329
Pierbbdf3782016-08-22 17:58:26 -07001330 parsed_pkt = simple_udp_packet(
1331 pktlen = 100,
1332 dl_vlan_enable = True,
1333 vlan_vid = port_to_in_vlan[in_port],
1334 eth_dst = port_to_dst_mac_str[in_port],
1335 eth_src = port_to_src_mac_str[in_port],
1336 ip_ttl = 64,
1337 ip_src = port_to_src_ip_str[in_port],
1338 ip_dst = dst_ip_str
1339 )
1340 pkt = str( parsed_pkt )
1341 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001342
Pierbbdf3782016-08-22 17:58:26 -07001343 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001344
Pierbbdf3782016-08-22 17:58:26 -07001345 parsed_pkt = simple_udp_packet(
1346 pktlen = 100,
1347 dl_vlan_enable = True,
1348 vlan_vid = port_to_out_vlan[out_port],
1349 eth_dst = port_to_dst_mac_str[in_port],
1350 eth_src = port_to_intf_src_mac_str[out_port],
1351 ip_ttl = 63,
1352 ip_src = port_to_src_ip_str[in_port],
1353 ip_dst = dst_ip_str
1354 )
1355 pkt = str( parsed_pkt )
1356 verify_packet( self, pkt, out_port )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001357
Pierbbdf3782016-08-22 17:58:26 -07001358 verify_no_other_packets( self )
1359
Pier7b031af2016-08-25 15:00:22 -07001360 finally:
1361 delete_all_flows( self.controller )
1362 delete_groups( self.controller, Groups )
1363 delete_all_groups( self.controller )
1364
Saurav Das5d1473d2018-07-12 11:02:56 -07001365@disabled
Pier7b031af2016-08-25 15:00:22 -07001366class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1367 """
Saurav Das5d1473d2018-07-12 11:02:56 -07001368 Fails on alternate runs
Pier7b031af2016-08-25 15:00:22 -07001369 Mcast routing, in this test case the traffic is untagged.
1370 4094 is used as internal vlan_id. The packet goes out
1371 untagged.
1372 """
1373 def runTest( self ):
1374 Groups = Queue.LifoQueue( )
1375 try:
1376 if len( config[ "port_map" ] ) < 2:
1377 logging.info( "Port count less than 2, can't run this case" )
1378 assert (False)
1379 return
1380 ports = config[ "port_map" ].keys( )
1381 dst_ip_str = "224.0.0.1"
1382 (
1383 port_to_in_vlan,
1384 port_to_out_vlan,
1385 port_to_src_mac_str,
1386 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001387 port_to_src_ip,
Pier7b031af2016-08-25 15:00:22 -07001388 port_to_src_ip_str,
1389 Groups) = fill_mcast_pipeline_L3toL2(
1390 self.controller,
1391 logging,
1392 ports,
1393 is_ingress_tagged = False,
1394 is_egress_tagged = False,
1395 is_vlan_translated = False,
1396 is_max_vlan = True
1397 )
1398
1399 for in_port in ports:
1400
1401 parsed_pkt = simple_udp_packet(
1402 pktlen = 96,
1403 eth_dst = port_to_dst_mac_str[in_port],
1404 eth_src = port_to_src_mac_str[in_port],
1405 ip_ttl = 64,
1406 ip_src = port_to_src_ip_str[in_port],
1407 ip_dst = dst_ip_str
1408 )
1409 pkt = str( parsed_pkt )
1410 self.dataplane.send( in_port, pkt )
1411
1412 for out_port in ports:
1413
1414 parsed_pkt = simple_udp_packet(
1415 pktlen = 96,
1416 eth_dst = port_to_dst_mac_str[in_port],
1417 eth_src = port_to_src_mac_str[in_port],
1418 ip_ttl = 64,
1419 ip_src = port_to_src_ip_str[in_port],
1420 ip_dst = dst_ip_str
1421 )
1422 pkt = str( parsed_pkt )
1423 if out_port == in_port:
1424 verify_no_packet( self, pkt, in_port )
1425 continue
1426 verify_packet( self, pkt, out_port )
1427 verify_no_other_packets( self )
1428 finally:
1429 delete_all_flows( self.controller )
1430 delete_groups( self.controller, Groups )
1431 delete_all_groups( self.controller )
1432
1433class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1434 """
1435 Mcast routing, in this test case the traffic is untagged.
1436 300 is used as vlan_id. The packet goes out
1437 tagged.
1438 """
1439 def runTest( self ):
1440 Groups = Queue.LifoQueue( )
1441 try:
1442 if len( config[ "port_map" ] ) < 2:
1443 logging.info( "Port count less than 2, can't run this case" )
1444 assert (False)
1445 return
1446 ports = config[ "port_map" ].keys( )
1447 dst_ip_str = "224.0.0.1"
1448 (
1449 port_to_in_vlan,
1450 port_to_out_vlan,
1451 port_to_src_mac_str,
1452 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001453 port_to_src_ip,
Pier7b031af2016-08-25 15:00:22 -07001454 port_to_src_ip_str,
1455 Groups) = fill_mcast_pipeline_L3toL2(
1456 self.controller,
1457 logging,
1458 ports,
1459 is_ingress_tagged = False,
1460 is_egress_tagged = True,
1461 is_vlan_translated = False,
1462 is_max_vlan = False
1463 )
1464
1465 for in_port in ports:
1466
1467 parsed_pkt = simple_udp_packet(
1468 pktlen = 96,
1469 eth_dst = port_to_dst_mac_str[in_port],
1470 eth_src = port_to_src_mac_str[in_port],
1471 ip_ttl = 64,
1472 ip_src = port_to_src_ip_str[in_port],
1473 ip_dst = dst_ip_str
1474 )
1475 pkt = str( parsed_pkt )
1476 self.dataplane.send( in_port, pkt )
1477
1478 for out_port in ports:
1479
1480 parsed_pkt = simple_udp_packet(
1481 pktlen = 100,
1482 dl_vlan_enable = True,
1483 vlan_vid = port_to_out_vlan[in_port],
1484 eth_dst = port_to_dst_mac_str[in_port],
1485 eth_src = port_to_src_mac_str[in_port],
1486 ip_ttl = 64,
1487 ip_src = port_to_src_ip_str[in_port],
1488 ip_dst = dst_ip_str
1489 )
1490 pkt = str( parsed_pkt )
1491 if out_port == in_port:
1492 verify_no_packet( self, pkt, in_port )
1493 continue
1494 verify_packet( self, pkt, out_port )
1495 verify_no_other_packets( self )
1496 finally:
1497 delete_all_flows( self.controller )
1498 delete_groups( self.controller, Groups )
1499 delete_all_groups( self.controller )
1500
1501
1502class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1503 """
1504 Mcast routing, in this test case the traffic is tagged.
1505 300 is used as vlan_id. The packet goes out
1506 untagged.
1507 """
1508 def runTest( self ):
1509 Groups = Queue.LifoQueue( )
1510 try:
1511 if len( config[ "port_map" ] ) < 2:
1512 logging.info( "Port count less than 2, can't run this case" )
1513 assert (False)
1514 return
1515 ports = config[ "port_map" ].keys( )
1516 dst_ip_str = "224.0.0.1"
1517 (
1518 port_to_in_vlan,
1519 port_to_out_vlan,
1520 port_to_src_mac_str,
1521 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001522 port_to_src_ip,
Pier7b031af2016-08-25 15:00:22 -07001523 port_to_src_ip_str,
1524 Groups) = fill_mcast_pipeline_L3toL2(
1525 self.controller,
1526 logging,
1527 ports,
1528 is_ingress_tagged = True,
1529 is_egress_tagged = False,
1530 is_vlan_translated = False,
1531 is_max_vlan = False
1532 )
1533
1534 for in_port in ports:
1535
1536 parsed_pkt = simple_udp_packet(
1537 pktlen = 100,
1538 dl_vlan_enable = True,
1539 vlan_vid = port_to_in_vlan[in_port],
1540 eth_dst = port_to_dst_mac_str[in_port],
1541 eth_src = port_to_src_mac_str[in_port],
1542 ip_ttl = 64,
1543 ip_src = port_to_src_ip_str[in_port],
1544 ip_dst = dst_ip_str
1545 )
1546 pkt = str( parsed_pkt )
1547 self.dataplane.send( in_port, pkt )
1548
1549 for out_port in ports:
1550
1551 parsed_pkt = simple_udp_packet(
1552 pktlen = 96,
1553 eth_dst = port_to_dst_mac_str[in_port],
1554 eth_src = port_to_src_mac_str[in_port],
1555 ip_ttl = 64,
1556 ip_src = port_to_src_ip_str[in_port],
1557 ip_dst = dst_ip_str
1558 )
1559 pkt = str( parsed_pkt )
1560 if out_port == in_port:
1561 verify_no_packet( self, pkt, in_port )
1562 continue
1563 verify_packet( self, pkt, out_port )
1564 verify_no_other_packets( self )
1565 finally:
1566 delete_all_flows( self.controller )
1567 delete_groups( self.controller, Groups )
1568 delete_all_groups( self.controller )
1569
1570class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1571 """
1572 Mcast routing, in this test case the traffic is tagged.
1573 300 is used as vlan_id. The packet goes out tagged.
1574 """
1575 def runTest( self ):
1576 Groups = Queue.LifoQueue( )
1577 try:
1578 if len( config[ "port_map" ] ) < 2:
1579 logging.info( "Port count less than 2, can't run this case" )
1580 assert (False)
1581 return
1582 ports = config[ "port_map" ].keys( )
1583 dst_ip_str = "224.0.0.1"
1584 (
1585 port_to_in_vlan,
1586 port_to_out_vlan,
1587 port_to_src_mac_str,
1588 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001589 port_to_src_ip,
Pier7b031af2016-08-25 15:00:22 -07001590 port_to_src_ip_str,
1591 Groups) = fill_mcast_pipeline_L3toL2(
1592 self.controller,
1593 logging,
1594 ports,
1595 is_ingress_tagged = True,
1596 is_egress_tagged = True,
1597 is_vlan_translated = False,
1598 is_max_vlan = False
1599 )
1600
1601 for in_port in ports:
1602
1603 parsed_pkt = simple_udp_packet(
1604 pktlen = 100,
1605 dl_vlan_enable = True,
1606 vlan_vid = port_to_in_vlan[in_port],
1607 eth_dst = port_to_dst_mac_str[in_port],
1608 eth_src = port_to_src_mac_str[in_port],
1609 ip_ttl = 64,
1610 ip_src = port_to_src_ip_str[in_port],
1611 ip_dst = dst_ip_str
1612 )
1613 pkt = str( parsed_pkt )
1614 self.dataplane.send( in_port, pkt )
1615
1616 for out_port in ports:
1617
1618 parsed_pkt = simple_udp_packet(
1619 pktlen = 100,
1620 dl_vlan_enable = True,
1621 vlan_vid = port_to_in_vlan[in_port],
1622 eth_dst = port_to_dst_mac_str[in_port],
1623 eth_src = port_to_src_mac_str[in_port],
1624 ip_ttl = 64,
1625 ip_src = port_to_src_ip_str[in_port],
1626 ip_dst = dst_ip_str
1627 )
1628 pkt = str( parsed_pkt )
1629 if out_port == in_port:
1630 verify_no_packet( self, pkt, in_port )
1631 continue
1632 verify_packet( self, pkt, out_port )
1633 verify_no_other_packets( self )
1634 finally:
1635 delete_all_flows( self.controller )
1636 delete_groups( self.controller, Groups )
1637 delete_all_groups( self.controller )
1638
1639class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1640 """
1641 Mcast routing, in this test case the traffic is tagged.
1642 port+1 is used as ingress vlan_id. The packet goes out
1643 tagged. 4094-port is used as egress vlan_id
1644 """
1645 def runTest( self ):
1646 Groups = Queue.LifoQueue( )
1647 try:
1648 if len( config[ "port_map" ] ) < 2:
1649 logging.info( "Port count less than 2, can't run this case" )
1650 assert (False)
1651 return
1652 ports = config[ "port_map" ].keys( )
1653 dst_ip_str = "224.0.0.1"
1654 (
1655 port_to_in_vlan,
1656 port_to_out_vlan,
1657 port_to_src_mac_str,
1658 port_to_dst_mac_str,
Andrea Campanella0ea96322018-04-19 19:11:49 +02001659 port_to_src_ip,
Pier7b031af2016-08-25 15:00:22 -07001660 port_to_src_ip_str,
1661 Groups) = fill_mcast_pipeline_L3toL2(
1662 self.controller,
1663 logging,
1664 ports,
1665 is_ingress_tagged = True,
1666 is_egress_tagged = True,
1667 is_vlan_translated = True,
1668 is_max_vlan = False
1669 )
1670
1671 for in_port in ports:
1672
1673 parsed_pkt = simple_udp_packet(
1674 pktlen = 100,
1675 dl_vlan_enable = True,
1676 vlan_vid = port_to_in_vlan[in_port],
1677 eth_dst = port_to_dst_mac_str[in_port],
1678 eth_src = port_to_src_mac_str[in_port],
1679 ip_ttl = 64,
1680 ip_src = port_to_src_ip_str[in_port],
1681 ip_dst = dst_ip_str
1682 )
1683 pkt = str( parsed_pkt )
1684 self.dataplane.send( in_port, pkt )
1685
1686 for out_port in ports:
1687
1688 parsed_pkt = simple_udp_packet(
1689 pktlen = 100,
1690 dl_vlan_enable = True,
1691 vlan_vid = port_to_out_vlan[in_port],
1692 eth_dst = port_to_dst_mac_str[in_port],
1693 eth_src = port_to_src_mac_str[in_port],
1694 ip_ttl = 64,
1695 ip_src = port_to_src_ip_str[in_port],
1696 ip_dst = dst_ip_str
1697 )
1698 pkt = str( parsed_pkt )
1699 if out_port == in_port:
1700 verify_no_packet( self, pkt, in_port )
1701 continue
1702 verify_packet( self, pkt, out_port )
1703 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001704 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001705 delete_all_flows( self.controller )
1706 delete_groups( self.controller, Groups )
1707 delete_all_groups( self.controller )
1708
Saurav Das5d1473d2018-07-12 11:02:56 -07001709@disabled
Andrea Campanella0ea96322018-04-19 19:11:49 +02001710class L3McastTrafficThenDrop( base_tests.SimpleDataPlane ):
Saurav Das5d1473d2018-07-12 11:02:56 -07001711 # fails on alternate repeated runs
Andrea Campanella0ea96322018-04-19 19:11:49 +02001712 """
1713 Mcast routing, in this test case the traffic is untagged.
1714 4094 is used as internal vlan_id. We first install aa full pipeline,
1715 test that it forwards properly then remove all rules on table 40 and
1716 mcast groups and ensure traffic is dropped. Blackhole of mcast traffic
1717 if no tree is programmed on the switch.
1718 """
1719 def runTest( self ):
1720 Groups = Queue.LifoQueue( )
1721 try:
1722 if len( config[ "port_map" ] ) < 2:
1723 logging.info( "Port count less than 2, can't run this case" )
1724 assert (False)
1725 return
1726 ports = config[ "port_map" ].keys( )
1727 dst_ip_str = "224.0.0.1"
1728 (
1729 port_to_in_vlan,
1730 port_to_out_vlan,
1731 port_to_src_mac_str,
1732 port_to_dst_mac_str,
1733 port_to_src_ip,
1734 port_to_src_ip_str,
1735 Groups) = fill_mcast_pipeline_L3toL2(
1736 self.controller,
1737 logging,
1738 ports,
1739 is_ingress_tagged = False,
1740 is_egress_tagged = False,
1741 is_vlan_translated = False,
1742 is_max_vlan = True
1743 )
1744
1745 for in_port in ports:
1746
1747 parsed_pkt = simple_udp_packet(
1748 pktlen = 96,
1749 eth_dst = port_to_dst_mac_str[in_port],
1750 eth_src = port_to_src_mac_str[in_port],
1751 ip_ttl = 64,
1752 ip_src = port_to_src_ip_str[in_port],
1753 ip_dst = dst_ip_str
1754 )
1755 pkt = str( parsed_pkt )
1756 self.dataplane.send( in_port, pkt )
1757
1758 for out_port in ports:
1759
1760 parsed_pkt = simple_udp_packet(
1761 pktlen = 96,
1762 eth_dst = port_to_dst_mac_str[in_port],
1763 eth_src = port_to_src_mac_str[in_port],
1764 ip_ttl = 64,
1765 ip_src = port_to_src_ip_str[in_port],
1766 ip_dst = dst_ip_str
1767 )
1768 pkt = str( parsed_pkt )
1769 if out_port == in_port:
1770 verify_no_packet( self, pkt, in_port )
1771 continue
1772 verify_packet( self, pkt, out_port )
1773 verify_no_other_packets( self )
1774
1775 delete_all_flows_one_table(ctrl=self.controller, logger=logging, table_id=40);
1776 delete_all_groups(self.controller)
1777
1778 for in_port in ports:
1779
1780 parsed_pkt = simple_udp_packet(
1781 pktlen = 96,
1782 eth_dst = port_to_dst_mac_str[in_port],
1783 eth_src = port_to_src_mac_str[in_port],
1784 ip_ttl = 64,
1785 ip_src = port_to_src_ip_str[in_port],
1786 ip_dst = dst_ip_str
1787 )
1788 pkt = str( parsed_pkt )
1789 self.dataplane.send( in_port, pkt )
1790
1791 for out_port in ports:
1792
1793 parsed_pkt = simple_udp_packet(
1794 pktlen = 96,
1795 eth_dst = port_to_dst_mac_str[in_port],
1796 eth_src = port_to_src_mac_str[in_port],
1797 ip_ttl = 64,
1798 ip_src = port_to_src_ip_str[in_port],
1799 ip_dst = dst_ip_str
1800 )
1801 pkt = str( parsed_pkt )
1802 if out_port == in_port:
1803 verify_no_packet( self, pkt, in_port )
1804 continue
1805 verify_no_packet( self, pkt, out_port )
1806 verify_no_other_packets( self )
1807 finally:
1808 delete_all_flows( self.controller )
1809 delete_groups( self.controller, Groups )
1810 delete_all_groups( self.controller )
1811
Saurav Das34992182017-04-14 15:59:48 -07001812@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001813class _MplsFwd( base_tests.SimpleDataPlane ):
Saurav Das34992182017-04-14 15:59:48 -07001814 """ Verify basic MPLS forwarding: Label switch router """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001815
1816 def runTest( self ):
1817 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001818 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001819 if len( config[ "port_map" ] ) < 2:
1820 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001821 return
1822 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001823 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1824 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001825 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001826 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001827 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001828 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1829 vlan_id = port + 16
1830 mpls_label = port + 16
1831
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001832 # add l2 interface group
1833 id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001834 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Charles Chan53cac542016-08-22 16:03:26 -07001835 dst_mac[ 5 ] = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001836 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1837 vlan_id, id )
1838 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1839 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
Charles Chan53cac542016-08-22 16:03:26 -07001840 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
Saurav Das34992182017-04-14 15:59:48 -07001841 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1842 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001843 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001844 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001845 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001846 if config["switch_type"] == "qmx":
1847 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1848 else:
1849 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Flavio Castro9debaaa2016-07-26 19:37:50 -07001850 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
Alex Yashchuk9f449462017-12-09 18:27:19 +02001851 if config["switch_type"] != 'xpliant':
1852 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
1853 else:
1854 xpliant_add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001855 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001856 Groups._put( l2_gid )
1857 Groups._put( mpls_gid )
1858 Groups._put( mpls_label_gid )
Saurav Das34992182017-04-14 15:59:48 -07001859 #Groups._put( ecmp_gid )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001860 do_barrier( self.controller )
castroflavio30c6cc52016-01-07 15:19:42 -08001861
Flavio Castroa7162bb2016-07-25 17:30:30 -07001862 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001863 for in_port in ports:
1864 ip_src = '192.168.%02d.1' % (in_port)
1865 for out_port in ports:
1866 if in_port == out_port:
1867 continue
Flavio Castro54947942016-02-03 16:05:20 -05001868
Charles Chan53cac542016-08-22 16:03:26 -07001869 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1870 out_mpls_label = out_port + 16
1871 in_vlan_vid = in_port + 16
1872 out_vlan_vid = out_port + 16
1873
1874 ip_dst = '192.168.%02d.1' % (out_port)
1875 label = (out_mpls_label, 0, 1, 32)
1876 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001877 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1878 pkt = str( parsed_pkt )
1879 self.dataplane.send( in_port, pkt )
Flavio Castro54947942016-02-03 16:05:20 -05001880
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001881 # build expect packet
1882 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001883 label = (out_mpls_label, 0, 1, 31)
1884 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001885 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1886 label=[ label ] )
1887 pkt = str( exp_pkt )
1888 verify_packet( self, pkt, out_port )
1889 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001890 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001891 delete_all_flows( self.controller )
1892 delete_groups( self.controller, Groups )
1893 delete_all_groups( self.controller )
Flavio Castrob702a2f2016-04-10 22:01:48 -04001894
Saurav Das34992182017-04-14 15:59:48 -07001895@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07001896class _MplsTermination( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07001897 """ Verify MPLS VPN Termination at penultimate hop """
Flavio Castroa7162bb2016-07-25 17:30:30 -07001898
1899 def runTest( self ):
1900 Groups = Queue.LifoQueue( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001901 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001902 if len( config[ "port_map" ] ) < 2:
1903 logging.info( "Port count less than 2, can't run this case" )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001904 return
1905 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07001906 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1907 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castrod80fbc32016-07-25 15:54:26 -07001908 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
Flavio Castroa7162bb2016-07-25 17:30:30 -07001909 ports = config[ "port_map" ].keys( )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001910 for port in ports:
Charles Chan53cac542016-08-22 16:03:26 -07001911 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1912 vlan_id = port + 16
1913 mpls_label = port + 16
1914
Flavio Castrod80fbc32016-07-25 15:54:26 -07001915 # add l2 interface group
Charles Chan53cac542016-08-22 16:03:26 -07001916 id, dst_mac[ 5 ] = port, port
Flavio Castroa7162bb2016-07-25 17:30:30 -07001917 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001918 # add L3 Unicast group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001919 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1920 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001921 # add L3 ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07001922 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001923 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01001924 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001925 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07001926 if config["switch_type"] == "qmx":
1927 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1928 else:
1929 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
Alex Yashchuk9f449462017-12-09 18:27:19 +02001930
1931 if config["switch_type"] != 'xpliant':
1932 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1933 else:
1934 xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1935
Flavio Castroa7162bb2016-07-25 17:30:30 -07001936 # add_mpls_flow(self.controller, label=port)
Flavio Castrod80fbc32016-07-25 15:54:26 -07001937 dst_ip = dip + (vlan_id << 8)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001938 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
Flavio Castrod80fbc32016-07-25 15:54:26 -07001939 # ecmp_msg.group_id, 1)
Flavio Castroa7162bb2016-07-25 17:30:30 -07001940 Groups._put( l2_gid )
1941 Groups._put( l3_msg.group_id )
1942 Groups._put( ecmp_msg.group_id )
1943 do_barrier( self.controller )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001944
Flavio Castroa7162bb2016-07-25 17:30:30 -07001945 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castrod80fbc32016-07-25 15:54:26 -07001946 for in_port in ports:
1947 ip_src = '192.168.%02d.1' % (in_port)
1948 for out_port in ports:
1949 if in_port == out_port:
1950 continue
Charles Chan53cac542016-08-22 16:03:26 -07001951
1952 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1953 out_mpls_label = out_port + 16
1954 in_vlan_vid = in_port + 16
1955 out_vlan_vid = out_port + 16
1956
Flavio Castrod80fbc32016-07-25 15:54:26 -07001957 ip_dst = '192.168.%02d.1' % (out_port)
Charles Chan53cac542016-08-22 16:03:26 -07001958 label = (out_mpls_label, 0, 1, 32)
1959 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
Flavio Castroa7162bb2016-07-25 17:30:30 -07001960 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1961 pkt = str( parsed_pkt )
1962 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001963 # build expect packet
1964 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Alex Yashchuk9f449462017-12-09 18:27:19 +02001965 if config["switch_type"] != 'xpliant':
1966 ip_ttl=31
1967 else:
1968 ip_ttl=64
Charles Chan53cac542016-08-22 16:03:26 -07001969 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
Alex Yashchuk9f449462017-12-09 18:27:19 +02001970 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=ip_ttl, ip_src=ip_src, ip_dst=ip_dst )
Flavio Castroa7162bb2016-07-25 17:30:30 -07001971 pkt = str( exp_pkt )
1972 verify_packet( self, pkt, out_port )
1973 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07001974 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07001975 delete_all_flows( self.controller )
1976 delete_groups( self.controller, Groups )
1977 delete_all_groups( self.controller )
Saurav Das15c2c262017-05-06 18:12:38 -07001978
Saurav Das34992182017-04-14 15:59:48 -07001979
1980@disabled
1981class One_MplsTermination( base_tests.SimpleDataPlane ):
1982 """
1983 Verify MPLS VPN Termination at penultimate hop in only one direction
1984 """
1985
1986 def runTest( self ):
1987 Groups = Queue.LifoQueue( )
1988 try:
1989 if len( config[ "port_map" ] ) < 2:
1990 logging.info( "Port count less than 2, can't run this case" )
1991 return
1992 dip = 0xc0a80001
1993 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1994 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1995 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1996 ports = config[ "port_map" ].keys( )
1997 inport = ports[0]
1998 outport = ports[1]
1999
2000 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
2001 invlan_id = inport + 16
2002 outvlan_id = outport + 16
2003 mpls_label = outport + 16
2004
2005 # add l2 interface group
2006 id, dst_mac[ 5 ] = inport, outport
2007 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
2008 # add L3 Unicast group
2009 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
2010 src_mac=intf_src_mac, dst_mac=dst_mac )
2011 # add L3 ecmp group
2012 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
2013 # add vlan flow table
2014 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2015 # add tmac flow
Saurav Dase94ba572017-04-28 17:47:21 -07002016 if config["switch_type"] == "qmx":
2017 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
2018 else:
2019 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
Saurav Das34992182017-04-14 15:59:48 -07002020 # add mpls termination flow
2021 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
2022 Groups._put( l2_gid )
2023 Groups._put( l3_msg.group_id )
2024 Groups._put( ecmp_msg.group_id )
2025
2026 time.sleep(0.1)
2027 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2028 ip_src = '192.168.%02d.1' % (inport)
2029 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
2030 out_mpls_label = outport + 16
2031 in_vlan_vid = inport + 16
2032 out_vlan_vid = outport + 16
2033
2034 ip_dst = '192.168.%02d.1' % (outport)
2035 label = (out_mpls_label, 0, 1, 32)
2036 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
2037 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
2038 pkt = str( parsed_pkt )
2039 self.dataplane.send( inport, pkt )
2040 # build expect packet
2041 mac_dst = '00:00:00:22:22:%02X' % (outport)
2042 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
2043 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
2044 pkt = str( exp_pkt )
2045 verify_packet( self, pkt, outport )
2046 verify_no_other_packets( self )
2047 finally:
2048 delete_all_flows( self.controller )
2049 delete_groups( self.controller, Groups )
2050 delete_all_groups( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05002051
Flavio Castroa7162bb2016-07-25 17:30:30 -07002052
2053class _24UcastTagged( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07002054 """ Verify /24 IP forwarding to L3 Interface """
Flavio Castro1c9b1252016-02-04 18:42:58 -05002055
Flavio Castroa7162bb2016-07-25 17:30:30 -07002056 def runTest( self ):
2057 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002058 try:
2059 test_id = 26
Flavio Castroa7162bb2016-07-25 17:30:30 -07002060 if len( config[ "port_map" ] ) < 2:
2061 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002062 return
Flavio Castroa7162bb2016-07-25 17:30:30 -07002063 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2064 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002065 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07002066 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002067 for port in ports:
2068 # add l2 interface group
2069 vlan_id = port + test_id
Flavio Castroa7162bb2016-07-25 17:30:30 -07002070 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2071 is_tagged=True, send_barrier=False )
2072 dst_mac[ 5 ] = vlan_id
2073 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
2074 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002075 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002076 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002077 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002078 if config["switch_type"] == "qmx":
2079 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2080 else:
2081 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002082 # add unicast routing flow
2083 dst_ip = dip + (vlan_id << 8)
Andrea Campanellabfb42b32018-04-26 10:57:23 +02002084 # def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False, priority = 1):
Flavio Castroa7162bb2016-07-25 17:30:30 -07002085 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
2086 Groups.put( l2gid )
2087 Groups.put( l3_msg.group_id )
2088 do_barrier( self.controller )
Flavio Castro1c9b1252016-02-04 18:42:58 -05002089
Flavio Castroa7162bb2016-07-25 17:30:30 -07002090 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002091 for in_port in ports:
2092 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
2093 ip_src = '192.168.%02d.1' % (test_id + in_port)
2094 for out_port in ports:
2095 if in_port == out_port:
2096 continue
2097 ip_dst = '192.168.%02d.1' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002098 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2099 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
2100 ip_src=ip_src, ip_dst=ip_dst )
2101 pkt = str( parsed_pkt )
2102 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002103 # build expected packet
2104 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002105 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2106 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
2107 ip_src=ip_src, ip_dst=ip_dst )
2108 pkt = str( exp_pkt )
2109 verify_packet( self, pkt, out_port )
2110 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002111 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002112 delete_all_flows( self.controller )
2113 delete_groups( self.controller, Groups )
2114 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002115
Andrea Campanellabfb42b32018-04-26 10:57:23 +02002116class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ):
2117 """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0"""
2118
2119 def runTest( self ):
2120 Groups = Queue.LifoQueue( )
2121 try:
2122 test_id = 27
2123 if len( config[ "port_map" ] ) < 2:
2124 logging.info( "Port count less than 2, can't run this case" )
2125 return
2126 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2127 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2128 dip = 0xc0a80001
2129 ports = config[ "port_map" ].keys( )
2130 for port in ports:
2131 # add l2 interface group
2132 vlan_id = port + test_id
2133 # add vlan flow table
2134 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2135 # add termination flow
2136 if config["switch_type"] == "qmx":
2137 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2138 else:
2139 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2140 # add unicast routing flow
2141 #dst ip = 10.0.0.0/8
2142 dst_ip = 0x0a000000
2143 add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 )
2144 do_barrier( self.controller )
2145
2146 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2147 for in_port in ports:
2148 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
2149 ip_src = '192.168.%02d.1' % (test_id + in_port)
2150 for out_port in ports:
2151 if in_port == out_port:
2152 continue
2153 ip_dst = '192.168.%02d.1' % (test_id + out_port)
2154 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2155 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
2156 ip_src=ip_src, ip_dst=ip_dst )
2157 pkt = str( parsed_pkt )
2158 self.dataplane.send( in_port, pkt )
2159 # build expected packet
2160 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
2161 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2162 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
2163 ip_src=ip_src, ip_dst=ip_dst )
2164 pkt = str( exp_pkt )
2165 verify_no_packet( self, pkt, out_port )
2166 verify_no_other_packets( self )
2167 finally:
2168 delete_all_flows( self.controller )
2169 delete_groups( self.controller, Groups )
2170 delete_all_groups( self.controller )
2171
Flavio Castroa7162bb2016-07-25 17:30:30 -07002172
2173class _0Ucast( base_tests.SimpleDataPlane ):
Flavio Castro76c5b262016-07-27 19:53:00 -07002174 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
Flavio Castro91d1a552016-05-17 16:59:44 -07002175
Flavio Castroa7162bb2016-07-25 17:30:30 -07002176 def runTest( self ):
2177 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002178 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002179 if len( config[ "port_map" ] ) < 2:
2180 logging.info( "Port count less than 2, can't run this case" )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002181 return
Flavio Castro91d1a552016-05-17 16:59:44 -07002182
Flavio Castroa7162bb2016-07-25 17:30:30 -07002183 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2184 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002185 dip = 0xc0a80001
Flavio Castroa7162bb2016-07-25 17:30:30 -07002186 ports = config[ "port_map" ].keys( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002187 for port in ports:
2188 # add l2 interface group
2189 vlan_id = port
Flavio Castroa7162bb2016-07-25 17:30:30 -07002190 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
2191 is_tagged=True, send_barrier=False )
2192 dst_mac[ 5 ] = vlan_id
2193 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
2194 src_mac=intf_src_mac, dst_mac=dst_mac )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002195 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002196 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002197 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002198 if config["switch_type"] == "qmx":
2199 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2200 else:
2201 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002202 # add unicast routing flow
2203 dst_ip = dip + (vlan_id << 8)
Alex Yashchuk9f449462017-12-09 18:27:19 +02002204 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id, priority=2 )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002205 Groups.put( l2gid )
2206 Groups.put( l3_msg.group_id )
2207 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002208 dst_ip = 0x0
Flavio Castroa7162bb2016-07-25 17:30:30 -07002209 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
2210 do_barrier( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002211
Flavio Castroa7162bb2016-07-25 17:30:30 -07002212 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002213 for in_port in ports:
2214 mac_src = '00:00:00:22:22:%02X' % (in_port)
2215 ip_src = '192.168.%02d.1' % (in_port)
2216 for out_port in ports:
2217 if in_port == out_port:
2218 continue
2219 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002220 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
2221 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2222 pkt = str( parsed_pkt )
2223 self.dataplane.send( in_port, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002224 # build expected packet
2225 mac_dst = '00:00:00:22:22:%02X' % (out_port)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002226 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
2227 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2228 pkt = str( exp_pkt )
2229 verify_packet( self, pkt, out_port )
2230 verify_no_other_packets( self )
2231 ip_dst = '1.168.%02d.1' % ports[ 0 ]
2232 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
2233 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2234 pkt = str( parsed_pkt )
2235 self.dataplane.send( in_port, pkt )
2236 # build expect packet
2237 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2238 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
2239 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
2240 pkt = str( exp_pkt )
2241 verify_packet( self, pkt, ports[ 0 ] )
2242 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002243 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002244 delete_all_flows( self.controller )
2245 delete_groups( self.controller, Groups )
2246 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002247
Flavio Castroa7162bb2016-07-25 17:30:30 -07002248
2249class Unfiltered( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002250 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002251 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
Flavio Castro423df652016-05-17 20:14:08 -04002252 """
Flavio Castro91d1a552016-05-17 16:59:44 -07002253
Flavio Castroa7162bb2016-07-25 17:30:30 -07002254 def runTest( self ):
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002255 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002256 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002257 vlan_id = 1;
2258 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002259 add_l2_unfiltered_group( self.controller, [ port ], False )
2260 do_barrier( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002261 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002262 delete_all_flows( self.controller )
2263 delete_all_groups( self.controller )
Flavio Castro91d1a552016-05-17 16:59:44 -07002264
Saurav Das34992182017-04-14 15:59:48 -07002265@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002266class L3McastToVPN( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002267 """
Flavio Castro76c5b262016-07-27 19:53:00 -07002268 Mcast routing and VPN initiation
Flavio Castro423df652016-05-17 20:14:08 -04002269 """
Flavio Castroa7162bb2016-07-25 17:30:30 -07002270
2271 def runTest( self ):
Flavio Castro423df652016-05-17 20:14:08 -04002272 """
2273 port1 (vlan 1)-> port 2 (vlan 2)
2274 """
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002275 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002276 delete_all_flows( self.controller )
2277 delete_all_groups( self.controller )
Flavio Castro423df652016-05-17 20:14:08 -04002278
Flavio Castroa7162bb2016-07-25 17:30:30 -07002279 if len( config[ "port_map" ] ) < 3:
2280 logging.info( "Port count less than 3, can't run this case" )
2281 assert (False)
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002282 return
Flavio Castro423df652016-05-17 20:14:08 -04002283
Flavio Castroa7162bb2016-07-25 17:30:30 -07002284 vlan_id = 1
2285 port2_out_vlan = 2
2286 port3_out_vlan = 3
2287 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
2288 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2289 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2290 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2291 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
2292 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
2293 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
2294 src_ip = 0xc0a80101
2295 src_ip_str = "192.168.1.1"
2296 dst_ip = 0xe0010101
2297 dst_ip_str = "224.1.1.1"
Flavio Castro423df652016-05-17 20:14:08 -04002298
Flavio Castroa7162bb2016-07-25 17:30:30 -07002299 port1 = config[ "port_map" ].keys( )[ 0 ]
2300 port2 = config[ "port_map" ].keys( )[ 1 ]
2301 # port3=config["port_map"].keys()[2]
Flavio Castro423df652016-05-17 20:14:08 -04002302
Flavio Castroa7162bb2016-07-25 17:30:30 -07002303 # add l2 interface group
2304 for port in config[ "port_map" ].keys( ):
2305 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
2306 send_barrier=False )
2307 # add vlan flow table
2308 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2309 vlan_id += 1
Flavio Castro423df652016-05-17 20:14:08 -04002310
Flavio Castroa7162bb2016-07-25 17:30:30 -07002311 # add termination flow
2312 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
2313 vlan_id )
Flavio Castro423df652016-05-17 20:14:08 -04002314
Flavio Castroa7162bb2016-07-25 17:30:30 -07002315 # add MPLS interface group
2316 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
2317 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
2318 port2_out_vlan, port2 )
2319 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
2320 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
2321 # add L3VPN groups
2322 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
2323 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
2324 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
2325 # 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 -07002326 # 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 -04002327
Flavio Castroa7162bb2016-07-25 17:30:30 -07002328 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
2329 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 -04002330
Flavio Castroa7162bb2016-07-25 17:30:30 -07002331 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
2332 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
2333 pkt = str( parsed_pkt )
2334 self.dataplane.send( port1, pkt )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002335 label = (12, 0, 1, 63)
Flavio Castroa7162bb2016-07-25 17:30:30 -07002336 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
2337 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
2338 pkt = str( exp_pkt )
2339 verify_packet( self, pkt, port2 )
2340 # verify_packet(self, pkt, port3)
2341 verify_no_other_packets( self )
2342 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002343 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002344 delete_all_flows( self.controller )
2345 delete_all_groups( self.controller )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002346
Saurav Das34992182017-04-14 15:59:48 -07002347@disabled
Flavio Castroa7162bb2016-07-25 17:30:30 -07002348class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
Flavio Castro423df652016-05-17 20:14:08 -04002349 """
2350 Test packet in function on a src-mac miss
2351 Send a packet to each dataplane port and verify that a packet
2352 in message is received from the controller for each
2353 #todo verify you stop receiving after adding rule
2354 """
2355
Flavio Castroa7162bb2016-07-25 17:30:30 -07002356 def runTest( self ):
2357 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002358 try:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002359 ports = sorted( config[ "port_map" ].keys( ) )
Flavio Castro423df652016-05-17 20:14:08 -04002360
Flavio Castroa7162bb2016-07-25 17:30:30 -07002361 Groups = Queue.LifoQueue( )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002362 for port in ports:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002363 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2364 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2365 Groups.put( L2gid )
2366 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2367 vlan_pkt = str( parsed_vlan_pkt )
2368 for of_port in config[ "port_map" ].keys( ):
2369 logging.info( "PacketInMiss test, port %d", of_port )
2370 self.dataplane.send( of_port, vlan_pkt )
2371 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2372 verify_no_other_packets( self )
Flavio Castro8c37e1c2016-07-19 18:26:33 -07002373 finally:
Flavio Castroa7162bb2016-07-25 17:30:30 -07002374 delete_all_flows( self.controller )
2375 delete_all_groups( self.controller )
2376
2377
2378class EcmpGroupMod( base_tests.SimpleDataPlane ):
2379 """
Saurav Das34992182017-04-14 15:59:48 -07002380 Verify referenced group can be modified by adding or removing buckets
Flavio Castroa7162bb2016-07-25 17:30:30 -07002381 """
2382
2383 def runTest( self ):
2384 Groups = Queue.LifoQueue( )
2385 try:
2386 if len( config[ "port_map" ] ) < 2:
2387 logging.info( "Port count less than 2, can't run this case" )
2388 return
2389
2390 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2391 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2392 dip = 0xc0a80001
2393 # Hashes Test Name and uses it as id for installing unique groups
2394 ports = config[ "port_map" ].keys( )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002395 ecmp = [ ]
Saurav Das34992182017-04-14 15:59:48 -07002396 dst_ips = []
2397 # add flows for all ports but include only the egress switchport (connected to ports[1])
2398 # in the ecmp group
Flavio Castroa7162bb2016-07-25 17:30:30 -07002399 for port in ports:
2400 vlan_id = port
2401 id = port
2402 # add l2 interface group
2403 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2404 is_tagged=True, send_barrier=False )
2405 dst_mac[ 5 ] = vlan_id
2406 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2407 src_mac=intf_src_mac, dst_mac=dst_mac )
Saurav Das34992182017-04-14 15:59:48 -07002408 if port == ports[1]:
2409 ecmp += [ l3_msg.group_id ]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002410 Groups._put( l2_gid )
2411 Groups._put( l3_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002412 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002413 # add vlan flow table
Pier265ad5f2017-02-28 17:46:28 +01002414 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002415 # add termination flow
Saurav Dase94ba572017-04-28 17:47:21 -07002416 if config["switch_type"] == "qmx":
2417 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2418 else:
2419 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
Flavio Castroa7162bb2016-07-25 17:30:30 -07002420 # add unicast routing flow
2421 dst_ip = dip + (vlan_id << 8)
Saurav Das34992182017-04-14 15:59:48 -07002422 dst_ips += [dst_ip]
Flavio Castroa7162bb2016-07-25 17:30:30 -07002423 Groups._put( ecmp_msg.group_id )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002424 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
Saurav Das34992182017-04-14 15:59:48 -07002425 for dst_ip in dst_ips:
2426 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
Saurav Das5d1473d2018-07-12 11:02:56 -07002427 do_barrier(self.controller)
Saurav Das34992182017-04-14 15:59:48 -07002428 time.sleep(0.1)
2429 # first part of the test: send packet from ingress switchport and expect it at egress switchport
Flavio Castroa7162bb2016-07-25 17:30:30 -07002430 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
Flavio Castro9debaaa2016-07-26 19:37:50 -07002431 parsed_pkt = exp_pkt = 0
Saurav Das34992182017-04-14 15:59:48 -07002432 in_port = ports[0]
2433 out_port = ports[1]
2434 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2435 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2436 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2437 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2438 tcp = out_port if out_port == 24 else 25
2439 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2440 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2441 ip_dst=ip_dst, tcp_dport=tcp )
2442 pkt = str( parsed_pkt )
2443 self.dataplane.send( ports[ 0 ], pkt )
2444 # build expected packet at egress switchport
2445 mac_dst = '00:00:00:22:22:%02X' % out_port
2446 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2447 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2448 ip_dst=ip_dst, tcp_dport=tcp )
2449 pkt = str( exp_pkt )
2450 verify_packet( self, pkt, out_port )
2451 verify_no_other_packets( self )
2452
2453 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2454 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2455 # it back on the ingress switchport
Flavio Castro9debaaa2016-07-26 19:37:50 -07002456 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2457 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Saurav Das34992182017-04-14 15:59:48 -07002458 time.sleep(0.1)
2459 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2460 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2461 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2462 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2463 tcp = port if port == 24 else 25
2464 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2465 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2466 ip_dst=ip_dst,tcp_dport=tcp )
2467 pkt = str( parsed_pkt )
2468 self.dataplane.send( ports[ 0 ], pkt )
2469 # build expected packet
2470 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2471 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2472 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2473 ip_dst=ip_dst,tcp_dport=tcp )
Alex Yashchuk9f449462017-12-09 18:27:19 +02002474 # Expects packet on the input port
2475 if config["switch_type"] != 'xpliant':
2476 pkt = str( exp_pkt )
2477 verify_packet( self, pkt, ports[ 0 ] )
2478 verify_no_other_packets( self )
Saurav Das34992182017-04-14 15:59:48 -07002479
2480 # third part of the test - edit the group to completely remove bucket. Packet sent
2481 # should be dropped by the switch
Flavio Castro9debaaa2016-07-26 19:37:50 -07002482 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
Saurav Das34992182017-04-14 15:59:48 -07002483 time.sleep(0.1)
2484 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2485 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2486 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2487 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2488 tcp = port if port == 24 else 25
2489 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2490 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2491 ip_dst=ip_dst,tcp_dport=tcp )
2492 pkt = str( parsed_pkt )
2493 self.dataplane.send( ports[ 0 ], pkt )
2494 verify_no_other_packets( self )
2495
2496 # final part of the test - edit the empty group to add back the bucket for the
2497 # original egress port, and verify packet is received on egress switch port
2498 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2499 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
Alex Yashchuk9f449462017-12-09 18:27:19 +02002500 do_barrier(self.controller)
Saurav Das34992182017-04-14 15:59:48 -07002501 in_port = ports[0]
2502 out_port = ports[1]
2503 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2504 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2505 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2506 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2507 tcp = out_port if out_port == 24 else 25
2508 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2509 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2510 ip_dst=ip_dst, tcp_dport=tcp )
2511 pkt = str( parsed_pkt )
2512 self.dataplane.send( ports[ 0 ], pkt )
2513 # build expected packet at egress switchport
2514 mac_dst = '00:00:00:22:22:%02X' % out_port
2515 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2516 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2517 ip_dst=ip_dst, tcp_dport=tcp )
2518 pkt = str( exp_pkt )
2519 verify_packet( self, pkt, out_port )
2520 verify_no_other_packets( self )
2521
Flavio Castroa7162bb2016-07-25 17:30:30 -07002522 finally:
2523 delete_all_flows( self.controller )
2524 delete_groups( self.controller, Groups )
2525 delete_all_groups( self.controller )
Pier8b223022016-08-19 22:47:49 -07002526
Saurav Das34992182017-04-14 15:59:48 -07002527
Pier8b223022016-08-19 22:47:49 -07002528class Untagged( base_tests.SimpleDataPlane ):
2529 """
2530 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2531 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2532 previous versions of the OFDPA.
2533
2534 Two rules are necessary in VLAN table (10):
2535 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2536 2) Filtering: match 0x100A/0x1FFF, goto 20
2537
2538 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2539 The remaining part of the test is based on the use of the bridging table
2540 """
2541
2542 MAX_INTERNAL_VLAN = 4094
2543
2544 def runTest( self ):
2545 groups = Queue.LifoQueue( )
2546 try:
2547 if len( config[ "port_map" ] ) < 2:
2548 logging.info( "Port count less than 2, can't run this case" )
2549 return
2550
2551 ports = sorted( config[ "port_map" ].keys( ) )
2552 for port in ports:
2553 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
Pier265ad5f2017-02-28 17:46:28 +01002554 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2555 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
Pier8b223022016-08-19 22:47:49 -07002556 for other_port in ports:
2557 if other_port == port:
2558 continue
2559 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2560 groups.put( L2gid )
2561 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2562
2563 do_barrier( self.controller )
2564
2565 for out_port in ports:
2566 # change dest based on port number
2567 mac_dst = '00:12:34:56:78:%02X' % out_port
2568 for in_port in ports:
2569 if in_port == out_port:
2570 continue
2571 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2572 self.dataplane.send( in_port, pkt )
2573 for ofport in ports:
2574 if ofport in [ out_port ]:
2575 verify_packet( self, pkt, ofport )
2576 else:
2577 verify_no_packet( self, pkt, ofport )
2578 verify_no_other_packets( self )
2579 finally:
2580 delete_all_flows( self.controller )
Pierf49f79b2016-08-25 15:12:04 -07002581 delete_groups( self.controller, groups )
Pier8b223022016-08-19 22:47:49 -07002582 delete_all_groups( self.controller )
Andreas Pantelopoulos6c76b942018-01-22 10:03:02 -08002583
2584class MPLSSwapTest( base_tests.SimpleDataPlane ):
2585 """
2586 MPLS switching with the same label used.
2587 Used for interconnecting spines between different fabrics where
2588 the label should not be popped, but swapepd with the same label.
2589 """
2590
2591 def runTest( self ):
2592 try:
2593 delete_all_flows( self.controller )
2594 delete_all_groups( self.controller )
2595
2596 if len( config[ "port_map" ] ) < 2:
2597 logging.info( "Port count less than 3, can't run this case" )
2598 assert (False)
2599 return
2600
2601 input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2602 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2603
2604 input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ]
2605 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2606
2607 output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ]
2608 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2609
2610 mpls_label = 1000
2611
2612 src_ip = 0xc0a80101
2613 src_ip_str = "192.168.1.1"
2614 dst_ip = 0xe0010101
2615 dst_ip_str = "224.1.1.1"
2616
2617 src_port = config[ "port_map" ].keys( )[ 0 ]
2618 dst_port = config[ "port_map" ].keys( )[ 1 ]
2619
2620 out_vlan = 4094
2621
2622 add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False,
2623 send_barrier=True )
2624
2625 # add vlan flow table
2626 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2627 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2628
2629 # add termination flow
2630
2631 if config["switch_type"] == "qmx":
2632 logging.debug("MPLSSwitching : Adding flow for qmx, without input port")
2633 add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2634 else:
2635 add_termination_flow( self.controller, in_port=src_port,
2636 eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2637
2638 # add groups that will be used now
2639 l2_gid = encode_l2_interface_group_id( out_vlan, dst_port)
2640 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid,
2641 output_dst_mac, input_dst_mac,
2642 out_vlan, dst_port, send_barrier=True)
2643 index = 60
2644 mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid,
2645 5, index, mpls_label)
2646
2647 # add flow to mpls table
2648 add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True)
2649
2650 # we generate the packet which carries a single label
2651 label = (mpls_label, 0, 1, 63)
2652 parsed_pkt = mpls_packet(
2653 pktlen=104,
2654 label=[label],
2655 eth_src=input_src_mac_str,
2656 eth_dst=input_dst_mac_str,
2657 )
2658 pkt = str( parsed_pkt )
Andreas Pantelopoulosaaa02622018-04-04 15:13:03 -07002659
Andreas Pantelopoulos6c76b942018-01-22 10:03:02 -08002660 self.dataplane.send( src_port, pkt )
2661
2662 label = (mpls_label, 0, 1, 62)
2663 parsed_pkt = mpls_packet(
2664 pktlen=104,
2665 label=[label],
2666 eth_src=input_dst_mac_str,
2667 eth_dst=output_dst_mac_str,
2668 )
2669 pkt = str( parsed_pkt )
2670
2671 verify_packet( self, pkt, dst_port )
2672 verify_no_packet( self, pkt, src_port )
2673 verify_no_other_packets( self )
2674
2675 delete_all_flows( self.controller )
2676 delete_all_groups( self.controller )
2677
2678 finally:
2679 delete_all_flows( self.controller )
2680 delete_all_groups( self.controller )
2681
Saurav Das5d1473d2018-07-12 11:02:56 -07002682@disabled
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07002683class DoubleToUntagged( base_tests.SimpleDataPlane ):
2684 """
2685 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2686 where we receive double tagged packets and output untagged
2687 packets.
2688
2689 Each double tagged packet represents a subscriber where Outer tag is pon
2690 and inner tag is the subrscriber tag.
2691 """
2692
2693 def runTest( self ):
2694 Groups = Queue.LifoQueue( )
2695 try:
2696 if len( config[ "port_map" ] ) < 2:
2697 logging.info( "Port count less than 2, can't run this case" )
2698 return
2699
2700 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2701 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2702
2703 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2704 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2705
2706 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2707 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2708
2709 dip = 0xc0a80001
2710 ports = config[ "port_map" ].keys( )
2711
2712 inner_vlan = 66
2713 outer_vlan = 77
2714 id = 10
2715 mpls_label = 152
2716
2717 port = ports[0]
2718 out_port = ports[1]
2719
2720 # add l2 interface group
2721 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2722
2723 # add MPLS interface group
2724 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2725 inner_vlan, id )
2726
2727 # add MPLS L3 VPN group
2728 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2729 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2730 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2731 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2732
2733 do_barrier( self.controller )
2734
2735 # add vlan flow table
2736 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2737 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2738
2739 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2740 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2741
2742 # add termination flow
2743 if config["switch_type"] == "qmx":
2744 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2745 else:
2746 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2747
2748 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2749 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2750 vrf=0 )
2751 Groups._put( l2_gid )
2752 Groups._put( mpls_gid )
2753 Groups._put( mpls_label_gid )
2754 Groups._put( ecmp_msg.group_id )
2755
2756 do_barrier( self.controller )
2757
2758 ip_src = '192.168.5.5'
2759 ip_dst = '192.168.0.5'
2760 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2761 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2762 pkt = str( parsed_pkt )
2763
2764 # print("Expected %s" % format_packet(pkt))
2765
2766 self.dataplane.send( port, pkt )
2767
2768 # build expect packet
2769 label = (mpls_label, 0, 1, 32)
2770 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2771 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2772 label=[ label ] )
2773 pkt = str( exp_pkt )
2774 verify_packet( self, pkt, out_port )
2775 verify_no_other_packets( self )
2776
2777 finally:
2778 delete_all_flows( self.controller )
2779 delete_groups( self.controller, Groups )
2780 delete_all_groups( self.controller )
2781
Saurav Das5d1473d2018-07-12 11:02:56 -07002782@disabled
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07002783class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ):
2784 """
2785 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2786 where we receive double tagged packets and output untagged
2787 packets.
2788
2789 Each double tagged packet represents a subscriber where Outer tag is pon
2790 and inner tag is the subrscriber tag.
2791 """
2792
2793 def runTest( self ):
2794 Groups = Queue.LifoQueue( )
2795 try:
2796 if len( config[ "port_map" ] ) < 2:
2797 logging.info( "Port count less than 2, can't run this case" )
2798 return
2799
2800 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
2801 subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"],
2802 [20, 0xc0a80002, 10, 101, "192.168.0.2"],
2803 [30, 0xc0a80003, 11, 100, "192.168.0.3"],
2804 [40, 0xc0a80004, 11, 101, "192.168.0.4"]]
2805
2806 print("")
2807
2808 for sub_info in subscriber_info:
2809
2810 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
2811
2812 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2813 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2814
2815 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2816 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2817
2818 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2819 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2820
2821 dip = sub_info[1]
2822 ports = config[ "port_map" ].keys( )
2823
2824 inner_vlan = sub_info[2]
2825 outer_vlan = sub_info[3]
2826 id = 10
2827 mpls_label = 152
2828
2829 port = ports[0]
2830 out_port = ports[1]
2831
2832 # add l2 interface group
2833 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2834
2835 # add MPLS interface group
2836 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2837 inner_vlan, id )
2838
2839 # add MPLS L3 VPN group
2840 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2841 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2842 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2843 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2844
2845 do_barrier( self.controller )
2846
2847 # add vlan flow table
2848 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2849 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2850
2851 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2852 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2853
2854 # add termination flow
2855 if config["switch_type"] == "qmx":
2856 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2857 else:
2858 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2859
2860 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2861 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2862 vrf=0 )
2863 Groups._put( l2_gid )
2864 Groups._put( mpls_gid )
2865 Groups._put( mpls_label_gid )
2866 Groups._put( ecmp_msg.group_id )
2867
2868 do_barrier( self.controller )
2869
2870 for sub_info in subscriber_info:
2871
2872 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
2873
2874 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2875 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2876
2877 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2878 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2879
2880 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2881 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2882
2883 dip = sub_info[1]
2884 ports = config[ "port_map" ].keys( )
2885
2886 inner_vlan = sub_info[2]
2887 outer_vlan = sub_info[3]
2888 id = 10
2889 mpls_label = 152
2890
2891 port = ports[0]
2892 out_port = ports[1]
2893
2894 ip_src = sub_info[4]
2895 ip_dst = '192.168.0.{}'.format(sub_info[0])
2896 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2897 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2898 pkt = str( parsed_pkt )
2899
2900 # print("Sent %s" % format_packet(pkt))
2901
2902 self.dataplane.send( port, pkt )
2903
2904 # build expect packet
2905 label = (mpls_label, 0, 1, 32)
2906 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2907 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2908 label=[ label ] )
2909 pkt = str( exp_pkt )
2910 verify_packet( self, pkt, out_port )
2911 verify_no_other_packets( self )
2912
2913 finally:
2914 delete_all_flows( self.controller )
2915 delete_groups( self.controller, Groups )
2916 delete_all_groups( self.controller )
2917
2918
Saurav Das5d1473d2018-07-12 11:02:56 -07002919@disabled
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07002920class UntaggedToDouble ( base_tests.SimpleDataPlane ):
2921 """
2922 Verify google senario where we need to go from
2923 an untagged packet to a double tagged packet.
2924
2925 This is used for a single subscriber.
2926 """
2927
2928 def runTest( self ):
2929 Groups = Queue.LifoQueue( )
2930 try:
2931 if len( config[ "port_map" ] ) < 2:
2932 logging.info( "Port count less than 2, can't run this case" )
2933 return
2934
2935 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2936 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2937
2938 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2939 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2940
2941 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2942 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2943
2944 dip = 0xc0a80001
2945 ports = config[ "port_map" ].keys( )
2946
2947 inner_vlan = 66
2948 outer_vlan = 77
2949 id = 10
2950 mpls_label = 152
2951
2952 port = ports[0]
2953 out_port = ports[1]
2954
2955 # add l2 unfiltered interface group
2956 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
2957
2958 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id,
2959 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
2960
2961 do_barrier( self.controller )
2962
2963 # add vlan flow table
2964 add_one_vlan_table_flow( self.controller, port, 1, 4094,
2965 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
2966
2967 # add termination flow
2968 if config["switch_type"] == "qmx":
2969 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
2970 else:
2971 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
2972
2973 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
2974 vrf=0 )
2975
2976 add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan)
2977
2978 Groups._put( l2_gid )
2979 Groups._put( l3_msg.group_id )
2980
2981 do_barrier( self.controller )
2982
2983 ip_src = '192.168.5.5'
2984 ip_dst = '192.168.0.1'
2985 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
2986 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2987 pkt = str( parsed_pkt )
2988
2989 # print("Input Packet %s" % format_packet(pkt))
2990
2991 self.dataplane.send( port, pkt )
2992
2993 # build expect packet
2994 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2995 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2996 pkt = str( exp_pkt )
2997
2998 # print("Expected Packet %s" % format_packet(pkt))
2999
3000 verify_packet( self, pkt, out_port )
3001 verify_no_other_packets( self )
3002 finally:
3003 delete_all_flows( self.controller )
3004 delete_groups( self.controller, Groups )
3005 delete_all_groups( self.controller )
3006
Saurav Das5d1473d2018-07-12 11:02:56 -07003007@disabled
Andreas Pantelopoulosf83e0212018-03-18 20:44:05 -07003008class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ):
3009 """
3010 Verify google senario where we need to go from
3011 an untagged packet to a double tagged packet.
3012
3013 This is used for multiple subscribers.
3014
3015 However, this solution does not scale, since we assign an internal vlan to each subscriber
3016 used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table.
3017 """
3018
3019 def runTest( self ):
3020 Groups = Queue.LifoQueue( )
3021 try:
3022 if len( config[ "port_map" ] ) < 2:
3023 logging.info( "Port count less than 2, can't run this case" )
3024 return
3025
3026 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan]
3027 subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000],
3028 [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001],
3029 [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002],
3030 [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]]
3031
3032 print("")
3033
3034 for sub_info in subscriber_info:
3035
3036 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
3037
3038 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3039 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3040
3041 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3042 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3043
3044 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3045 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3046
3047 dip = sub_info[1]
3048 ports = config[ "port_map" ].keys( )
3049
3050 inner_vlan = sub_info[2]
3051 outer_vlan = sub_info[3]
3052 internal_vlan = sub_info[5]
3053 id = sub_info[0] + 10
3054
3055 port = ports[0]
3056 out_port = ports[1]
3057
3058 # add l2 unfiltered interface group
3059 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3060
3061 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id,
3062 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
3063
3064 do_barrier( self.controller )
3065
3066 # add vlan flow table
3067 add_one_vlan_table_flow( self.controller, port, 1, 4094,
3068 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
3069
3070 # add termination flow
3071 if config["switch_type"] == "qmx":
3072 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
3073 else:
3074 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
3075
3076 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
3077 vrf=0 )
3078
3079 add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan)
3080
3081 Groups._put( l2_gid )
3082 Groups._put( l3_msg.group_id )
3083 do_barrier( self.controller )
3084
3085 for sub_info in subscriber_info:
3086
3087 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
3088
3089 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3090 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3091
3092 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3093 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3094
3095 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3096 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3097
3098 dip = sub_info[1]
3099 ports = config[ "port_map" ].keys( )
3100
3101 inner_vlan = sub_info[2]
3102 outer_vlan = sub_info[3]
3103 internal_vlan = sub_info[5]
3104
3105 id = sub_info[0] + 10
3106 ip_src = '192.168.5.5'
3107 ip_dst = '192.168.0.{}'.format(sub_info[0])
3108 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
3109 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3110 pkt = str( parsed_pkt )
3111
3112 # print("Input Packet %s" % format_packet(pkt))
3113
3114 self.dataplane.send( port, pkt )
3115
3116 # build expect packet
3117 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
3118 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
3119 pkt = str( exp_pkt )
3120
3121 # print("Expected Packet %s" % format_packet(pkt))
3122
3123 verify_packet( self, pkt, out_port )
3124 verify_no_other_packets( self )
3125 finally:
3126 delete_all_flows( self.controller )
3127 delete_groups( self.controller, Groups )
3128 delete_all_groups( self.controller )
Andreas Pantelopoulos6c76b942018-01-22 10:03:02 -08003129
Saurav Das5d1473d2018-07-12 11:02:56 -07003130@disabled
Jonghwan Hyunff0dfd52018-03-20 15:04:35 -07003131class UntaggedToDoubleChangeEthertype ( base_tests.SimpleDataPlane ):
3132
3133 def runTest( self ):
3134 Groups = Queue.LifoQueue()
Andreas Pantelopoulosaaa02622018-04-04 15:13:03 -07003135
Jonghwan Hyunff0dfd52018-03-20 15:04:35 -07003136 try:
3137 if len( config[ "port_map" ] ) < 2:
Andreas Pantelopoulosaaa02622018-04-04 15:13:03 -07003138 logging.info( "port count less than 2, can't run this case" )
Jonghwan Hyunff0dfd52018-03-20 15:04:35 -07003139 return
3140
3141 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3142 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3143
3144 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3145 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3146
3147 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3148 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3149
3150 dip = 0xc0a80001
3151 ports = config[ "port_map" ].keys( )
3152
3153 inner_vlan = 66
3154 outer_vlan = 77
3155 id = 10
3156
3157 port = ports[0]
3158 out_port = ports[1]
3159
3160 # add l2 unfiltered interface group
3161 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3162
3163 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id,
3164 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
3165
3166 do_barrier( self.controller )
3167
3168 # add vlan flow table
3169 add_one_vlan_table_flow( self.controller, port, 1, 4094,
3170 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
3171
3172 # add termination flow
3173 if config["switch_type"] == "qmx":
3174 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
3175 else:
3176 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
3177
3178 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
3179 vrf=0 )
3180
3181 add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan)
3182
3183 Groups._put( l2_gid )
3184 Groups._put( l3_msg.group_id )
3185
3186 # add vlan flow table
3187 add_one_egress_vlan_tpid_table_flow( self.controller, out_port, outer_vlan+0x1000 )
3188 do_barrier( self.controller )
3189
3190 ip_src = '192.168.5.5'
3191 ip_dst = '192.168.0.1'
3192 parsed_pkt = simple_tcp_packet( pktlen=100,
3193 dl_vlan_enable=False,
3194 eth_dst=input_dst_mac_str,
3195 eth_src=input_src_mac_str,
3196 ip_ttl=64,
3197 ip_src=ip_src,
3198 ip_dst=ip_dst )
3199 pkt = str( parsed_pkt )
3200
3201 print("Input Packet %s" % format_packet(pkt))
3202
3203 self.dataplane.send( port, pkt )
3204
3205 # build expect packet
3206 exp_pkt = simple_tcp_packet_two_vlan( pktlen=108,
3207 out_dl_vlan_enable=True,
3208 out_vlan_vid=outer_vlan,
3209 out_vlan_tpid=0x88a8,
3210 in_dl_vlan_enable=True,
3211 in_vlan_vid=inner_vlan,
3212 eth_dst=output_dst_mac_str,
3213 eth_src=input_dst_mac_str,
3214 ip_ttl=63,
3215 ip_src=ip_src,
3216 ip_dst=ip_dst )
3217 pkt = str( exp_pkt )
3218
3219 print("Expected Packet %s" % format_packet(pkt))
3220
3221 verify_packet( self, pkt, out_port )
3222 verify_no_other_packets( self )
3223 finally:
3224 delete_all_flows( self.controller )
3225 delete_groups( self.controller, Groups )
Andreas Pantelopoulosaaa02622018-04-04 15:13:03 -07003226 delete_all_groups( self.controller )
3227
Saurav Das5d1473d2018-07-12 11:02:56 -07003228@disabled
Andreas Pantelopoulosaaa02622018-04-04 15:13:03 -07003229class _MplsFwdInterfaceProblem_PW( base_tests.SimpleDataPlane ):
3230 """
3231 Reproduces the pseudowire bug with the wrongly set destination mac address.
3232 """
3233 def runTest( self ):
3234 Groups = Queue.LifoQueue( )
3235 try:
3236 if len( config[ "port_map" ] ) < 1:
3237 logging.info( "Port count less than 1, can't run this case" )
3238 assert (False)
3239 return
3240
3241 macs_to_test = [( [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x00 ], [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ], '00:00:00:11:11:00', '00:00:00:22:22:00'),
3242 ( [ 0x00, 0x00, 0x00, 0x11, 0x22, 0x00 ], [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ], '00:00:00:11:22:00', '00:00:00:33:33:00'),
3243 ( [ 0x00, 0x00, 0x00, 0x11, 0x33, 0x00 ], [ 0x00, 0x00, 0x00, 0x44, 0x44, 0x00 ], '00:00:00:11:33:00', '00:00:00:44:44:00'),
3244 ( [ 0x00, 0x00, 0x00, 0x11, 0x44, 0x00 ], [ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00 ], '00:00:00:11:44:00', '00:00:00:55:55:00'),
3245 ( [ 0x00, 0x00, 0x00, 0x11, 0x55, 0x00 ], [ 0x00, 0x00, 0x00, 0x66, 0x66, 0x00 ], '00:00:00:11:55:00', '00:00:00:66:66:00')]
3246
3247 for dummy_dst_mac, dst_mac, mac_dst_dummy, mac_dst in macs_to_test:
3248
3249 dip = 0xc0a80001
3250 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3251
3252 out_port = 12
3253 port = 24
3254 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
3255 vlan_id = port + 16
3256 mpls_label = port + 16
3257
3258 in_port = 24
3259 ip_src = '192.168.%02d.1' % (in_port)
3260
3261 # create dummy groups
3262 id = port
3263 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, vlan_id, False, False)
3264 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dummy_dst_mac, intf_src_mac,
3265 vlan_id, id, send_barrier=True)
3266 do_barrier( self.controller )
3267
3268 # PW Case.
3269 raw_input("Press anything to move on with pseudowire rules, after that you should see the updated groups in the switch.")
3270 logging.info("Installing entries for pseudowire!")
3271 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
3272 mpls_label = 100
3273 mpls_label_SR2 = 100 + 10
3274 mpls_label_PW = 100 + 15
3275
3276 print("Install MPLS intf group for dst mac {0}", dst_mac)
3277 # add MPLS interface group
3278 mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group(
3279 ctrl=self.controller,
3280 ref_gid=l2_gid,
3281 dst_mac=dst_mac,
3282 src_mac=intf_src_mac,
3283 vid=vlan_id,
3284 index=id,
3285 add=False,
3286 send_barrier=True
3287 )
3288
3289 # add MPLS flow with BoS=0
3290 add_mpls_flow_pw(
3291 ctrl=self.controller,
3292 action_group_id=mpls_intf_gid,
3293 label=mpls_label_SR2,
3294 ethertype=0x8847,
3295 tunnel_index=1,
3296 bos=0
3297 )
3298
3299 # add Termination flow
3300 add_termination_flow(
3301 ctrl=self.controller,
3302 in_port=in_port,
3303 eth_type=0x8847,
3304 dst_mac=intf_src_mac,
3305 vlanid=vlan_id,
3306 goto_table=23
3307 )
3308
3309 # add VLAN flows
3310 add_one_vlan_table_flow(
3311 ctrl=self.controller,
3312 of_port=in_port,
3313 vlan_id=vlan_id,
3314 flag=VLAN_TABLE_FLAG_ONLY_TAG,
3315 )
3316 add_one_vlan_table_flow(
3317 ctrl=self.controller,
3318 of_port=in_port,
3319 vlan_id=vlan_id,
3320 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
3321 )
3322 # Packet generation with sleep
3323 time.sleep(2)
3324 label_SR2 = (mpls_label_SR2, 0, 0, 32)
3325 label_2 = (mpls_label_PW, 0, 1, 32)
3326
3327 # set to false to test if routing traffic
3328 # comes through
3329 raw_input("Press enter to send the packet, inspect the groups in the switch!")
3330 print("Sending packet with dst mac {0} and labels {1}".format(switch_mac, [label_SR2, label_2]))
3331 parsed_pkt = mpls_packet(
3332 pktlen=104,
3333 ip_ttl=63,
3334 label=[label_SR2, label_2],
3335 encapsulated_ethernet = True,
3336 eth_dst=switch_mac
3337 )
3338
3339 pkt = str( parsed_pkt )
3340 self.dataplane.send( in_port, pkt )
3341
3342 expected_label = (mpls_label_PW, 0, 1, 31)
3343 print("Expecting packet with dst mac {0} and labels {1}".format(mac_dst, [label_2]))
3344 parsed_pkt = mpls_packet(
3345 pktlen=100,
3346 ip_ttl=63,
3347 eth_dst=mac_dst,
3348 eth_src=switch_mac,
3349 label=[ expected_label ],
3350 encapsulated_ethernet = True
3351 )
3352
3353 pkt = str( parsed_pkt )
3354 verify_packet( self, pkt, out_port )
3355 verify_no_packet( self, pkt, in_port )
3356
3357 delete_all_flows( self.controller )
3358 delete_groups( self.controller, Groups )
3359 delete_all_groups( self.controller )
3360
3361 finally:
3362 delete_all_flows( self.controller )
3363 delete_groups( self.controller, Groups )
3364 delete_all_groups( self.controller )
3365
3366
Saurav Das5d1473d2018-07-12 11:02:56 -07003367class VlanCrossConnect ( base_tests.SimpleDataPlane ):
3368 """
3369 Tries the cross connect functionality of the ofdpa switches.
3370 """
3371 def runTest( self ):
3372 Groups = Queue.LifoQueue( )
3373 try:
3374 if len( config[ "port_map" ] ) < 2:
3375 logging.info( "Port count less than 2, can't run this case" )
3376 return
3377
3378 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
3379 subscriber_info = [ [10, 0xc0a80001, 12, 11, "192.168.0.1"] ]
3380
3381 index = 5
3382 for sub_info in subscriber_info:
3383
3384 #print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
3385
3386 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3387 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3388
3389 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3390 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3391
3392 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3393 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3394
3395 dip = sub_info[1]
3396 ports = config[ "port_map" ].keys( )
3397
3398 inner_vlan = sub_info[2]
3399 outer_vlan = sub_info[3]
3400
3401 index = inner_vlan
3402
3403 port = ports[0]
3404 out_port = ports[1]
3405
3406 # add l2 interface group, uncomment for unfiltered
3407 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, outer_vlan, True, True)
3408 #i l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, 1, True)
3409
3410 # add vlan flow table
3411 add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED )
3412 add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan ,outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True)
3413 add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=l2_gid, qos_index=0, goto=ACL_FLOW_TABLE)
3414 index += 1
3415
3416 Groups._put( l2_gid )
3417 do_barrier( self.controller )
3418
3419 for sub_info in subscriber_info:
3420 #print("Sending packet for subscriber with id {0}".format(sub_info[0]))
3421 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3422 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3423
3424 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3425 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3426
3427 dip = sub_info[1]
3428 ports = config[ "port_map" ].keys( )
3429
3430 inner_vlan = sub_info[2]
3431 outer_vlan = sub_info[3]
3432
3433 port = ports[0]
3434 out_port = ports[1]
3435
3436 ip_src = sub_info[4]
3437 ip_dst = '192.168.0.{}'.format(sub_info[0])
3438 parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan,
3439 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3440 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True, in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan,
3441 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3442
3443 pkt = str( parsed_pkt )
3444
3445 self.dataplane.send( port, pkt )
3446 verify_packet( self, pkt, out_port )
3447 verify_no_other_packets( self )
3448
3449 finally:
3450 delete_all_flows( self.controller )
3451 delete_groups( self.controller, Groups )
3452 delete_all_groups( self.controller )
3453
3454
Saurav Dasb4b841e2018-08-17 15:51:56 -07003455@disabled
3456class Lag( base_tests.SimpleDataPlane ):
3457 """
3458 Checks the L2 load balancing (LAG) functionality of the ofdpa switches.
3459 """
3460 def runTest( self ):
3461 Groups = Queue.LifoQueue( )
3462 try:
3463 if len( config[ "port_map" ] ) < 2:
3464 logging.info( "Port count less than 2, can't run this case" )
3465 return
3466
3467 ports = sorted(config[ "port_map" ].keys( ))
3468 in_port = ports[0]
3469 out_port = ports[1]
3470
3471 # add l2 interface unfiltered group
3472 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3473
3474 # create l2 load-balance group
3475 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3476 Groups.put(l2_o_gid, lag_gid)
3477
3478 # --- TEST 1: bridging with load-bal----
3479 vlan_in_port_untagged = 31
3480 # table 10 flows and bridging flows for dstMac+vlan -> l2-load-bal group
3481 add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3482 send_barrier=True)
3483 mac_dst = [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ]
3484 mac_dst_str = '00:11:22:33:44:55'
3485 add_bridge_flow( self.controller, mac_dst, vlan_in_port_untagged, lag_gid, True )
3486 # untagged packet input becomes tagged packet at output
3487 time.sleep(0.1)
3488 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=mac_dst_str ) )
3489 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=mac_dst_str ) )
3490 self.dataplane.send( in_port, pkt )
3491 verify_packet( self, exp_pkt, out_port )
3492 verify_no_other_packets( self )
3493
3494 # --- TEST 2: flooding with load-bal ----
3495 # flooding group --> load-bal group --> l2 unfiltered interface
3496 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 )
3497 Groups.put( floodmsg.group_id )
3498 # add bridging flows for flooding groups
3499 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3500 # unknown dstmac packet input to hit flood group
3501 un_mac_dst_str = '00:11:22:ff:ff:ff'
3502 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3503 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3504 time.sleep(0.1)
3505 self.dataplane.send( in_port, pkt )
3506 verify_packet( self, exp_pkt, out_port )
3507 verify_no_other_packets( self )
3508
3509 # --- TEST 3: editing load-bal ----
3510 # create and add another l2 unfiltered interface group to the load-balancing group
3511 l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True)
3512 msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True)
3513 self.dataplane.send( in_port, pkt )
3514 verify_packet( self, exp_pkt, out_port )
3515
3516 # delete all buckets in loadbal group
3517 msg = mod_l2_loadbal_group(self.controller, 1, [], True)
3518 time.sleep(0.1)
3519 self.dataplane.send( in_port, pkt )
3520 verify_no_other_packets( self ) # no buckets
3521
3522 # only input port in load balancing group
3523 msg = mod_l2_loadbal_group(self.controller, 1, [l2_i_gid], True)
3524 self.dataplane.send( in_port, pkt )
3525 verify_no_other_packets( self ) # packet should not be sent out of in port
3526
3527 # remove input port and add output port in lag group
3528 msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3529 time.sleep(0.1)
3530 self.dataplane.send( in_port, pkt )
3531 verify_packet( self, exp_pkt, out_port )
3532 verify_no_other_packets( self )
3533
3534 finally:
3535 #print("done")
3536 delete_all_flows( self.controller )
3537 delete_groups( self.controller, Groups )
3538 delete_all_groups( self.controller )
3539
3540@disabled
3541class FloodMix( base_tests.SimpleDataPlane ):
3542 """
3543 Checks the combination of L2 filtered and L2 load balancing (LAG) groups
3544 in a flooding group
3545 """
3546 def runTest( self ):
3547 Groups = Queue.LifoQueue( )
3548 try:
3549 if len( config[ "port_map" ] ) < 2:
3550 logging.info( "Port count less than 2, can't run this case" )
3551 return
3552
3553 ports = sorted(config[ "port_map" ].keys( ))
3554 in_port = ports[0]
3555 out_port = ports[1]
3556 vlan_in_port_untagged = 31
3557
3558 # add l2 unfiltered interface group for outport
3559 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3560
3561 # create l2 load-balance group
3562 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3563
3564 # create l2 interface (filtered) group for inport
3565 l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged,
3566 is_tagged=False, send_barrier=True)
3567
3568 # create l2 flood group with mix of l2i and l2-loadbal
3569 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 )
3570 Groups.put( l2_o_gid )
3571 Groups.put( lag_gid )
3572 Groups.put( l2_i_gid )
3573 Groups.put( floodmsg.group_id )
3574
3575 # table 10 flows for untagged input
3576 add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3577 send_barrier=True)
3578
3579 # add bridging flows for flooding groups
3580 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3581 # unknown dstmac packet will hit flood group
3582 un_mac_dst_str = '00:11:22:ff:ff:ff'
3583
3584 # check one direction -> packet enters through filtered port (inport) and exits through
3585 # unfiltered port (outport) via the flood and lag groups
3586 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3587 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3588 self.dataplane.send( in_port, pkt )
3589 verify_packet( self, exp_pkt, out_port )
3590 verify_no_other_packets( self )
3591
3592 # check other direction -> packet enters through unfiltered port (outport) and exits through
3593 # filtered port (inport) via the flood group
3594 add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3595 send_barrier=True)
3596 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3597 exp_pkt = pkt # ingress packet gets internal vlan 31 which gets popped at l2 interface group before egress
3598 self.dataplane.send( out_port, pkt )
3599 verify_packet( self, exp_pkt, in_port )
3600 verify_no_other_packets( self )
3601
3602 finally:
3603 print("done")
3604 delete_all_flows( self.controller )
3605 delete_groups( self.controller, Groups )
3606 delete_all_groups( self.controller )
3607
3608@disabled
3609class LagMix( base_tests.SimpleDataPlane ):
3610 """
3611 Checks the combination of L2 filtered and unfiltered interface groups
3612 in a L2 load balancing (LAG) group - this should not work according to spec
3613 """
3614 def runTest( self ):
3615 Groups = Queue.LifoQueue( )
3616 try:
3617 if len( config[ "port_map" ] ) < 2:
3618 logging.info( "Port count less than 2, can't run this case" )
3619 return
3620
3621 ports = sorted(config[ "port_map" ].keys( ))
3622 in_port = ports[0]
3623 out_port = ports[1]
3624 vlan_in_port_untagged = 31
3625
3626 # add l2 unfiltered interface group
3627 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3628
3629 # create l2 interface (filtered) group
3630 l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged,
3631 is_tagged=False, send_barrier=True)
3632
3633 # create l2 load-balance group with a mix of filtered and unfiltered groups
3634 """
3635 XXX the following does not work - the group does not get created but curiously we don't get an openflow
3636 error message. The ofdpa logs show
3637 ofdbGroupBucketValidate: Referenced Group Id 0x1f000c not of type L2 Unfiltered Interface.
3638 We do get an openflow error message for the flood group that follows because it cannot
3639 find the lag group it points to (because it did not get created).
3640 """
3641 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True)
3642
3643 # create l2 flood group to point to lag group
3644 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 )
3645 Groups.put( floodmsg.group_id, l2_i_gid, lag_gid )
3646 Groups.put( l2_o_gid )
3647
3648 finally:
3649 #print("done")
3650 delete_all_flows( self.controller )
3651 delete_groups( self.controller, Groups )
3652 delete_all_groups( self.controller )
3653
3654
3655@disabled
3656class LagXconn( base_tests.SimpleDataPlane ):
3657 """
3658 Checks the L2 load balancing (LAG) with vlan crossconnects.
3659 Note that for this to work, basic VlanCrossConnect test above (without LAG) should work first
3660 Note: this doesn't work on XGS or QMX yet with premium 1.1.7
3661 """
3662 def runTest( self ):
3663 Groups = Queue.LifoQueue( )
3664 try:
3665 if len( config[ "port_map" ] ) < 2:
3666 logging.info( "Port count less than 2, can't run this case" )
3667 return
3668
3669 ports = sorted(config[ "port_map" ].keys( ))
3670 in_port = ports[0]
3671 out_port = ports[1]
3672
3673 # add l2 interface unfiltered group
3674 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3675
3676 # create l2 load-balance group
3677 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3678 Groups.put(l2_o_gid, lag_gid)
3679
3680 # a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
3681 sub_info = [10, 0xc0a80001, 12, 11, "192.168.0.1"]
3682
3683 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3684 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3685 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3686 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3687 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3688 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3689
3690 dip = sub_info[1]
3691 ports = config[ "port_map" ].keys( )
3692 inner_vlan = sub_info[2]
3693 outer_vlan = sub_info[3]
3694 index = inner_vlan
3695 port = ports[0]
3696 out_port = ports[1]
3697
3698 # add vlan flow table
3699 add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED )
3700 add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan, outer_vlan_id=outer_vlan,
3701 inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True)
3702 """
3703 XXX The following flow in table 13 is rejected by the switch (qmx) probably due to the reference to lag group
3704 ofdpa logs say: 08-22 00:43:10.344338 [ofstatemanager] Error from Forwarding while inserting flow: Unknown error
3705 """
3706 add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=lag_gid,
3707 qos_index=0, goto=ACL_FLOW_TABLE)
3708 do_barrier( self.controller )
3709
3710 ip_src = sub_info[4]
3711 ip_dst = '192.168.0.{}'.format(sub_info[0])
3712 parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan,
3713 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3714 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True,
3715 in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan,
3716 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str,
3717 ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3718
3719 pkt = str( parsed_pkt )
3720 self.dataplane.send( port, pkt )
3721 verify_packet( self, pkt, out_port )
3722 verify_no_other_packets( self )
3723
3724 finally:
3725 #print("done")
3726 delete_all_flows( self.controller )
3727 delete_groups( self.controller, Groups )
3728 delete_all_groups( self.controller )
3729
3730@disabled
3731class LagRouting( base_tests.SimpleDataPlane ):
3732 """
3733 Checks the L2 load balancing (LAG) with routing flows.
3734 Specifically route -> L3Unicast -> Lag -> L2 Unfiltered interface
3735 """
3736 def runTest( self ):
3737 Groups = Queue.LifoQueue( )
3738 try:
3739 if len( config[ "port_map" ] ) < 2:
3740 logging.info( "Port count less than 2, can't run this case" )
3741 return
3742
3743 ports = sorted(config[ "port_map" ].keys( ))
3744 in_port = ports[0]
3745 out_port = ports[1]
3746
3747 # add l2 interface unfiltered group
3748 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3749
3750 # create l2 load-balance group
3751 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3752 Groups.put(l2_o_gid, lag_gid)
3753
3754 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3755 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3756 dip = 0xc0a80001
3757 vlan_id = 31
3758
3759 # create L3 Unicast group to point to Lag group
3760 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=vlan_id, id=vlan_id,
3761 src_mac=intf_src_mac, dst_mac=dst_mac, gid=lag_gid )
3762 # add vlan flow table
3763 add_one_vlan_table_flow( self.controller, in_port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
3764 # add termination flow
3765 if config["switch_type"] == "qmx":
3766 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
3767 else:
3768 add_termination_flow( self.controller, in_port, 0x0800, intf_src_mac, vlan_id )
3769 # add unicast routing flow
3770 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id )
3771
3772 Groups.put( l3_msg.group_id )
3773 do_barrier( self.controller )
3774
3775 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
3776 mac_src = '00:00:00:22:22:%02X' % (in_port)
3777 ip_src = '192.168.0.2'
3778 ip_dst = '192.168.0.1'
3779 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
3780 vlan_vid=vlan_id, eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
3781 ip_src=ip_src, ip_dst=ip_dst )
3782 pkt = str( parsed_pkt )
3783 self.dataplane.send( in_port, pkt )
3784 # build expected packet
3785 mac_dst = '00:00:00:22:22:00'
3786 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
3787 vlan_vid=vlan_id, eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
3788 ip_src=ip_src, ip_dst=ip_dst )
3789 pkt = str( exp_pkt )
3790 verify_packet( self, pkt, out_port )
3791 verify_no_other_packets( self )
3792
3793 finally:
3794 #print("done")
3795 delete_all_flows( self.controller )
3796 delete_groups( self.controller, Groups )
3797 delete_all_groups( self.controller )