Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1 | |
| 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 | |
| 17 | """ |
| 18 | Check README file |
| 19 | """ |
| 20 | import Queue |
| 21 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 22 | import os |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 23 | from oftest import config |
| 24 | import inspect |
| 25 | import logging |
| 26 | import oftest.base_tests as base_tests |
| 27 | import ofp |
| 28 | import time |
| 29 | from oftest.oft12.testutils import delete_all_flows_one_table |
| 30 | from oftest.testutils import * |
| 31 | from accton_util import * |
| 32 | from oftest.utils import * |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 33 | import pexpect |
| 34 | import json |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 35 | |
| 36 | |
| 37 | class FabricSW_OF_PacketInUDP_TC_0010( base_tests.SimpleDataPlane ): |
| 38 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 39 | To verify the switch can trap an UDP packet and send it to controller and a non-conforming packet does not match the flow. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 40 | """ |
| 41 | |
| 42 | def runTest( self ): |
| 43 | try: |
| 44 | parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 45 | vlan_pkt = str( parsed_vlan_pkt ) |
| 46 | # create match |
| 47 | match = ofp.match( ) |
| 48 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 49 | match.oxm_list.append( ofp.oxm.ip_proto( 2 ) ) |
| 50 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 51 | ofp.instruction.apply_actions( actions=[ |
| 52 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 53 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 54 | logging.info( "Inserting packet in flow to controller" ) |
| 55 | self.controller.message_send( request ) |
| 56 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 57 | ports = sorted(config["port_map"].keys()) |
| 58 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 59 | for of_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 60 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 61 | self.dataplane.send( of_port, vlan_pkt ) |
| 62 | |
| 63 | verify_no_packet_in( self, vlan_pkt, of_port ) |
| 64 | delete_all_flows( self.controller ) |
| 65 | do_barrier( self.controller ) |
| 66 | |
| 67 | match = ofp.match( ) |
| 68 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 69 | match.oxm_list.append( ofp.oxm.ip_proto( 17 ) ) |
| 70 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 71 | ofp.instruction.apply_actions( actions=[ |
| 72 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 73 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 74 | logging.info( "Inserting packet in flow to controller" ) |
| 75 | self.controller.message_send( request ) |
| 76 | do_barrier( self.controller ) |
| 77 | |
| 78 | for of_port in config[ "port_map" ].keys( ): |
| 79 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 80 | self.dataplane.send( of_port, vlan_pkt ) |
| 81 | |
| 82 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION ) |
| 83 | |
| 84 | verify_no_other_packets( self ) |
| 85 | finally: |
| 86 | delete_all_flows( self.controller ) |
| 87 | delete_all_groups( self.controller ) |
| 88 | |
| 89 | @disabled |
| 90 | class ArpNL2( base_tests.SimpleDataPlane ): |
| 91 | """ |
| 92 | Needs a description, disabled for now. Also needs try/finally |
| 93 | """ |
| 94 | def runTest( self ): |
| 95 | delete_all_flows( self.controller ) |
| 96 | delete_all_groups( self.controller ) |
| 97 | |
| 98 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 99 | match = ofp.match( ) |
| 100 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 101 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 102 | ofp.instruction.apply_actions( actions=[ |
| 103 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 104 | buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| 105 | self.controller.message_send( request ) |
| 106 | for port in ports: |
| 107 | add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| 108 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 109 | group_id = encode_l2_interface_group_id( 1, port ) |
| 110 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| 111 | do_barrier( self.controller ) |
| 112 | parsed_arp_pkt = simple_arp_packet( ) |
| 113 | arp_pkt = str( parsed_arp_pkt ) |
| 114 | |
| 115 | for out_port in ports: |
| 116 | self.dataplane.send( out_port, arp_pkt ) |
| 117 | verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
| 118 | # change dest based on port number |
| 119 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 120 | for in_port in ports: |
| 121 | if in_port == out_port: |
| 122 | continue |
| 123 | # change source based on port number to avoid packet-ins from learning |
| 124 | mac_src = '00:12:34:56:78:%02X' % in_port |
| 125 | parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| 126 | pkt = str( parsed_pkt ) |
| 127 | self.dataplane.send( in_port, pkt ) |
| 128 | |
| 129 | for ofport in ports: |
| 130 | if ofport in [ out_port ]: |
| 131 | verify_packet( self, pkt, ofport ) |
| 132 | else: |
| 133 | verify_no_packet( self, pkt, ofport ) |
| 134 | |
| 135 | verify_no_other_packets( self ) |
| 136 | |
| 137 | class FabricSW_OF_PacketInArp_TC_0005( base_tests.SimpleDataPlane ): |
| 138 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 139 | To verify the switch can trap an ARP request and send it to controller. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 140 | """ |
| 141 | |
| 142 | def runTest( self ): |
| 143 | try: |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 144 | ports = sorted(config["port_map"].keys()) |
| 145 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 146 | parsed_arp_pkt = simple_arp_packet( ) |
| 147 | arp_pkt = str( parsed_arp_pkt ) |
| 148 | # create match |
| 149 | match = ofp.match( ) |
| 150 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 151 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 152 | ofp.instruction.apply_actions( actions=[ |
| 153 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 154 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 155 | |
| 156 | logging.info( "Inserting arp flow " ) |
| 157 | self.controller.message_send( request ) |
| 158 | do_barrier( self.controller ) |
| 159 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 160 | for of_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 161 | logging.info( "PacketInArp test, sending arp packet to port %d", of_port ) |
| 162 | self.dataplane.send( of_port, arp_pkt ) |
| 163 | |
| 164 | verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
| 165 | |
| 166 | verify_no_other_packets( self ) |
| 167 | finally: |
| 168 | delete_all_flows( self.controller ) |
| 169 | delete_all_groups( self.controller ) |
| 170 | |
| 171 | @disabled |
| 172 | class PacketInIPTable( base_tests.SimpleDataPlane ): |
| 173 | """ |
| 174 | Verify Packet-in message from IP table when controller action is used |
| 175 | Send a packet to each dataplane port and verify that a packet |
| 176 | in message is received from the controller for each |
| 177 | #todo verify you stop receiving after adding rule |
| 178 | """ |
| 179 | |
| 180 | def runTest( self ): |
| 181 | Groups = Queue.LifoQueue( ) |
| 182 | try: |
| 183 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 184 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 185 | dip = 0xc0a80001 |
| 186 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 187 | |
| 188 | for port in ports: |
| 189 | # add l2 interface group |
| 190 | vlan_id = port |
| 191 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| 192 | send_barrier=False ) |
| 193 | dst_mac[ 5 ] = vlan_id |
| 194 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 195 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 196 | # add vlan flow table |
| 197 | add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 198 | # add termination flow |
| 199 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 200 | # add unicast routing flow |
| 201 | dst_ip = dip + (vlan_id << 8) |
| 202 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| 203 | send_ctrl=True ) |
| 204 | Groups.put( l3_msg.group_id ) |
| 205 | |
| 206 | do_barrier( self.controller ) |
| 207 | |
| 208 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 209 | for in_port in ports: |
| 210 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 211 | ip_src = '192.168.%02d.1' % in_port |
| 212 | for out_port in ports: |
| 213 | if in_port == out_port: |
| 214 | continue |
| 215 | ip_dst = '192.168.%02d.1' % out_port |
| 216 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 217 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 218 | pkt = str( parsed_pkt ) |
| 219 | self.dataplane.send( in_port, pkt ) |
| 220 | verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| 221 | # verify_no_other_packets(self) |
| 222 | finally: |
| 223 | delete_all_flows( self.controller ) |
| 224 | delete_groups( self.controller, Groups ) |
| 225 | delete_all_groups( self.controller ) |
| 226 | |
| 227 | |
| 228 | class FabricSW_OF_L2FloodQinQ_TC_0015( base_tests.SimpleDataPlane ): |
| 229 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 230 | To verify the switch can flood Q-in-Q frames based on its outer vlan-id. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 231 | """ |
| 232 | |
| 233 | def runTest( self ): |
| 234 | Groups = Queue.LifoQueue( ) |
| 235 | try: |
| 236 | ports = sorted( config[ "port_map" ].keys( ) ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 237 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 238 | vlan_id = 100 |
| 239 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 240 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 241 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 242 | add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 243 | Groups.put( L2gid ) |
| 244 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 245 | msg = add_l2_flood_group( self.controller, pair, vlan_id, vlan_id ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 246 | Groups.put( msg.group_id ) |
| 247 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 248 | do_barrier( self.controller ) |
| 249 | |
| 250 | # verify flood |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 251 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 252 | # change dest based on port number |
| 253 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 254 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 255 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 256 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 257 | pkt = str( parsed_pkt ) |
| 258 | self.dataplane.send( ofport, pkt ) |
| 259 | # self won't rx packet |
| 260 | verify_no_packet( self, pkt, ofport ) |
| 261 | # others will rx packet |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 262 | tmp_ports = list( pair ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 263 | tmp_ports.remove( ofport ) |
| 264 | verify_packets( self, pkt, tmp_ports ) |
| 265 | |
| 266 | verify_no_other_packets( self ) |
| 267 | finally: |
| 268 | delete_all_flows( self.controller ) |
| 269 | delete_groups( self.controller, Groups ) |
| 270 | delete_all_groups( self.controller ) |
| 271 | |
| 272 | |
| 273 | |
| 274 | @disabled |
| 275 | class L2FloodTagged( base_tests.SimpleDataPlane ): |
| 276 | """ |
| 277 | currently disabled; fix with try/finally |
| 278 | Test L2 flood to a vlan |
| 279 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 280 | """ |
| 281 | |
| 282 | def runTest( self ): |
| 283 | # Hashes Test Name and uses it as id for installing unique groups |
| 284 | vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
| 285 | print vlan_id |
| 286 | |
| 287 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 288 | |
| 289 | delete_all_flows( self.controller ) |
| 290 | delete_all_groups( self.controller ) |
| 291 | |
| 292 | # Installing flows to avoid packet-in |
| 293 | for port in ports: |
| 294 | add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 295 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 296 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 297 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 298 | do_barrier( self.controller ) |
| 299 | |
| 300 | # verify flood |
| 301 | for ofport in ports: |
| 302 | # change dest based on port number |
| 303 | pkt = str( |
| 304 | simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| 305 | self.dataplane.send( ofport, pkt ) |
| 306 | # self won't rx packet |
| 307 | verify_no_packet( self, pkt, ofport ) |
| 308 | # others will rx packet |
| 309 | tmp_ports = list( ports ) |
| 310 | tmp_ports.remove( ofport ) |
| 311 | verify_packets( self, pkt, tmp_ports ) |
| 312 | verify_no_other_packets( self ) |
| 313 | |
| 314 | |
| 315 | class FabricSW_OF_L2UnicastTagged_TC_0020( base_tests.SimpleDataPlane ): |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 316 | """ To verify the switch can match frames based on VLAN-ID and MAC address and forward the packet out a data port. """ |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 317 | |
| 318 | def runTest( self ): |
| 319 | |
| 320 | Groups = Queue.LifoQueue( ) |
| 321 | try: |
| 322 | ports = sorted( config[ "port_map" ].keys( ) ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 323 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 324 | vlan_id = 1; |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 325 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 326 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 327 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 328 | Groups.put( L2gid ) |
| 329 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 330 | True ) |
| 331 | do_barrier( self.controller ) |
| 332 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 333 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 334 | # change dest based on port number |
| 335 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 336 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 337 | if in_port == out_port: |
| 338 | continue |
| 339 | pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 340 | self.dataplane.send( in_port, pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 341 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 342 | if ofport in [ out_port ]: |
| 343 | verify_packet( self, pkt, ofport ) |
| 344 | else: |
| 345 | verify_no_packet( self, pkt, ofport ) |
| 346 | verify_no_other_packets( self ) |
| 347 | finally: |
| 348 | delete_all_flows( self.controller ) |
| 349 | delete_groups( self.controller, Groups ) |
| 350 | delete_all_groups( self.controller ) |
| 351 | |
| 352 | |
| 353 | class FabricSW_OF_Bridging_TC_0001( base_tests.SimpleDataPlane ): |
| 354 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 355 | Verify bridging, flooding and trapping of control packets to controller works with VLAN tagged and untagged packets. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 356 | """ |
| 357 | |
| 358 | def runTest( self ): |
| 359 | Groupd = Queue.LifoQueue() |
| 360 | try: |
| 361 | if len( config[ "port_map" ] ) < 2: |
| 362 | logging.info( "Port count less than 2, can't run this case" ) |
| 363 | return |
| 364 | ports = sorted( config[ "port_map" ].keys() ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 365 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 366 | vlan_p0_untagged = 31 |
| 367 | vlan_p1_tagged = 31 |
| 368 | vlan_p1_native = 41 |
| 369 | |
| 370 | #l2 interface groups and table 10 flows |
| 371 | L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged, |
| 372 | is_tagged=False, send_barrier=False ) |
| 373 | add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 374 | send_barrier=True) |
| 375 | L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged, |
| 376 | is_tagged=True, send_barrier=False ) |
| 377 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 378 | send_barrier=True) |
| 379 | L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native, |
| 380 | is_tagged=False, send_barrier=False ) |
| 381 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 382 | send_barrier=True) |
| 383 | #flooding groups |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 384 | Floodmsg31 = add_l2_flood_group( self.controller, pair, vlan_p0_untagged, id=0 ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 385 | Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 ) |
| 386 | |
| 387 | #add bridging flows for flooding groups |
| 388 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id ) |
| 389 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id ) |
| 390 | do_barrier( self.controller ) |
| 391 | |
| 392 | # add bridging flows for dstMac+vlan |
| 393 | add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True ) |
| 394 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True ) |
| 395 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True ) |
| 396 | |
| 397 | # add terminationMac flow |
| 398 | router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 399 | if config["switch_type"] == "qmx": |
| 400 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged ) |
| 401 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native ) |
| 402 | else: |
| 403 | add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged ) |
| 404 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged ) |
| 405 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native ) |
| 406 | |
| 407 | # add acl rule for arp |
| 408 | match = ofp.match( ) |
| 409 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 410 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 411 | ofp.instruction.apply_actions( actions=[ |
| 412 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 413 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 414 | self.controller.message_send( request ) |
| 415 | do_barrier( self.controller ) |
| 416 | |
| 417 | #acl rule for gateway ip |
| 418 | match = ofp.match( ) |
| 419 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 420 | match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) ) |
| 421 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 422 | ofp.instruction.apply_actions( actions=[ |
| 423 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), |
| 424 | ofp.instruction.clear_actions() ], |
| 425 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 426 | self.controller.message_send( request ) |
| 427 | do_barrier( self.controller ) |
| 428 | |
| 429 | # send ARP request |
| 430 | parsed_arp_pkt = simple_arp_packet(pktlen=80, |
| 431 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 432 | eth_src='00:66:77:88:99:aa', |
| 433 | vlan_vid=vlan_p1_tagged, |
| 434 | vlan_pcp=0, |
| 435 | arp_op=1, |
| 436 | ip_snd='192.168.0.2', |
| 437 | ip_tgt='192.168.0.1', |
| 438 | hw_snd='00:66:77:88:99:aa', |
| 439 | hw_tgt='00:00:00:00:00:00') |
| 440 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 441 | logging.info( "sending arp request to port %d", ports[1] ) |
| 442 | self.dataplane.send( ports[1], arp_pkt_to_send ) |
| 443 | verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION ) |
| 444 | parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76, |
| 445 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 446 | eth_src='00:66:77:88:99:aa', |
| 447 | vlan_vid=0, |
| 448 | vlan_pcp=0, |
| 449 | arp_op=1, |
| 450 | ip_snd='192.168.0.2', |
| 451 | ip_tgt='192.168.0.1', |
| 452 | hw_snd='00:66:77:88:99:aa', |
| 453 | hw_tgt='00:00:00:00:00:00') |
| 454 | arp_pkt_dest = str( parsed_arp_pkt_untagged ) |
| 455 | verify_packet( self, arp_pkt_dest, ports[0] ) |
| 456 | #verify_no_other_packets( self ) |
| 457 | |
| 458 | # send ARP reply |
| 459 | parsed_arp_pkt = simple_arp_packet(pktlen=76, |
| 460 | eth_dst='00:66:77:88:99:aa', |
| 461 | eth_src='00:11:22:33:44:55', |
| 462 | vlan_vid=0, |
| 463 | vlan_pcp=0, |
| 464 | arp_op=2, |
| 465 | ip_snd='192.168.0.1', |
| 466 | ip_tgt='192.168.0.2', |
| 467 | hw_snd='00:11:22:33:44:55', |
| 468 | hw_tgt='00:66:77:88:99:aa') |
| 469 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 470 | logging.info( "sending arp reply to port %d", ports[0] ) |
| 471 | self.dataplane.send( ports[0], arp_pkt_to_send ) |
| 472 | verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION ) |
| 473 | parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80, |
| 474 | eth_dst='00:66:77:88:99:aa', |
| 475 | eth_src='00:11:22:33:44:55', |
| 476 | vlan_vid=vlan_p1_tagged, |
| 477 | vlan_pcp=0, |
| 478 | arp_op=2, |
| 479 | ip_snd='192.168.0.1', |
| 480 | ip_tgt='192.168.0.2', |
| 481 | hw_snd='00:11:22:33:44:55', |
| 482 | hw_tgt='00:66:77:88:99:aa') |
| 483 | arp_pkt_dest = str( parsed_arp_pkt_tagged ) |
| 484 | verify_packet( self, arp_pkt_dest, ports[1] ) |
| 485 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 486 | # Send and verify VLAN 31 tagged unicast packets |
| 487 | mac_src = '00:12:34:56:78:%02X' % pair[1] |
| 488 | unicast_to_send = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 489 | out_vlan_vid=vlan_p1_tagged, in_dl_vlan_enable=False, |
| 490 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 491 | |
| 492 | unicast_to_expect = simple_tcp_packet_two_vlan(pktlen=104, out_dl_vlan_enable=False, |
| 493 | in_dl_vlan_enable=False, |
| 494 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 495 | |
| 496 | |
| 497 | tmp_ports = list(pair) |
| 498 | tmp_ports.remove(pair[1]) |
| 499 | pkt_s = str(unicast_to_send) |
| 500 | pkt_e = str(unicast_to_expect) |
| 501 | self.dataplane.send(pair[1], pkt_s) |
| 502 | verify_no_packet(self, pkt_s, pair[1]) |
| 503 | verify_packets(self, pkt_e, tmp_ports) |
| 504 | |
| 505 | # Send and verify untagged unicast packets |
| 506 | mac_src = '00:12:34:56:78:%02X' % pair[0] |
| 507 | unicast_to_expect = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 508 | out_vlan_vid=vlan_p1_tagged, out_vlan_pcp=0, in_dl_vlan_enable=False, |
| 509 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 510 | |
| 511 | unicast_to_send = simple_tcp_packet_two_vlan(pktlen=104, out_dl_vlan_enable=False, |
| 512 | in_dl_vlan_enable=False, |
| 513 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 514 | |
| 515 | tmp_ports = list(pair) |
| 516 | tmp_ports.remove(pair[0]) |
| 517 | pkt_s = str(unicast_to_send) |
| 518 | pkt_e = str(unicast_to_expect) |
| 519 | self.dataplane.send(pair[0], pkt_s) |
| 520 | verify_no_packet(self, pkt_s, pair[0]) |
| 521 | verify_packets(self, pkt_e, tmp_ports) |
| 522 | |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 523 | finally: |
| 524 | delete_all_flows( self.controller ) |
| 525 | delete_all_groups( self.controller ) |
| 526 | #print("done") |
| 527 | |
| 528 | |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 529 | class FabricSW_OF_Mtu1500_TC_0035( base_tests.SimpleDataPlane ): |
| 530 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 531 | To verify the switch owners the MTU limits. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 532 | """ |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 533 | # Read config parameters from JSON file |
| 534 | ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 535 | with open(ROOT_DIR + '/' + 'global_vars.json') as f: |
| 536 | data = json.load(f) |
| 537 | |
| 538 | switch_ip = data['switch_ip'] |
| 539 | switch_user = data['switch_user'] |
| 540 | switch_passwd = data['switch_passwd'] |
| 541 | controller_ip = data['controller_ip'] |
| 542 | controller_port = data['controller_port'] |
| 543 | onos_server_ip = data['onos_server_ip'] |
| 544 | onos_port = data['onos_port'] |
| 545 | onos_user = data['onos_user'] |
| 546 | onos_passwd = data['onos_passwd'] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 547 | |
| 548 | def runTest( self ): |
| 549 | Groups = Queue.LifoQueue( ) |
| 550 | try: |
| 551 | ports = sorted( config[ "port_map" ].keys( ) ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 552 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 553 | vlan_id = 18 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 554 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 555 | L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 556 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 557 | Groups.put( L2gid ) |
| 558 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 559 | True ) |
| 560 | do_barrier( self.controller ) |
| 561 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 562 | # Send 1500 packet length, default MTU |
| 563 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 564 | # change dest based on port number |
| 565 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 566 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 567 | if in_port == out_port: |
| 568 | continue |
| 569 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 570 | eth_dst=mac_dst ) ) |
| 571 | self.dataplane.send( in_port, pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 572 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 573 | if ofport in [ out_port ]: |
| 574 | verify_packet( self, pkt, ofport ) |
| 575 | else: |
| 576 | verify_no_packet( self, pkt, ofport ) |
| 577 | verify_no_other_packets( self ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 578 | |
| 579 | # Change MTU of server's data ports to 2000 bytes |
| 580 | self.dataplane.port_mtu(pair[0], 2000) |
| 581 | self.dataplane.port_mtu(pair[1], 2000) |
| 582 | time.sleep(1) |
| 583 | |
| 584 | # Change MTU of switch's data ports to 1500 bytes |
| 585 | switch_port_set_mtu(self, pair[0], 1500) |
| 586 | switch_port_set_mtu(self, pair[1], 1500) |
| 587 | |
| 588 | time.sleep(1) |
| 589 | |
| 590 | # Send 2000 packet length |
| 591 | # change dest based on port number |
| 592 | mac_dst = '00:12:34:56:78:%02X' % pair[1] |
| 593 | pkt = str( simple_tcp_packet( pktlen=2000, dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 594 | self.dataplane.send( pair[0], pkt ) |
| 595 | tmp_ports = list(pair) |
| 596 | tmp_ports.remove(pair[0]) |
| 597 | verify_no_packet(self, pkt, pair[0]) |
| 598 | verify_no_packet(self, pkt, pair[1]) |
| 599 | |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 600 | finally: |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 601 | self.dataplane.port_mtu(pair[0], 1500) |
| 602 | self.dataplane.port_mtu(pair[1], 1500) |
| 603 | time.sleep(1) |
| 604 | switch_port_set_mtu(self, pair[0], 9412) |
| 605 | switch_port_set_mtu(self, pair[1], 9412) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 606 | delete_all_flows( self.controller ) |
| 607 | delete_groups( self.controller, Groups ) |
| 608 | delete_all_groups( self.controller ) |
| 609 | |
| 610 | |
| 611 | class FabricSW_OF__32UcastTagged_TC_0055( base_tests.SimpleDataPlane ): |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 612 | """ To Verify the switch can perform IP forwarding on a /32 subnet using L2 Interface and L3 Unicast groups.""" |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 613 | |
| 614 | def runTest( self ): |
| 615 | Groups = Queue.LifoQueue( ) |
| 616 | try: |
| 617 | test_id = 26 |
| 618 | if len( config[ "port_map" ] ) < 2: |
| 619 | logging.info( "Port count less than 2, can't run this case" ) |
| 620 | return |
| 621 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 622 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 623 | dip = 0xc0a80001 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 624 | ports = sorted(config["port_map"].keys()) |
| 625 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 626 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 627 | vlan_id = port + test_id |
| 628 | # add l2 interface group and l3 unicast group |
| 629 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 630 | is_tagged=True, send_barrier=False ) |
| 631 | dst_mac[ 5 ] = vlan_id |
| 632 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 633 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 634 | # add vlan flow table |
| 635 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 636 | # add termination flow |
| 637 | if config["switch_type"] == "qmx": |
| 638 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 639 | else: |
| 640 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 641 | # add unicast routing flow |
| 642 | dst_ip = dip + (vlan_id << 8) |
| 643 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 644 | Groups.put( l2gid ) |
| 645 | Groups.put( l3_msg.group_id ) |
| 646 | do_barrier( self.controller ) |
| 647 | |
| 648 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 649 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 650 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 651 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 652 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 653 | if in_port == out_port: |
| 654 | continue |
| 655 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 656 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 657 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 658 | ip_src=ip_src, ip_dst=ip_dst ) |
| 659 | pkt = str( parsed_pkt ) |
| 660 | self.dataplane.send( in_port, pkt ) |
| 661 | # build expected packet |
| 662 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 663 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 664 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 665 | ip_src=ip_src, ip_dst=ip_dst ) |
| 666 | pkt = str( exp_pkt ) |
| 667 | verify_packet( self, pkt, out_port ) |
| 668 | verify_no_other_packets( self ) |
| 669 | finally: |
| 670 | delete_all_flows( self.controller ) |
| 671 | delete_groups( self.controller, Groups ) |
| 672 | delete_all_groups( self.controller ) |
| 673 | |
| 674 | @disabled |
| 675 | class _32VPN( base_tests.SimpleDataPlane ): |
| 676 | """ |
| 677 | Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 678 | No ECMP group used |
| 679 | """ |
| 680 | |
| 681 | def runTest( self ): |
| 682 | Groups = Queue.LifoQueue( ) |
| 683 | try: |
| 684 | if len( config[ "port_map" ] ) < 2: |
| 685 | logging.info( "Port count less than 2, can't run this case" ) |
| 686 | return |
| 687 | |
| 688 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 689 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 690 | dip = 0xc0a80001 |
| 691 | ports = config[ "port_map" ].keys( ) |
| 692 | for port in ports: |
| 693 | # add l2 interface group |
| 694 | id = port |
| 695 | vlan_id = port |
| 696 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 697 | dst_mac[ 5 ] = vlan_id |
| 698 | # add MPLS interface group |
| 699 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 700 | vlan_id, id ) |
| 701 | # add MPLS L3 VPN group |
| 702 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 703 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 704 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 705 | do_barrier( self.controller ) |
| 706 | # add vlan flow table |
| 707 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2, |
| 708 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 709 | # add termination flow |
| 710 | if config["switch_type"] == "qmx": |
| 711 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 712 | else: |
| 713 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 714 | # add routing flow |
| 715 | dst_ip = dip + (vlan_id << 8) |
| 716 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 717 | Groups._put( l2_gid ) |
| 718 | Groups._put( mpls_gid ) |
| 719 | Groups._put( mpls_label_gid ) |
| 720 | do_barrier( self.controller ) |
| 721 | |
| 722 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 723 | for in_port in ports: |
| 724 | ip_src = '192.168.%02d.1' % (in_port) |
| 725 | for out_port in ports: |
| 726 | if in_port == out_port: |
| 727 | continue |
| 728 | ip_dst = '192.168.%02d.1' % (out_port) |
| 729 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 730 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 731 | pkt = str( parsed_pkt ) |
| 732 | self.dataplane.send( in_port, pkt ) |
| 733 | # build expect packet |
| 734 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 735 | label = (out_port, 0, 1, 32) |
| 736 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 737 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 738 | label=[ label ] ) |
| 739 | pkt = str( exp_pkt ) |
| 740 | verify_packet( self, pkt, out_port ) |
| 741 | verify_no_other_packets( self ) |
| 742 | finally: |
| 743 | delete_all_flows( self.controller ) |
| 744 | delete_groups( self.controller, Groups ) |
| 745 | delete_all_groups( self.controller ) |
| 746 | |
| 747 | @disabled |
| 748 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
| 749 | """ |
| 750 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 751 | """ |
| 752 | |
| 753 | def runTest( self ): |
| 754 | Groups = Queue.LifoQueue( ) |
| 755 | try: |
| 756 | if len( config[ "port_map" ] ) < 2: |
| 757 | logging.info( "Port count less than 2, can't run this case" ) |
| 758 | return |
| 759 | |
| 760 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 761 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 762 | dip = 0xc0a80001 |
| 763 | ports = config[ "port_map" ].keys( ) |
| 764 | for port in ports: |
| 765 | # add l2 interface group |
| 766 | id = port |
| 767 | vlan_id = port |
| 768 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 769 | dst_mac[ 5 ] = vlan_id |
| 770 | # add MPLS interface group |
| 771 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 772 | vlan_id, id ) |
| 773 | # add MPLS L3 VPN group |
| 774 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 775 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 776 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 777 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 778 | do_barrier( self.controller ) |
| 779 | # add vlan flow table |
| 780 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| 781 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 782 | # add termination flow |
| 783 | if config["switch_type"] == "qmx": |
| 784 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 785 | else: |
| 786 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 787 | # add routing flow |
| 788 | dst_ip = dip + (vlan_id << 8) |
| 789 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 790 | Groups._put( l2_gid ) |
| 791 | Groups._put( mpls_gid ) |
| 792 | Groups._put( mpls_label_gid ) |
| 793 | Groups._put( ecmp_msg.group_id ) |
| 794 | do_barrier( self.controller ) |
| 795 | |
| 796 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 797 | for in_port in ports: |
| 798 | ip_src = '192.168.%02d.1' % (in_port) |
| 799 | for out_port in ports: |
| 800 | if in_port == out_port: |
| 801 | continue |
| 802 | ip_dst = '192.168.%02d.1' % (out_port) |
| 803 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 804 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 805 | pkt = str( parsed_pkt ) |
| 806 | self.dataplane.send( in_port, pkt ) |
| 807 | # build expect packet |
| 808 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 809 | label = (out_port, 0, 1, 32) |
| 810 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 811 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 812 | label=[ label ] ) |
| 813 | pkt = str( exp_pkt ) |
| 814 | verify_packet( self, pkt, out_port ) |
| 815 | verify_no_other_packets( self ) |
| 816 | |
| 817 | finally: |
| 818 | delete_all_flows( self.controller ) |
| 819 | delete_groups( self.controller, Groups ) |
| 820 | delete_all_groups( self.controller ) |
| 821 | |
| 822 | |
| 823 | @disabled |
| 824 | class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| 825 | """ |
| 826 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 827 | in only one direction |
| 828 | """ |
| 829 | |
| 830 | def runTest( self ): |
| 831 | Groups = Queue.LifoQueue( ) |
| 832 | try: |
| 833 | if len( config[ "port_map" ] ) < 2: |
| 834 | logging.info( "Port count less than 2, can't run this case" ) |
| 835 | return |
| 836 | |
| 837 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 838 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 839 | dip = 0xc0a80001 |
| 840 | ports = config[ "port_map" ].keys( ) |
| 841 | # add l2 interface group |
| 842 | id = ports[1] |
| 843 | in_offset = 19 |
| 844 | out_offset = 20 |
| 845 | vlan_id = ports[1] + out_offset |
| 846 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True ) |
| 847 | dst_mac[ 5 ] = ports[1] |
| 848 | # add MPLS interface group |
| 849 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 850 | vlan_id, id ) |
| 851 | # add MPLS L3 VPN group |
| 852 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 853 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 854 | push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 ) |
| 855 | # add ECMP group |
| 856 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 857 | do_barrier( self.controller ) |
| 858 | # add vlan flow table |
| 859 | add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0, |
| 860 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 861 | # add termination flow |
| 862 | if config["switch_type"] == "qmx": |
| 863 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| 864 | else: |
| 865 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| 866 | # add routing flow |
| 867 | dst_ip = dip + (vlan_id << 8) |
| 868 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 869 | Groups._put( l2_gid ) |
| 870 | Groups._put( mpls_gid ) |
| 871 | Groups._put( mpls_label_gid ) |
| 872 | Groups._put( ecmp_msg.group_id ) |
| 873 | |
| 874 | |
| 875 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 876 | in_port = ports[0] |
| 877 | out_port = ports[1] |
| 878 | ip_src = '192.168.%02d.1' % (in_port) |
| 879 | ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| 880 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
| 881 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 882 | pkt = str( parsed_pkt ) |
| 883 | self.dataplane.send( in_port, pkt ) |
| 884 | # build expect packet |
| 885 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 886 | label = (out_port+out_offset, 0, 1, 32) |
| 887 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
| 888 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 889 | label=[ label ] ) |
| 890 | pkt = str( exp_pkt ) |
| 891 | verify_packet( self, pkt, out_port ) |
| 892 | #verify_no_other_packets( self ) |
| 893 | |
| 894 | finally: |
| 895 | delete_all_flows( self.controller ) |
| 896 | delete_group(self.controller, ecmp_msg.group_id) |
| 897 | delete_group(self.controller, mpls_label_gid) |
| 898 | delete_group(self.controller, mpls_gid) |
| 899 | delete_group(self.controller, l2_gid) |
| 900 | |
| 901 | |
| 902 | class FabricSW_OF__32ECMPL3_TC_0050( base_tests.SimpleDataPlane ): |
| 903 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 904 | To verify the switch can do unicast routing for /32 mask subnet using ECMP, L3 Unicast and L3 ECMP groups. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 905 | """ |
| 906 | |
| 907 | def runTest( self ): |
| 908 | Groups = Queue.LifoQueue( ) |
| 909 | try: |
| 910 | if len( config[ "port_map" ] ) < 2: |
| 911 | logging.info( "Port count less than 2, can't run this case" ) |
| 912 | return |
| 913 | |
| 914 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 915 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 916 | dip = 0xc0a80001 |
| 917 | # Hashes Test Name and uses it as id for installing unique groups |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 918 | ports = sorted(config["port_map"].keys()) |
| 919 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 920 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 921 | vlan_id = port |
| 922 | id = port |
| 923 | # add l2 interface group |
| 924 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 925 | is_tagged=True, send_barrier=False ) |
| 926 | dst_mac[ 5 ] = vlan_id |
| 927 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 928 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 929 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 930 | # add vlan flow table |
| 931 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 932 | # add termination flow |
| 933 | if config["switch_type"] == "qmx": |
| 934 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 935 | else: |
| 936 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 937 | # add unicast routing flow |
| 938 | dst_ip = dip + (vlan_id << 8) |
| 939 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 940 | Groups._put( l2_gid ) |
| 941 | Groups._put( l3_msg.group_id ) |
| 942 | Groups._put( ecmp_msg.group_id ) |
| 943 | do_barrier( self.controller ) |
| 944 | |
| 945 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 946 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 947 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 948 | ip_src = '192.168.%02d.1' % in_port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 949 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 950 | if in_port == out_port: |
| 951 | continue |
| 952 | ip_dst = '192.168.%02d.1' % out_port |
| 953 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 954 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 955 | pkt = str( parsed_pkt ) |
| 956 | self.dataplane.send( in_port, pkt ) |
| 957 | # build expected packet |
| 958 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 959 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 960 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 961 | pkt = str( exp_pkt ) |
| 962 | verify_packet( self, pkt, out_port ) |
| 963 | verify_no_other_packets( self ) |
| 964 | finally: |
| 965 | delete_all_flows( self.controller ) |
| 966 | delete_groups( self.controller, Groups ) |
| 967 | delete_all_groups( self.controller ) |
| 968 | |
| 969 | @disabled |
| 970 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 971 | """ |
| 972 | Verifies /32 IP routing and ECMP with no label push |
| 973 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 974 | in only one direction |
| 975 | """ |
| 976 | |
| 977 | def runTest( self ): |
| 978 | Groups = Queue.LifoQueue( ) |
| 979 | try: |
| 980 | if len( config[ "port_map" ] ) < 2: |
| 981 | logging.info( "Port count less than 2, can't run this case" ) |
| 982 | return |
| 983 | |
| 984 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 985 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 986 | dip = 0xc0a80001 |
| 987 | # Hashes Test Name and uses it as id for installing unique groups |
| 988 | ports = config[ "port_map" ].keys( ) |
| 989 | inport = ports[0] |
| 990 | outport = ports[1] |
| 991 | in_offset = 19 |
| 992 | out_offset = 20 |
| 993 | vlan_id = outport + out_offset |
| 994 | id = outport |
| 995 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 996 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 997 | is_tagged=True, send_barrier=False ) |
| 998 | dst_mac[ 5 ] = outport |
| 999 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 1000 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1001 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1002 | # add vlan flow table |
| 1003 | add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1004 | # add termination flow |
| 1005 | if config["switch_type"] == "qmx": |
| 1006 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset ) |
| 1007 | else: |
| 1008 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
| 1009 | # add unicast routing flow |
| 1010 | dst_ip = dip + (vlan_id << 8) |
| 1011 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 1012 | Groups._put( l2_gid ) |
| 1013 | Groups._put( l3_msg.group_id ) |
| 1014 | Groups._put( ecmp_msg.group_id ) |
| 1015 | |
| 1016 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1017 | mac_src = '00:00:00:22:22:%02X' % inport |
| 1018 | ip_src = '192.168.%02d.1' % inport |
| 1019 | ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| 1020 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
| 1021 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1022 | pkt = str( parsed_pkt ) |
| 1023 | self.dataplane.send( inport, pkt ) |
| 1024 | # build expected packet |
| 1025 | mac_dst = '00:00:00:22:22:%02X' % outport |
| 1026 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset, |
| 1027 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1028 | pkt = str( exp_pkt ) |
| 1029 | verify_packet( self, pkt, outport ) |
| 1030 | verify_no_other_packets( self ) |
| 1031 | finally: |
| 1032 | delete_all_flows( self.controller ) |
| 1033 | delete_groups( self.controller, Groups ) |
| 1034 | delete_all_groups( self.controller ) |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | @disabled |
| 1040 | class _24VPN( base_tests.SimpleDataPlane ): |
| 1041 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
| 1042 | |
| 1043 | def runTest( self ): |
| 1044 | Groups = Queue.LifoQueue( ) |
| 1045 | try: |
| 1046 | if len( config[ "port_map" ] ) < 2: |
| 1047 | logging.info( "Port count less than 2, can't run this case" ) |
| 1048 | return |
| 1049 | |
| 1050 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1051 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1052 | dip = 0xc0a80001 |
| 1053 | ports = config[ "port_map" ].keys( ) |
| 1054 | for port in ports: |
| 1055 | # add l2 interface group |
| 1056 | id = port |
| 1057 | vlan_id = port |
| 1058 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 1059 | dst_mac[ 5 ] = vlan_id |
| 1060 | # add MPLS interface group |
| 1061 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1062 | vlan_id, id ) |
| 1063 | # add MPLS L3 VPN group |
| 1064 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1065 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 1066 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 1067 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 1068 | do_barrier( self.controller ) |
| 1069 | # add vlan flow table |
| 1070 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| 1071 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1072 | # add termination flow |
| 1073 | if config["switch_type"] == "qmx": |
| 1074 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1075 | else: |
| 1076 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1077 | # add routing flow |
| 1078 | dst_ip = dip + (vlan_id << 8) |
| 1079 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 1080 | Groups._put( l2_gid ) |
| 1081 | Groups._put( mpls_gid ) |
| 1082 | Groups._put( mpls_label_gid ) |
| 1083 | do_barrier( self.controller ) |
| 1084 | |
| 1085 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1086 | for in_port in ports: |
| 1087 | ip_src = '192.168.%02d.1' % (in_port) |
| 1088 | for out_port in ports: |
| 1089 | if in_port == out_port: |
| 1090 | continue |
| 1091 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1092 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1093 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1094 | pkt = str( parsed_pkt ) |
| 1095 | self.dataplane.send( in_port, pkt ) |
| 1096 | # build expect packet |
| 1097 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1098 | label = (out_port, 0, 1, 32) |
| 1099 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1100 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1101 | label=[ label ] ) |
| 1102 | pkt = str( exp_pkt ) |
| 1103 | verify_packet( self, pkt, out_port ) |
| 1104 | verify_no_other_packets( self ) |
| 1105 | finally: |
| 1106 | delete_all_flows( self.controller ) |
| 1107 | delete_groups( self.controller, Groups ) |
| 1108 | delete_all_groups( self.controller ) |
| 1109 | |
| 1110 | @disabled |
| 1111 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
| 1112 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
| 1113 | |
| 1114 | def runTest( self ): |
| 1115 | Groups = Queue.LifoQueue( ) |
| 1116 | try: |
| 1117 | if len( config[ "port_map" ] ) < 2: |
| 1118 | logging.info( "Port count less than 2, can't run this case" ) |
| 1119 | return |
| 1120 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1121 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1122 | dip = 0xc0a80001 |
| 1123 | ports = config[ "port_map" ].keys( ) |
| 1124 | for port in ports: |
| 1125 | # add l2 interface group |
| 1126 | id = port |
| 1127 | vlan_id = id |
| 1128 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 1129 | dst_mac[ 5 ] = vlan_id |
| 1130 | # add MPLS interface group |
| 1131 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1132 | vlan_id, id ) |
| 1133 | # add MPLS L3 VPN group |
| 1134 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1135 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 1136 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 1137 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 1138 | do_barrier( self.controller ) |
| 1139 | # add vlan flow table |
| 1140 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| 1141 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1142 | # add termination flow |
| 1143 | if config["switch_type"] == "qmx": |
| 1144 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1145 | else: |
| 1146 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1147 | # add routing flow |
| 1148 | dst_ip = dip + (vlan_id << 8) |
| 1149 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 1150 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 1151 | vrf=0 ) |
| 1152 | Groups._put( l2_gid ) |
| 1153 | Groups._put( mpls_gid ) |
| 1154 | Groups._put( mpls_label_gid ) |
| 1155 | Groups._put( ecmp_msg.group_id ) |
| 1156 | |
| 1157 | do_barrier( self.controller ) |
| 1158 | |
| 1159 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1160 | for in_port in ports: |
| 1161 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1162 | ip_src = '192.168.%02d.1' % (in_port) |
| 1163 | for out_port in ports: |
| 1164 | if in_port == out_port: |
| 1165 | continue |
| 1166 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1167 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1168 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1169 | pkt = str( parsed_pkt ) |
| 1170 | self.dataplane.send( in_port, pkt ) |
| 1171 | # build expect packet |
| 1172 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1173 | label = (out_port, 0, 1, 32) |
| 1174 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1175 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1176 | label=[ label ] ) |
| 1177 | pkt = str( exp_pkt ) |
| 1178 | verify_packet( self, pkt, out_port ) |
| 1179 | verify_no_other_packets( self ) |
| 1180 | finally: |
| 1181 | delete_all_flows( self.controller ) |
| 1182 | delete_groups( self.controller, Groups ) |
| 1183 | delete_all_groups( self.controller ) |
| 1184 | |
| 1185 | |
| 1186 | class FabricSW_OF_FloodGroupMod_TC_0030( base_tests.SimpleDataPlane ): |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 1187 | """ Verify packet forwarding when an L2 Interface Group reference in an L2 Flood Group is modified. """ |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1188 | |
| 1189 | def runTest( self ): |
| 1190 | Groups = Queue.LifoQueue( ) |
| 1191 | try: |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1192 | ports = sorted(config["port_map"].keys()) |
| 1193 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1194 | vlan_id = 1 |
| 1195 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1196 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1197 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1198 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1199 | Groups.put( L2gid ) |
| 1200 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1201 | msg = add_l2_flood_group( self.controller, pair, vlan_id, vlan_id ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1202 | Groups.put( msg.group_id ) |
| 1203 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 1204 | do_barrier( self.controller ) |
| 1205 | # verify flood |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1206 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1207 | # change dest based on port number |
| 1208 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 1209 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1210 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 1211 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 1212 | pkt = str( parsed_pkt ) |
| 1213 | self.dataplane.send( ofport, pkt ) |
| 1214 | # self won't rx packet |
| 1215 | verify_no_packet( self, pkt, ofport ) |
| 1216 | # others will rx packet |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1217 | tmp_ports = list( pair ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1218 | tmp_ports.remove( ofport ) |
| 1219 | verify_packets( self, pkt, tmp_ports ) |
| 1220 | verify_no_other_packets( self ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1221 | msg = mod_l2_flood_group( self.controller, [ pair[ 0 ] ], vlan_id, vlan_id ) |
| 1222 | mac_src = '00:12:34:56:78:%02X' % pair[ 1 ] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1223 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1224 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 1225 | eth_src=mac_src ) |
| 1226 | pkt = str( parsed_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1227 | self.dataplane.send( pair[ 1 ], pkt ) |
| 1228 | verify_packets( self, pkt, [ pair[ 0 ] ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1229 | finally: |
| 1230 | delete_all_flows( self.controller ) |
| 1231 | delete_groups( self.controller, Groups ) |
| 1232 | delete_all_groups( self.controller ) |
| 1233 | |
| 1234 | |
| 1235 | class FabricSW_OF__24ECMPL3_TC_0040( base_tests.SimpleDataPlane ): |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 1236 | """ To verify the switch can do unicast routing for /24 mask subnet using ECMP, L3 Unicast and L3 ECMP groups.""" |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1237 | |
| 1238 | def runTest( self ): |
| 1239 | Groups = Queue.LifoQueue( ) |
| 1240 | try: |
| 1241 | if len( config[ "port_map" ] ) < 2: |
| 1242 | logging.info( "Port count less than 2, can't run this case" ) |
| 1243 | return |
| 1244 | |
| 1245 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1246 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1247 | dip = 0xc0a80001 |
| 1248 | # Hashes Test Name and uses it as id for installing unique groups |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1249 | ports = sorted(config["port_map"].keys()) |
| 1250 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 1251 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1252 | vlan_id = port |
| 1253 | id = port |
| 1254 | # add l2 interface group |
| 1255 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1256 | is_tagged=True, send_barrier=False ) |
| 1257 | dst_mac[ 5 ] = vlan_id |
| 1258 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1259 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1260 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1261 | # add vlan flow table |
| 1262 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1263 | # add termination flow |
| 1264 | if config["switch_type"] == "qmx": |
| 1265 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1266 | else: |
| 1267 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1268 | # add unicast routing flow |
| 1269 | dst_ip = dip + (vlan_id << 8) |
| 1270 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1271 | Groups._put( l2_gid ) |
| 1272 | Groups._put( l3_msg.group_id ) |
| 1273 | Groups._put( ecmp_msg.group_id ) |
| 1274 | do_barrier( self.controller ) |
| 1275 | |
| 1276 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1277 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1278 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1279 | ip_src = '192.168.%02d.1' % in_port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1280 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1281 | if in_port == out_port: |
| 1282 | continue |
| 1283 | ip_dst = '192.168.%02d.1' % out_port |
| 1284 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1285 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1286 | pkt = str( parsed_pkt ) |
| 1287 | self.dataplane.send( in_port, pkt ) |
| 1288 | # build expected packet |
| 1289 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1290 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1291 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1292 | pkt = str( exp_pkt ) |
| 1293 | verify_packet( self, pkt, out_port ) |
| 1294 | verify_no_other_packets( self ) |
| 1295 | finally: |
| 1296 | delete_all_flows( self.controller ) |
| 1297 | delete_groups( self.controller, Groups ) |
| 1298 | delete_all_groups( self.controller ) |
| 1299 | |
| 1300 | |
| 1301 | @disabled |
| 1302 | class MPLSBUG( base_tests.SimpleDataPlane ): |
| 1303 | """ |
| 1304 | Needs a description or needs to be removed |
| 1305 | """ |
| 1306 | def runTest( self ): |
| 1307 | if len( config[ "port_map" ] ) < 2: |
| 1308 | logging.info( "Port count less than 2, can't run this case" ) |
| 1309 | return |
| 1310 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1311 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1312 | dip = 0xc0a80001 |
| 1313 | Groups = Queue.LifoQueue( ) |
| 1314 | ports = config[ "port_map" ].keys( ) |
| 1315 | for port in ports: |
| 1316 | # add l2 interface group |
| 1317 | vlan_id = port |
| 1318 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1319 | dst_mac[ 5 ] = vlan_id |
| 1320 | # add L3 Unicast group |
| 1321 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1322 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1323 | # add vlan flow table |
| 1324 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 1325 | # add termination flow |
| 1326 | if config["switch_type"] == "qmx": |
| 1327 | add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1328 | else: |
| 1329 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1330 | # add mpls flow |
| 1331 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
| 1332 | # add termination flow |
| 1333 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1334 | # add unicast routing flow |
| 1335 | dst_ip = dip + (vlan_id << 8) |
| 1336 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1337 | Groups._put( l2_gid ) |
| 1338 | Groups._put( l3_msg.group_id ) |
| 1339 | do_barrier( self.controller ) |
| 1340 | |
| 1341 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1342 | for in_port in ports: |
| 1343 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1344 | ip_src = '192.168.%02d.1' % in_port |
| 1345 | for out_port in ports: |
| 1346 | if in_port == out_port: |
| 1347 | continue |
| 1348 | ip_dst = '192.168.%02d.1' % out_port |
| 1349 | switch_mac = "00:00:00:cc:cc:cc" |
| 1350 | label = (out_port, 0, 1, 32) |
| 1351 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1352 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1353 | pkt = str( parsed_pkt ) |
| 1354 | self.dataplane.send( in_port, pkt ) |
| 1355 | |
| 1356 | # build expect packet |
| 1357 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1358 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1359 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1360 | pkt = str( exp_pkt ) |
| 1361 | verify_packet( self, pkt, out_port ) |
| 1362 | verify_no_other_packets( self ) |
| 1363 | |
| 1364 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1365 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1366 | pkt = str( parsed_pkt ) |
| 1367 | self.dataplane.send( in_port, pkt ) |
| 1368 | # build expected packet |
| 1369 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1370 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1371 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1372 | pkt = str( exp_pkt ) |
| 1373 | verify_packet( self, pkt, out_port ) |
| 1374 | verify_no_other_packets( self ) |
| 1375 | delete_all_flows( self.controller ) |
| 1376 | delete_groups( self.controller, Groups ) |
| 1377 | |
| 1378 | class L3McastToL3( base_tests.SimpleDataPlane ): |
| 1379 | """ |
| 1380 | Mcast routing, in this test case the traffic comes in tagged. |
| 1381 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1382 | different ports. 4094-port is used as egress vlan_id. |
| 1383 | """ |
| 1384 | def runTest( self ): |
| 1385 | """ |
| 1386 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1387 | """ |
| 1388 | Groups = Queue.LifoQueue( ) |
| 1389 | try: |
| 1390 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1391 | if len( config[ "port_map" ] ) < 1: |
| 1392 | logging.info( "Port count less than 1, can't run this case" ) |
| 1393 | assert (False) |
| 1394 | return |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1395 | ports = sorted(config["port_map"].keys()) |
| 1396 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1397 | dst_ip_str = "224.0.0.1" |
| 1398 | ( |
| 1399 | port_to_in_vlan, |
| 1400 | port_to_out_vlan, |
| 1401 | port_to_src_mac_str, |
| 1402 | port_to_dst_mac_str, |
| 1403 | port_to_src_ip, |
| 1404 | port_to_src_ip_str, |
| 1405 | port_to_intf_src_mac_str, |
| 1406 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1407 | self.controller, |
| 1408 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1409 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1410 | is_ingress_tagged = True, |
| 1411 | is_egress_tagged = True, |
| 1412 | is_vlan_translated = True, |
| 1413 | is_max_vlan = False |
| 1414 | ) |
| 1415 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1416 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1417 | |
| 1418 | parsed_pkt = simple_udp_packet( |
| 1419 | pktlen = 100, |
| 1420 | dl_vlan_enable = True, |
| 1421 | vlan_vid = port_to_in_vlan[in_port], |
| 1422 | eth_dst = port_to_dst_mac_str[in_port], |
| 1423 | eth_src = port_to_src_mac_str[in_port], |
| 1424 | ip_ttl = 64, |
| 1425 | ip_src = port_to_src_ip_str[in_port], |
| 1426 | ip_dst = dst_ip_str |
| 1427 | ) |
| 1428 | pkt = str( parsed_pkt ) |
| 1429 | self.dataplane.send( in_port, pkt ) |
| 1430 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1431 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1432 | |
| 1433 | parsed_pkt = simple_udp_packet( |
| 1434 | pktlen = 100, |
| 1435 | dl_vlan_enable = True, |
| 1436 | vlan_vid = port_to_out_vlan[out_port], |
| 1437 | eth_dst = port_to_dst_mac_str[in_port], |
| 1438 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1439 | ip_ttl = 63, |
| 1440 | ip_src = port_to_src_ip_str[in_port], |
| 1441 | ip_dst = dst_ip_str |
| 1442 | ) |
| 1443 | pkt = str( parsed_pkt ) |
| 1444 | verify_packet( self, pkt, out_port ) |
| 1445 | |
| 1446 | verify_no_other_packets( self ) |
| 1447 | |
| 1448 | finally: |
| 1449 | delete_all_flows( self.controller ) |
| 1450 | delete_groups( self.controller, Groups ) |
| 1451 | delete_all_groups( self.controller ) |
| 1452 | |
| 1453 | @disabled |
| 1454 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1455 | """ |
| 1456 | Fails on alternate runs |
| 1457 | Mcast routing, in this test case the traffic is untagged. |
| 1458 | 4094 is used as internal vlan_id. The packet goes out |
| 1459 | untagged. |
| 1460 | """ |
| 1461 | def runTest( self ): |
| 1462 | Groups = Queue.LifoQueue( ) |
| 1463 | try: |
| 1464 | if len( config[ "port_map" ] ) < 2: |
| 1465 | logging.info( "Port count less than 2, can't run this case" ) |
| 1466 | assert (False) |
| 1467 | return |
| 1468 | ports = config[ "port_map" ].keys( ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1469 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1470 | dst_ip_str = "224.0.0.1" |
| 1471 | ( |
| 1472 | port_to_in_vlan, |
| 1473 | port_to_out_vlan, |
| 1474 | port_to_src_mac_str, |
| 1475 | port_to_dst_mac_str, |
| 1476 | port_to_src_ip, |
| 1477 | port_to_src_ip_str, |
| 1478 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1479 | self.controller, |
| 1480 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1481 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1482 | is_ingress_tagged = False, |
| 1483 | is_egress_tagged = False, |
| 1484 | is_vlan_translated = False, |
| 1485 | is_max_vlan = True |
| 1486 | ) |
| 1487 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1488 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1489 | |
| 1490 | parsed_pkt = simple_udp_packet( |
| 1491 | pktlen = 96, |
| 1492 | eth_dst = port_to_dst_mac_str[in_port], |
| 1493 | eth_src = port_to_src_mac_str[in_port], |
| 1494 | ip_ttl = 64, |
| 1495 | ip_src = port_to_src_ip_str[in_port], |
| 1496 | ip_dst = dst_ip_str |
| 1497 | ) |
| 1498 | pkt = str( parsed_pkt ) |
| 1499 | self.dataplane.send( in_port, pkt ) |
| 1500 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1501 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1502 | |
| 1503 | parsed_pkt = simple_udp_packet( |
| 1504 | pktlen = 96, |
| 1505 | eth_dst = port_to_dst_mac_str[in_port], |
| 1506 | eth_src = port_to_src_mac_str[in_port], |
| 1507 | ip_ttl = 64, |
| 1508 | ip_src = port_to_src_ip_str[in_port], |
| 1509 | ip_dst = dst_ip_str |
| 1510 | ) |
| 1511 | pkt = str( parsed_pkt ) |
| 1512 | if out_port == in_port: |
| 1513 | verify_no_packet( self, pkt, in_port ) |
| 1514 | continue |
| 1515 | verify_packet( self, pkt, out_port ) |
| 1516 | verify_no_other_packets( self ) |
| 1517 | finally: |
| 1518 | delete_all_flows( self.controller ) |
| 1519 | delete_groups( self.controller, Groups ) |
| 1520 | delete_all_groups( self.controller ) |
| 1521 | |
| 1522 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1523 | """ |
| 1524 | Mcast routing, in this test case the traffic is untagged. |
| 1525 | 300 is used as vlan_id. The packet goes out |
| 1526 | tagged. |
| 1527 | """ |
| 1528 | def runTest( self ): |
| 1529 | Groups = Queue.LifoQueue( ) |
| 1530 | try: |
| 1531 | if len( config[ "port_map" ] ) < 2: |
| 1532 | logging.info( "Port count less than 2, can't run this case" ) |
| 1533 | assert (False) |
| 1534 | return |
| 1535 | ports = config[ "port_map" ].keys( ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1536 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1537 | dst_ip_str = "224.0.0.1" |
| 1538 | ( |
| 1539 | port_to_in_vlan, |
| 1540 | port_to_out_vlan, |
| 1541 | port_to_src_mac_str, |
| 1542 | port_to_dst_mac_str, |
| 1543 | port_to_src_ip, |
| 1544 | port_to_src_ip_str, |
| 1545 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1546 | self.controller, |
| 1547 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1548 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1549 | is_ingress_tagged = False, |
| 1550 | is_egress_tagged = True, |
| 1551 | is_vlan_translated = False, |
| 1552 | is_max_vlan = False |
| 1553 | ) |
| 1554 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1555 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1556 | |
| 1557 | parsed_pkt = simple_udp_packet( |
| 1558 | pktlen = 96, |
| 1559 | eth_dst = port_to_dst_mac_str[in_port], |
| 1560 | eth_src = port_to_src_mac_str[in_port], |
| 1561 | ip_ttl = 64, |
| 1562 | ip_src = port_to_src_ip_str[in_port], |
| 1563 | ip_dst = dst_ip_str |
| 1564 | ) |
| 1565 | pkt = str( parsed_pkt ) |
| 1566 | self.dataplane.send( in_port, pkt ) |
| 1567 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1568 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1569 | |
| 1570 | parsed_pkt = simple_udp_packet( |
| 1571 | pktlen = 100, |
| 1572 | dl_vlan_enable = True, |
| 1573 | vlan_vid = port_to_out_vlan[in_port], |
| 1574 | eth_dst = port_to_dst_mac_str[in_port], |
| 1575 | eth_src = port_to_src_mac_str[in_port], |
| 1576 | ip_ttl = 64, |
| 1577 | ip_src = port_to_src_ip_str[in_port], |
| 1578 | ip_dst = dst_ip_str |
| 1579 | ) |
| 1580 | pkt = str( parsed_pkt ) |
| 1581 | if out_port == in_port: |
| 1582 | verify_no_packet( self, pkt, in_port ) |
| 1583 | continue |
| 1584 | verify_packet( self, pkt, out_port ) |
| 1585 | verify_no_other_packets( self ) |
| 1586 | finally: |
| 1587 | delete_all_flows( self.controller ) |
| 1588 | delete_groups( self.controller, Groups ) |
| 1589 | delete_all_groups( self.controller ) |
| 1590 | |
| 1591 | |
| 1592 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1593 | """ |
| 1594 | Mcast routing, in this test case the traffic is tagged. |
| 1595 | 300 is used as vlan_id. The packet goes out |
| 1596 | untagged. |
| 1597 | """ |
| 1598 | def runTest( self ): |
| 1599 | Groups = Queue.LifoQueue( ) |
| 1600 | try: |
| 1601 | if len( config[ "port_map" ] ) < 2: |
| 1602 | logging.info( "Port count less than 2, can't run this case" ) |
| 1603 | assert (False) |
| 1604 | return |
| 1605 | ports = config[ "port_map" ].keys( ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1606 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1607 | dst_ip_str = "224.0.0.1" |
| 1608 | ( |
| 1609 | port_to_in_vlan, |
| 1610 | port_to_out_vlan, |
| 1611 | port_to_src_mac_str, |
| 1612 | port_to_dst_mac_str, |
| 1613 | port_to_src_ip, |
| 1614 | port_to_src_ip_str, |
| 1615 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1616 | self.controller, |
| 1617 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1618 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1619 | is_ingress_tagged = True, |
| 1620 | is_egress_tagged = False, |
| 1621 | is_vlan_translated = False, |
| 1622 | is_max_vlan = False |
| 1623 | ) |
| 1624 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1625 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1626 | |
| 1627 | parsed_pkt = simple_udp_packet( |
| 1628 | pktlen = 100, |
| 1629 | dl_vlan_enable = True, |
| 1630 | vlan_vid = port_to_in_vlan[in_port], |
| 1631 | eth_dst = port_to_dst_mac_str[in_port], |
| 1632 | eth_src = port_to_src_mac_str[in_port], |
| 1633 | ip_ttl = 64, |
| 1634 | ip_src = port_to_src_ip_str[in_port], |
| 1635 | ip_dst = dst_ip_str |
| 1636 | ) |
| 1637 | pkt = str( parsed_pkt ) |
| 1638 | self.dataplane.send( in_port, pkt ) |
| 1639 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1640 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1641 | |
| 1642 | parsed_pkt = simple_udp_packet( |
| 1643 | pktlen = 96, |
| 1644 | eth_dst = port_to_dst_mac_str[in_port], |
| 1645 | eth_src = port_to_src_mac_str[in_port], |
| 1646 | ip_ttl = 64, |
| 1647 | ip_src = port_to_src_ip_str[in_port], |
| 1648 | ip_dst = dst_ip_str |
| 1649 | ) |
| 1650 | pkt = str( parsed_pkt ) |
| 1651 | if out_port == in_port: |
| 1652 | verify_no_packet( self, pkt, in_port ) |
| 1653 | continue |
| 1654 | verify_packet( self, pkt, out_port ) |
| 1655 | verify_no_other_packets( self ) |
| 1656 | finally: |
| 1657 | delete_all_flows( self.controller ) |
| 1658 | delete_groups( self.controller, Groups ) |
| 1659 | delete_all_groups( self.controller ) |
| 1660 | |
| 1661 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1662 | """ |
| 1663 | Mcast routing, in this test case the traffic is tagged. |
| 1664 | 300 is used as vlan_id. The packet goes out tagged. |
| 1665 | """ |
| 1666 | def runTest( self ): |
| 1667 | Groups = Queue.LifoQueue( ) |
| 1668 | try: |
| 1669 | if len( config[ "port_map" ] ) < 2: |
| 1670 | logging.info( "Port count less than 2, can't run this case" ) |
| 1671 | assert (False) |
| 1672 | return |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1673 | ports = sorted(config["port_map"].keys()) |
| 1674 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1675 | dst_ip_str = "224.0.0.1" |
| 1676 | ( |
| 1677 | port_to_in_vlan, |
| 1678 | port_to_out_vlan, |
| 1679 | port_to_src_mac_str, |
| 1680 | port_to_dst_mac_str, |
| 1681 | port_to_src_ip, |
| 1682 | port_to_src_ip_str, |
| 1683 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1684 | self.controller, |
| 1685 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1686 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1687 | is_ingress_tagged = True, |
| 1688 | is_egress_tagged = True, |
| 1689 | is_vlan_translated = False, |
| 1690 | is_max_vlan = False |
| 1691 | ) |
| 1692 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1693 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1694 | |
| 1695 | parsed_pkt = simple_udp_packet( |
| 1696 | pktlen = 100, |
| 1697 | dl_vlan_enable = True, |
| 1698 | vlan_vid = port_to_in_vlan[in_port], |
| 1699 | eth_dst = port_to_dst_mac_str[in_port], |
| 1700 | eth_src = port_to_src_mac_str[in_port], |
| 1701 | ip_ttl = 64, |
| 1702 | ip_src = port_to_src_ip_str[in_port], |
| 1703 | ip_dst = dst_ip_str |
| 1704 | ) |
| 1705 | pkt = str( parsed_pkt ) |
| 1706 | self.dataplane.send( in_port, pkt ) |
| 1707 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1708 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1709 | |
| 1710 | parsed_pkt = simple_udp_packet( |
| 1711 | pktlen = 100, |
| 1712 | dl_vlan_enable = True, |
| 1713 | vlan_vid = port_to_in_vlan[in_port], |
| 1714 | eth_dst = port_to_dst_mac_str[in_port], |
| 1715 | eth_src = port_to_src_mac_str[in_port], |
| 1716 | ip_ttl = 64, |
| 1717 | ip_src = port_to_src_ip_str[in_port], |
| 1718 | ip_dst = dst_ip_str |
| 1719 | ) |
| 1720 | pkt = str( parsed_pkt ) |
| 1721 | if out_port == in_port: |
| 1722 | verify_no_packet( self, pkt, in_port ) |
| 1723 | continue |
| 1724 | verify_packet( self, pkt, out_port ) |
| 1725 | verify_no_other_packets( self ) |
| 1726 | finally: |
| 1727 | delete_all_flows( self.controller ) |
| 1728 | delete_groups( self.controller, Groups ) |
| 1729 | delete_all_groups( self.controller ) |
| 1730 | |
| 1731 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1732 | """ |
| 1733 | Mcast routing, in this test case the traffic is tagged. |
| 1734 | port+1 is used as ingress vlan_id. The packet goes out |
| 1735 | tagged. 4094-port is used as egress vlan_id |
| 1736 | """ |
| 1737 | def runTest( self ): |
| 1738 | Groups = Queue.LifoQueue( ) |
| 1739 | try: |
| 1740 | if len( config[ "port_map" ] ) < 2: |
| 1741 | logging.info( "Port count less than 2, can't run this case" ) |
| 1742 | assert (False) |
| 1743 | return |
| 1744 | ports = config[ "port_map" ].keys( ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1745 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1746 | dst_ip_str = "224.0.0.1" |
| 1747 | ( |
| 1748 | port_to_in_vlan, |
| 1749 | port_to_out_vlan, |
| 1750 | port_to_src_mac_str, |
| 1751 | port_to_dst_mac_str, |
| 1752 | port_to_src_ip, |
| 1753 | port_to_src_ip_str, |
| 1754 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1755 | self.controller, |
| 1756 | logging, |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1757 | pair, |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1758 | is_ingress_tagged = True, |
| 1759 | is_egress_tagged = True, |
| 1760 | is_vlan_translated = True, |
| 1761 | is_max_vlan = False |
| 1762 | ) |
| 1763 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1764 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1765 | |
| 1766 | parsed_pkt = simple_udp_packet( |
| 1767 | pktlen = 100, |
| 1768 | dl_vlan_enable = True, |
| 1769 | vlan_vid = port_to_in_vlan[in_port], |
| 1770 | eth_dst = port_to_dst_mac_str[in_port], |
| 1771 | eth_src = port_to_src_mac_str[in_port], |
| 1772 | ip_ttl = 64, |
| 1773 | ip_src = port_to_src_ip_str[in_port], |
| 1774 | ip_dst = dst_ip_str |
| 1775 | ) |
| 1776 | pkt = str( parsed_pkt ) |
| 1777 | self.dataplane.send( in_port, pkt ) |
| 1778 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 1779 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 1780 | |
| 1781 | parsed_pkt = simple_udp_packet( |
| 1782 | pktlen = 100, |
| 1783 | dl_vlan_enable = True, |
| 1784 | vlan_vid = port_to_out_vlan[in_port], |
| 1785 | eth_dst = port_to_dst_mac_str[in_port], |
| 1786 | eth_src = port_to_src_mac_str[in_port], |
| 1787 | ip_ttl = 64, |
| 1788 | ip_src = port_to_src_ip_str[in_port], |
| 1789 | ip_dst = dst_ip_str |
| 1790 | ) |
| 1791 | pkt = str( parsed_pkt ) |
| 1792 | if out_port == in_port: |
| 1793 | verify_no_packet( self, pkt, in_port ) |
| 1794 | continue |
| 1795 | verify_packet( self, pkt, out_port ) |
| 1796 | verify_no_other_packets( self ) |
| 1797 | finally: |
| 1798 | delete_all_flows( self.controller ) |
| 1799 | delete_groups( self.controller, Groups ) |
| 1800 | delete_all_groups( self.controller ) |
| 1801 | |
| 1802 | @disabled |
| 1803 | class L3McastTrafficThenDrop( base_tests.SimpleDataPlane ): |
| 1804 | # fails on alternate repeated runs |
| 1805 | """ |
| 1806 | Mcast routing, in this test case the traffic is untagged. |
| 1807 | 4094 is used as internal vlan_id. We first install aa full pipeline, |
| 1808 | test that it forwards properly then remove all rules on table 40 and |
| 1809 | mcast groups and ensure traffic is dropped. Blackhole of mcast traffic |
| 1810 | if no tree is programmed on the switch. |
| 1811 | """ |
| 1812 | def runTest( self ): |
| 1813 | Groups = Queue.LifoQueue( ) |
| 1814 | try: |
| 1815 | if len( config[ "port_map" ] ) < 2: |
| 1816 | logging.info( "Port count less than 2, can't run this case" ) |
| 1817 | assert (False) |
| 1818 | return |
| 1819 | ports = config[ "port_map" ].keys( ) |
| 1820 | dst_ip_str = "224.0.0.1" |
| 1821 | ( |
| 1822 | port_to_in_vlan, |
| 1823 | port_to_out_vlan, |
| 1824 | port_to_src_mac_str, |
| 1825 | port_to_dst_mac_str, |
| 1826 | port_to_src_ip, |
| 1827 | port_to_src_ip_str, |
| 1828 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1829 | self.controller, |
| 1830 | logging, |
| 1831 | ports, |
| 1832 | is_ingress_tagged = False, |
| 1833 | is_egress_tagged = False, |
| 1834 | is_vlan_translated = False, |
| 1835 | is_max_vlan = True |
| 1836 | ) |
| 1837 | |
| 1838 | for in_port in ports: |
| 1839 | |
| 1840 | parsed_pkt = simple_udp_packet( |
| 1841 | pktlen = 96, |
| 1842 | eth_dst = port_to_dst_mac_str[in_port], |
| 1843 | eth_src = port_to_src_mac_str[in_port], |
| 1844 | ip_ttl = 64, |
| 1845 | ip_src = port_to_src_ip_str[in_port], |
| 1846 | ip_dst = dst_ip_str |
| 1847 | ) |
| 1848 | pkt = str( parsed_pkt ) |
| 1849 | self.dataplane.send( in_port, pkt ) |
| 1850 | |
| 1851 | for out_port in ports: |
| 1852 | |
| 1853 | parsed_pkt = simple_udp_packet( |
| 1854 | pktlen = 96, |
| 1855 | eth_dst = port_to_dst_mac_str[in_port], |
| 1856 | eth_src = port_to_src_mac_str[in_port], |
| 1857 | ip_ttl = 64, |
| 1858 | ip_src = port_to_src_ip_str[in_port], |
| 1859 | ip_dst = dst_ip_str |
| 1860 | ) |
| 1861 | pkt = str( parsed_pkt ) |
| 1862 | if out_port == in_port: |
| 1863 | verify_no_packet( self, pkt, in_port ) |
| 1864 | continue |
| 1865 | verify_packet( self, pkt, out_port ) |
| 1866 | verify_no_other_packets( self ) |
| 1867 | |
| 1868 | delete_all_flows_one_table(ctrl=self.controller, logger=logging, table_id=40); |
| 1869 | delete_all_groups(self.controller) |
| 1870 | |
| 1871 | for in_port in ports: |
| 1872 | |
| 1873 | parsed_pkt = simple_udp_packet( |
| 1874 | pktlen = 96, |
| 1875 | eth_dst = port_to_dst_mac_str[in_port], |
| 1876 | eth_src = port_to_src_mac_str[in_port], |
| 1877 | ip_ttl = 64, |
| 1878 | ip_src = port_to_src_ip_str[in_port], |
| 1879 | ip_dst = dst_ip_str |
| 1880 | ) |
| 1881 | pkt = str( parsed_pkt ) |
| 1882 | self.dataplane.send( in_port, pkt ) |
| 1883 | |
| 1884 | for out_port in ports: |
| 1885 | |
| 1886 | parsed_pkt = simple_udp_packet( |
| 1887 | pktlen = 96, |
| 1888 | eth_dst = port_to_dst_mac_str[in_port], |
| 1889 | eth_src = port_to_src_mac_str[in_port], |
| 1890 | ip_ttl = 64, |
| 1891 | ip_src = port_to_src_ip_str[in_port], |
| 1892 | ip_dst = dst_ip_str |
| 1893 | ) |
| 1894 | pkt = str( parsed_pkt ) |
| 1895 | if out_port == in_port: |
| 1896 | verify_no_packet( self, pkt, in_port ) |
| 1897 | continue |
| 1898 | verify_no_packet( self, pkt, out_port ) |
| 1899 | verify_no_other_packets( self ) |
| 1900 | finally: |
| 1901 | delete_all_flows( self.controller ) |
| 1902 | delete_groups( self.controller, Groups ) |
| 1903 | delete_all_groups( self.controller ) |
| 1904 | |
| 1905 | @disabled |
| 1906 | class _MplsFwd( base_tests.SimpleDataPlane ): |
| 1907 | """ Verify basic MPLS forwarding: Label switch router """ |
| 1908 | |
| 1909 | def runTest( self ): |
| 1910 | Groups = Queue.LifoQueue( ) |
| 1911 | try: |
| 1912 | if len( config[ "port_map" ] ) < 2: |
| 1913 | logging.info( "Port count less than 2, can't run this case" ) |
| 1914 | return |
| 1915 | dip = 0xc0a80001 |
| 1916 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1917 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1918 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1919 | ports = config[ "port_map" ].keys( ) |
| 1920 | for port in ports: |
| 1921 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1922 | vlan_id = port + 16 |
| 1923 | mpls_label = port + 16 |
| 1924 | |
| 1925 | # add l2 interface group |
| 1926 | id = port |
| 1927 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1928 | dst_mac[ 5 ] = port |
| 1929 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1930 | vlan_id, id ) |
| 1931 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1932 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
| 1933 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
| 1934 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1935 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
| 1936 | # add vlan flow table |
| 1937 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1938 | # add termination flow |
| 1939 | if config["switch_type"] == "qmx": |
| 1940 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1941 | else: |
| 1942 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1943 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
| 1944 | if config["switch_type"] != 'xpliant': |
| 1945 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| 1946 | else: |
| 1947 | xpliant_add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| 1948 | dst_ip = dip + (vlan_id << 8) |
| 1949 | Groups._put( l2_gid ) |
| 1950 | Groups._put( mpls_gid ) |
| 1951 | Groups._put( mpls_label_gid ) |
| 1952 | #Groups._put( ecmp_gid ) |
| 1953 | do_barrier( self.controller ) |
| 1954 | |
| 1955 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1956 | for in_port in ports: |
| 1957 | ip_src = '192.168.%02d.1' % (in_port) |
| 1958 | for out_port in ports: |
| 1959 | if in_port == out_port: |
| 1960 | continue |
| 1961 | |
| 1962 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1963 | out_mpls_label = out_port + 16 |
| 1964 | in_vlan_vid = in_port + 16 |
| 1965 | out_vlan_vid = out_port + 16 |
| 1966 | |
| 1967 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1968 | label = (out_mpls_label, 0, 1, 32) |
| 1969 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 1970 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1971 | pkt = str( parsed_pkt ) |
| 1972 | self.dataplane.send( in_port, pkt ) |
| 1973 | |
| 1974 | # build expect packet |
| 1975 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1976 | label = (out_mpls_label, 0, 1, 31) |
| 1977 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 1978 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1979 | label=[ label ] ) |
| 1980 | pkt = str( exp_pkt ) |
| 1981 | verify_packet( self, pkt, out_port ) |
| 1982 | verify_no_other_packets( self ) |
| 1983 | finally: |
| 1984 | delete_all_flows( self.controller ) |
| 1985 | delete_groups( self.controller, Groups ) |
| 1986 | delete_all_groups( self.controller ) |
| 1987 | |
| 1988 | @disabled |
| 1989 | class _MplsTermination( base_tests.SimpleDataPlane ): |
| 1990 | """ Verify MPLS VPN Termination at penultimate hop """ |
| 1991 | |
| 1992 | def runTest( self ): |
| 1993 | Groups = Queue.LifoQueue( ) |
| 1994 | try: |
| 1995 | if len( config[ "port_map" ] ) < 2: |
| 1996 | logging.info( "Port count less than 2, can't run this case" ) |
| 1997 | return |
| 1998 | dip = 0xc0a80001 |
| 1999 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2000 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2001 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 2002 | ports = config[ "port_map" ].keys( ) |
| 2003 | for port in ports: |
| 2004 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2005 | vlan_id = port + 16 |
| 2006 | mpls_label = port + 16 |
| 2007 | |
| 2008 | # add l2 interface group |
| 2009 | id, dst_mac[ 5 ] = port, port |
| 2010 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 2011 | # add L3 Unicast group |
| 2012 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2013 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2014 | # add L3 ecmp group |
| 2015 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 2016 | # add vlan flow table |
| 2017 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2018 | # add termination flow |
| 2019 | if config["switch_type"] == "qmx": |
| 2020 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 2021 | else: |
| 2022 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 2023 | |
| 2024 | if config["switch_type"] != 'xpliant': |
| 2025 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 2026 | else: |
| 2027 | xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 2028 | |
| 2029 | # add_mpls_flow(self.controller, label=port) |
| 2030 | dst_ip = dip + (vlan_id << 8) |
| 2031 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
| 2032 | # ecmp_msg.group_id, 1) |
| 2033 | Groups._put( l2_gid ) |
| 2034 | Groups._put( l3_msg.group_id ) |
| 2035 | Groups._put( ecmp_msg.group_id ) |
| 2036 | do_barrier( self.controller ) |
| 2037 | |
| 2038 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2039 | for in_port in ports: |
| 2040 | ip_src = '192.168.%02d.1' % (in_port) |
| 2041 | for out_port in ports: |
| 2042 | if in_port == out_port: |
| 2043 | continue |
| 2044 | |
| 2045 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2046 | out_mpls_label = out_port + 16 |
| 2047 | in_vlan_vid = in_port + 16 |
| 2048 | out_vlan_vid = out_port + 16 |
| 2049 | |
| 2050 | ip_dst = '192.168.%02d.1' % (out_port) |
| 2051 | label = (out_mpls_label, 0, 1, 32) |
| 2052 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 2053 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 2054 | pkt = str( parsed_pkt ) |
| 2055 | self.dataplane.send( in_port, pkt ) |
| 2056 | # build expect packet |
| 2057 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 2058 | if config["switch_type"] != 'xpliant': |
| 2059 | ip_ttl=31 |
| 2060 | else: |
| 2061 | ip_ttl=64 |
| 2062 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 2063 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=ip_ttl, ip_src=ip_src, ip_dst=ip_dst ) |
| 2064 | pkt = str( exp_pkt ) |
| 2065 | verify_packet( self, pkt, out_port ) |
| 2066 | verify_no_other_packets( self ) |
| 2067 | finally: |
| 2068 | delete_all_flows( self.controller ) |
| 2069 | delete_groups( self.controller, Groups ) |
| 2070 | delete_all_groups( self.controller ) |
| 2071 | |
| 2072 | |
| 2073 | @disabled |
| 2074 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 2075 | """ |
| 2076 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 2077 | """ |
| 2078 | |
| 2079 | def runTest( self ): |
| 2080 | Groups = Queue.LifoQueue( ) |
| 2081 | try: |
| 2082 | if len( config[ "port_map" ] ) < 2: |
| 2083 | logging.info( "Port count less than 2, can't run this case" ) |
| 2084 | return |
| 2085 | dip = 0xc0a80001 |
| 2086 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2087 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2088 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 2089 | ports = config[ "port_map" ].keys( ) |
| 2090 | inport = ports[0] |
| 2091 | outport = ports[1] |
| 2092 | |
| 2093 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2094 | invlan_id = inport + 16 |
| 2095 | outvlan_id = outport + 16 |
| 2096 | mpls_label = outport + 16 |
| 2097 | |
| 2098 | # add l2 interface group |
| 2099 | id, dst_mac[ 5 ] = inport, outport |
| 2100 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 2101 | # add L3 Unicast group |
| 2102 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 2103 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2104 | # add L3 ecmp group |
| 2105 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 2106 | # add vlan flow table |
| 2107 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2108 | # add tmac flow |
| 2109 | if config["switch_type"] == "qmx": |
| 2110 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 2111 | else: |
| 2112 | add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 2113 | # add mpls termination flow |
| 2114 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 2115 | Groups._put( l2_gid ) |
| 2116 | Groups._put( l3_msg.group_id ) |
| 2117 | Groups._put( ecmp_msg.group_id ) |
| 2118 | |
| 2119 | time.sleep(0.1) |
| 2120 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2121 | ip_src = '192.168.%02d.1' % (inport) |
| 2122 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2123 | out_mpls_label = outport + 16 |
| 2124 | in_vlan_vid = inport + 16 |
| 2125 | out_vlan_vid = outport + 16 |
| 2126 | |
| 2127 | ip_dst = '192.168.%02d.1' % (outport) |
| 2128 | label = (out_mpls_label, 0, 1, 32) |
| 2129 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 2130 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 2131 | pkt = str( parsed_pkt ) |
| 2132 | self.dataplane.send( inport, pkt ) |
| 2133 | # build expect packet |
| 2134 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 2135 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 2136 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 2137 | pkt = str( exp_pkt ) |
| 2138 | verify_packet( self, pkt, outport ) |
| 2139 | verify_no_other_packets( self ) |
| 2140 | finally: |
| 2141 | delete_all_flows( self.controller ) |
| 2142 | delete_groups( self.controller, Groups ) |
| 2143 | delete_all_groups( self.controller ) |
| 2144 | |
| 2145 | |
| 2146 | class FabricSW_OF__24UcastTagged_TC_0045( base_tests.SimpleDataPlane ): |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 2147 | """ To Verify the switch can perform IP forwarding on a /24 subnet using L2 Interface and L3 Unicast groups.""" |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2148 | |
| 2149 | def runTest( self ): |
| 2150 | Groups = Queue.LifoQueue( ) |
| 2151 | try: |
| 2152 | test_id = 26 |
| 2153 | if len( config[ "port_map" ] ) < 2: |
| 2154 | logging.info( "Port count less than 2, can't run this case" ) |
| 2155 | return |
| 2156 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2157 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2158 | dip = 0xc0a80001 |
| 2159 | ports = config[ "port_map" ].keys( ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2160 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 2161 | |
| 2162 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2163 | # add l2 interface group |
| 2164 | vlan_id = port + test_id |
| 2165 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2166 | is_tagged=True, send_barrier=False ) |
| 2167 | dst_mac[ 5 ] = vlan_id |
| 2168 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 2169 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2170 | # add vlan flow table |
| 2171 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2172 | # add termination flow |
| 2173 | if config["switch_type"] == "qmx": |
| 2174 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2175 | else: |
| 2176 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2177 | # add unicast routing flow |
| 2178 | dst_ip = dip + (vlan_id << 8) |
| 2179 | # def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False, priority = 1): |
| 2180 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 2181 | Groups.put( l2gid ) |
| 2182 | Groups.put( l3_msg.group_id ) |
| 2183 | do_barrier( self.controller ) |
| 2184 | |
| 2185 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2186 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2187 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2188 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2189 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2190 | if in_port == out_port: |
| 2191 | continue |
| 2192 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 2193 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2194 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2195 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2196 | pkt = str( parsed_pkt ) |
| 2197 | self.dataplane.send( in_port, pkt ) |
| 2198 | # build expected packet |
| 2199 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 2200 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2201 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2202 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2203 | pkt = str( exp_pkt ) |
| 2204 | verify_packet( self, pkt, out_port ) |
| 2205 | verify_no_other_packets( self ) |
| 2206 | finally: |
| 2207 | delete_all_flows( self.controller ) |
| 2208 | delete_groups( self.controller, Groups ) |
| 2209 | delete_all_groups( self.controller ) |
| 2210 | |
| 2211 | class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ): |
| 2212 | """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0""" |
| 2213 | |
| 2214 | def runTest( self ): |
| 2215 | Groups = Queue.LifoQueue( ) |
| 2216 | try: |
| 2217 | test_id = 27 |
| 2218 | if len( config[ "port_map" ] ) < 2: |
| 2219 | logging.info( "Port count less than 2, can't run this case" ) |
| 2220 | return |
| 2221 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2222 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2223 | dip = 0xc0a80001 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2224 | ports = sorted(config["port_map"].keys()) |
| 2225 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 2226 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2227 | # add l2 interface group |
| 2228 | vlan_id = port + test_id |
| 2229 | # add vlan flow table |
| 2230 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2231 | # add termination flow |
| 2232 | if config["switch_type"] == "qmx": |
| 2233 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2234 | else: |
| 2235 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2236 | # add unicast routing flow |
| 2237 | #dst ip = 10.0.0.0/8 |
| 2238 | dst_ip = 0x0a000000 |
| 2239 | add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 ) |
| 2240 | do_barrier( self.controller ) |
| 2241 | |
| 2242 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2243 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2244 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2245 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2246 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2247 | if in_port == out_port: |
| 2248 | continue |
| 2249 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 2250 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2251 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2252 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2253 | pkt = str( parsed_pkt ) |
| 2254 | self.dataplane.send( in_port, pkt ) |
| 2255 | # build expected packet |
| 2256 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 2257 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2258 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2259 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2260 | pkt = str( exp_pkt ) |
| 2261 | verify_no_packet( self, pkt, out_port ) |
| 2262 | verify_no_other_packets( self ) |
| 2263 | finally: |
| 2264 | delete_all_flows( self.controller ) |
| 2265 | delete_groups( self.controller, Groups ) |
| 2266 | delete_all_groups( self.controller ) |
| 2267 | |
| 2268 | |
| 2269 | class _0Ucast( base_tests.SimpleDataPlane ): |
| 2270 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
| 2271 | |
| 2272 | def runTest( self ): |
| 2273 | Groups = Queue.LifoQueue( ) |
| 2274 | try: |
| 2275 | if len( config[ "port_map" ] ) < 2: |
| 2276 | logging.info( "Port count less than 2, can't run this case" ) |
| 2277 | return |
| 2278 | |
| 2279 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2280 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2281 | dip = 0xc0a80001 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2282 | ports = sorted(config["port_map"].keys()) |
| 2283 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 2284 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2285 | # add l2 interface group |
| 2286 | vlan_id = port |
| 2287 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 2288 | is_tagged=True, send_barrier=False ) |
| 2289 | dst_mac[ 5 ] = vlan_id |
| 2290 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 2291 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2292 | # add vlan flow table |
| 2293 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2294 | # add termination flow |
| 2295 | if config["switch_type"] == "qmx": |
| 2296 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2297 | else: |
| 2298 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2299 | # add unicast routing flow |
| 2300 | dst_ip = dip + (vlan_id << 8) |
| 2301 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id, priority=2 ) |
| 2302 | Groups.put( l2gid ) |
| 2303 | Groups.put( l3_msg.group_id ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2304 | l3_gid = encode_l3_unicast_group_id( pair[ 0 ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2305 | dst_ip = 0x0 |
| 2306 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 2307 | do_barrier( self.controller ) |
| 2308 | |
| 2309 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2310 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2311 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 2312 | ip_src = '192.168.%02d.1' % (in_port) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2313 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2314 | if in_port == out_port: |
| 2315 | continue |
| 2316 | ip_dst = '192.168.%02d.1' % (out_port) |
| 2317 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 2318 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2319 | pkt = str( parsed_pkt ) |
| 2320 | self.dataplane.send( in_port, pkt ) |
| 2321 | # build expected packet |
| 2322 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 2323 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 2324 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2325 | pkt = str( exp_pkt ) |
| 2326 | verify_packet( self, pkt, out_port ) |
| 2327 | verify_no_other_packets( self ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2328 | ip_dst = '1.168.%02d.1' % pair[ 0 ] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2329 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 2330 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2331 | pkt = str( parsed_pkt ) |
| 2332 | self.dataplane.send( in_port, pkt ) |
| 2333 | # build expect packet |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2334 | mac_dst = '00:00:00:22:22:%02X' % pair[ 0 ] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2335 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 2336 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 2337 | pkt = str( exp_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2338 | verify_packet( self, pkt, pair[ 0 ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2339 | verify_no_other_packets( self ) |
| 2340 | finally: |
| 2341 | delete_all_flows( self.controller ) |
| 2342 | delete_groups( self.controller, Groups ) |
| 2343 | delete_all_groups( self.controller ) |
| 2344 | |
| 2345 | |
| 2346 | class Unfiltered( base_tests.SimpleDataPlane ): |
| 2347 | """ |
| 2348 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
| 2349 | """ |
| 2350 | |
| 2351 | def runTest( self ): |
| 2352 | try: |
| 2353 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2354 | vlan_id = 1; |
| 2355 | for port in ports: |
| 2356 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 2357 | do_barrier( self.controller ) |
| 2358 | finally: |
| 2359 | delete_all_flows( self.controller ) |
| 2360 | delete_all_groups( self.controller ) |
| 2361 | |
| 2362 | @disabled |
| 2363 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
| 2364 | """ |
| 2365 | Mcast routing and VPN initiation |
| 2366 | """ |
| 2367 | |
| 2368 | def runTest( self ): |
| 2369 | """ |
| 2370 | port1 (vlan 1)-> port 2 (vlan 2) |
| 2371 | """ |
| 2372 | try: |
| 2373 | delete_all_flows( self.controller ) |
| 2374 | delete_all_groups( self.controller ) |
| 2375 | |
| 2376 | if len( config[ "port_map" ] ) < 3: |
| 2377 | logging.info( "Port count less than 3, can't run this case" ) |
| 2378 | assert (False) |
| 2379 | return |
| 2380 | |
| 2381 | vlan_id = 1 |
| 2382 | port2_out_vlan = 2 |
| 2383 | port3_out_vlan = 3 |
| 2384 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 2385 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2386 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2387 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2388 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 2389 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 2390 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 2391 | src_ip = 0xc0a80101 |
| 2392 | src_ip_str = "192.168.1.1" |
| 2393 | dst_ip = 0xe0010101 |
| 2394 | dst_ip_str = "224.1.1.1" |
| 2395 | |
| 2396 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 2397 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 2398 | # port3=config["port_map"].keys()[2] |
| 2399 | |
| 2400 | # add l2 interface group |
| 2401 | for port in config[ "port_map" ].keys( ): |
| 2402 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 2403 | send_barrier=False ) |
| 2404 | # add vlan flow table |
| 2405 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2406 | vlan_id += 1 |
| 2407 | |
| 2408 | # add termination flow |
| 2409 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 2410 | vlan_id ) |
| 2411 | |
| 2412 | # add MPLS interface group |
| 2413 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 2414 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 2415 | port2_out_vlan, port2 ) |
| 2416 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 2417 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 2418 | # add L3VPN groups |
| 2419 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2420 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 2421 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 2422 | # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 2423 | # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
| 2424 | |
| 2425 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 2426 | add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
| 2427 | |
| 2428 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 2429 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 2430 | pkt = str( parsed_pkt ) |
| 2431 | self.dataplane.send( port1, pkt ) |
| 2432 | label = (12, 0, 1, 63) |
| 2433 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 2434 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 2435 | pkt = str( exp_pkt ) |
| 2436 | verify_packet( self, pkt, port2 ) |
| 2437 | # verify_packet(self, pkt, port3) |
| 2438 | verify_no_other_packets( self ) |
| 2439 | delete_all_groups( self.controller ) |
| 2440 | finally: |
| 2441 | delete_all_flows( self.controller ) |
| 2442 | delete_all_groups( self.controller ) |
| 2443 | |
| 2444 | @disabled |
| 2445 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
| 2446 | """ |
| 2447 | Test packet in function on a src-mac miss |
| 2448 | Send a packet to each dataplane port and verify that a packet |
| 2449 | in message is received from the controller for each |
| 2450 | #todo verify you stop receiving after adding rule |
| 2451 | """ |
| 2452 | |
| 2453 | def runTest( self ): |
| 2454 | Groups = Queue.LifoQueue( ) |
| 2455 | try: |
| 2456 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2457 | |
| 2458 | Groups = Queue.LifoQueue( ) |
| 2459 | for port in ports: |
| 2460 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 2461 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2462 | Groups.put( L2gid ) |
| 2463 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 2464 | vlan_pkt = str( parsed_vlan_pkt ) |
| 2465 | for of_port in config[ "port_map" ].keys( ): |
| 2466 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 2467 | self.dataplane.send( of_port, vlan_pkt ) |
| 2468 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 2469 | verify_no_other_packets( self ) |
| 2470 | finally: |
| 2471 | delete_all_flows( self.controller ) |
| 2472 | delete_all_groups( self.controller ) |
| 2473 | |
| 2474 | |
| 2475 | class FabricSW_OF_EcmpGroupMod_TC_0025( base_tests.SimpleDataPlane ): |
| 2476 | """ |
| 2477 | Verify referenced group can be modified by adding or removing buckets |
| 2478 | """ |
| 2479 | |
| 2480 | def runTest( self ): |
| 2481 | Groups = Queue.LifoQueue( ) |
| 2482 | try: |
| 2483 | if len( config[ "port_map" ] ) < 2: |
| 2484 | logging.info( "Port count less than 2, can't run this case" ) |
| 2485 | return |
| 2486 | |
| 2487 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2488 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2489 | dip = 0xc0a80001 |
| 2490 | # Hashes Test Name and uses it as id for installing unique groups |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2491 | ports = sorted(config["port_map"].keys()) |
| 2492 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2493 | ecmp = [ ] |
| 2494 | dst_ips = [] |
| 2495 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2496 | # in the ecmp group |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2497 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2498 | vlan_id = port |
| 2499 | id = port |
| 2500 | # add l2 interface group |
| 2501 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2502 | is_tagged=True, send_barrier=False ) |
| 2503 | dst_mac[ 5 ] = vlan_id |
| 2504 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2505 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2506 | if port == pair[1]: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2507 | ecmp += [ l3_msg.group_id ] |
| 2508 | Groups._put( l2_gid ) |
| 2509 | Groups._put( l3_msg.group_id ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2510 | ecmp_msg = add_l3_ecmp_group( self.controller, pair[ 0 ], [ l3_msg.group_id ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2511 | # add vlan flow table |
| 2512 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2513 | # add termination flow |
| 2514 | if config["switch_type"] == "qmx": |
| 2515 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2516 | else: |
| 2517 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2518 | # add unicast routing flow |
| 2519 | dst_ip = dip + (vlan_id << 8) |
| 2520 | dst_ips += [dst_ip] |
| 2521 | Groups._put( ecmp_msg.group_id ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2522 | mod_l3_ecmp_group( self.controller, pair[ 0 ], ecmp ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2523 | for dst_ip in dst_ips: |
| 2524 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2525 | do_barrier(self.controller) |
| 2526 | time.sleep(0.1) |
| 2527 | # first part of the test: send packet from ingress switchport and expect it at egress switchport |
| 2528 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2529 | parsed_pkt = exp_pkt = 0 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2530 | in_port = pair[0] |
| 2531 | out_port = pair[1] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2532 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2533 | mac_src = '00:00:00:22:22:%02X' % pair[ 0 ] |
| 2534 | ip_src = '192.168.%02d.%02d' % (pair[ 0 ], 1) |
| 2535 | ip_dst = '192.168.%02d.%02d' % (pair[ 1 ], 1) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2536 | tcp = out_port if out_port == 24 else 25 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2537 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=pair[ 0 ], |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2538 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2539 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2540 | pkt = str( parsed_pkt ) |
| 2541 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2542 | # build expected packet at egress switchport |
| 2543 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2544 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2545 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2546 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2547 | pkt = str( exp_pkt ) |
| 2548 | verify_packet( self, pkt, out_port ) |
| 2549 | verify_no_other_packets( self ) |
| 2550 | |
| 2551 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2552 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2553 | # it back on the ingress switchport |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2554 | l3_gid = encode_l3_unicast_group_id( pair[ 0 ] ) |
| 2555 | mod_l3_ecmp_group( self.controller, pair[ 0 ], [ l3_gid ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2556 | time.sleep(0.1) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2557 | logging.info("Sending packet to port: " + str(pair[0]) + ", expected egress on port: " + str(pair[0])) |
| 2558 | mac_src = '00:00:00:22:22:%02X' % pair[ 0 ] |
| 2559 | ip_src = '192.168.%02d.%02d' % (pair[ 0 ], 1) |
| 2560 | ip_dst = '192.168.%02d.%02d' % (pair[ 1 ], 1) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2561 | tcp = port if port == 24 else 25 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2562 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=pair[ 0 ], |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2563 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2564 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2565 | pkt = str( parsed_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2566 | self.dataplane.send( pair[ 0 ], pkt ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2567 | # build expected packet |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2568 | mac_dst = '00:00:00:22:22:%02X' % pair[ 0 ] |
| 2569 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=pair[ 0 ], |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2570 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2571 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2572 | # Expects packet on the input port |
| 2573 | if config["switch_type"] != 'xpliant': |
| 2574 | pkt = str( exp_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2575 | verify_packet( self, pkt, pair[ 0 ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2576 | verify_no_other_packets( self ) |
| 2577 | |
| 2578 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2579 | # should be dropped by the switch |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2580 | mod_l3_ecmp_group( self.controller, pair[ 0 ], [ ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2581 | time.sleep(0.1) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2582 | logging.info("Sending packet to port: " + str(pair[0]) + ", expected drop") |
| 2583 | mac_src = '00:00:00:22:22:%02X' % pair[ 0 ] |
| 2584 | ip_src = '192.168.%02d.%02d' % (pair[ 0 ], 1) |
| 2585 | ip_dst = '192.168.%02d.%02d' % (pair[ 1 ], 1) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2586 | tcp = port if port == 24 else 25 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2587 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=pair[ 0 ], |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2588 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2589 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2590 | pkt = str( parsed_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2591 | self.dataplane.send( pair[ 0 ], pkt ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2592 | verify_no_other_packets( self ) |
| 2593 | |
| 2594 | # final part of the test - edit the empty group to add back the bucket for the |
| 2595 | # original egress port, and verify packet is received on egress switch port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2596 | l3_gid = encode_l3_unicast_group_id( pair[ 1 ] ) |
| 2597 | mod_l3_ecmp_group( self.controller, pair[ 0 ], [ l3_gid ] ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2598 | do_barrier(self.controller) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2599 | in_port = pair[0] |
| 2600 | out_port = pair[1] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2601 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2602 | mac_src = '00:00:00:22:22:%02X' % pair[ 0 ] |
| 2603 | ip_src = '192.168.%02d.%02d' % (pair[ 0 ], 1) |
| 2604 | ip_dst = '192.168.%02d.%02d' % (pair[ 1 ], 1) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2605 | tcp = out_port if out_port == 24 else 25 |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2606 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=pair[ 0 ], |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2607 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2608 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2609 | pkt = str( parsed_pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2610 | self.dataplane.send( pair[ 0 ], pkt ) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2611 | # build expected packet at egress switchport |
| 2612 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2613 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2614 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2615 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2616 | pkt = str( exp_pkt ) |
| 2617 | verify_packet( self, pkt, out_port ) |
| 2618 | verify_no_other_packets( self ) |
| 2619 | |
| 2620 | finally: |
| 2621 | delete_all_flows( self.controller ) |
| 2622 | delete_groups( self.controller, Groups ) |
| 2623 | delete_all_groups( self.controller ) |
| 2624 | |
| 2625 | |
| 2626 | class Untagged( base_tests.SimpleDataPlane ): |
| 2627 | """ |
| 2628 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2629 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2630 | previous versions of the OFDPA. |
| 2631 | |
| 2632 | Two rules are necessary in VLAN table (10): |
| 2633 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2634 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2635 | |
| 2636 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2637 | The remaining part of the test is based on the use of the bridging table |
| 2638 | """ |
| 2639 | |
| 2640 | MAX_INTERNAL_VLAN = 4094 |
| 2641 | |
| 2642 | def runTest( self ): |
| 2643 | groups = Queue.LifoQueue( ) |
| 2644 | try: |
| 2645 | if len( config[ "port_map" ] ) < 2: |
| 2646 | logging.info( "Port count less than 2, can't run this case" ) |
| 2647 | return |
| 2648 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2649 | ports = sorted(config["port_map"].keys()) |
| 2650 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 2651 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2652 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
| 2653 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2654 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2655 | for other_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2656 | if other_port == port: |
| 2657 | continue |
| 2658 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2659 | groups.put( L2gid ) |
| 2660 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2661 | |
| 2662 | do_barrier( self.controller ) |
| 2663 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2664 | for out_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2665 | # change dest based on port number |
| 2666 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2667 | for in_port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2668 | if in_port == out_port: |
| 2669 | continue |
| 2670 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2671 | self.dataplane.send( in_port, pkt ) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 2672 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 2673 | if ofport in [ out_port ]: |
| 2674 | verify_packet( self, pkt, ofport ) |
| 2675 | else: |
| 2676 | verify_no_packet( self, pkt, ofport ) |
| 2677 | verify_no_other_packets( self ) |
| 2678 | finally: |
| 2679 | delete_all_flows( self.controller ) |
| 2680 | delete_groups( self.controller, groups ) |
| 2681 | delete_all_groups( self.controller ) |
| 2682 | |
| 2683 | class MPLSSwapTest( base_tests.SimpleDataPlane ): |
| 2684 | """ |
| 2685 | MPLS switching with the same label used. |
| 2686 | Used for interconnecting spines between different fabrics where |
| 2687 | the label should not be popped, but swapepd with the same label. |
| 2688 | """ |
| 2689 | |
| 2690 | def runTest( self ): |
| 2691 | try: |
| 2692 | delete_all_flows( self.controller ) |
| 2693 | delete_all_groups( self.controller ) |
| 2694 | |
| 2695 | if len( config[ "port_map" ] ) < 2: |
| 2696 | logging.info( "Port count less than 3, can't run this case" ) |
| 2697 | assert (False) |
| 2698 | return |
| 2699 | |
| 2700 | input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2701 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2702 | |
| 2703 | input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ] |
| 2704 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2705 | |
| 2706 | output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ] |
| 2707 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2708 | |
| 2709 | mpls_label = 1000 |
| 2710 | |
| 2711 | src_ip = 0xc0a80101 |
| 2712 | src_ip_str = "192.168.1.1" |
| 2713 | dst_ip = 0xe0010101 |
| 2714 | dst_ip_str = "224.1.1.1" |
| 2715 | |
| 2716 | src_port = config[ "port_map" ].keys( )[ 0 ] |
| 2717 | dst_port = config[ "port_map" ].keys( )[ 1 ] |
| 2718 | |
| 2719 | out_vlan = 4094 |
| 2720 | |
| 2721 | add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False, |
| 2722 | send_barrier=True ) |
| 2723 | |
| 2724 | # add vlan flow table |
| 2725 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2726 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2727 | |
| 2728 | # add termination flow |
| 2729 | |
| 2730 | if config["switch_type"] == "qmx": |
| 2731 | logging.debug("MPLSSwitching : Adding flow for qmx, without input port") |
| 2732 | add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2733 | else: |
| 2734 | add_termination_flow( self.controller, in_port=src_port, |
| 2735 | eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2736 | |
| 2737 | # add groups that will be used now |
| 2738 | l2_gid = encode_l2_interface_group_id( out_vlan, dst_port) |
| 2739 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, |
| 2740 | output_dst_mac, input_dst_mac, |
| 2741 | out_vlan, dst_port, send_barrier=True) |
| 2742 | index = 60 |
| 2743 | mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid, |
| 2744 | 5, index, mpls_label) |
| 2745 | |
| 2746 | # add flow to mpls table |
| 2747 | add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True) |
| 2748 | |
| 2749 | # we generate the packet which carries a single label |
| 2750 | label = (mpls_label, 0, 1, 63) |
| 2751 | parsed_pkt = mpls_packet( |
| 2752 | pktlen=104, |
| 2753 | label=[label], |
| 2754 | eth_src=input_src_mac_str, |
| 2755 | eth_dst=input_dst_mac_str, |
| 2756 | ) |
| 2757 | pkt = str( parsed_pkt ) |
| 2758 | |
| 2759 | self.dataplane.send( src_port, pkt ) |
| 2760 | |
| 2761 | label = (mpls_label, 0, 1, 62) |
| 2762 | parsed_pkt = mpls_packet( |
| 2763 | pktlen=104, |
| 2764 | label=[label], |
| 2765 | eth_src=input_dst_mac_str, |
| 2766 | eth_dst=output_dst_mac_str, |
| 2767 | ) |
| 2768 | pkt = str( parsed_pkt ) |
| 2769 | |
| 2770 | verify_packet( self, pkt, dst_port ) |
| 2771 | verify_no_packet( self, pkt, src_port ) |
| 2772 | verify_no_other_packets( self ) |
| 2773 | |
| 2774 | delete_all_flows( self.controller ) |
| 2775 | delete_all_groups( self.controller ) |
| 2776 | |
| 2777 | finally: |
| 2778 | delete_all_flows( self.controller ) |
| 2779 | delete_all_groups( self.controller ) |
| 2780 | |
| 2781 | @disabled |
| 2782 | class DoubleToUntagged( base_tests.SimpleDataPlane ): |
| 2783 | """ |
| 2784 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2785 | where we receive double tagged packets and output untagged |
| 2786 | packets. |
| 2787 | |
| 2788 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2789 | and inner tag is the subrscriber tag. |
| 2790 | """ |
| 2791 | |
| 2792 | def runTest( self ): |
| 2793 | Groups = Queue.LifoQueue( ) |
| 2794 | try: |
| 2795 | if len( config[ "port_map" ] ) < 2: |
| 2796 | logging.info( "Port count less than 2, can't run this case" ) |
| 2797 | return |
| 2798 | |
| 2799 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2800 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2801 | |
| 2802 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2803 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2804 | |
| 2805 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2806 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2807 | |
| 2808 | dip = 0xc0a80001 |
| 2809 | ports = config[ "port_map" ].keys( ) |
| 2810 | |
| 2811 | inner_vlan = 66 |
| 2812 | outer_vlan = 77 |
| 2813 | id = 10 |
| 2814 | mpls_label = 152 |
| 2815 | |
| 2816 | port = ports[0] |
| 2817 | out_port = ports[1] |
| 2818 | |
| 2819 | # add l2 interface group |
| 2820 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2821 | |
| 2822 | # add MPLS interface group |
| 2823 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2824 | inner_vlan, id ) |
| 2825 | |
| 2826 | # add MPLS L3 VPN group |
| 2827 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2828 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2829 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2830 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2831 | |
| 2832 | do_barrier( self.controller ) |
| 2833 | |
| 2834 | # add vlan flow table |
| 2835 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2836 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2837 | |
| 2838 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2839 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2840 | |
| 2841 | # add termination flow |
| 2842 | if config["switch_type"] == "qmx": |
| 2843 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2844 | else: |
| 2845 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2846 | |
| 2847 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2848 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2849 | vrf=0 ) |
| 2850 | Groups._put( l2_gid ) |
| 2851 | Groups._put( mpls_gid ) |
| 2852 | Groups._put( mpls_label_gid ) |
| 2853 | Groups._put( ecmp_msg.group_id ) |
| 2854 | |
| 2855 | do_barrier( self.controller ) |
| 2856 | |
| 2857 | ip_src = '192.168.5.5' |
| 2858 | ip_dst = '192.168.0.5' |
| 2859 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2860 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2861 | pkt = str( parsed_pkt ) |
| 2862 | |
| 2863 | # print("Expected %s" % format_packet(pkt)) |
| 2864 | |
| 2865 | self.dataplane.send( port, pkt ) |
| 2866 | |
| 2867 | # build expect packet |
| 2868 | label = (mpls_label, 0, 1, 32) |
| 2869 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2870 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2871 | label=[ label ] ) |
| 2872 | pkt = str( exp_pkt ) |
| 2873 | verify_packet( self, pkt, out_port ) |
| 2874 | verify_no_other_packets( self ) |
| 2875 | |
| 2876 | finally: |
| 2877 | delete_all_flows( self.controller ) |
| 2878 | delete_groups( self.controller, Groups ) |
| 2879 | delete_all_groups( self.controller ) |
| 2880 | |
| 2881 | @disabled |
| 2882 | class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ): |
| 2883 | """ |
| 2884 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2885 | where we receive double tagged packets and output untagged |
| 2886 | packets. |
| 2887 | |
| 2888 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2889 | and inner tag is the subrscriber tag. |
| 2890 | """ |
| 2891 | |
| 2892 | def runTest( self ): |
| 2893 | Groups = Queue.LifoQueue( ) |
| 2894 | try: |
| 2895 | if len( config[ "port_map" ] ) < 2: |
| 2896 | logging.info( "Port count less than 2, can't run this case" ) |
| 2897 | return |
| 2898 | |
| 2899 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 2900 | subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"], |
| 2901 | [20, 0xc0a80002, 10, 101, "192.168.0.2"], |
| 2902 | [30, 0xc0a80003, 11, 100, "192.168.0.3"], |
| 2903 | [40, 0xc0a80004, 11, 101, "192.168.0.4"]] |
| 2904 | |
| 2905 | print("") |
| 2906 | |
| 2907 | for sub_info in subscriber_info: |
| 2908 | |
| 2909 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 2910 | |
| 2911 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2912 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2913 | |
| 2914 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2915 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2916 | |
| 2917 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2918 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2919 | |
| 2920 | dip = sub_info[1] |
| 2921 | ports = config[ "port_map" ].keys( ) |
| 2922 | |
| 2923 | inner_vlan = sub_info[2] |
| 2924 | outer_vlan = sub_info[3] |
| 2925 | id = 10 |
| 2926 | mpls_label = 152 |
| 2927 | |
| 2928 | port = ports[0] |
| 2929 | out_port = ports[1] |
| 2930 | |
| 2931 | # add l2 interface group |
| 2932 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2933 | |
| 2934 | # add MPLS interface group |
| 2935 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2936 | inner_vlan, id ) |
| 2937 | |
| 2938 | # add MPLS L3 VPN group |
| 2939 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2940 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2941 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2942 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2943 | |
| 2944 | do_barrier( self.controller ) |
| 2945 | |
| 2946 | # add vlan flow table |
| 2947 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2948 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2949 | |
| 2950 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2951 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2952 | |
| 2953 | # add termination flow |
| 2954 | if config["switch_type"] == "qmx": |
| 2955 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2956 | else: |
| 2957 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2958 | |
| 2959 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2960 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2961 | vrf=0 ) |
| 2962 | Groups._put( l2_gid ) |
| 2963 | Groups._put( mpls_gid ) |
| 2964 | Groups._put( mpls_label_gid ) |
| 2965 | Groups._put( ecmp_msg.group_id ) |
| 2966 | |
| 2967 | do_barrier( self.controller ) |
| 2968 | |
| 2969 | for sub_info in subscriber_info: |
| 2970 | |
| 2971 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 2972 | |
| 2973 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2974 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2975 | |
| 2976 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2977 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2978 | |
| 2979 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2980 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2981 | |
| 2982 | dip = sub_info[1] |
| 2983 | ports = config[ "port_map" ].keys( ) |
| 2984 | |
| 2985 | inner_vlan = sub_info[2] |
| 2986 | outer_vlan = sub_info[3] |
| 2987 | id = 10 |
| 2988 | mpls_label = 152 |
| 2989 | |
| 2990 | port = ports[0] |
| 2991 | out_port = ports[1] |
| 2992 | |
| 2993 | ip_src = sub_info[4] |
| 2994 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 2995 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2996 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2997 | pkt = str( parsed_pkt ) |
| 2998 | |
| 2999 | # print("Sent %s" % format_packet(pkt)) |
| 3000 | |
| 3001 | self.dataplane.send( port, pkt ) |
| 3002 | |
| 3003 | # build expect packet |
| 3004 | label = (mpls_label, 0, 1, 32) |
| 3005 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 3006 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 3007 | label=[ label ] ) |
| 3008 | pkt = str( exp_pkt ) |
| 3009 | verify_packet( self, pkt, out_port ) |
| 3010 | verify_no_other_packets( self ) |
| 3011 | |
| 3012 | finally: |
| 3013 | delete_all_flows( self.controller ) |
| 3014 | delete_groups( self.controller, Groups ) |
| 3015 | delete_all_groups( self.controller ) |
| 3016 | |
| 3017 | |
| 3018 | @disabled |
| 3019 | class UntaggedToDouble ( base_tests.SimpleDataPlane ): |
| 3020 | """ |
| 3021 | Verify google senario where we need to go from |
| 3022 | an untagged packet to a double tagged packet. |
| 3023 | |
| 3024 | This is used for a single subscriber. |
| 3025 | """ |
| 3026 | |
| 3027 | def runTest( self ): |
| 3028 | Groups = Queue.LifoQueue( ) |
| 3029 | try: |
| 3030 | if len( config[ "port_map" ] ) < 2: |
| 3031 | logging.info( "Port count less than 2, can't run this case" ) |
| 3032 | return |
| 3033 | |
| 3034 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3035 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3036 | |
| 3037 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3038 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3039 | |
| 3040 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3041 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3042 | |
| 3043 | dip = 0xc0a80001 |
| 3044 | ports = config[ "port_map" ].keys( ) |
| 3045 | |
| 3046 | inner_vlan = 66 |
| 3047 | outer_vlan = 77 |
| 3048 | id = 10 |
| 3049 | mpls_label = 152 |
| 3050 | |
| 3051 | port = ports[0] |
| 3052 | out_port = ports[1] |
| 3053 | |
| 3054 | # add l2 unfiltered interface group |
| 3055 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3056 | |
| 3057 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 3058 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3059 | |
| 3060 | do_barrier( self.controller ) |
| 3061 | |
| 3062 | # add vlan flow table |
| 3063 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3064 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3065 | |
| 3066 | # add termination flow |
| 3067 | if config["switch_type"] == "qmx": |
| 3068 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3069 | else: |
| 3070 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3071 | |
| 3072 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3073 | vrf=0 ) |
| 3074 | |
| 3075 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 3076 | |
| 3077 | Groups._put( l2_gid ) |
| 3078 | Groups._put( l3_msg.group_id ) |
| 3079 | |
| 3080 | do_barrier( self.controller ) |
| 3081 | |
| 3082 | ip_src = '192.168.5.5' |
| 3083 | ip_dst = '192.168.0.1' |
| 3084 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 3085 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3086 | pkt = str( parsed_pkt ) |
| 3087 | |
| 3088 | # print("Input Packet %s" % format_packet(pkt)) |
| 3089 | |
| 3090 | self.dataplane.send( port, pkt ) |
| 3091 | |
| 3092 | # build expect packet |
| 3093 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 3094 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 3095 | pkt = str( exp_pkt ) |
| 3096 | |
| 3097 | # print("Expected Packet %s" % format_packet(pkt)) |
| 3098 | |
| 3099 | verify_packet( self, pkt, out_port ) |
| 3100 | verify_no_other_packets( self ) |
| 3101 | finally: |
| 3102 | delete_all_flows( self.controller ) |
| 3103 | delete_groups( self.controller, Groups ) |
| 3104 | delete_all_groups( self.controller ) |
| 3105 | |
| 3106 | @disabled |
| 3107 | class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ): |
| 3108 | """ |
| 3109 | Verify google senario where we need to go from |
| 3110 | an untagged packet to a double tagged packet. |
| 3111 | |
| 3112 | This is used for multiple subscribers. |
| 3113 | |
| 3114 | However, this solution does not scale, since we assign an internal vlan to each subscriber |
| 3115 | used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table. |
| 3116 | """ |
| 3117 | |
| 3118 | def runTest( self ): |
| 3119 | Groups = Queue.LifoQueue( ) |
| 3120 | try: |
| 3121 | if len( config[ "port_map" ] ) < 2: |
| 3122 | logging.info( "Port count less than 2, can't run this case" ) |
| 3123 | return |
| 3124 | |
| 3125 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan] |
| 3126 | subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000], |
| 3127 | [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001], |
| 3128 | [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002], |
| 3129 | [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]] |
| 3130 | |
| 3131 | print("") |
| 3132 | |
| 3133 | for sub_info in subscriber_info: |
| 3134 | |
| 3135 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 3136 | |
| 3137 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3138 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3139 | |
| 3140 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3141 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3142 | |
| 3143 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3144 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3145 | |
| 3146 | dip = sub_info[1] |
| 3147 | ports = config[ "port_map" ].keys( ) |
| 3148 | |
| 3149 | inner_vlan = sub_info[2] |
| 3150 | outer_vlan = sub_info[3] |
| 3151 | internal_vlan = sub_info[5] |
| 3152 | id = sub_info[0] + 10 |
| 3153 | |
| 3154 | port = ports[0] |
| 3155 | out_port = ports[1] |
| 3156 | |
| 3157 | # add l2 unfiltered interface group |
| 3158 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3159 | |
| 3160 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id, |
| 3161 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3162 | |
| 3163 | do_barrier( self.controller ) |
| 3164 | |
| 3165 | # add vlan flow table |
| 3166 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3167 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3168 | |
| 3169 | # add termination flow |
| 3170 | if config["switch_type"] == "qmx": |
| 3171 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3172 | else: |
| 3173 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3174 | |
| 3175 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3176 | vrf=0 ) |
| 3177 | |
| 3178 | add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan) |
| 3179 | |
| 3180 | Groups._put( l2_gid ) |
| 3181 | Groups._put( l3_msg.group_id ) |
| 3182 | do_barrier( self.controller ) |
| 3183 | |
| 3184 | for sub_info in subscriber_info: |
| 3185 | |
| 3186 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 3187 | |
| 3188 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3189 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3190 | |
| 3191 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3192 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3193 | |
| 3194 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3195 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3196 | |
| 3197 | dip = sub_info[1] |
| 3198 | ports = config[ "port_map" ].keys( ) |
| 3199 | |
| 3200 | inner_vlan = sub_info[2] |
| 3201 | outer_vlan = sub_info[3] |
| 3202 | internal_vlan = sub_info[5] |
| 3203 | |
| 3204 | id = sub_info[0] + 10 |
| 3205 | ip_src = '192.168.5.5' |
| 3206 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3207 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 3208 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3209 | pkt = str( parsed_pkt ) |
| 3210 | |
| 3211 | # print("Input Packet %s" % format_packet(pkt)) |
| 3212 | |
| 3213 | self.dataplane.send( port, pkt ) |
| 3214 | |
| 3215 | # build expect packet |
| 3216 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 3217 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 3218 | pkt = str( exp_pkt ) |
| 3219 | |
| 3220 | # print("Expected Packet %s" % format_packet(pkt)) |
| 3221 | |
| 3222 | verify_packet( self, pkt, out_port ) |
| 3223 | verify_no_other_packets( self ) |
| 3224 | finally: |
| 3225 | delete_all_flows( self.controller ) |
| 3226 | delete_groups( self.controller, Groups ) |
| 3227 | delete_all_groups( self.controller ) |
| 3228 | |
| 3229 | @disabled |
| 3230 | class UntaggedToDoubleChangeEthertype ( base_tests.SimpleDataPlane ): |
| 3231 | |
| 3232 | def runTest( self ): |
| 3233 | Groups = Queue.LifoQueue() |
| 3234 | |
| 3235 | try: |
| 3236 | if len( config[ "port_map" ] ) < 2: |
| 3237 | logging.info( "port count less than 2, can't run this case" ) |
| 3238 | return |
| 3239 | |
| 3240 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3241 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3242 | |
| 3243 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3244 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3245 | |
| 3246 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3247 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3248 | |
| 3249 | dip = 0xc0a80001 |
| 3250 | ports = config[ "port_map" ].keys( ) |
| 3251 | |
| 3252 | inner_vlan = 66 |
| 3253 | outer_vlan = 77 |
| 3254 | id = 10 |
| 3255 | |
| 3256 | port = ports[0] |
| 3257 | out_port = ports[1] |
| 3258 | |
| 3259 | # add l2 unfiltered interface group |
| 3260 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3261 | |
| 3262 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 3263 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3264 | |
| 3265 | do_barrier( self.controller ) |
| 3266 | |
| 3267 | # add vlan flow table |
| 3268 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3269 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3270 | |
| 3271 | # add termination flow |
| 3272 | if config["switch_type"] == "qmx": |
| 3273 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3274 | else: |
| 3275 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3276 | |
| 3277 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3278 | vrf=0 ) |
| 3279 | |
| 3280 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 3281 | |
| 3282 | Groups._put( l2_gid ) |
| 3283 | Groups._put( l3_msg.group_id ) |
| 3284 | |
| 3285 | # add vlan flow table |
| 3286 | add_one_egress_vlan_tpid_table_flow( self.controller, out_port, outer_vlan+0x1000 ) |
| 3287 | do_barrier( self.controller ) |
| 3288 | |
| 3289 | ip_src = '192.168.5.5' |
| 3290 | ip_dst = '192.168.0.1' |
| 3291 | parsed_pkt = simple_tcp_packet( pktlen=100, |
| 3292 | dl_vlan_enable=False, |
| 3293 | eth_dst=input_dst_mac_str, |
| 3294 | eth_src=input_src_mac_str, |
| 3295 | ip_ttl=64, |
| 3296 | ip_src=ip_src, |
| 3297 | ip_dst=ip_dst ) |
| 3298 | pkt = str( parsed_pkt ) |
| 3299 | |
| 3300 | print("Input Packet %s" % format_packet(pkt)) |
| 3301 | |
| 3302 | self.dataplane.send( port, pkt ) |
| 3303 | |
| 3304 | # build expect packet |
| 3305 | exp_pkt = simple_tcp_packet_two_vlan( pktlen=108, |
| 3306 | out_dl_vlan_enable=True, |
| 3307 | out_vlan_vid=outer_vlan, |
| 3308 | out_vlan_tpid=0x88a8, |
| 3309 | in_dl_vlan_enable=True, |
| 3310 | in_vlan_vid=inner_vlan, |
| 3311 | eth_dst=output_dst_mac_str, |
| 3312 | eth_src=input_dst_mac_str, |
| 3313 | ip_ttl=63, |
| 3314 | ip_src=ip_src, |
| 3315 | ip_dst=ip_dst ) |
| 3316 | pkt = str( exp_pkt ) |
| 3317 | |
| 3318 | print("Expected Packet %s" % format_packet(pkt)) |
| 3319 | |
| 3320 | verify_packet( self, pkt, out_port ) |
| 3321 | verify_no_other_packets( self ) |
| 3322 | finally: |
| 3323 | delete_all_flows( self.controller ) |
| 3324 | delete_groups( self.controller, Groups ) |
| 3325 | delete_all_groups( self.controller ) |
| 3326 | |
| 3327 | @disabled |
| 3328 | class _MplsFwdInterfaceProblem_PW( base_tests.SimpleDataPlane ): |
| 3329 | """ |
| 3330 | Reproduces the pseudowire bug with the wrongly set destination mac address. |
| 3331 | """ |
| 3332 | def runTest( self ): |
| 3333 | Groups = Queue.LifoQueue( ) |
| 3334 | try: |
| 3335 | if len( config[ "port_map" ] ) < 1: |
| 3336 | logging.info( "Port count less than 1, can't run this case" ) |
| 3337 | assert (False) |
| 3338 | return |
| 3339 | |
| 3340 | 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'), |
| 3341 | ( [ 0x00, 0x00, 0x00, 0x11, 0x22, 0x00 ], [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ], '00:00:00:11:22:00', '00:00:00:33:33:00'), |
| 3342 | ( [ 0x00, 0x00, 0x00, 0x11, 0x33, 0x00 ], [ 0x00, 0x00, 0x00, 0x44, 0x44, 0x00 ], '00:00:00:11:33:00', '00:00:00:44:44:00'), |
| 3343 | ( [ 0x00, 0x00, 0x00, 0x11, 0x44, 0x00 ], [ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00 ], '00:00:00:11:44:00', '00:00:00:55:55:00'), |
| 3344 | ( [ 0x00, 0x00, 0x00, 0x11, 0x55, 0x00 ], [ 0x00, 0x00, 0x00, 0x66, 0x66, 0x00 ], '00:00:00:11:55:00', '00:00:00:66:66:00')] |
| 3345 | |
| 3346 | for dummy_dst_mac, dst_mac, mac_dst_dummy, mac_dst in macs_to_test: |
| 3347 | |
| 3348 | dip = 0xc0a80001 |
| 3349 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3350 | |
| 3351 | out_port = 12 |
| 3352 | port = 24 |
| 3353 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 3354 | vlan_id = port + 16 |
| 3355 | mpls_label = port + 16 |
| 3356 | |
| 3357 | in_port = 24 |
| 3358 | ip_src = '192.168.%02d.1' % (in_port) |
| 3359 | |
| 3360 | # create dummy groups |
| 3361 | id = port |
| 3362 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, vlan_id, False, False) |
| 3363 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dummy_dst_mac, intf_src_mac, |
| 3364 | vlan_id, id, send_barrier=True) |
| 3365 | do_barrier( self.controller ) |
| 3366 | |
| 3367 | # PW Case. |
| 3368 | raw_input("Press anything to move on with pseudowire rules, after that you should see the updated groups in the switch.") |
| 3369 | logging.info("Installing entries for pseudowire!") |
| 3370 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 3371 | mpls_label = 100 |
| 3372 | mpls_label_SR2 = 100 + 10 |
| 3373 | mpls_label_PW = 100 + 15 |
| 3374 | |
| 3375 | print("Install MPLS intf group for dst mac {0}", dst_mac) |
| 3376 | # add MPLS interface group |
| 3377 | mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group( |
| 3378 | ctrl=self.controller, |
| 3379 | ref_gid=l2_gid, |
| 3380 | dst_mac=dst_mac, |
| 3381 | src_mac=intf_src_mac, |
| 3382 | vid=vlan_id, |
| 3383 | index=id, |
| 3384 | add=False, |
| 3385 | send_barrier=True |
| 3386 | ) |
| 3387 | |
| 3388 | # add MPLS flow with BoS=0 |
| 3389 | add_mpls_flow_pw( |
| 3390 | ctrl=self.controller, |
| 3391 | action_group_id=mpls_intf_gid, |
| 3392 | label=mpls_label_SR2, |
| 3393 | ethertype=0x8847, |
| 3394 | tunnel_index=1, |
| 3395 | bos=0 |
| 3396 | ) |
| 3397 | |
| 3398 | # add Termination flow |
| 3399 | add_termination_flow( |
| 3400 | ctrl=self.controller, |
| 3401 | in_port=in_port, |
| 3402 | eth_type=0x8847, |
| 3403 | dst_mac=intf_src_mac, |
| 3404 | vlanid=vlan_id, |
| 3405 | goto_table=23 |
| 3406 | ) |
| 3407 | |
| 3408 | # add VLAN flows |
| 3409 | add_one_vlan_table_flow( |
| 3410 | ctrl=self.controller, |
| 3411 | of_port=in_port, |
| 3412 | vlan_id=vlan_id, |
| 3413 | flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 3414 | ) |
| 3415 | add_one_vlan_table_flow( |
| 3416 | ctrl=self.controller, |
| 3417 | of_port=in_port, |
| 3418 | vlan_id=vlan_id, |
| 3419 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG |
| 3420 | ) |
| 3421 | # Packet generation with sleep |
| 3422 | time.sleep(2) |
| 3423 | label_SR2 = (mpls_label_SR2, 0, 0, 32) |
| 3424 | label_2 = (mpls_label_PW, 0, 1, 32) |
| 3425 | |
| 3426 | # set to false to test if routing traffic |
| 3427 | # comes through |
| 3428 | raw_input("Press enter to send the packet, inspect the groups in the switch!") |
| 3429 | print("Sending packet with dst mac {0} and labels {1}".format(switch_mac, [label_SR2, label_2])) |
| 3430 | parsed_pkt = mpls_packet( |
| 3431 | pktlen=104, |
| 3432 | ip_ttl=63, |
| 3433 | label=[label_SR2, label_2], |
| 3434 | encapsulated_ethernet = True, |
| 3435 | eth_dst=switch_mac |
| 3436 | ) |
| 3437 | |
| 3438 | pkt = str( parsed_pkt ) |
| 3439 | self.dataplane.send( in_port, pkt ) |
| 3440 | |
| 3441 | expected_label = (mpls_label_PW, 0, 1, 31) |
| 3442 | print("Expecting packet with dst mac {0} and labels {1}".format(mac_dst, [label_2])) |
| 3443 | parsed_pkt = mpls_packet( |
| 3444 | pktlen=100, |
| 3445 | ip_ttl=63, |
| 3446 | eth_dst=mac_dst, |
| 3447 | eth_src=switch_mac, |
| 3448 | label=[ expected_label ], |
| 3449 | encapsulated_ethernet = True |
| 3450 | ) |
| 3451 | |
| 3452 | pkt = str( parsed_pkt ) |
| 3453 | verify_packet( self, pkt, out_port ) |
| 3454 | verify_no_packet( self, pkt, in_port ) |
| 3455 | |
| 3456 | delete_all_flows( self.controller ) |
| 3457 | delete_groups( self.controller, Groups ) |
| 3458 | delete_all_groups( self.controller ) |
| 3459 | |
| 3460 | finally: |
| 3461 | delete_all_flows( self.controller ) |
| 3462 | delete_groups( self.controller, Groups ) |
| 3463 | delete_all_groups( self.controller ) |
| 3464 | |
| 3465 | |
| 3466 | class VlanCrossConnect ( base_tests.SimpleDataPlane ): |
| 3467 | """ |
| 3468 | Tries the cross connect functionality of the ofdpa switches. |
| 3469 | """ |
| 3470 | def runTest( self ): |
| 3471 | Groups = Queue.LifoQueue( ) |
| 3472 | try: |
| 3473 | if len( config[ "port_map" ] ) < 2: |
| 3474 | logging.info( "Port count less than 2, can't run this case" ) |
| 3475 | return |
| 3476 | |
| 3477 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 3478 | subscriber_info = [ [10, 0xc0a80001, 12, 11, "192.168.0.1"] ] |
| 3479 | |
| 3480 | index = 5 |
| 3481 | for sub_info in subscriber_info: |
| 3482 | |
| 3483 | #print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 3484 | |
| 3485 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3486 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3487 | |
| 3488 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3489 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3490 | |
| 3491 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3492 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3493 | |
| 3494 | dip = sub_info[1] |
| 3495 | ports = config[ "port_map" ].keys( ) |
| 3496 | |
| 3497 | inner_vlan = sub_info[2] |
| 3498 | outer_vlan = sub_info[3] |
| 3499 | |
| 3500 | index = inner_vlan |
| 3501 | |
| 3502 | port = ports[0] |
| 3503 | out_port = ports[1] |
| 3504 | |
| 3505 | # add l2 interface group, uncomment for unfiltered |
| 3506 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, outer_vlan, True, True) |
| 3507 | #i l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, 1, True) |
| 3508 | |
| 3509 | # add vlan flow table |
| 3510 | add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 3511 | 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) |
| 3512 | 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) |
| 3513 | index += 1 |
| 3514 | |
| 3515 | Groups._put( l2_gid ) |
| 3516 | do_barrier( self.controller ) |
| 3517 | |
| 3518 | for sub_info in subscriber_info: |
| 3519 | #print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 3520 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3521 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3522 | |
| 3523 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3524 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3525 | |
| 3526 | dip = sub_info[1] |
| 3527 | ports = config[ "port_map" ].keys( ) |
| 3528 | |
| 3529 | inner_vlan = sub_info[2] |
| 3530 | outer_vlan = sub_info[3] |
| 3531 | |
| 3532 | port = ports[0] |
| 3533 | out_port = ports[1] |
| 3534 | |
| 3535 | ip_src = sub_info[4] |
| 3536 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3537 | parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan, |
| 3538 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3539 | 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, |
| 3540 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3541 | |
| 3542 | pkt = str( parsed_pkt ) |
| 3543 | |
| 3544 | self.dataplane.send( port, pkt ) |
| 3545 | verify_packet( self, pkt, out_port ) |
| 3546 | verify_no_other_packets( self ) |
| 3547 | |
| 3548 | finally: |
| 3549 | delete_all_flows( self.controller ) |
| 3550 | delete_groups( self.controller, Groups ) |
| 3551 | delete_all_groups( self.controller ) |
| 3552 | |
| 3553 | |
| 3554 | @disabled |
| 3555 | class Lag( base_tests.SimpleDataPlane ): |
| 3556 | """ |
| 3557 | Checks the L2 load balancing (LAG) functionality of the ofdpa switches. |
| 3558 | """ |
| 3559 | def runTest( self ): |
| 3560 | Groups = Queue.LifoQueue( ) |
| 3561 | try: |
| 3562 | if len( config[ "port_map" ] ) < 2: |
| 3563 | logging.info( "Port count less than 2, can't run this case" ) |
| 3564 | return |
| 3565 | |
| 3566 | ports = sorted(config[ "port_map" ].keys( )) |
| 3567 | in_port = ports[0] |
| 3568 | out_port = ports[1] |
| 3569 | |
| 3570 | # add l2 interface unfiltered group |
| 3571 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3572 | |
| 3573 | # create l2 load-balance group |
| 3574 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3575 | Groups.put(l2_o_gid, lag_gid) |
| 3576 | |
| 3577 | # --- TEST 1: bridging with load-bal---- |
| 3578 | vlan_in_port_untagged = 31 |
| 3579 | # table 10 flows and bridging flows for dstMac+vlan -> l2-load-bal group |
| 3580 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3581 | send_barrier=True) |
| 3582 | mac_dst = [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ] |
| 3583 | mac_dst_str = '00:11:22:33:44:55' |
| 3584 | add_bridge_flow( self.controller, mac_dst, vlan_in_port_untagged, lag_gid, True ) |
| 3585 | # untagged packet input becomes tagged packet at output |
| 3586 | time.sleep(0.1) |
| 3587 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=mac_dst_str ) ) |
| 3588 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=mac_dst_str ) ) |
| 3589 | self.dataplane.send( in_port, pkt ) |
| 3590 | verify_packet( self, exp_pkt, out_port ) |
| 3591 | verify_no_other_packets( self ) |
| 3592 | |
| 3593 | # --- TEST 2: flooding with load-bal ---- |
| 3594 | # flooding group --> load-bal group --> l2 unfiltered interface |
| 3595 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 ) |
| 3596 | Groups.put( floodmsg.group_id ) |
| 3597 | # add bridging flows for flooding groups |
| 3598 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3599 | # unknown dstmac packet input to hit flood group |
| 3600 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3601 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3602 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3603 | time.sleep(0.1) |
| 3604 | self.dataplane.send( in_port, pkt ) |
| 3605 | verify_packet( self, exp_pkt, out_port ) |
| 3606 | verify_no_other_packets( self ) |
| 3607 | |
| 3608 | # --- TEST 3: editing load-bal ---- |
| 3609 | # create and add another l2 unfiltered interface group to the load-balancing group |
| 3610 | l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True) |
| 3611 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True) |
| 3612 | self.dataplane.send( in_port, pkt ) |
| 3613 | verify_packet( self, exp_pkt, out_port ) |
| 3614 | |
| 3615 | # delete all buckets in loadbal group |
| 3616 | msg = mod_l2_loadbal_group(self.controller, 1, [], True) |
| 3617 | time.sleep(0.1) |
| 3618 | self.dataplane.send( in_port, pkt ) |
| 3619 | verify_no_other_packets( self ) # no buckets |
| 3620 | |
| 3621 | # only input port in load balancing group |
| 3622 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_i_gid], True) |
| 3623 | self.dataplane.send( in_port, pkt ) |
| 3624 | verify_no_other_packets( self ) # packet should not be sent out of in port |
| 3625 | |
| 3626 | # remove input port and add output port in lag group |
| 3627 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3628 | time.sleep(0.1) |
| 3629 | self.dataplane.send( in_port, pkt ) |
| 3630 | verify_packet( self, exp_pkt, out_port ) |
| 3631 | verify_no_other_packets( self ) |
| 3632 | |
| 3633 | finally: |
| 3634 | #print("done") |
| 3635 | delete_all_flows( self.controller ) |
| 3636 | delete_groups( self.controller, Groups ) |
| 3637 | delete_all_groups( self.controller ) |
| 3638 | |
| 3639 | @disabled |
| 3640 | class FloodLb( base_tests.SimpleDataPlane ): |
| 3641 | """ |
| 3642 | Checks L2 flood group pointing to L2 load balance group with 2 buckets (unfiltered). |
| 3643 | The packet from in_port should not be seen on the out_port |
| 3644 | """ |
| 3645 | def runTest( self ): |
| 3646 | Groups = Queue.LifoQueue( ) |
| 3647 | try: |
| 3648 | if len( config[ "port_map" ] ) < 2: |
| 3649 | logging.info( "Port count less than 2, can't run this case" ) |
| 3650 | return |
| 3651 | |
| 3652 | ports = sorted(config[ "port_map" ].keys( )) |
| 3653 | in_port = ports[0] |
| 3654 | out_port = ports[1] |
| 3655 | vlan_in_port_untagged = 31 |
| 3656 | |
| 3657 | # add l2 unfiltered interface group for outport |
| 3658 | l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True) |
| 3659 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3660 | |
| 3661 | # create l2 load-balance group |
| 3662 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_i_gid, l2_o_gid], True) |
| 3663 | |
| 3664 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3665 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0, send_barrier=True ) |
| 3666 | Groups.put( l2_i_gid ) |
| 3667 | Groups.put( l2_o_gid ) |
| 3668 | Groups.put( lag_gid ) |
| 3669 | Groups.put( floodmsg.group_id ) |
| 3670 | |
| 3671 | # table 10 flows for untagged input |
| 3672 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3673 | send_barrier=True) |
| 3674 | add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3675 | send_barrier=True) |
| 3676 | |
| 3677 | # add bridging flows for flooding groups |
| 3678 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3679 | # unknown dstmac packet will hit flood group |
| 3680 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3681 | |
| 3682 | # check one direction -> packet enters through inport should not be seen on the outport |
| 3683 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3684 | self.dataplane.send( in_port, pkt ) |
| 3685 | verify_no_other_packets( self ) |
| 3686 | |
| 3687 | # check other direction -> packet enters through outport should not be seen on the inport |
| 3688 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3689 | self.dataplane.send( out_port, pkt ) |
| 3690 | verify_no_other_packets( self ) |
| 3691 | |
| 3692 | finally: |
| 3693 | #print("done") |
| 3694 | delete_all_flows( self.controller ) |
| 3695 | delete_groups( self.controller, Groups ) |
| 3696 | delete_all_groups( self.controller ) |
| 3697 | |
| 3698 | @disabled |
| 3699 | class FloodMixUntagged( base_tests.SimpleDataPlane ): |
| 3700 | """ |
| 3701 | Checks the combination of L2 filtered and L2 load balancing (LAG) groups |
| 3702 | in a flooding group |
| 3703 | """ |
| 3704 | def runTest( self ): |
| 3705 | Groups = Queue.LifoQueue( ) |
| 3706 | try: |
| 3707 | if len( config[ "port_map" ] ) < 2: |
| 3708 | logging.info( "Port count less than 2, can't run this case" ) |
| 3709 | return |
| 3710 | |
| 3711 | ports = sorted(config[ "port_map" ].keys( )) |
| 3712 | in_port = ports[0] |
| 3713 | out_port = ports[1] |
| 3714 | vlan_in_port_untagged = 31 |
| 3715 | |
| 3716 | # add l2 unfiltered interface group for outport |
| 3717 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3718 | |
| 3719 | # create l2 load-balance group |
| 3720 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3721 | |
| 3722 | # create l2 interface (filtered) group for inport |
| 3723 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3724 | is_tagged=False, send_barrier=True) |
| 3725 | |
| 3726 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3727 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 ) |
| 3728 | Groups.put( l2_o_gid ) |
| 3729 | Groups.put( lag_gid ) |
| 3730 | Groups.put( l2_i_gid ) |
| 3731 | Groups.put( floodmsg.group_id ) |
| 3732 | |
| 3733 | # table 10 flows for untagged input |
| 3734 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3735 | send_barrier=True) |
| 3736 | |
| 3737 | # add bridging flows for flooding groups |
| 3738 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3739 | # unknown dstmac packet will hit flood group |
| 3740 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3741 | |
| 3742 | # check one direction -> packet enters through filtered port (inport) and exits through |
| 3743 | # unfiltered port (outport) via the flood and lag groups |
| 3744 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3745 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3746 | self.dataplane.send( in_port, pkt ) |
| 3747 | verify_packet( self, exp_pkt, out_port ) |
| 3748 | verify_no_other_packets( self ) |
| 3749 | |
| 3750 | # check other direction -> packet enters through unfiltered port (outport) and exits through |
| 3751 | # filtered port (inport) via the flood group |
| 3752 | add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3753 | send_barrier=True) |
| 3754 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3755 | exp_pkt = pkt # ingress packet gets internal vlan 31 which gets popped at l2 interface group before egress |
| 3756 | self.dataplane.send( out_port, pkt ) |
| 3757 | verify_packet( self, exp_pkt, in_port ) |
| 3758 | verify_no_other_packets( self ) |
| 3759 | |
| 3760 | finally: |
| 3761 | print("done") |
| 3762 | delete_all_flows( self.controller ) |
| 3763 | delete_groups( self.controller, Groups ) |
| 3764 | delete_all_groups( self.controller ) |
| 3765 | |
| 3766 | @disabled |
| 3767 | class FloodMixTagged( base_tests.SimpleDataPlane ): |
| 3768 | """ |
| 3769 | Checks the combination of L2 filtered and L2 load balancing (LAG) groups |
| 3770 | in a flooding group |
| 3771 | """ |
| 3772 | def runTest( self ): |
| 3773 | Groups = Queue.LifoQueue( ) |
| 3774 | try: |
| 3775 | if len( config[ "port_map" ] ) < 2: |
| 3776 | logging.info( "Port count less than 2, can't run this case" ) |
| 3777 | return |
| 3778 | |
| 3779 | ports = sorted(config[ "port_map" ].keys( )) |
| 3780 | in_port = ports[0] |
| 3781 | out_port = ports[1] |
| 3782 | vlan_in_port_untagged = 31 |
| 3783 | |
| 3784 | # add l2 unfiltered interface group for outport |
| 3785 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3786 | |
| 3787 | # create l2 load-balance group |
| 3788 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3789 | |
| 3790 | # create l2 interface (filtered) group for inport |
| 3791 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3792 | is_tagged=True, send_barrier=True) |
| 3793 | |
| 3794 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3795 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 ) |
| 3796 | Groups.put( l2_o_gid ) |
| 3797 | Groups.put( lag_gid ) |
| 3798 | Groups.put( l2_i_gid ) |
| 3799 | Groups.put( floodmsg.group_id ) |
| 3800 | |
| 3801 | # table 10 flows for tagged in_port. Note: VLAN in table 10 must be wildcarded for an unfiltered port |
| 3802 | add_vlan_table_flow_allow_all_vlan(self.controller, in_port, send_barrier=True) |
| 3803 | |
| 3804 | # add bridging flows for flooding groups |
| 3805 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3806 | # unknown dstmac packet will hit flood group |
| 3807 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3808 | |
| 3809 | # check one direction -> packet enters through unfiltered port (inport) and exits through |
| 3810 | # unfiltered port (outport) via the flood and lag groups |
| 3811 | pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3812 | exp_pkt = pkt |
| 3813 | self.dataplane.send( in_port, pkt ) |
| 3814 | verify_packet( self, exp_pkt, out_port ) |
| 3815 | verify_no_other_packets( self ) |
| 3816 | |
| 3817 | # check other direction -> packet enters through unfiltered port (outport) and exits through |
| 3818 | # unfiltered port (inport) via the flood group |
| 3819 | |
| 3820 | # table 10 flows for tagged out_port. Note: VLAN must be wildcarded for an unfiltered port |
| 3821 | add_vlan_table_flow_allow_all_vlan(self.controller, out_port, send_barrier=True) |
| 3822 | pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3823 | exp_pkt = pkt |
| 3824 | self.dataplane.send( out_port, pkt ) |
| 3825 | verify_packet( self, exp_pkt, in_port ) |
| 3826 | verify_no_other_packets( self ) |
| 3827 | |
| 3828 | finally: |
| 3829 | print("done") |
| 3830 | delete_all_flows( self.controller ) |
| 3831 | delete_groups( self.controller, Groups ) |
| 3832 | delete_all_groups( self.controller ) |
| 3833 | |
| 3834 | @disabled |
| 3835 | class LagMix( base_tests.SimpleDataPlane ): |
| 3836 | """ |
| 3837 | Checks the combination of L2 filtered and unfiltered interface groups |
| 3838 | in a L2 load balancing (LAG) group - this should not work according to spec |
| 3839 | """ |
| 3840 | def runTest( self ): |
| 3841 | Groups = Queue.LifoQueue( ) |
| 3842 | try: |
| 3843 | if len( config[ "port_map" ] ) < 2: |
| 3844 | logging.info( "Port count less than 2, can't run this case" ) |
| 3845 | return |
| 3846 | |
| 3847 | ports = sorted(config[ "port_map" ].keys( )) |
| 3848 | in_port = ports[0] |
| 3849 | out_port = ports[1] |
| 3850 | vlan_in_port_untagged = 31 |
| 3851 | |
| 3852 | # add l2 unfiltered interface group |
| 3853 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3854 | |
| 3855 | # create l2 interface (filtered) group |
| 3856 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3857 | is_tagged=False, send_barrier=True) |
| 3858 | |
| 3859 | # create l2 load-balance group with a mix of filtered and unfiltered groups |
| 3860 | """ |
| 3861 | XXX the following does not work - the group does not get created but curiously we don't get an openflow |
| 3862 | error message. The ofdpa logs show |
| 3863 | ofdbGroupBucketValidate: Referenced Group Id 0x1f000c not of type L2 Unfiltered Interface. |
| 3864 | We do get an openflow error message for the flood group that follows because it cannot |
| 3865 | find the lag group it points to (because it did not get created). |
| 3866 | """ |
| 3867 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True) |
| 3868 | |
| 3869 | # create l2 flood group to point to lag group |
| 3870 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 ) |
| 3871 | Groups.put( floodmsg.group_id, l2_i_gid, lag_gid ) |
| 3872 | Groups.put( l2_o_gid ) |
| 3873 | |
| 3874 | finally: |
| 3875 | #print("done") |
| 3876 | delete_all_flows( self.controller ) |
| 3877 | delete_groups( self.controller, Groups ) |
| 3878 | delete_all_groups( self.controller ) |
| 3879 | |
| 3880 | |
| 3881 | @disabled |
| 3882 | class LagXconn( base_tests.SimpleDataPlane ): |
| 3883 | """ |
| 3884 | Checks the L2 load balancing (LAG) with vlan crossconnects. |
| 3885 | Note that for this to work, basic VlanCrossConnect test above (without LAG) should work first |
| 3886 | Note: this doesn't work on XGS or QMX yet with premium 1.1.7 |
| 3887 | """ |
| 3888 | def runTest( self ): |
| 3889 | Groups = Queue.LifoQueue( ) |
| 3890 | try: |
| 3891 | if len( config[ "port_map" ] ) < 2: |
| 3892 | logging.info( "Port count less than 2, can't run this case" ) |
| 3893 | return |
| 3894 | |
| 3895 | ports = sorted(config[ "port_map" ].keys( )) |
| 3896 | in_port = ports[0] |
| 3897 | out_port = ports[1] |
| 3898 | |
| 3899 | # add l2 interface unfiltered group |
| 3900 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3901 | |
| 3902 | # create l2 load-balance group |
| 3903 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3904 | Groups.put(l2_o_gid, lag_gid) |
| 3905 | |
| 3906 | # a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 3907 | sub_info = [10, 0xc0a80001, 12, 11, "192.168.0.1"] |
| 3908 | |
| 3909 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3910 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3911 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3912 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3913 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3914 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3915 | |
| 3916 | dip = sub_info[1] |
| 3917 | ports = config[ "port_map" ].keys( ) |
| 3918 | inner_vlan = sub_info[2] |
| 3919 | outer_vlan = sub_info[3] |
| 3920 | index = inner_vlan |
| 3921 | port = ports[0] |
| 3922 | out_port = ports[1] |
| 3923 | |
| 3924 | # add vlan flow table |
| 3925 | add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 3926 | add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan, outer_vlan_id=outer_vlan, |
| 3927 | inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True) |
| 3928 | """ |
| 3929 | XXX The following flow in table 13 is rejected by the switch (qmx) probably due to the reference to lag group |
| 3930 | ofdpa logs say: 08-22 00:43:10.344338 [ofstatemanager] Error from Forwarding while inserting flow: Unknown error |
| 3931 | """ |
| 3932 | add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=lag_gid, |
| 3933 | qos_index=0, goto=ACL_FLOW_TABLE) |
| 3934 | do_barrier( self.controller ) |
| 3935 | |
| 3936 | ip_src = sub_info[4] |
| 3937 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3938 | parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan, |
| 3939 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3940 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True, |
| 3941 | in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan, |
| 3942 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, |
| 3943 | ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3944 | |
| 3945 | pkt = str( parsed_pkt ) |
| 3946 | self.dataplane.send( port, pkt ) |
| 3947 | verify_packet( self, pkt, out_port ) |
| 3948 | verify_no_other_packets( self ) |
| 3949 | |
| 3950 | finally: |
| 3951 | #print("done") |
| 3952 | delete_all_flows( self.controller ) |
| 3953 | delete_groups( self.controller, Groups ) |
| 3954 | delete_all_groups( self.controller ) |
| 3955 | |
| 3956 | @disabled |
| 3957 | class LagRouting( base_tests.SimpleDataPlane ): |
| 3958 | """ |
| 3959 | Checks the L2 load balancing (LAG) with routing flows. |
| 3960 | Specifically route -> L3Unicast -> Lag -> L2 Unfiltered interface |
| 3961 | """ |
| 3962 | def runTest( self ): |
| 3963 | Groups = Queue.LifoQueue( ) |
| 3964 | try: |
| 3965 | if len( config[ "port_map" ] ) < 2: |
| 3966 | logging.info( "Port count less than 2, can't run this case" ) |
| 3967 | return |
| 3968 | |
| 3969 | ports = sorted(config[ "port_map" ].keys( )) |
| 3970 | in_port = ports[0] |
| 3971 | out_port = ports[1] |
| 3972 | |
| 3973 | # add l2 interface unfiltered group |
| 3974 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3975 | |
| 3976 | # create l2 load-balance group |
| 3977 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3978 | Groups.put(l2_o_gid, lag_gid) |
| 3979 | |
| 3980 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3981 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3982 | dip = 0xc0a80001 |
| 3983 | vlan_id = 31 |
| 3984 | |
| 3985 | # create L3 Unicast group to point to Lag group |
| 3986 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=vlan_id, id=vlan_id, |
| 3987 | src_mac=intf_src_mac, dst_mac=dst_mac, gid=lag_gid ) |
| 3988 | # add vlan flow table |
| 3989 | add_one_vlan_table_flow( self.controller, in_port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 3990 | # add termination flow |
| 3991 | if config["switch_type"] == "qmx": |
| 3992 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 3993 | else: |
| 3994 | add_termination_flow( self.controller, in_port, 0x0800, intf_src_mac, vlan_id ) |
| 3995 | # add unicast routing flow |
| 3996 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id ) |
| 3997 | |
| 3998 | Groups.put( l3_msg.group_id ) |
| 3999 | do_barrier( self.controller ) |
| 4000 | |
| 4001 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 4002 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 4003 | ip_src = '192.168.0.2' |
| 4004 | ip_dst = '192.168.0.1' |
| 4005 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 4006 | vlan_vid=vlan_id, eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 4007 | ip_src=ip_src, ip_dst=ip_dst ) |
| 4008 | pkt = str( parsed_pkt ) |
| 4009 | self.dataplane.send( in_port, pkt ) |
| 4010 | # build expected packet |
| 4011 | mac_dst = '00:00:00:22:22:00' |
| 4012 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 4013 | vlan_vid=vlan_id, eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 4014 | ip_src=ip_src, ip_dst=ip_dst ) |
| 4015 | pkt = str( exp_pkt ) |
| 4016 | verify_packet( self, pkt, out_port ) |
| 4017 | verify_no_other_packets( self ) |
| 4018 | |
| 4019 | finally: |
| 4020 | #print("done") |
| 4021 | delete_all_flows( self.controller ) |
| 4022 | delete_groups( self.controller, Groups ) |
| 4023 | delete_all_groups( self.controller ) |
| 4024 | |
| 4025 | class FabricSW_OF_EAPOL_TC_0060(base_tests.SimpleDataPlane): |
| 4026 | """ |
| 4027 | To verify double VLAN tagged EAPOL packets can be matched and sent to controller. |
| 4028 | """ |
| 4029 | |
| 4030 | def runTest(self): |
| 4031 | try: |
| 4032 | eth_type_eapol = 0x888e |
| 4033 | eth_type_non_eapol = 0x88ee |
| 4034 | eth_type = 0x8100 |
| 4035 | vlan_id100 = 100 |
| 4036 | vlanid200 = 200 |
| 4037 | |
| 4038 | logging.info("Step 1") |
| 4039 | logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.") |
| 4040 | |
| 4041 | ports = sorted(config["port_map"].keys()) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4042 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 4043 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4044 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4045 | |
| 4046 | add_acl_rule(self.controller, eth_type=eth_type_eapol) |
| 4047 | |
| 4048 | match = ofp.match() |
| 4049 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol)) |
| 4050 | |
| 4051 | logging.info("Step 2") |
| 4052 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_eapol))) |
| 4053 | parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4054 | in_dl_vlan_enable=True, |
| 4055 | out_vlan_tpid=eth_type, |
| 4056 | in_vlan_tpid=eth_type_eapol, |
| 4057 | out_vlan_vid=vlan_id100, |
| 4058 | in_vlan_vid=vlanid200) |
| 4059 | vlan_pkt = str(parsed_pkt) |
| 4060 | |
| 4061 | logging.info("Step 3") |
| 4062 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_eapol))) |
| 4063 | parsed_pkt_non_eapol = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4064 | in_dl_vlan_enable=True, |
| 4065 | out_vlan_tpid=eth_type, |
| 4066 | in_vlan_tpid=eth_type_non_eapol, |
| 4067 | out_vlan_vid=vlan_id100, |
| 4068 | in_vlan_vid=vlanid200) |
| 4069 | vlan_pkt_non_eapol = str(parsed_pkt_non_eapol) |
| 4070 | |
| 4071 | logging.info("Step 4") |
| 4072 | logging.info( |
| 4073 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_eapol), ports[0])) |
| 4074 | self.dataplane.send(ports[0], vlan_pkt) |
| 4075 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4076 | |
| 4077 | logging.info("Step 5") |
| 4078 | logging.info( |
| 4079 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_eapol), ports[0])) |
| 4080 | self.dataplane.send(ports[0], vlan_pkt_non_eapol) |
| 4081 | verify_no_packet_in(self, vlan_pkt_non_eapol, ports[0]) |
| 4082 | |
| 4083 | logging.info("Step 6 Cleanup flows") |
| 4084 | delete_all_flows(self.controller) |
| 4085 | time.sleep(1) |
| 4086 | |
| 4087 | logging.info("Step 7") |
| 4088 | logging.info("Add flows again ID=10 and ID=60") |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4089 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4090 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4091 | |
| 4092 | add_acl_rule(self.controller, eth_type=eth_type_eapol) |
| 4093 | |
| 4094 | match = ofp.match() |
| 4095 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol)) |
| 4096 | time.sleep(1) |
| 4097 | |
| 4098 | logging.info("Step 8") |
| 4099 | logging.info( |
| 4100 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_eapol), ports[0])) |
| 4101 | self.dataplane.send(ports[0], vlan_pkt) |
| 4102 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4103 | |
| 4104 | |
| 4105 | finally: |
| 4106 | delete_all_flows( self.controller ) |
| 4107 | delete_all_groups( self.controller ) |
| 4108 | logging.info("End of Test") |
| 4109 | |
| 4110 | |
| 4111 | |
| 4112 | class FabricSW_OF_ARP_TC_0065(base_tests.SimpleDataPlane): |
| 4113 | """ |
| 4114 | To verify double VLAN tagged ARP packets can be matched and sent to controller. |
| 4115 | """ |
| 4116 | |
| 4117 | def runTest(self): |
| 4118 | try: |
| 4119 | eth_type_arp = 0x806 |
| 4120 | eth_type_non_arp = 0x888e |
| 4121 | eth_type = 0x8100 |
| 4122 | vlan_id100 = 100 |
| 4123 | vlanid200 = 200 |
| 4124 | |
| 4125 | logging.info("Step 1") |
| 4126 | logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.") |
| 4127 | |
| 4128 | ports = sorted(config["port_map"].keys()) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4129 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
| 4130 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4131 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4132 | |
| 4133 | add_acl_rule(self.controller, eth_type=eth_type_arp) |
| 4134 | |
| 4135 | match = ofp.match() |
| 4136 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp)) |
| 4137 | |
| 4138 | logging.info("Step 2") |
| 4139 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_arp))) |
| 4140 | parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4141 | in_dl_vlan_enable=True, |
| 4142 | out_vlan_tpid=eth_type, |
| 4143 | in_vlan_tpid=eth_type_arp, |
| 4144 | out_vlan_vid=vlan_id100, |
| 4145 | in_vlan_vid=vlanid200) |
| 4146 | vlan_pkt = str(parsed_pkt) |
| 4147 | |
| 4148 | logging.info("Step 3") |
| 4149 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_arp))) |
| 4150 | parsed_pkt_non_arp = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4151 | in_dl_vlan_enable=True, |
| 4152 | out_vlan_tpid=eth_type, |
| 4153 | in_vlan_tpid=eth_type_non_arp, |
| 4154 | out_vlan_vid=vlan_id100, |
| 4155 | in_vlan_vid=vlanid200) |
| 4156 | vlan_pkt_non_arp = str(parsed_pkt_non_arp) |
| 4157 | |
| 4158 | logging.info("Step 4") |
| 4159 | logging.info( |
| 4160 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0])) |
| 4161 | self.dataplane.send(ports[0], vlan_pkt) |
| 4162 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4163 | |
| 4164 | logging.info("Step 5") |
| 4165 | logging.info( |
| 4166 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_arp), ports[0])) |
| 4167 | self.dataplane.send(ports[0], vlan_pkt_non_arp) |
| 4168 | verify_no_packet_in(self, vlan_pkt_non_arp, ports[0]) |
| 4169 | |
| 4170 | logging.info("Step 6 Cleanup flows") |
| 4171 | delete_all_flows(self.controller) |
| 4172 | time.sleep(1) |
| 4173 | |
| 4174 | logging.info("Step 7") |
| 4175 | logging.info("Add flows again ID=10 and ID=60") |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4176 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4177 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4178 | |
| 4179 | add_acl_rule(self.controller, eth_type=eth_type_arp) |
| 4180 | |
| 4181 | match = ofp.match() |
| 4182 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp)) |
| 4183 | time.sleep(1) |
| 4184 | |
| 4185 | logging.info("Step 8") |
| 4186 | logging.info( |
| 4187 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0])) |
| 4188 | self.dataplane.send(ports[0], vlan_pkt) |
| 4189 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4190 | |
| 4191 | |
| 4192 | finally: |
| 4193 | delete_all_flows(self.controller) |
| 4194 | delete_all_groups(self.controller) |
| 4195 | logging.info("End of Test") |
| 4196 | |
| 4197 | @disabled |
| 4198 | class FabricSW_OF_ARP_LAG_TC(base_tests.SimpleDataPlane): |
| 4199 | """ |
| 4200 | To verify double VLAN tagged ARP packets received over a LAG interface can be matched and sent to controller. |
| 4201 | |
| 4202 | TODO: Need to add step: Create a logical port (LAG) and bind data ports 1 and 2 to the logical port. |
| 4203 | """ |
| 4204 | |
| 4205 | def runTest(self): |
| 4206 | try: |
| 4207 | eth_type_arp = 0x806 |
| 4208 | eth_type_non_arp = 0x888e |
| 4209 | eth_type = 0x8100 |
| 4210 | vlan_id100 = 100 |
| 4211 | vlanid200 = 200 |
| 4212 | |
| 4213 | logging.info("Step 1") |
| 4214 | logging.info( |
| 4215 | "Create a logical port (LAG) and bind data ports 1 and 2 to the logical port.") |
| 4216 | |
| 4217 | # TODO: add LAG here: |
| 4218 | |
| 4219 | logging.info("Step 2") |
| 4220 | logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.") |
| 4221 | |
| 4222 | ports = sorted(config["port_map"].keys()) |
| 4223 | for port in ports: |
| 4224 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4225 | |
| 4226 | add_acl_rule(self.controller, eth_type=eth_type_arp) |
| 4227 | |
| 4228 | match = ofp.match() |
| 4229 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp)) |
| 4230 | |
| 4231 | logging.info("Step 3") |
| 4232 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_arp))) |
| 4233 | parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4234 | in_dl_vlan_enable=True, |
| 4235 | out_vlan_tpid=eth_type, |
| 4236 | in_vlan_tpid=eth_type_arp, |
| 4237 | out_vlan_vid=vlan_id100, |
| 4238 | in_vlan_vid=vlanid200) |
| 4239 | vlan_pkt = str(parsed_pkt) |
| 4240 | |
| 4241 | logging.info("Step 4") |
| 4242 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_arp))) |
| 4243 | parsed_pkt_non_eapol = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4244 | in_dl_vlan_enable=True, |
| 4245 | out_vlan_tpid=eth_type, |
| 4246 | in_vlan_tpid=eth_type_non_arp, |
| 4247 | out_vlan_vid=vlan_id100, |
| 4248 | in_vlan_vid=vlanid200) |
| 4249 | vlan_pkt_non_eapol = str(parsed_pkt_non_eapol) |
| 4250 | |
| 4251 | logging.info("Step 5") |
| 4252 | for port in ports: |
| 4253 | logging.info( |
| 4254 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), port)) |
| 4255 | self.dataplane.send(port, vlan_pkt) |
| 4256 | verify_packet_in(self, vlan_pkt, port, ofp.OFPR_ACTION) |
| 4257 | |
| 4258 | logging.info("Step 7") |
| 4259 | logging.info( |
| 4260 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_arp), ports[0])) |
| 4261 | self.dataplane.send(ports[0], vlan_pkt_non_eapol) |
| 4262 | verify_no_packet_in(self, vlan_pkt_non_eapol, ports[0]) |
| 4263 | |
| 4264 | logging.info("Step 8 Cleanup flows") |
| 4265 | delete_all_flows(self.controller) |
| 4266 | |
| 4267 | match = ofp.match() |
| 4268 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp)) |
| 4269 | |
| 4270 | logging.info("Step 9") |
| 4271 | logging.info( |
| 4272 | "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0])) |
| 4273 | self.dataplane.send(ports[0], vlan_pkt) |
| 4274 | verify_no_packet_in(self, vlan_pkt, ports[0]) |
| 4275 | |
| 4276 | |
| 4277 | finally: |
| 4278 | delete_all_flows( self.controller ) |
| 4279 | delete_all_groups( self.controller ) |
| 4280 | logging.info("End of Test") |
| 4281 | |
| 4282 | |
| 4283 | class FabricSW_OF_VLANPUSH_TC_0070(base_tests.SimpleDataPlane): |
| 4284 | """ |
| 4285 | To verify a VLAN tag can be pushed into an untagged packet received on a physical interface. |
| 4286 | """ |
| 4287 | |
| 4288 | def runTest(self): |
| 4289 | try: |
| 4290 | vlan_id100 = 100 |
| 4291 | ports = sorted(config["port_map"].keys()) |
| 4292 | |
| 4293 | logging.info("Step 1") |
| 4294 | logging.info("Add a flow to TABLE-10 to match untagged packets received in Data Port 1 and immediate " |
| 4295 | "action to insert VLAN tag {} and transition to TABLE-20.".format(vlan_id100)) |
| 4296 | add_one_vlan_table_flow(ctrl=self.controller, of_port=ports[0], vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4297 | add_one_vlan_table_flow(ctrl=self.controller, of_port=ports[0], vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_UNTAG) |
| 4298 | |
| 4299 | logging.info("Step 2") |
| 4300 | logging.info("Add a flow to TABLE-60 to match VLAN tag {} and action Send to Controller".format(vlan_id100)) |
| 4301 | add_acl_rule(ctrl=self.controller, vlan_id=vlan_id100) |
| 4302 | |
| 4303 | match = ofp.match() |
| 4304 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id100)) |
| 4305 | |
| 4306 | logging.info("Step 3") |
| 4307 | logging.info("Creating an untagged vlan packet") |
| 4308 | parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=False, |
| 4309 | in_dl_vlan_enable=False) |
| 4310 | vlan_pkt = str(parsed_pkt) |
| 4311 | |
| 4312 | logging.info("Step 4") |
| 4313 | logging.info("Send untagged packet to port {}".format(ports[0])) |
| 4314 | self.dataplane.send(ports[0], vlan_pkt) |
| 4315 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4316 | |
| 4317 | logging.info("Step 6 Cleanup flows") |
| 4318 | delete_all_flows(self.controller) |
| 4319 | |
| 4320 | logging.info("Step 5") |
| 4321 | logging.info("Send untagged packet to port {}".format(ports[0])) |
| 4322 | self.dataplane.send(ports[0], vlan_pkt) |
| 4323 | verify_no_packet_in(self, vlan_pkt, ports[0]) |
| 4324 | |
| 4325 | |
| 4326 | finally: |
| 4327 | delete_all_flows(self.controller) |
| 4328 | delete_all_groups(self.controller) |
| 4329 | logging.info("End of Test") |
| 4330 | |
| 4331 | |
| 4332 | class FabricSW_OF_LLDP_TC_0075(base_tests.SimpleDataPlane): |
| 4333 | """ |
| 4334 | To verify LLDP packets received on a physical interface can be matched and sent to Controller. |
| 4335 | """ |
| 4336 | |
| 4337 | def runTest(self): |
| 4338 | try: |
| 4339 | eth_type_lldp = 0x88cc |
| 4340 | eth_type_non_lldp = 0x88ee |
| 4341 | |
| 4342 | similar_steps(eth_type_lldp, eth_type_non_lldp, self) |
| 4343 | |
| 4344 | finally: |
| 4345 | delete_all_flows(self.controller) |
| 4346 | delete_all_groups(self.controller) |
| 4347 | logging.info("End of Test") |
| 4348 | |
| 4349 | |
| 4350 | class FabricSW_OF_BDDP_TC_0080(base_tests.SimpleDataPlane): |
| 4351 | """ |
| 4352 | To verify BDDP packets received on a physical interface can be matched and sent to Controller. |
| 4353 | """ |
| 4354 | |
| 4355 | def runTest(self): |
| 4356 | try: |
| 4357 | eth_type_bddp = 0x8942 |
| 4358 | eth_type_non_bddp = 0x888e |
| 4359 | |
| 4360 | similar_steps(eth_type_bddp, eth_type_non_bddp, self) |
| 4361 | |
| 4362 | finally: |
| 4363 | delete_all_flows(self.controller) |
| 4364 | delete_all_groups(self.controller) |
| 4365 | logging.info("End of Test") |
| 4366 | |
| 4367 | |
| 4368 | class FabricSW_OF_VLANXConnect_Single_TC_0085(base_tests.SimpleDataPlane): |
| 4369 | """ |
| 4370 | Verify QnQ traffic flooding between 2 cross (one-to-one) connected physical interfaces. |
| 4371 | """ |
| 4372 | |
| 4373 | def runTest(self): |
| 4374 | groups = Queue.LifoQueue() |
| 4375 | try: |
| 4376 | ports = sorted(config["port_map"].keys()) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4377 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4378 | vlan_id = 100 |
| 4379 | vlan_id101 = 101 |
| 4380 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4381 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4382 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 4383 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4384 | groups.put(L2gid) |
| 4385 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4386 | msg = add_l2_flood_group(self.controller, pair, vlan_id, vlan_id) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4387 | groups.put(msg.group_id) |
| 4388 | add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True) |
| 4389 | |
| 4390 | #do_barrier(self.controller) |
| 4391 | |
| 4392 | logging.info( |
| 4393 | "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id)) |
| 4394 | add_acl_rule(self.controller, vlan_id=vlan_id) |
| 4395 | |
| 4396 | match = ofp.match() |
| 4397 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id)) |
| 4398 | |
| 4399 | # verify flood |
| 4400 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id)) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4401 | for ofport in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4402 | # change dest based on port number |
| 4403 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 4404 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4405 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 4406 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4407 | |
| 4408 | pkt = str(parsed_pkt) |
| 4409 | self.dataplane.send(ofport, pkt) |
| 4410 | # self won't rx packet |
| 4411 | verify_no_packet(self, pkt, ofport) |
| 4412 | # others will rx packet |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4413 | tmp_ports = list(pair) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4414 | tmp_ports.remove(ofport) |
| 4415 | verify_packets(self, pkt, tmp_ports) |
| 4416 | |
| 4417 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101)) |
| 4418 | mac_src = '00:12:34:56:78:%02X' % ports[0] |
| 4419 | parsed_pkt_101 = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4420 | out_vlan_vid=vlan_id101, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 4421 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4422 | |
| 4423 | pkt_101 = str(parsed_pkt_101) |
| 4424 | logging.info("Send double tugged packet to port {}".format(ports[0])) |
| 4425 | self.dataplane.send(ports[0], pkt_101) |
| 4426 | |
| 4427 | logging.info("Verify the packet is not flooded to data port2 with outer vlan id {}".format(vlan_id101)) |
| 4428 | verify_no_packet(self, pkt_101, ports[1]) |
| 4429 | |
| 4430 | logging.info("Cleanup flows") |
| 4431 | delete_all_flows(self.controller) |
| 4432 | |
| 4433 | logging.info("Send double tugged packet to port {}".format(ports[1])) |
| 4434 | self.dataplane.send(ports[1], pkt) |
| 4435 | |
| 4436 | logging.info("Verify the packet is not flooded to data port1 with outer vlan id {}".format(vlan_id)) |
| 4437 | verify_no_packet(self, pkt, ports[0]) |
| 4438 | |
| 4439 | finally: |
| 4440 | delete_all_flows(self.controller) |
| 4441 | delete_groups(self.controller, groups) |
| 4442 | delete_all_groups(self.controller) |
| 4443 | logging.info("End of Test") |
| 4444 | |
| 4445 | |
| 4446 | class FabricSW_OF_VLANXConnect_Multi_TC_0090(base_tests.SimpleDataPlane): |
| 4447 | """ |
Roman Bubyr | 73f24a4 | 2019-07-12 13:19:08 +0300 | [diff] [blame] | 4448 | To verify Q-n-Q traffic flooding between Many-to-One (multiple S tags to single BNG) |
| 4449 | and One-Many (Single BNG to multiple S tags) cross connected physical interfaces. |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4450 | """ |
| 4451 | |
| 4452 | def runTest(self): |
| 4453 | groups = Queue.LifoQueue() |
| 4454 | try: |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4455 | if len( config[ "port_map" ] ) < 4: |
| 4456 | logging.info( "Port count less than 4, can't run this case" ) |
| 4457 | assert (False) |
| 4458 | return |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4459 | ports = sorted(config["port_map"].keys()) |
| 4460 | vlan_id100 = 100 |
| 4461 | vlan_id101 = 101 |
| 4462 | vlan_id102 = 102 |
| 4463 | |
| 4464 | # Create VLAN100 flow and tables for port1 and port4 |
| 4465 | tmp_ports = list(ports) |
| 4466 | tmp_ports.remove(ports[1]) |
| 4467 | tmp_ports.remove(ports[2]) |
| 4468 | |
| 4469 | for port in tmp_ports: |
| 4470 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id100, True, False) |
| 4471 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4472 | groups.put(L2gid) |
| 4473 | |
| 4474 | msg = add_l2_flood_group(self.controller, tmp_ports, vlan_id100, vlan_id100) |
| 4475 | groups.put(msg.group_id) |
| 4476 | add_bridge_flow(self.controller, None, vlan_id100, msg.group_id, True) |
| 4477 | |
| 4478 | # do_barrier(self.controller) |
| 4479 | |
| 4480 | logging.info( |
| 4481 | "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id100)) |
| 4482 | add_acl_rule(self.controller, vlan_id=vlan_id100) |
| 4483 | |
| 4484 | match = ofp.match() |
| 4485 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id100)) |
| 4486 | |
| 4487 | # Create VLAN101 flow and tables for port2 and port4 |
| 4488 | tmp_ports1 = list(ports) |
| 4489 | tmp_ports1.remove(ports[0]) |
| 4490 | tmp_ports1.remove(ports[2]) |
| 4491 | |
| 4492 | for port in tmp_ports1: |
| 4493 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id101, True, False) |
| 4494 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id101, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4495 | groups.put(L2gid) |
| 4496 | |
| 4497 | msg = add_l2_flood_group(self.controller, tmp_ports1, vlan_id101, vlan_id101) |
| 4498 | groups.put(msg.group_id) |
| 4499 | add_bridge_flow(self.controller, None, vlan_id101, msg.group_id, True) |
| 4500 | |
| 4501 | # do_barrier(self.controller) |
| 4502 | |
| 4503 | logging.info( |
| 4504 | "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id101)) |
| 4505 | add_acl_rule(self.controller, vlan_id=vlan_id101) |
| 4506 | |
| 4507 | match = ofp.match() |
| 4508 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id101)) |
| 4509 | |
| 4510 | # Create VLAN102 flow and tables for port3 and port4 |
| 4511 | tmp_ports2 = list(ports) |
| 4512 | tmp_ports2.remove(ports[0]) |
| 4513 | tmp_ports2.remove(ports[1]) |
| 4514 | |
| 4515 | for port in tmp_ports2: |
| 4516 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id102, True, False) |
| 4517 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id102, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4518 | groups.put(L2gid) |
| 4519 | |
| 4520 | msg = add_l2_flood_group(self.controller, tmp_ports2, vlan_id102, vlan_id102) |
| 4521 | groups.put(msg.group_id) |
| 4522 | add_bridge_flow(self.controller, None, vlan_id102, msg.group_id, True) |
| 4523 | |
| 4524 | # do_barrier(self.controller) |
| 4525 | |
| 4526 | logging.info( |
| 4527 | "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id102)) |
| 4528 | add_acl_rule(self.controller, vlan_id=vlan_id102) |
| 4529 | |
| 4530 | match = ofp.match() |
| 4531 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id102)) |
| 4532 | |
| 4533 | |
| 4534 | # verify flood VLAN100 from port1 to port4 |
| 4535 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100)) |
| 4536 | for ofport in tmp_ports: |
| 4537 | # change dest based on port number |
| 4538 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 4539 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4540 | out_vlan_vid=vlan_id100, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 4541 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4542 | |
| 4543 | pkt = str(parsed_pkt) |
| 4544 | self.dataplane.send(ofport, pkt) |
| 4545 | # self won't rx packet |
| 4546 | verify_no_packet(self, pkt, ofport) |
| 4547 | # others will rx packet |
| 4548 | tmp_ports.remove(ofport) |
| 4549 | verify_packets(self, pkt, tmp_ports) |
| 4550 | |
| 4551 | # verify flood VLAN101 from port2 to port4 |
| 4552 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101)) |
| 4553 | for ofport in tmp_ports1: |
| 4554 | # change dest based on port number |
| 4555 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 4556 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4557 | out_vlan_vid=vlan_id101, in_dl_vlan_enable=True, |
| 4558 | in_vlan_vid=10, |
| 4559 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4560 | |
| 4561 | pkt = str(parsed_pkt) |
| 4562 | self.dataplane.send(ofport, pkt) |
| 4563 | # self won't rx packet |
| 4564 | verify_no_packet(self, pkt, ofport) |
| 4565 | # others will rx packet |
| 4566 | tmp_ports1.remove(ofport) |
| 4567 | verify_packets(self, pkt, tmp_ports1) |
| 4568 | |
| 4569 | # verify flood VLAN102 from port3 to port4 |
| 4570 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id102)) |
| 4571 | for ofport in tmp_ports2: |
| 4572 | # change dest based on port number |
| 4573 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 4574 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4575 | out_vlan_vid=vlan_id102, in_dl_vlan_enable=True, |
| 4576 | in_vlan_vid=10, |
| 4577 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4578 | |
| 4579 | pkt = str(parsed_pkt) |
| 4580 | self.dataplane.send(ofport, pkt) |
| 4581 | # self won't rx packet |
| 4582 | verify_no_packet(self, pkt, ofport) |
| 4583 | # others will rx packet |
| 4584 | tmp_ports2.remove(ofport) |
| 4585 | verify_packets(self, pkt, tmp_ports2) |
| 4586 | |
| 4587 | # verify flood VLAN101 to port1 - no receive on other ports |
| 4588 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101)) |
| 4589 | mac_src = '00:12:34:56:78:01' |
| 4590 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4591 | out_vlan_vid=vlan_id101, in_dl_vlan_enable=True, |
| 4592 | in_vlan_vid=10, |
| 4593 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4594 | |
| 4595 | pkt = str(parsed_pkt) |
| 4596 | self.dataplane.send(ports[0], pkt) |
| 4597 | # won't rx packet |
| 4598 | verify_no_packet(self, pkt, ports[1]) |
| 4599 | verify_no_packet(self, pkt, ports[2]) |
| 4600 | verify_no_packet(self, pkt, ports[3]) |
| 4601 | |
| 4602 | # verify flood VLAN100 to port4 - receive on port1 |
| 4603 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100)) |
| 4604 | mac_src = '00:12:34:56:78:04' |
| 4605 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4606 | out_vlan_vid=vlan_id100, in_dl_vlan_enable=True, |
| 4607 | in_vlan_vid=10, |
| 4608 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4609 | |
| 4610 | pkt = str(parsed_pkt) |
| 4611 | self.dataplane.send(ports[3], pkt) |
| 4612 | tmp_ports = list(ports) |
| 4613 | tmp_ports.remove(ports[1]) |
| 4614 | tmp_ports.remove(ports[2]) |
| 4615 | tmp_ports.remove(ports[3]) |
| 4616 | # rx packet on port1 |
| 4617 | verify_packets(self, pkt, tmp_ports) |
| 4618 | |
| 4619 | # verify flood VLAN101 to port4 - receive on port2 |
| 4620 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101)) |
| 4621 | mac_src = '00:12:34:56:78:04' |
| 4622 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4623 | out_vlan_vid=vlan_id101, in_dl_vlan_enable=True, |
| 4624 | in_vlan_vid=10, |
| 4625 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4626 | |
| 4627 | pkt = str(parsed_pkt) |
| 4628 | self.dataplane.send(ports[3], pkt) |
| 4629 | tmp_ports = list(ports) |
| 4630 | tmp_ports.remove(ports[0]) |
| 4631 | tmp_ports.remove(ports[2]) |
| 4632 | tmp_ports.remove(ports[3]) |
| 4633 | # rx packet on port1 |
| 4634 | verify_packets(self, pkt, tmp_ports) |
| 4635 | |
| 4636 | # verify flood VLAN102 to port4 - receive on port3 |
| 4637 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id102)) |
| 4638 | mac_src = '00:12:34:56:78:04' |
| 4639 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4640 | out_vlan_vid=vlan_id102, in_dl_vlan_enable=True, |
| 4641 | in_vlan_vid=10, |
| 4642 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4643 | |
| 4644 | pkt = str(parsed_pkt) |
| 4645 | self.dataplane.send(ports[3], pkt) |
| 4646 | tmp_ports = list(ports) |
| 4647 | tmp_ports.remove(ports[0]) |
| 4648 | tmp_ports.remove(ports[1]) |
| 4649 | tmp_ports.remove(ports[3]) |
| 4650 | # rx packet on port1 |
| 4651 | verify_packets(self, pkt, tmp_ports) |
| 4652 | |
| 4653 | logging.info("Cleanup flows") |
| 4654 | delete_all_flows(self.controller) |
| 4655 | |
| 4656 | # verify flood VLAN101 to port1 and port4 - no receive on any ports |
| 4657 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100)) |
| 4658 | mac_src = '00:12:34:56:78:01' |
| 4659 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4660 | out_vlan_vid=vlan_id100, in_dl_vlan_enable=True, |
| 4661 | in_vlan_vid=10, |
| 4662 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4663 | |
| 4664 | pkt = str(parsed_pkt) |
| 4665 | self.dataplane.send(ports[0], pkt) |
| 4666 | tmp_ports = list(ports) |
| 4667 | tmp_ports.remove(ports[0]) |
| 4668 | # won't rx packet |
| 4669 | verify_no_packet(self, pkt, ports[1]) |
| 4670 | verify_no_packet(self, pkt, ports[2]) |
| 4671 | verify_no_packet(self, pkt, ports[3]) |
| 4672 | |
| 4673 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100)) |
| 4674 | mac_src = '00:12:34:56:78:04' |
| 4675 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, |
| 4676 | out_vlan_vid=vlan_id100, in_dl_vlan_enable=True, |
| 4677 | in_vlan_vid=10, |
| 4678 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 4679 | |
| 4680 | pkt = str(parsed_pkt) |
| 4681 | self.dataplane.send(ports[3], pkt) |
| 4682 | tmp_ports = list(ports) |
| 4683 | tmp_ports.remove(ports[3]) |
| 4684 | # won't rx packet |
| 4685 | verify_no_packet(self, pkt, ports[0]) |
| 4686 | verify_no_packet(self, pkt, ports[1]) |
| 4687 | verify_no_packet(self, pkt, ports[2]) |
| 4688 | |
| 4689 | finally: |
| 4690 | delete_all_flows(self.controller) |
| 4691 | delete_groups(self.controller, groups) |
| 4692 | delete_all_groups(self.controller) |
| 4693 | logging.info("End of Test") |
| 4694 | |
| 4695 | |
| 4696 | class FabricSW_OF_Counters_TC_0095(base_tests.SimpleDataPlane): |
| 4697 | """ |
| 4698 | To verify the following port counters can be retrieved successfully from Open Flow switch: |
| 4699 | rx_bytes_total, tx_bytes_total, rx_packets_total, tx_packets_total, rx_drop_packets_total, tx_drop_packets_total. |
| 4700 | """ |
| 4701 | |
| 4702 | def runTest(self): |
| 4703 | groups = Queue.LifoQueue() |
| 4704 | try: |
| 4705 | ports = sorted(config["port_map"].keys()) |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4706 | pair = [ports[(1 - 1)], ports[(2 - 1)]] |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4707 | vlan_id = 100 |
| 4708 | vlan_len = 4 |
| 4709 | num_pkts = 5 |
| 4710 | pktlen = 108 |
| 4711 | rx_bytes_expected = (pktlen + vlan_len) * num_pkts |
| 4712 | rx_dropped_expected = 0 |
| 4713 | tx_pkt_expected = num_pkts |
| 4714 | tx_bytes_expected = rx_bytes_expected |
| 4715 | tx_dropped_expected = 0 |
| 4716 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4717 | for port in pair: |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4718 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 4719 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4720 | groups.put(L2gid) |
| 4721 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4722 | msg = add_l2_flood_group(self.controller, pair, vlan_id, vlan_id) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4723 | groups.put(msg.group_id) |
| 4724 | add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True) |
| 4725 | |
| 4726 | # do_barrier(self.controller) |
| 4727 | |
| 4728 | logging.info("Add a flow to TABLE-60 to match vlan {}".format(vlan_id)) |
| 4729 | add_acl_rule(self.controller, vlan_id=vlan_id) |
| 4730 | |
| 4731 | match = ofp.match() |
| 4732 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id)) |
| 4733 | |
| 4734 | # Send Port_Stats request for the ingress port (retrieve old counter state) |
| 4735 | initial_stats_rx = get_port_stats(self, ports[0]) |
| 4736 | initial_stats_tx = get_port_stats(self, ports[1]) |
| 4737 | |
Roman Bubyr | 8c38557 | 2019-04-25 11:45:13 +0300 | [diff] [blame] | 4738 | time.sleep(2) |
Sreeju Sreedhar | e3fefd9 | 2019-04-02 15:57:15 -0700 | [diff] [blame] | 4739 | logging.info("Get required counter values from port".format(ports[0])) |
| 4740 | rx_bytes_before = get_required_statistic_from_port(self, ports[0], "rx_bytes") |
| 4741 | rx_pkts_before = get_required_statistic_from_port(self, ports[0], "rx_packets") |
| 4742 | rx_dropped_before = get_required_statistic_from_port(self, ports[0], "rx_dropped") |
| 4743 | tx_bytes_before = get_required_statistic_from_port(self, ports[1], "tx_bytes") |
| 4744 | tx_packets_before = get_required_statistic_from_port(self, ports[1], "tx_packets") |
| 4745 | tx_dropped_before = get_required_statistic_from_port(self, ports[1], "tx_dropped") |
| 4746 | |
| 4747 | logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id)) |
| 4748 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=pktlen, |
| 4749 | out_dl_vlan_enable=True, |
| 4750 | out_vlan_vid=vlan_id, |
| 4751 | in_dl_vlan_enable=True, |
| 4752 | in_vlan_vid=10, |
| 4753 | eth_dst='00:12:34:56:78:9a') |
| 4754 | pkt = str(parsed_pkt) |
| 4755 | |
| 4756 | logging.info("Send double tugged packets to port {}".format(ports[0])) |
| 4757 | for pkt_cnt in range(num_pkts): |
| 4758 | self.dataplane.send(ports[0], pkt) |
| 4759 | |
| 4760 | logging.info("Verify transmitted_packet counters") |
| 4761 | verify_port_stats(self, ports[0], initial=initial_stats_rx, rx_pkts=num_pkts) |
| 4762 | verify_port_stats(self, ports[1], initial=initial_stats_tx, tx_pkts=num_pkts) |
| 4763 | |
| 4764 | logging.info("Get required counter values from port after sending packets".format(ports[0])) |
| 4765 | rx_bytes_after = get_required_statistic_from_port(self, ports[0], "rx_bytes") |
| 4766 | rx_pkts_after = get_required_statistic_from_port(self, ports[0], "rx_packets") |
| 4767 | rx_dropped_after = get_required_statistic_from_port(self, ports[0], "rx_dropped") |
| 4768 | tx_bytes_after = get_required_statistic_from_port(self, ports[1], "tx_bytes") |
| 4769 | tx_packets_after = get_required_statistic_from_port(self, ports[1], "tx_packets") |
| 4770 | tx_dropped_after = get_required_statistic_from_port(self, ports[1], "tx_dropped") |
| 4771 | |
| 4772 | logging.info("Verify values incremented as expected on port".format(ports[0])) |
| 4773 | self.assertGreaterEqual(rx_pkts_after - rx_pkts_before, num_pkts, |
| 4774 | "Port RX packet counter is not updated as expected: {}, current value: {}".format(num_pkts, rx_pkts_after - rx_pkts_before)) |
| 4775 | self.assertGreaterEqual(rx_bytes_after - rx_bytes_before, rx_bytes_expected, |
| 4776 | "Port RX bytes counter is not updated as expected: {}, current value: {}".format(rx_bytes_expected, rx_bytes_after - rx_bytes_before)) |
| 4777 | self.assertGreaterEqual(rx_dropped_after - rx_dropped_before, rx_dropped_expected, |
| 4778 | "Port RX dropped counter is not updated as expected: {}, current value: {}".format(rx_dropped_expected, rx_dropped_after - rx_dropped_before)) |
| 4779 | |
| 4780 | self.assertEqual(tx_packets_after - tx_packets_before, tx_pkt_expected, |
| 4781 | "Port TX packet counter is not updated as expected: {}, current value: {}".format(tx_pkt_expected, tx_packets_after - tx_packets_before)) |
| 4782 | self.assertEqual(tx_bytes_after - tx_bytes_before, tx_bytes_expected, |
| 4783 | "Port TX bytes counter is not updated as expected: {}, current value: {}".format(tx_bytes_expected, tx_bytes_after - tx_bytes_before)) |
| 4784 | self.assertEqual(tx_dropped_after - tx_dropped_before, tx_dropped_expected, |
| 4785 | "Port TX dropped counter is not updated as expected: {}, current value: {}".format(tx_dropped_expected, tx_dropped_after - tx_dropped_before)) |
| 4786 | |
| 4787 | finally: |
| 4788 | delete_all_flows(self.controller) |
| 4789 | delete_groups(self.controller, groups) |
| 4790 | delete_all_groups(self.controller) |
| 4791 | logging.info("End of Test") |
| 4792 | |
| 4793 | |
| 4794 | def similar_steps(eth_type, not_expected_eth_type, self): |
| 4795 | """ |
| 4796 | Similar steps for tests: FabricSW_OF_BDDP_TC_0020 and FabricSW_OF_LLDP_TC_0015 |
| 4797 | parameters: |
| 4798 | @param eth_type matched ethernet type |
| 4799 | @param not_expected_eth_type not matched ethernet type |
| 4800 | @param self class instance |
| 4801 | """ |
| 4802 | |
| 4803 | ports = sorted(config["port_map"].keys()) |
| 4804 | |
| 4805 | logging.info("Step 1") |
| 4806 | logging.info( |
| 4807 | "Add a flow to TABLE-60 to match Ethernet Type to {} and action Send to Controller".format(eth_type)) |
| 4808 | add_acl_rule(self.controller, eth_type=eth_type) |
| 4809 | |
| 4810 | match = ofp.match() |
| 4811 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
| 4812 | |
| 4813 | logging.info("Step 2") |
| 4814 | logging.info("Creating an untagged packet with ethernet type {}".format(hex(eth_type))) |
| 4815 | parsed_pkt = simple_eth_packet(eth_type=eth_type) |
| 4816 | eth_pkt = str(parsed_pkt) |
| 4817 | |
| 4818 | logging.info("Step 3") |
| 4819 | logging.info("Creating an untagged packet with ethernet type {}".format(hex(not_expected_eth_type))) |
| 4820 | parsed_pkt_not_expected = simple_eth_packet(eth_type=not_expected_eth_type) |
| 4821 | eth_pkt_non_lldp = str(parsed_pkt_not_expected) |
| 4822 | |
| 4823 | logging.info("Step 4") |
| 4824 | logging.info( |
| 4825 | "Send untagged packet with ethernet type {} to port {}".format(hex(eth_type), ports[0])) |
| 4826 | self.dataplane.send(ports[0], eth_pkt) |
| 4827 | verify_packet_in(self, eth_pkt, ports[0], ofp.OFPR_ACTION) |
| 4828 | |
| 4829 | logging.info("Step 5") |
| 4830 | logging.info( |
| 4831 | "Send untagged packet with ethernet type {} to port {}".format(hex(not_expected_eth_type), ports[0])) |
| 4832 | self.dataplane.send(ports[0], eth_pkt_non_lldp) |
| 4833 | verify_no_packet_in(self, eth_pkt_non_lldp, ports[0]) |
| 4834 | |
| 4835 | logging.info("Step 6 Cleanup flows") |
| 4836 | delete_all_flows(self.controller) |
| 4837 | time.sleep(1) |
| 4838 | |
| 4839 | logging.info("Step 7") |
| 4840 | logging.info( |
| 4841 | "Send untagged packet with ethernet type {} to port {}".format(hex(eth_type), ports[0])) |
| 4842 | self.dataplane.send(ports[0], eth_pkt) |
| 4843 | verify_no_packet_in(self, eth_pkt, ports[0]) |
| 4844 | |
| 4845 | |
| 4846 | @disabled |
| 4847 | class test_interface_flap(base_tests.SimpleDataPlane): |
| 4848 | """ |
| 4849 | This is pilot test case to verify interface flap |
| 4850 | """ |
| 4851 | |
| 4852 | def runTest(self): |
| 4853 | try: |
| 4854 | eth_type_eapol = 0x888e |
| 4855 | eth_type = 0x8100 |
| 4856 | vlan_id100 = 100 |
| 4857 | vlanid200 = 200 |
| 4858 | |
| 4859 | logging.info("Step 1") |
| 4860 | logging.info( |
| 4861 | "Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.") |
| 4862 | |
| 4863 | ports = sorted(config["port_map"].keys()) |
| 4864 | for port in ports: |
| 4865 | add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 4866 | |
| 4867 | add_acl_rule(self.controller, eth_type=eth_type_eapol) |
| 4868 | |
| 4869 | match = ofp.match() |
| 4870 | match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol)) |
| 4871 | |
| 4872 | logging.info("Step 2") |
| 4873 | logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_eapol))) |
| 4874 | parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True, |
| 4875 | in_dl_vlan_enable=True, |
| 4876 | out_vlan_tpid=eth_type, |
| 4877 | in_vlan_tpid=eth_type_eapol, |
| 4878 | out_vlan_vid=vlan_id100, |
| 4879 | in_vlan_vid=vlanid200) |
| 4880 | vlan_pkt = str(parsed_pkt) |
| 4881 | |
| 4882 | logging.info("Step 4") |
| 4883 | logging.info("Send untagged packet to port {}".format(ports[0])) |
| 4884 | |
| 4885 | self.dataplane.send(ports[0], vlan_pkt) |
| 4886 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4887 | |
| 4888 | print("") |
| 4889 | print("flapping interface") |
| 4890 | self.dataplane.port_down(ports[0]) |
| 4891 | |
| 4892 | time.sleep(2) |
| 4893 | |
| 4894 | print("bring up interface") |
| 4895 | self.dataplane.port_up(ports[0]) |
| 4896 | |
| 4897 | self.dataplane.send(ports[0], vlan_pkt) |
| 4898 | verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION) |
| 4899 | |
| 4900 | |
| 4901 | finally: |
| 4902 | delete_all_flows(self.controller) |
| 4903 | delete_all_groups(self.controller) |
| 4904 | logging.info("End of Test") |