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