Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -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 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 17 | """ |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 18 | Check README file |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 19 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 20 | import Queue |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 21 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 22 | from oftest import config |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 23 | import inspect |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 24 | import logging |
| 25 | import oftest.base_tests as base_tests |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 26 | import ofp |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 27 | import time |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 28 | from oftest.testutils import * |
| 29 | from accton_util import * |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 30 | from utils import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 31 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 32 | class PacketInUDP( base_tests.SimpleDataPlane ): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 33 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 34 | Verify ACL rule for IP_PROTO=2 wont match a UDP packet and a rule for IP_PROTO=17 WILL match a UDP packet. |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 35 | """ |
| 36 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 37 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 38 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 39 | parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 40 | vlan_pkt = str( parsed_vlan_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 41 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 42 | match = ofp.match( ) |
| 43 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 44 | match.oxm_list.append( ofp.oxm.ip_proto( 2 ) ) |
| 45 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 46 | ofp.instruction.apply_actions( actions=[ |
| 47 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 48 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 49 | logging.info( "Inserting packet in flow to controller" ) |
| 50 | self.controller.message_send( request ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 51 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 52 | for of_port in config[ "port_map" ].keys( ): |
| 53 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 54 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 55 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 56 | verify_no_packet_in( self, vlan_pkt, of_port ) |
| 57 | delete_all_flows( self.controller ) |
| 58 | do_barrier( self.controller ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 59 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 60 | match = ofp.match( ) |
| 61 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 62 | match.oxm_list.append( ofp.oxm.ip_proto( 17 ) ) |
| 63 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 64 | ofp.instruction.apply_actions( actions=[ |
| 65 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 66 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 67 | logging.info( "Inserting packet in flow to controller" ) |
| 68 | self.controller.message_send( request ) |
| 69 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 70 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 71 | for of_port in config[ "port_map" ].keys( ): |
| 72 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 73 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 74 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 75 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 76 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 77 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 78 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 79 | delete_all_flows( self.controller ) |
| 80 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 81 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 82 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 83 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 84 | class ArpNL2( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 85 | """ |
| 86 | Needs a description, disabled for now. Also needs try/finally |
| 87 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 88 | def runTest( self ): |
| 89 | delete_all_flows( self.controller ) |
| 90 | delete_all_groups( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 91 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 92 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 93 | match = ofp.match( ) |
| 94 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 95 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 96 | ofp.instruction.apply_actions( actions=[ |
| 97 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 98 | buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| 99 | self.controller.message_send( request ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 100 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 101 | add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| 102 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 103 | group_id = encode_l2_interface_group_id( 1, port ) |
| 104 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| 105 | do_barrier( self.controller ) |
| 106 | parsed_arp_pkt = simple_arp_packet( ) |
| 107 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 108 | |
| 109 | for out_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 110 | self.dataplane.send( out_port, arp_pkt ) |
| 111 | verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 112 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 113 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 114 | for in_port in ports: |
| 115 | if in_port == out_port: |
| 116 | continue |
| 117 | # change source based on port number to avoid packet-ins from learning |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 118 | mac_src = '00:12:34:56:78:%02X' % in_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 119 | parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| 120 | pkt = str( parsed_pkt ) |
| 121 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 122 | |
| 123 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 124 | if ofport in [ out_port ]: |
| 125 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 126 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 127 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 128 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 129 | verify_no_other_packets( self ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 130 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 131 | class PacketInArp( base_tests.SimpleDataPlane ): |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 132 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 133 | Verify Packet-in message from eth_type 0x806 on ACL table |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 134 | """ |
| 135 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 136 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 137 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 138 | parsed_arp_pkt = simple_arp_packet( ) |
| 139 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 140 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 141 | match = ofp.match( ) |
| 142 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 143 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 144 | ofp.instruction.apply_actions( actions=[ |
| 145 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 146 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 147 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 148 | logging.info( "Inserting arp flow " ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 149 | self.controller.message_send( request ) |
| 150 | do_barrier( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 151 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 152 | for of_port in config[ "port_map" ].keys( ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 153 | logging.info( "PacketInArp test, sending arp packet to port %d", of_port ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 154 | self.dataplane.send( of_port, arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 155 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 156 | verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 157 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 158 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 159 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 160 | delete_all_flows( self.controller ) |
| 161 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 162 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 163 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 164 | class PacketInIPTable( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 165 | """ |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 166 | Verify Packet-in message from IP table when controller action is used |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 167 | Send a packet to each dataplane port and verify that a packet |
| 168 | in message is received from the controller for each |
| 169 | #todo verify you stop receiving after adding rule |
| 170 | """ |
| 171 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 172 | def runTest( self ): |
| 173 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 174 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 175 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 176 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 177 | dip = 0xc0a80001 |
| 178 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 179 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 180 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 181 | # add l2 interface group |
| 182 | vlan_id = port |
| 183 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| 184 | send_barrier=False ) |
| 185 | dst_mac[ 5 ] = vlan_id |
| 186 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 187 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 188 | # add vlan flow table |
| 189 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 190 | # add termination flow |
| 191 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 192 | # add unicast routing flow |
| 193 | dst_ip = dip + (vlan_id << 8) |
| 194 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| 195 | send_ctrl=True ) |
| 196 | Groups.put( l3_msg.group_id ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 197 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 198 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 199 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 200 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 201 | for in_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 202 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 203 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 204 | for out_port in ports: |
| 205 | if in_port == out_port: |
| 206 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 207 | ip_dst = '192.168.%02d.1' % out_port |
| 208 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 209 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 210 | pkt = str( parsed_pkt ) |
| 211 | self.dataplane.send( in_port, pkt ) |
| 212 | verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| 213 | # verify_no_other_packets(self) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 214 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 215 | delete_all_flows( self.controller ) |
| 216 | delete_groups( self.controller, Groups ) |
| 217 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 218 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 219 | |
| 220 | class L2FloodQinQ( base_tests.SimpleDataPlane ): |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 221 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 222 | Verify Vlan based flooding of QinQ based on its outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 223 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 224 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 225 | def runTest( self ): |
| 226 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 227 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 228 | ports = sorted( config[ "port_map" ].keys( ) ) |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 229 | vlan_id = 100 |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 230 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 231 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 232 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Saurav Das | 15c2c26 | 2017-05-06 18:12:38 -0700 | [diff] [blame] | 233 | add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 234 | Groups.put( L2gid ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 235 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 236 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 237 | Groups.put( msg.group_id ) |
| 238 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 239 | do_barrier( self.controller ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 240 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 241 | # verify flood |
| 242 | for ofport in ports: |
| 243 | # change dest based on port number |
| 244 | mac_src = '00:12:34:56:78:%02X' % ofport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 245 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 246 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 247 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 248 | pkt = str( parsed_pkt ) |
| 249 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 250 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 251 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 252 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 253 | tmp_ports = list( ports ) |
| 254 | tmp_ports.remove( ofport ) |
| 255 | verify_packets( self, pkt, tmp_ports ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 256 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 257 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 258 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 259 | delete_all_flows( self.controller ) |
| 260 | delete_groups( self.controller, Groups ) |
| 261 | delete_all_groups( self.controller ) |
| 262 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 263 | |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 264 | |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 265 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 266 | class L2FloodTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 267 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 268 | currently disabled; fix with try/finally |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 269 | Test L2 flood to a vlan |
| 270 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 271 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 272 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 273 | def runTest( self ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 274 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 275 | vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 276 | print vlan_id |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 277 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 278 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 279 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 280 | delete_all_flows( self.controller ) |
| 281 | delete_all_groups( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 282 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 283 | # Installing flows to avoid packet-in |
| 284 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 285 | add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 286 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 287 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 288 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 289 | do_barrier( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 290 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 291 | # verify flood |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 292 | for ofport in ports: |
| 293 | # change dest based on port number |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 294 | pkt = str( |
| 295 | simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| 296 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 297 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 298 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 299 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 300 | tmp_ports = list( ports ) |
| 301 | tmp_ports.remove( ofport ) |
| 302 | verify_packets( self, pkt, tmp_ports ) |
| 303 | verify_no_other_packets( self ) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 304 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 305 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 306 | class L2UnicastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 307 | """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 308 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 309 | def runTest( self ): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 310 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 311 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 312 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 313 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 314 | vlan_id = 1; |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 315 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 316 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 317 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 318 | Groups.put( L2gid ) |
| 319 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 320 | True ) |
| 321 | do_barrier( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 322 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 323 | for out_port in ports: |
| 324 | # change dest based on port number |
| 325 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 326 | for in_port in ports: |
| 327 | if in_port == out_port: |
| 328 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 329 | pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 330 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 331 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 332 | if ofport in [ out_port ]: |
| 333 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 334 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 335 | verify_no_packet( self, pkt, ofport ) |
| 336 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 337 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 338 | delete_all_flows( self.controller ) |
| 339 | delete_groups( self.controller, Groups ) |
| 340 | delete_all_groups( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 341 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 342 | |
| 343 | class Mtu1500( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 344 | """ |
| 345 | Verifies basic mtu limits |
| 346 | """ |
| 347 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 348 | def runTest( self ): |
| 349 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 350 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 351 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 352 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 353 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 354 | L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 355 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 356 | Groups.put( L2gid ) |
| 357 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 358 | True ) |
| 359 | do_barrier( self.controller ) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 360 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 361 | for out_port in ports: |
| 362 | # change dest based on port number |
| 363 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 364 | for in_port in ports: |
| 365 | if in_port == out_port: |
| 366 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 367 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 368 | eth_dst=mac_dst ) ) |
| 369 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 370 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 371 | if ofport in [ out_port ]: |
| 372 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 373 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 374 | verify_no_packet( self, pkt, ofport ) |
| 375 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 376 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 377 | delete_all_flows( self.controller ) |
| 378 | delete_groups( self.controller, Groups ) |
| 379 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 380 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 381 | |
| 382 | class _32UcastTagged( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 383 | """ Verify /32 IP forwarding to L3 Unicast-> L2Interface""" |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 384 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 385 | def runTest( self ): |
| 386 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 387 | try: |
| 388 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 389 | if len( config[ "port_map" ] ) < 2: |
| 390 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 391 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 392 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 393 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 394 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 395 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 396 | for port in ports: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 397 | vlan_id = port + test_id |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 398 | # add l2 interface group and l3 unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 399 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 400 | is_tagged=True, send_barrier=False ) |
| 401 | dst_mac[ 5 ] = vlan_id |
| 402 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 403 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 404 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 405 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 406 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 407 | if config["switch_type"] == "qmx": |
| 408 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 409 | else: |
| 410 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 411 | # add unicast routing flow |
| 412 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 413 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 414 | Groups.put( l2gid ) |
| 415 | Groups.put( l3_msg.group_id ) |
| 416 | do_barrier( self.controller ) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 417 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 418 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 419 | for in_port in ports: |
| 420 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 421 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 422 | for out_port in ports: |
| 423 | if in_port == out_port: |
| 424 | continue |
| 425 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 426 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 427 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 428 | ip_src=ip_src, ip_dst=ip_dst ) |
| 429 | pkt = str( parsed_pkt ) |
| 430 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 431 | # build expected packet |
| 432 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 433 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 434 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 435 | ip_src=ip_src, ip_dst=ip_dst ) |
| 436 | pkt = str( exp_pkt ) |
| 437 | verify_packet( self, pkt, out_port ) |
| 438 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 439 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 440 | delete_all_flows( self.controller ) |
| 441 | delete_groups( self.controller, Groups ) |
| 442 | delete_all_groups( self.controller ) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 443 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 444 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 445 | class _32VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 446 | """ |
| 447 | Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 448 | No ECMP group used |
| 449 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 450 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 451 | def runTest( self ): |
| 452 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 453 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 454 | if len( config[ "port_map" ] ) < 2: |
| 455 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 456 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 457 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 458 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 459 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 460 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 461 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 462 | for port in ports: |
| 463 | # add l2 interface group |
| 464 | id = port |
| 465 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 466 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 467 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 468 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 469 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 470 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 471 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 472 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 473 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 474 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 475 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 476 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 477 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 478 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 479 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 480 | if config["switch_type"] == "qmx": |
| 481 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 482 | else: |
| 483 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 484 | # add routing flow |
| 485 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 486 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 487 | Groups._put( l2_gid ) |
| 488 | Groups._put( mpls_gid ) |
| 489 | Groups._put( mpls_label_gid ) |
| 490 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 491 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 492 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 493 | for in_port in ports: |
| 494 | ip_src = '192.168.%02d.1' % (in_port) |
| 495 | for out_port in ports: |
| 496 | if in_port == out_port: |
| 497 | continue |
| 498 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 499 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 500 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 501 | pkt = str( parsed_pkt ) |
| 502 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 503 | # build expect packet |
| 504 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 505 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 506 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 507 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 508 | label=[ label ] ) |
| 509 | pkt = str( exp_pkt ) |
| 510 | verify_packet( self, pkt, out_port ) |
| 511 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 512 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 513 | delete_all_flows( self.controller ) |
| 514 | delete_groups( self.controller, Groups ) |
| 515 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 516 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 517 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 518 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 519 | """ |
| 520 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 521 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 522 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 523 | def runTest( self ): |
| 524 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 525 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 526 | if len( config[ "port_map" ] ) < 2: |
| 527 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 528 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 529 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 530 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 531 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 532 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 533 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 534 | for port in ports: |
| 535 | # add l2 interface group |
| 536 | id = port |
| 537 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 538 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 539 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 540 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 541 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 542 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 543 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 544 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 545 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 546 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 547 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 548 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 549 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 550 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 551 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 552 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 553 | if config["switch_type"] == "qmx": |
| 554 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 555 | else: |
| 556 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 557 | # add routing flow |
| 558 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 559 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 560 | Groups._put( l2_gid ) |
| 561 | Groups._put( mpls_gid ) |
| 562 | Groups._put( mpls_label_gid ) |
| 563 | Groups._put( ecmp_msg.group_id ) |
| 564 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 565 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 566 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 567 | for in_port in ports: |
| 568 | ip_src = '192.168.%02d.1' % (in_port) |
| 569 | for out_port in ports: |
| 570 | if in_port == out_port: |
| 571 | continue |
| 572 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 573 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 574 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 575 | pkt = str( parsed_pkt ) |
| 576 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 577 | # build expect packet |
| 578 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 579 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 580 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 581 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 582 | label=[ label ] ) |
| 583 | pkt = str( exp_pkt ) |
| 584 | verify_packet( self, pkt, out_port ) |
| 585 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 586 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 587 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 588 | delete_all_flows( self.controller ) |
| 589 | delete_groups( self.controller, Groups ) |
| 590 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 591 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 592 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 593 | @disabled |
| 594 | class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| 595 | """ |
| 596 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 597 | in only one direction |
| 598 | """ |
| 599 | |
| 600 | def runTest( self ): |
| 601 | Groups = Queue.LifoQueue( ) |
| 602 | try: |
| 603 | if len( config[ "port_map" ] ) < 2: |
| 604 | logging.info( "Port count less than 2, can't run this case" ) |
| 605 | return |
| 606 | |
| 607 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 608 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 609 | dip = 0xc0a80001 |
| 610 | ports = config[ "port_map" ].keys( ) |
| 611 | # add l2 interface group |
| 612 | id = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 613 | in_offset = 19 |
| 614 | out_offset = 20 |
| 615 | vlan_id = ports[1] + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 616 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 617 | dst_mac[ 5 ] = ports[1] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 618 | # add MPLS interface group |
| 619 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 620 | vlan_id, id ) |
| 621 | # add MPLS L3 VPN group |
| 622 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 623 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 624 | push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 625 | # add ECMP group |
| 626 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 627 | do_barrier( self.controller ) |
| 628 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 629 | add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 630 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 631 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 632 | if config["switch_type"] == "qmx": |
| 633 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| 634 | else: |
| 635 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 636 | # add routing flow |
| 637 | dst_ip = dip + (vlan_id << 8) |
| 638 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 639 | Groups._put( l2_gid ) |
| 640 | Groups._put( mpls_gid ) |
| 641 | Groups._put( mpls_label_gid ) |
| 642 | Groups._put( ecmp_msg.group_id ) |
| 643 | |
| 644 | |
| 645 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 646 | in_port = ports[0] |
| 647 | out_port = ports[1] |
| 648 | ip_src = '192.168.%02d.1' % (in_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 649 | ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| 650 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 651 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 652 | pkt = str( parsed_pkt ) |
| 653 | self.dataplane.send( in_port, pkt ) |
| 654 | # build expect packet |
| 655 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 656 | label = (out_port+out_offset, 0, 1, 32) |
| 657 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 658 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 659 | label=[ label ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 660 | pkt = str( exp_pkt ) |
| 661 | verify_packet( self, pkt, out_port ) |
| 662 | #verify_no_other_packets( self ) |
| 663 | |
| 664 | finally: |
| 665 | delete_all_flows( self.controller ) |
| 666 | delete_group(self.controller, ecmp_msg.group_id) |
| 667 | delete_group(self.controller, mpls_label_gid) |
| 668 | delete_group(self.controller, mpls_gid) |
| 669 | delete_group(self.controller, l2_gid) |
| 670 | |
| 671 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 672 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 673 | """ |
| 674 | Verifies /32 IP routing and ECMP with no label push |
| 675 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 676 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 677 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 678 | def runTest( self ): |
| 679 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 680 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 681 | if len( config[ "port_map" ] ) < 2: |
| 682 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 683 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 684 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 685 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 686 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 687 | dip = 0xc0a80001 |
| 688 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 689 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 690 | for port in ports: |
| 691 | vlan_id = port |
| 692 | id = port |
| 693 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 694 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 695 | is_tagged=True, send_barrier=False ) |
| 696 | dst_mac[ 5 ] = vlan_id |
| 697 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 698 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 699 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 700 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 701 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 702 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 703 | if config["switch_type"] == "qmx": |
| 704 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 705 | else: |
| 706 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 707 | # add unicast routing flow |
| 708 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 709 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 710 | Groups._put( l2_gid ) |
| 711 | Groups._put( l3_msg.group_id ) |
| 712 | Groups._put( ecmp_msg.group_id ) |
| 713 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 714 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 715 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 716 | for in_port in ports: |
| 717 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 718 | ip_src = '192.168.%02d.1' % in_port |
| 719 | for out_port in ports: |
| 720 | if in_port == out_port: |
| 721 | continue |
| 722 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 723 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 724 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 725 | pkt = str( parsed_pkt ) |
| 726 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 727 | # build expected packet |
| 728 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 729 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 730 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 731 | pkt = str( exp_pkt ) |
| 732 | verify_packet( self, pkt, out_port ) |
| 733 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 734 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 735 | delete_all_flows( self.controller ) |
| 736 | delete_groups( self.controller, Groups ) |
| 737 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 738 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 739 | @disabled |
| 740 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 741 | """ |
| 742 | Verifies /32 IP routing and ECMP with no label push |
| 743 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 744 | in only one direction |
| 745 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 746 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 747 | def runTest( self ): |
| 748 | Groups = Queue.LifoQueue( ) |
| 749 | try: |
| 750 | if len( config[ "port_map" ] ) < 2: |
| 751 | logging.info( "Port count less than 2, can't run this case" ) |
| 752 | return |
| 753 | |
| 754 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 755 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 756 | dip = 0xc0a80001 |
| 757 | # Hashes Test Name and uses it as id for installing unique groups |
| 758 | ports = config[ "port_map" ].keys( ) |
| 759 | inport = ports[0] |
| 760 | outport = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 761 | in_offset = 19 |
| 762 | out_offset = 20 |
| 763 | vlan_id = outport + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 764 | id = outport |
| 765 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 766 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 767 | is_tagged=True, send_barrier=False ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 768 | dst_mac[ 5 ] = outport |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 769 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 770 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 771 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 772 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 773 | add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 774 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 775 | if config["switch_type"] == "qmx": |
| 776 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset ) |
| 777 | else: |
| 778 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 779 | # add unicast routing flow |
| 780 | dst_ip = dip + (vlan_id << 8) |
| 781 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 782 | Groups._put( l2_gid ) |
| 783 | Groups._put( l3_msg.group_id ) |
| 784 | Groups._put( ecmp_msg.group_id ) |
| 785 | |
| 786 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 787 | mac_src = '00:00:00:22:22:%02X' % inport |
| 788 | ip_src = '192.168.%02d.1' % inport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 789 | ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| 790 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 791 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 792 | pkt = str( parsed_pkt ) |
| 793 | self.dataplane.send( inport, pkt ) |
| 794 | # build expected packet |
| 795 | mac_dst = '00:00:00:22:22:%02X' % outport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 796 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 797 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 798 | pkt = str( exp_pkt ) |
| 799 | verify_packet( self, pkt, outport ) |
| 800 | verify_no_other_packets( self ) |
| 801 | finally: |
| 802 | delete_all_flows( self.controller ) |
| 803 | delete_groups( self.controller, Groups ) |
| 804 | delete_all_groups( self.controller ) |
| 805 | |
| 806 | |
| 807 | |
| 808 | |
| 809 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 810 | class _24VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 811 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 812 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 813 | def runTest( self ): |
| 814 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 815 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 816 | if len( config[ "port_map" ] ) < 2: |
| 817 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 818 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 819 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 820 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 821 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 822 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 823 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 824 | for port in ports: |
| 825 | # add l2 interface group |
| 826 | id = port |
| 827 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 828 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 829 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 830 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 831 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 832 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 833 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 834 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 835 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 836 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 837 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 838 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 839 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 840 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 841 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 842 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 843 | if config["switch_type"] == "qmx": |
| 844 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 845 | else: |
| 846 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 847 | # add routing flow |
| 848 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 849 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 850 | Groups._put( l2_gid ) |
| 851 | Groups._put( mpls_gid ) |
| 852 | Groups._put( mpls_label_gid ) |
| 853 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 854 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 855 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 856 | for in_port in ports: |
| 857 | ip_src = '192.168.%02d.1' % (in_port) |
| 858 | for out_port in ports: |
| 859 | if in_port == out_port: |
| 860 | continue |
| 861 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 862 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 863 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 864 | pkt = str( parsed_pkt ) |
| 865 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 866 | # build expect packet |
| 867 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 868 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 869 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 870 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 871 | label=[ label ] ) |
| 872 | pkt = str( exp_pkt ) |
| 873 | verify_packet( self, pkt, out_port ) |
| 874 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 875 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 876 | delete_all_flows( self.controller ) |
| 877 | delete_groups( self.controller, Groups ) |
| 878 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 879 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 880 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 881 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 882 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 883 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 884 | def runTest( self ): |
| 885 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 886 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 887 | if len( config[ "port_map" ] ) < 2: |
| 888 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 889 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 890 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 891 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 892 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 893 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 894 | for port in ports: |
| 895 | # add l2 interface group |
| 896 | id = port |
| 897 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 898 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 899 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 900 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 901 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 902 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 903 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 904 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 905 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 906 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 907 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 908 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 909 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 910 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 911 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 912 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 913 | if config["switch_type"] == "qmx": |
| 914 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 915 | else: |
| 916 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 917 | # add routing flow |
| 918 | dst_ip = dip + (vlan_id << 8) |
| 919 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 920 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 921 | vrf=0 ) |
| 922 | Groups._put( l2_gid ) |
| 923 | Groups._put( mpls_gid ) |
| 924 | Groups._put( mpls_label_gid ) |
| 925 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 926 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 927 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 928 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 929 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 930 | for in_port in ports: |
| 931 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 932 | ip_src = '192.168.%02d.1' % (in_port) |
| 933 | for out_port in ports: |
| 934 | if in_port == out_port: |
| 935 | continue |
| 936 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 937 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 938 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 939 | pkt = str( parsed_pkt ) |
| 940 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 941 | # build expect packet |
| 942 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 943 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 944 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 945 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 946 | label=[ label ] ) |
| 947 | pkt = str( exp_pkt ) |
| 948 | verify_packet( self, pkt, out_port ) |
| 949 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 950 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 951 | delete_all_flows( self.controller ) |
| 952 | delete_groups( self.controller, Groups ) |
| 953 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 954 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 955 | |
| 956 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 957 | """ Modify a referenced flood group """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 958 | |
| 959 | def runTest( self ): |
| 960 | Groups = Queue.LifoQueue( ) |
| 961 | try: |
| 962 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 963 | vlan_id = 1 |
| 964 | |
| 965 | for port in ports: |
| 966 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 967 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 968 | Groups.put( L2gid ) |
| 969 | |
| 970 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 971 | Groups.put( msg.group_id ) |
| 972 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 973 | do_barrier( self.controller ) |
| 974 | # verify flood |
| 975 | for ofport in ports: |
| 976 | # change dest based on port number |
| 977 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 978 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 979 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 980 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 981 | pkt = str( parsed_pkt ) |
| 982 | self.dataplane.send( ofport, pkt ) |
| 983 | # self won't rx packet |
| 984 | verify_no_packet( self, pkt, ofport ) |
| 985 | # others will rx packet |
| 986 | tmp_ports = list( ports ) |
| 987 | tmp_ports.remove( ofport ) |
| 988 | verify_packets( self, pkt, tmp_ports ) |
| 989 | verify_no_other_packets( self ) |
| 990 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 991 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 992 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 993 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 994 | eth_src=mac_src ) |
| 995 | pkt = str( parsed_pkt ) |
| 996 | self.dataplane.send( ports[ 1 ], pkt ) |
| 997 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 998 | finally: |
| 999 | delete_all_flows( self.controller ) |
| 1000 | delete_groups( self.controller, Groups ) |
| 1001 | delete_all_groups( self.controller ) |
| 1002 | |
| 1003 | |
| 1004 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1005 | """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1006 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1007 | def runTest( self ): |
| 1008 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1009 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1010 | if len( config[ "port_map" ] ) < 2: |
| 1011 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1012 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1013 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1014 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1015 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1016 | dip = 0xc0a80001 |
| 1017 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1018 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1019 | for port in ports: |
| 1020 | vlan_id = port |
| 1021 | id = port |
| 1022 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1023 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1024 | is_tagged=True, send_barrier=False ) |
| 1025 | dst_mac[ 5 ] = vlan_id |
| 1026 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1027 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1028 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1029 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1030 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1031 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1032 | if config["switch_type"] == "qmx": |
| 1033 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1034 | else: |
| 1035 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1036 | # add unicast routing flow |
| 1037 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1038 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1039 | Groups._put( l2_gid ) |
| 1040 | Groups._put( l3_msg.group_id ) |
| 1041 | Groups._put( ecmp_msg.group_id ) |
| 1042 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1043 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1044 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1045 | for in_port in ports: |
| 1046 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1047 | ip_src = '192.168.%02d.1' % in_port |
| 1048 | for out_port in ports: |
| 1049 | if in_port == out_port: |
| 1050 | continue |
| 1051 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1052 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1053 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1054 | pkt = str( parsed_pkt ) |
| 1055 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1056 | # build expected packet |
| 1057 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1058 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1059 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1060 | pkt = str( exp_pkt ) |
| 1061 | verify_packet( self, pkt, out_port ) |
| 1062 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1063 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1064 | delete_all_flows( self.controller ) |
| 1065 | delete_groups( self.controller, Groups ) |
| 1066 | delete_all_groups( self.controller ) |
| 1067 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1068 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 1069 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1070 | class MPLSBUG( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1071 | """ |
| 1072 | Needs a description or needs to be removed |
| 1073 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1074 | def runTest( self ): |
| 1075 | if len( config[ "port_map" ] ) < 2: |
| 1076 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1077 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1078 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1079 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1080 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1081 | Groups = Queue.LifoQueue( ) |
| 1082 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1083 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1084 | # add l2 interface group |
| 1085 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1086 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1087 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1088 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1089 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1090 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1091 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1092 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1093 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1094 | if config["switch_type"] == "qmx": |
| 1095 | add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1096 | else: |
| 1097 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1098 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1099 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1100 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1101 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1102 | # add unicast routing flow |
| 1103 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1104 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1105 | Groups._put( l2_gid ) |
| 1106 | Groups._put( l3_msg.group_id ) |
| 1107 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1108 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1109 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1110 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1111 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1112 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1113 | for out_port in ports: |
| 1114 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1115 | continue |
| 1116 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1117 | switch_mac = "00:00:00:cc:cc:cc" |
| 1118 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1119 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1120 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1121 | pkt = str( parsed_pkt ) |
| 1122 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1123 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1124 | # build expect packet |
| 1125 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1126 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1127 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1128 | pkt = str( exp_pkt ) |
| 1129 | verify_packet( self, pkt, out_port ) |
| 1130 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1131 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1132 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1133 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1134 | pkt = str( parsed_pkt ) |
| 1135 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1136 | # build expected packet |
| 1137 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1138 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1139 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1140 | pkt = str( exp_pkt ) |
| 1141 | verify_packet( self, pkt, out_port ) |
| 1142 | verify_no_other_packets( self ) |
| 1143 | delete_all_flows( self.controller ) |
| 1144 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1145 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1146 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1147 | """ |
| 1148 | Mcast routing, in this test case the traffic comes in tagged. |
| 1149 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1150 | different ports. 4094-port is used as egress vlan_id. |
| 1151 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1152 | def runTest( self ): |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1153 | """ |
| 1154 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1155 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1156 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1157 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1158 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1159 | if len( config[ "port_map" ] ) < 1: |
| 1160 | logging.info( "Port count less than 1, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1161 | assert (False) |
| 1162 | return |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1163 | ports = config[ "port_map" ].keys( ) |
| 1164 | dst_ip_str = "224.0.0.1" |
| 1165 | ( |
| 1166 | port_to_in_vlan, |
| 1167 | port_to_out_vlan, |
| 1168 | port_to_src_mac_str, |
| 1169 | port_to_dst_mac_str, |
| 1170 | port_to_src_ip_str, |
| 1171 | port_to_intf_src_mac_str, |
| 1172 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1173 | self.controller, |
| 1174 | logging, |
| 1175 | ports, |
| 1176 | is_ingress_tagged = True, |
| 1177 | is_egress_tagged = True, |
| 1178 | is_vlan_translated = True, |
| 1179 | is_max_vlan = False |
| 1180 | ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1181 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1182 | for in_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1183 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1184 | parsed_pkt = simple_udp_packet( |
| 1185 | pktlen = 100, |
| 1186 | dl_vlan_enable = True, |
| 1187 | vlan_vid = port_to_in_vlan[in_port], |
| 1188 | eth_dst = port_to_dst_mac_str[in_port], |
| 1189 | eth_src = port_to_src_mac_str[in_port], |
| 1190 | ip_ttl = 64, |
| 1191 | ip_src = port_to_src_ip_str[in_port], |
| 1192 | ip_dst = dst_ip_str |
| 1193 | ) |
| 1194 | pkt = str( parsed_pkt ) |
| 1195 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1196 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1197 | for out_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1198 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1199 | parsed_pkt = simple_udp_packet( |
| 1200 | pktlen = 100, |
| 1201 | dl_vlan_enable = True, |
| 1202 | vlan_vid = port_to_out_vlan[out_port], |
| 1203 | eth_dst = port_to_dst_mac_str[in_port], |
| 1204 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1205 | ip_ttl = 63, |
| 1206 | ip_src = port_to_src_ip_str[in_port], |
| 1207 | ip_dst = dst_ip_str |
| 1208 | ) |
| 1209 | pkt = str( parsed_pkt ) |
| 1210 | verify_packet( self, pkt, out_port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1211 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1212 | verify_no_other_packets( self ) |
| 1213 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1214 | finally: |
| 1215 | delete_all_flows( self.controller ) |
| 1216 | delete_groups( self.controller, Groups ) |
| 1217 | delete_all_groups( self.controller ) |
| 1218 | |
| 1219 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1220 | """ |
| 1221 | Mcast routing, in this test case the traffic is untagged. |
| 1222 | 4094 is used as internal vlan_id. The packet goes out |
| 1223 | untagged. |
| 1224 | """ |
| 1225 | def runTest( self ): |
| 1226 | Groups = Queue.LifoQueue( ) |
| 1227 | try: |
| 1228 | if len( config[ "port_map" ] ) < 2: |
| 1229 | logging.info( "Port count less than 2, can't run this case" ) |
| 1230 | assert (False) |
| 1231 | return |
| 1232 | ports = config[ "port_map" ].keys( ) |
| 1233 | dst_ip_str = "224.0.0.1" |
| 1234 | ( |
| 1235 | port_to_in_vlan, |
| 1236 | port_to_out_vlan, |
| 1237 | port_to_src_mac_str, |
| 1238 | port_to_dst_mac_str, |
| 1239 | port_to_src_ip_str, |
| 1240 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1241 | self.controller, |
| 1242 | logging, |
| 1243 | ports, |
| 1244 | is_ingress_tagged = False, |
| 1245 | is_egress_tagged = False, |
| 1246 | is_vlan_translated = False, |
| 1247 | is_max_vlan = True |
| 1248 | ) |
| 1249 | |
| 1250 | for in_port in ports: |
| 1251 | |
| 1252 | parsed_pkt = simple_udp_packet( |
| 1253 | pktlen = 96, |
| 1254 | eth_dst = port_to_dst_mac_str[in_port], |
| 1255 | eth_src = port_to_src_mac_str[in_port], |
| 1256 | ip_ttl = 64, |
| 1257 | ip_src = port_to_src_ip_str[in_port], |
| 1258 | ip_dst = dst_ip_str |
| 1259 | ) |
| 1260 | pkt = str( parsed_pkt ) |
| 1261 | self.dataplane.send( in_port, pkt ) |
| 1262 | |
| 1263 | for out_port in ports: |
| 1264 | |
| 1265 | parsed_pkt = simple_udp_packet( |
| 1266 | pktlen = 96, |
| 1267 | eth_dst = port_to_dst_mac_str[in_port], |
| 1268 | eth_src = port_to_src_mac_str[in_port], |
| 1269 | ip_ttl = 64, |
| 1270 | ip_src = port_to_src_ip_str[in_port], |
| 1271 | ip_dst = dst_ip_str |
| 1272 | ) |
| 1273 | pkt = str( parsed_pkt ) |
| 1274 | if out_port == in_port: |
| 1275 | verify_no_packet( self, pkt, in_port ) |
| 1276 | continue |
| 1277 | verify_packet( self, pkt, out_port ) |
| 1278 | verify_no_other_packets( self ) |
| 1279 | finally: |
| 1280 | delete_all_flows( self.controller ) |
| 1281 | delete_groups( self.controller, Groups ) |
| 1282 | delete_all_groups( self.controller ) |
| 1283 | |
| 1284 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1285 | """ |
| 1286 | Mcast routing, in this test case the traffic is untagged. |
| 1287 | 300 is used as vlan_id. The packet goes out |
| 1288 | tagged. |
| 1289 | """ |
| 1290 | def runTest( self ): |
| 1291 | Groups = Queue.LifoQueue( ) |
| 1292 | try: |
| 1293 | if len( config[ "port_map" ] ) < 2: |
| 1294 | logging.info( "Port count less than 2, can't run this case" ) |
| 1295 | assert (False) |
| 1296 | return |
| 1297 | ports = config[ "port_map" ].keys( ) |
| 1298 | dst_ip_str = "224.0.0.1" |
| 1299 | ( |
| 1300 | port_to_in_vlan, |
| 1301 | port_to_out_vlan, |
| 1302 | port_to_src_mac_str, |
| 1303 | port_to_dst_mac_str, |
| 1304 | port_to_src_ip_str, |
| 1305 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1306 | self.controller, |
| 1307 | logging, |
| 1308 | ports, |
| 1309 | is_ingress_tagged = False, |
| 1310 | is_egress_tagged = True, |
| 1311 | is_vlan_translated = False, |
| 1312 | is_max_vlan = False |
| 1313 | ) |
| 1314 | |
| 1315 | for in_port in ports: |
| 1316 | |
| 1317 | parsed_pkt = simple_udp_packet( |
| 1318 | pktlen = 96, |
| 1319 | eth_dst = port_to_dst_mac_str[in_port], |
| 1320 | eth_src = port_to_src_mac_str[in_port], |
| 1321 | ip_ttl = 64, |
| 1322 | ip_src = port_to_src_ip_str[in_port], |
| 1323 | ip_dst = dst_ip_str |
| 1324 | ) |
| 1325 | pkt = str( parsed_pkt ) |
| 1326 | self.dataplane.send( in_port, pkt ) |
| 1327 | |
| 1328 | for out_port in ports: |
| 1329 | |
| 1330 | parsed_pkt = simple_udp_packet( |
| 1331 | pktlen = 100, |
| 1332 | dl_vlan_enable = True, |
| 1333 | vlan_vid = port_to_out_vlan[in_port], |
| 1334 | eth_dst = port_to_dst_mac_str[in_port], |
| 1335 | eth_src = port_to_src_mac_str[in_port], |
| 1336 | ip_ttl = 64, |
| 1337 | ip_src = port_to_src_ip_str[in_port], |
| 1338 | ip_dst = dst_ip_str |
| 1339 | ) |
| 1340 | pkt = str( parsed_pkt ) |
| 1341 | if out_port == in_port: |
| 1342 | verify_no_packet( self, pkt, in_port ) |
| 1343 | continue |
| 1344 | verify_packet( self, pkt, out_port ) |
| 1345 | verify_no_other_packets( self ) |
| 1346 | finally: |
| 1347 | delete_all_flows( self.controller ) |
| 1348 | delete_groups( self.controller, Groups ) |
| 1349 | delete_all_groups( self.controller ) |
| 1350 | |
| 1351 | |
| 1352 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1353 | """ |
| 1354 | Mcast routing, in this test case the traffic is tagged. |
| 1355 | 300 is used as vlan_id. The packet goes out |
| 1356 | untagged. |
| 1357 | """ |
| 1358 | def runTest( self ): |
| 1359 | Groups = Queue.LifoQueue( ) |
| 1360 | try: |
| 1361 | if len( config[ "port_map" ] ) < 2: |
| 1362 | logging.info( "Port count less than 2, can't run this case" ) |
| 1363 | assert (False) |
| 1364 | return |
| 1365 | ports = config[ "port_map" ].keys( ) |
| 1366 | dst_ip_str = "224.0.0.1" |
| 1367 | ( |
| 1368 | port_to_in_vlan, |
| 1369 | port_to_out_vlan, |
| 1370 | port_to_src_mac_str, |
| 1371 | port_to_dst_mac_str, |
| 1372 | port_to_src_ip_str, |
| 1373 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1374 | self.controller, |
| 1375 | logging, |
| 1376 | ports, |
| 1377 | is_ingress_tagged = True, |
| 1378 | is_egress_tagged = False, |
| 1379 | is_vlan_translated = False, |
| 1380 | is_max_vlan = False |
| 1381 | ) |
| 1382 | |
| 1383 | for in_port in ports: |
| 1384 | |
| 1385 | parsed_pkt = simple_udp_packet( |
| 1386 | pktlen = 100, |
| 1387 | dl_vlan_enable = True, |
| 1388 | vlan_vid = port_to_in_vlan[in_port], |
| 1389 | eth_dst = port_to_dst_mac_str[in_port], |
| 1390 | eth_src = port_to_src_mac_str[in_port], |
| 1391 | ip_ttl = 64, |
| 1392 | ip_src = port_to_src_ip_str[in_port], |
| 1393 | ip_dst = dst_ip_str |
| 1394 | ) |
| 1395 | pkt = str( parsed_pkt ) |
| 1396 | self.dataplane.send( in_port, pkt ) |
| 1397 | |
| 1398 | for out_port in ports: |
| 1399 | |
| 1400 | parsed_pkt = simple_udp_packet( |
| 1401 | pktlen = 96, |
| 1402 | eth_dst = port_to_dst_mac_str[in_port], |
| 1403 | eth_src = port_to_src_mac_str[in_port], |
| 1404 | ip_ttl = 64, |
| 1405 | ip_src = port_to_src_ip_str[in_port], |
| 1406 | ip_dst = dst_ip_str |
| 1407 | ) |
| 1408 | pkt = str( parsed_pkt ) |
| 1409 | if out_port == in_port: |
| 1410 | verify_no_packet( self, pkt, in_port ) |
| 1411 | continue |
| 1412 | verify_packet( self, pkt, out_port ) |
| 1413 | verify_no_other_packets( self ) |
| 1414 | finally: |
| 1415 | delete_all_flows( self.controller ) |
| 1416 | delete_groups( self.controller, Groups ) |
| 1417 | delete_all_groups( self.controller ) |
| 1418 | |
| 1419 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1420 | """ |
| 1421 | Mcast routing, in this test case the traffic is tagged. |
| 1422 | 300 is used as vlan_id. The packet goes out tagged. |
| 1423 | """ |
| 1424 | def runTest( self ): |
| 1425 | Groups = Queue.LifoQueue( ) |
| 1426 | try: |
| 1427 | if len( config[ "port_map" ] ) < 2: |
| 1428 | logging.info( "Port count less than 2, can't run this case" ) |
| 1429 | assert (False) |
| 1430 | return |
| 1431 | ports = config[ "port_map" ].keys( ) |
| 1432 | dst_ip_str = "224.0.0.1" |
| 1433 | ( |
| 1434 | port_to_in_vlan, |
| 1435 | port_to_out_vlan, |
| 1436 | port_to_src_mac_str, |
| 1437 | port_to_dst_mac_str, |
| 1438 | port_to_src_ip_str, |
| 1439 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1440 | self.controller, |
| 1441 | logging, |
| 1442 | ports, |
| 1443 | is_ingress_tagged = True, |
| 1444 | is_egress_tagged = True, |
| 1445 | is_vlan_translated = False, |
| 1446 | is_max_vlan = False |
| 1447 | ) |
| 1448 | |
| 1449 | for in_port in ports: |
| 1450 | |
| 1451 | parsed_pkt = simple_udp_packet( |
| 1452 | pktlen = 100, |
| 1453 | dl_vlan_enable = True, |
| 1454 | vlan_vid = port_to_in_vlan[in_port], |
| 1455 | eth_dst = port_to_dst_mac_str[in_port], |
| 1456 | eth_src = port_to_src_mac_str[in_port], |
| 1457 | ip_ttl = 64, |
| 1458 | ip_src = port_to_src_ip_str[in_port], |
| 1459 | ip_dst = dst_ip_str |
| 1460 | ) |
| 1461 | pkt = str( parsed_pkt ) |
| 1462 | self.dataplane.send( in_port, pkt ) |
| 1463 | |
| 1464 | for out_port in ports: |
| 1465 | |
| 1466 | parsed_pkt = simple_udp_packet( |
| 1467 | pktlen = 100, |
| 1468 | dl_vlan_enable = True, |
| 1469 | vlan_vid = port_to_in_vlan[in_port], |
| 1470 | eth_dst = port_to_dst_mac_str[in_port], |
| 1471 | eth_src = port_to_src_mac_str[in_port], |
| 1472 | ip_ttl = 64, |
| 1473 | ip_src = port_to_src_ip_str[in_port], |
| 1474 | ip_dst = dst_ip_str |
| 1475 | ) |
| 1476 | pkt = str( parsed_pkt ) |
| 1477 | if out_port == in_port: |
| 1478 | verify_no_packet( self, pkt, in_port ) |
| 1479 | continue |
| 1480 | verify_packet( self, pkt, out_port ) |
| 1481 | verify_no_other_packets( self ) |
| 1482 | finally: |
| 1483 | delete_all_flows( self.controller ) |
| 1484 | delete_groups( self.controller, Groups ) |
| 1485 | delete_all_groups( self.controller ) |
| 1486 | |
| 1487 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1488 | """ |
| 1489 | Mcast routing, in this test case the traffic is tagged. |
| 1490 | port+1 is used as ingress vlan_id. The packet goes out |
| 1491 | tagged. 4094-port is used as egress vlan_id |
| 1492 | """ |
| 1493 | def runTest( self ): |
| 1494 | Groups = Queue.LifoQueue( ) |
| 1495 | try: |
| 1496 | if len( config[ "port_map" ] ) < 2: |
| 1497 | logging.info( "Port count less than 2, can't run this case" ) |
| 1498 | assert (False) |
| 1499 | return |
| 1500 | ports = config[ "port_map" ].keys( ) |
| 1501 | dst_ip_str = "224.0.0.1" |
| 1502 | ( |
| 1503 | port_to_in_vlan, |
| 1504 | port_to_out_vlan, |
| 1505 | port_to_src_mac_str, |
| 1506 | port_to_dst_mac_str, |
| 1507 | port_to_src_ip_str, |
| 1508 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1509 | self.controller, |
| 1510 | logging, |
| 1511 | ports, |
| 1512 | is_ingress_tagged = True, |
| 1513 | is_egress_tagged = True, |
| 1514 | is_vlan_translated = True, |
| 1515 | is_max_vlan = False |
| 1516 | ) |
| 1517 | |
| 1518 | for in_port in ports: |
| 1519 | |
| 1520 | parsed_pkt = simple_udp_packet( |
| 1521 | pktlen = 100, |
| 1522 | dl_vlan_enable = True, |
| 1523 | vlan_vid = port_to_in_vlan[in_port], |
| 1524 | eth_dst = port_to_dst_mac_str[in_port], |
| 1525 | eth_src = port_to_src_mac_str[in_port], |
| 1526 | ip_ttl = 64, |
| 1527 | ip_src = port_to_src_ip_str[in_port], |
| 1528 | ip_dst = dst_ip_str |
| 1529 | ) |
| 1530 | pkt = str( parsed_pkt ) |
| 1531 | self.dataplane.send( in_port, pkt ) |
| 1532 | |
| 1533 | for out_port in ports: |
| 1534 | |
| 1535 | parsed_pkt = simple_udp_packet( |
| 1536 | pktlen = 100, |
| 1537 | dl_vlan_enable = True, |
| 1538 | vlan_vid = port_to_out_vlan[in_port], |
| 1539 | eth_dst = port_to_dst_mac_str[in_port], |
| 1540 | eth_src = port_to_src_mac_str[in_port], |
| 1541 | ip_ttl = 64, |
| 1542 | ip_src = port_to_src_ip_str[in_port], |
| 1543 | ip_dst = dst_ip_str |
| 1544 | ) |
| 1545 | pkt = str( parsed_pkt ) |
| 1546 | if out_port == in_port: |
| 1547 | verify_no_packet( self, pkt, in_port ) |
| 1548 | continue |
| 1549 | verify_packet( self, pkt, out_port ) |
| 1550 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1551 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1552 | delete_all_flows( self.controller ) |
| 1553 | delete_groups( self.controller, Groups ) |
| 1554 | delete_all_groups( self.controller ) |
| 1555 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1556 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1557 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1558 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1559 | |
| 1560 | def runTest( self ): |
| 1561 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1562 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1563 | if len( config[ "port_map" ] ) < 2: |
| 1564 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1565 | return |
| 1566 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1567 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1568 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1569 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1570 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1571 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1572 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1573 | vlan_id = port + 16 |
| 1574 | mpls_label = port + 16 |
| 1575 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1576 | # add l2 interface group |
| 1577 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1578 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1579 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1580 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1581 | vlan_id, id ) |
| 1582 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1583 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1584 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1585 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1586 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1587 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1588 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1589 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1590 | if config["switch_type"] == "qmx": |
| 1591 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1592 | else: |
| 1593 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1594 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1595 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1596 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1597 | Groups._put( l2_gid ) |
| 1598 | Groups._put( mpls_gid ) |
| 1599 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1600 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1601 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1602 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1603 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1604 | for in_port in ports: |
| 1605 | ip_src = '192.168.%02d.1' % (in_port) |
| 1606 | for out_port in ports: |
| 1607 | if in_port == out_port: |
| 1608 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1609 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1610 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1611 | out_mpls_label = out_port + 16 |
| 1612 | in_vlan_vid = in_port + 16 |
| 1613 | out_vlan_vid = out_port + 16 |
| 1614 | |
| 1615 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1616 | label = (out_mpls_label, 0, 1, 32) |
| 1617 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1618 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1619 | pkt = str( parsed_pkt ) |
| 1620 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1621 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1622 | # build expect packet |
| 1623 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1624 | label = (out_mpls_label, 0, 1, 31) |
| 1625 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1626 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1627 | label=[ label ] ) |
| 1628 | pkt = str( exp_pkt ) |
| 1629 | verify_packet( self, pkt, out_port ) |
| 1630 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1631 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1632 | delete_all_flows( self.controller ) |
| 1633 | delete_groups( self.controller, Groups ) |
| 1634 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1635 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1636 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1637 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1638 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1639 | |
| 1640 | def runTest( self ): |
| 1641 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1642 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1643 | if len( config[ "port_map" ] ) < 2: |
| 1644 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1645 | return |
| 1646 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1647 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1648 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1649 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1650 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1651 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1652 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1653 | vlan_id = port + 16 |
| 1654 | mpls_label = port + 16 |
| 1655 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1656 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1657 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1658 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1659 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1660 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1661 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1662 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1663 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1664 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1665 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1666 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1667 | if config["switch_type"] == "qmx": |
| 1668 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1669 | else: |
| 1670 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1671 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1672 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1673 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1674 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1675 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1676 | Groups._put( l2_gid ) |
| 1677 | Groups._put( l3_msg.group_id ) |
| 1678 | Groups._put( ecmp_msg.group_id ) |
| 1679 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1680 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1681 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1682 | for in_port in ports: |
| 1683 | ip_src = '192.168.%02d.1' % (in_port) |
| 1684 | for out_port in ports: |
| 1685 | if in_port == out_port: |
| 1686 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1687 | |
| 1688 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1689 | out_mpls_label = out_port + 16 |
| 1690 | in_vlan_vid = in_port + 16 |
| 1691 | out_vlan_vid = out_port + 16 |
| 1692 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1693 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1694 | label = (out_mpls_label, 0, 1, 32) |
| 1695 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1696 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1697 | pkt = str( parsed_pkt ) |
| 1698 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1699 | # build expect packet |
| 1700 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1701 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1702 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1703 | pkt = str( exp_pkt ) |
| 1704 | verify_packet( self, pkt, out_port ) |
| 1705 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1706 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1707 | delete_all_flows( self.controller ) |
| 1708 | delete_groups( self.controller, Groups ) |
| 1709 | delete_all_groups( self.controller ) |
Saurav Das | 15c2c26 | 2017-05-06 18:12:38 -0700 | [diff] [blame] | 1710 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1711 | |
| 1712 | @disabled |
| 1713 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1714 | """ |
| 1715 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1716 | """ |
| 1717 | |
| 1718 | def runTest( self ): |
| 1719 | Groups = Queue.LifoQueue( ) |
| 1720 | try: |
| 1721 | if len( config[ "port_map" ] ) < 2: |
| 1722 | logging.info( "Port count less than 2, can't run this case" ) |
| 1723 | return |
| 1724 | dip = 0xc0a80001 |
| 1725 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1726 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1727 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1728 | ports = config[ "port_map" ].keys( ) |
| 1729 | inport = ports[0] |
| 1730 | outport = ports[1] |
| 1731 | |
| 1732 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1733 | invlan_id = inport + 16 |
| 1734 | outvlan_id = outport + 16 |
| 1735 | mpls_label = outport + 16 |
| 1736 | |
| 1737 | # add l2 interface group |
| 1738 | id, dst_mac[ 5 ] = inport, outport |
| 1739 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 1740 | # add L3 Unicast group |
| 1741 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 1742 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1743 | # add L3 ecmp group |
| 1744 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1745 | # add vlan flow table |
| 1746 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1747 | # add tmac flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1748 | if config["switch_type"] == "qmx": |
| 1749 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 1750 | else: |
| 1751 | add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1752 | # add mpls termination flow |
| 1753 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 1754 | Groups._put( l2_gid ) |
| 1755 | Groups._put( l3_msg.group_id ) |
| 1756 | Groups._put( ecmp_msg.group_id ) |
| 1757 | |
| 1758 | time.sleep(0.1) |
| 1759 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1760 | ip_src = '192.168.%02d.1' % (inport) |
| 1761 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1762 | out_mpls_label = outport + 16 |
| 1763 | in_vlan_vid = inport + 16 |
| 1764 | out_vlan_vid = outport + 16 |
| 1765 | |
| 1766 | ip_dst = '192.168.%02d.1' % (outport) |
| 1767 | label = (out_mpls_label, 0, 1, 32) |
| 1768 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 1769 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1770 | pkt = str( parsed_pkt ) |
| 1771 | self.dataplane.send( inport, pkt ) |
| 1772 | # build expect packet |
| 1773 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 1774 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 1775 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1776 | pkt = str( exp_pkt ) |
| 1777 | verify_packet( self, pkt, outport ) |
| 1778 | verify_no_other_packets( self ) |
| 1779 | finally: |
| 1780 | delete_all_flows( self.controller ) |
| 1781 | delete_groups( self.controller, Groups ) |
| 1782 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1783 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1784 | |
| 1785 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1786 | """ Verify /24 IP forwarding to L3 Interface """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1787 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1788 | def runTest( self ): |
| 1789 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1790 | try: |
| 1791 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1792 | if len( config[ "port_map" ] ) < 2: |
| 1793 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1794 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1795 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1796 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1797 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1798 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1799 | for port in ports: |
| 1800 | # add l2 interface group |
| 1801 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1802 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1803 | is_tagged=True, send_barrier=False ) |
| 1804 | dst_mac[ 5 ] = vlan_id |
| 1805 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1806 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1807 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1808 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1809 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1810 | if config["switch_type"] == "qmx": |
| 1811 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1812 | else: |
| 1813 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1814 | # add unicast routing flow |
| 1815 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1816 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1817 | Groups.put( l2gid ) |
| 1818 | Groups.put( l3_msg.group_id ) |
| 1819 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1820 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1821 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1822 | for in_port in ports: |
| 1823 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1824 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1825 | for out_port in ports: |
| 1826 | if in_port == out_port: |
| 1827 | continue |
| 1828 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1829 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1830 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1831 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1832 | pkt = str( parsed_pkt ) |
| 1833 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1834 | # build expected packet |
| 1835 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1836 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1837 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1838 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1839 | pkt = str( exp_pkt ) |
| 1840 | verify_packet( self, pkt, out_port ) |
| 1841 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1842 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1843 | delete_all_flows( self.controller ) |
| 1844 | delete_groups( self.controller, Groups ) |
| 1845 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1846 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1847 | |
| 1848 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1849 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1850 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1851 | def runTest( self ): |
| 1852 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1853 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1854 | if len( config[ "port_map" ] ) < 2: |
| 1855 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1856 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1857 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1858 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1859 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1860 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1861 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1862 | for port in ports: |
| 1863 | # add l2 interface group |
| 1864 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1865 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 1866 | is_tagged=True, send_barrier=False ) |
| 1867 | dst_mac[ 5 ] = vlan_id |
| 1868 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 1869 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1870 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1871 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1872 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1873 | if config["switch_type"] == "qmx": |
| 1874 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1875 | else: |
| 1876 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1877 | # add unicast routing flow |
| 1878 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1879 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1880 | Groups.put( l2gid ) |
| 1881 | Groups.put( l3_msg.group_id ) |
| 1882 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1883 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1884 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 1885 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1886 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1887 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1888 | for in_port in ports: |
| 1889 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1890 | ip_src = '192.168.%02d.1' % (in_port) |
| 1891 | for out_port in ports: |
| 1892 | if in_port == out_port: |
| 1893 | continue |
| 1894 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1895 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1896 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1897 | pkt = str( parsed_pkt ) |
| 1898 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1899 | # build expected packet |
| 1900 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1901 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 1902 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1903 | pkt = str( exp_pkt ) |
| 1904 | verify_packet( self, pkt, out_port ) |
| 1905 | verify_no_other_packets( self ) |
| 1906 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 1907 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1908 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1909 | pkt = str( parsed_pkt ) |
| 1910 | self.dataplane.send( in_port, pkt ) |
| 1911 | # build expect packet |
| 1912 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1913 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 1914 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 1915 | pkt = str( exp_pkt ) |
| 1916 | verify_packet( self, pkt, ports[ 0 ] ) |
| 1917 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1918 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1919 | delete_all_flows( self.controller ) |
| 1920 | delete_groups( self.controller, Groups ) |
| 1921 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1922 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1923 | |
| 1924 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1925 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1926 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1927 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1928 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1929 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1930 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1931 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1932 | vlan_id = 1; |
| 1933 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1934 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 1935 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1936 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1937 | delete_all_flows( self.controller ) |
| 1938 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1939 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1940 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1941 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1942 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1943 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1944 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1945 | |
| 1946 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1947 | """ |
| 1948 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1949 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1950 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1951 | delete_all_flows( self.controller ) |
| 1952 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1953 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1954 | if len( config[ "port_map" ] ) < 3: |
| 1955 | logging.info( "Port count less than 3, can't run this case" ) |
| 1956 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1957 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1958 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1959 | vlan_id = 1 |
| 1960 | port2_out_vlan = 2 |
| 1961 | port3_out_vlan = 3 |
| 1962 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1963 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1964 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1965 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1966 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1967 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1968 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 1969 | src_ip = 0xc0a80101 |
| 1970 | src_ip_str = "192.168.1.1" |
| 1971 | dst_ip = 0xe0010101 |
| 1972 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1973 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1974 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1975 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1976 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1977 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1978 | # add l2 interface group |
| 1979 | for port in config[ "port_map" ].keys( ): |
| 1980 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 1981 | send_barrier=False ) |
| 1982 | # add vlan flow table |
| 1983 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1984 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1985 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1986 | # add termination flow |
| 1987 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1988 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1989 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1990 | # add MPLS interface group |
| 1991 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 1992 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1993 | port2_out_vlan, port2 ) |
| 1994 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1995 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1996 | # add L3VPN groups |
| 1997 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1998 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 1999 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 2000 | # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2001 | # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2002 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2003 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 2004 | add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2005 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2006 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 2007 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 2008 | pkt = str( parsed_pkt ) |
| 2009 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2010 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2011 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 2012 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 2013 | pkt = str( exp_pkt ) |
| 2014 | verify_packet( self, pkt, port2 ) |
| 2015 | # verify_packet(self, pkt, port3) |
| 2016 | verify_no_other_packets( self ) |
| 2017 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2018 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2019 | delete_all_flows( self.controller ) |
| 2020 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2021 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2022 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2023 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2024 | """ |
| 2025 | Test packet in function on a src-mac miss |
| 2026 | Send a packet to each dataplane port and verify that a packet |
| 2027 | in message is received from the controller for each |
| 2028 | #todo verify you stop receiving after adding rule |
| 2029 | """ |
| 2030 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2031 | def runTest( self ): |
| 2032 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2033 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2034 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2035 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2036 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2037 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2038 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 2039 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2040 | Groups.put( L2gid ) |
| 2041 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 2042 | vlan_pkt = str( parsed_vlan_pkt ) |
| 2043 | for of_port in config[ "port_map" ].keys( ): |
| 2044 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 2045 | self.dataplane.send( of_port, vlan_pkt ) |
| 2046 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 2047 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2048 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2049 | delete_all_flows( self.controller ) |
| 2050 | delete_all_groups( self.controller ) |
| 2051 | |
| 2052 | |
| 2053 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 2054 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2055 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2056 | """ |
| 2057 | |
| 2058 | def runTest( self ): |
| 2059 | Groups = Queue.LifoQueue( ) |
| 2060 | try: |
| 2061 | if len( config[ "port_map" ] ) < 2: |
| 2062 | logging.info( "Port count less than 2, can't run this case" ) |
| 2063 | return |
| 2064 | |
| 2065 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2066 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2067 | dip = 0xc0a80001 |
| 2068 | # Hashes Test Name and uses it as id for installing unique groups |
| 2069 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2070 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2071 | dst_ips = [] |
| 2072 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2073 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2074 | for port in ports: |
| 2075 | vlan_id = port |
| 2076 | id = port |
| 2077 | # add l2 interface group |
| 2078 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2079 | is_tagged=True, send_barrier=False ) |
| 2080 | dst_mac[ 5 ] = vlan_id |
| 2081 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2082 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2083 | if port == ports[1]: |
| 2084 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2085 | Groups._put( l2_gid ) |
| 2086 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2087 | ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2088 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2089 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2090 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2091 | if config["switch_type"] == "qmx": |
| 2092 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2093 | else: |
| 2094 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2095 | # add unicast routing flow |
| 2096 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2097 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2098 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2099 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2100 | for dst_ip in dst_ips: |
| 2101 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2102 | time.sleep(0.1) |
| 2103 | # first part of the test: send packet from ingress switchport and expect it at egress switchport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2104 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2105 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2106 | in_port = ports[0] |
| 2107 | out_port = ports[1] |
| 2108 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2109 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2110 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2111 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2112 | tcp = out_port if out_port == 24 else 25 |
| 2113 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2114 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2115 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2116 | pkt = str( parsed_pkt ) |
| 2117 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2118 | # build expected packet at egress switchport |
| 2119 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2120 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2121 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2122 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2123 | pkt = str( exp_pkt ) |
| 2124 | verify_packet( self, pkt, out_port ) |
| 2125 | verify_no_other_packets( self ) |
| 2126 | |
| 2127 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2128 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2129 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2130 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2131 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2132 | time.sleep(0.1) |
| 2133 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2134 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2135 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2136 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2137 | tcp = port if port == 24 else 25 |
| 2138 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2139 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2140 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2141 | pkt = str( parsed_pkt ) |
| 2142 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2143 | # build expected packet |
| 2144 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2145 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2146 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2147 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2148 | pkt = str( exp_pkt ) |
| 2149 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2150 | verify_no_other_packets( self ) |
| 2151 | |
| 2152 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2153 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2154 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2155 | time.sleep(0.1) |
| 2156 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2157 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2158 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2159 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2160 | tcp = port if port == 24 else 25 |
| 2161 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2162 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2163 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2164 | pkt = str( parsed_pkt ) |
| 2165 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2166 | verify_no_other_packets( self ) |
| 2167 | |
| 2168 | # final part of the test - edit the empty group to add back the bucket for the |
| 2169 | # original egress port, and verify packet is received on egress switch port |
| 2170 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2171 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
| 2172 | time.sleep(0.1) |
| 2173 | in_port = ports[0] |
| 2174 | out_port = ports[1] |
| 2175 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2176 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2177 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2178 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2179 | tcp = out_port if out_port == 24 else 25 |
| 2180 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2181 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2182 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2183 | pkt = str( parsed_pkt ) |
| 2184 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2185 | # build expected packet at egress switchport |
| 2186 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2187 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2188 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2189 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2190 | pkt = str( exp_pkt ) |
| 2191 | verify_packet( self, pkt, out_port ) |
| 2192 | verify_no_other_packets( self ) |
| 2193 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2194 | finally: |
| 2195 | delete_all_flows( self.controller ) |
| 2196 | delete_groups( self.controller, Groups ) |
| 2197 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2198 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2199 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2200 | class Untagged( base_tests.SimpleDataPlane ): |
| 2201 | """ |
| 2202 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2203 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2204 | previous versions of the OFDPA. |
| 2205 | |
| 2206 | Two rules are necessary in VLAN table (10): |
| 2207 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2208 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2209 | |
| 2210 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2211 | The remaining part of the test is based on the use of the bridging table |
| 2212 | """ |
| 2213 | |
| 2214 | MAX_INTERNAL_VLAN = 4094 |
| 2215 | |
| 2216 | def runTest( self ): |
| 2217 | groups = Queue.LifoQueue( ) |
| 2218 | try: |
| 2219 | if len( config[ "port_map" ] ) < 2: |
| 2220 | logging.info( "Port count less than 2, can't run this case" ) |
| 2221 | return |
| 2222 | |
| 2223 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2224 | for port in ports: |
| 2225 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2226 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2227 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2228 | for other_port in ports: |
| 2229 | if other_port == port: |
| 2230 | continue |
| 2231 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2232 | groups.put( L2gid ) |
| 2233 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2234 | |
| 2235 | do_barrier( self.controller ) |
| 2236 | |
| 2237 | for out_port in ports: |
| 2238 | # change dest based on port number |
| 2239 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2240 | for in_port in ports: |
| 2241 | if in_port == out_port: |
| 2242 | continue |
| 2243 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2244 | self.dataplane.send( in_port, pkt ) |
| 2245 | for ofport in ports: |
| 2246 | if ofport in [ out_port ]: |
| 2247 | verify_packet( self, pkt, ofport ) |
| 2248 | else: |
| 2249 | verify_no_packet( self, pkt, ofport ) |
| 2250 | verify_no_other_packets( self ) |
| 2251 | finally: |
| 2252 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2253 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2254 | delete_all_groups( self.controller ) |