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 |
TonyChou | af5505c | 2017-08-24 09:11:19 +0800 | [diff] [blame] | 189 | 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] | 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 | |
Saurav Das | 59fae5e | 2017-12-07 12:02:02 -0800 | [diff] [blame] | 343 | class Bridging( base_tests.SimpleDataPlane ): |
| 344 | """ |
| 345 | Verify bridging works including flooding with different vlans |
| 346 | ports[0] has vlan 31 untagged |
| 347 | ports[1] has vlan 31 untagged (native) and vlan 41 tagged |
| 348 | ARP request should be flooded |
| 349 | ARP reply should be forwarded by bridging rule |
| 350 | Both arp messages should also be copied to controller |
| 351 | """ |
| 352 | |
| 353 | def runTest( self ): |
| 354 | Groupd = Queue.LifoQueue() |
| 355 | try: |
| 356 | if len( config[ "port_map" ] ) < 2: |
| 357 | logging.info( "Port count less than 2, can't run this case" ) |
| 358 | return |
| 359 | ports = sorted( config[ "port_map" ].keys() ) |
| 360 | vlan_p0_untagged = 31 |
| 361 | vlan_p1_tagged = 31 |
| 362 | vlan_p1_native = 41 |
| 363 | |
| 364 | #l2 interface groups and table 10 flows |
| 365 | L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged, |
| 366 | is_tagged=False, send_barrier=False ) |
| 367 | add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 368 | send_barrier=True) |
| 369 | L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged, |
| 370 | is_tagged=True, send_barrier=False ) |
| 371 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 372 | send_barrier=True) |
| 373 | L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native, |
| 374 | is_tagged=False, send_barrier=False ) |
| 375 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 376 | send_barrier=True) |
| 377 | #flooding groups |
| 378 | Floodmsg31 = add_l2_flood_group( self.controller, ports, vlan_p0_untagged, id=0 ) |
| 379 | Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 ) |
| 380 | |
| 381 | #add bridging flows for flooding groups |
| 382 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id ) |
| 383 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id ) |
| 384 | do_barrier( self.controller ) |
| 385 | |
| 386 | # add bridging flows for dstMac+vlan |
| 387 | add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True ) |
| 388 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True ) |
| 389 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True ) |
| 390 | |
| 391 | # add terminationMac flow |
| 392 | router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 393 | if config["switch_type"] == "qmx": |
| 394 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged ) |
| 395 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native ) |
| 396 | else: |
| 397 | add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged ) |
| 398 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged ) |
| 399 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native ) |
| 400 | |
| 401 | # add acl rule for arp |
| 402 | match = ofp.match( ) |
| 403 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 404 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 405 | ofp.instruction.apply_actions( actions=[ |
| 406 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 407 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 408 | self.controller.message_send( request ) |
| 409 | do_barrier( self.controller ) |
| 410 | |
| 411 | #acl rule for gateway ip |
| 412 | match = ofp.match( ) |
| 413 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 414 | match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) ) |
| 415 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 416 | ofp.instruction.apply_actions( actions=[ |
| 417 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), |
| 418 | ofp.instruction.clear_actions() ], |
| 419 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 420 | self.controller.message_send( request ) |
| 421 | do_barrier( self.controller ) |
| 422 | |
| 423 | # send ARP request |
| 424 | parsed_arp_pkt = simple_arp_packet(pktlen=80, |
| 425 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 426 | eth_src='00:66:77:88:99:aa', |
| 427 | vlan_vid=vlan_p1_tagged, |
| 428 | vlan_pcp=0, |
| 429 | arp_op=1, |
| 430 | ip_snd='192.168.0.2', |
| 431 | ip_tgt='192.168.0.1', |
| 432 | hw_snd='00:66:77:88:99:aa', |
| 433 | hw_tgt='00:00:00:00:00:00') |
| 434 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 435 | logging.info( "sending arp request to port %d", ports[1] ) |
| 436 | self.dataplane.send( ports[1], arp_pkt_to_send ) |
| 437 | verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION ) |
| 438 | parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76, |
| 439 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 440 | eth_src='00:66:77:88:99:aa', |
| 441 | vlan_vid=0, |
| 442 | vlan_pcp=0, |
| 443 | arp_op=1, |
| 444 | ip_snd='192.168.0.2', |
| 445 | ip_tgt='192.168.0.1', |
| 446 | hw_snd='00:66:77:88:99:aa', |
| 447 | hw_tgt='00:00:00:00:00:00') |
| 448 | arp_pkt_dest = str( parsed_arp_pkt_untagged ) |
| 449 | verify_packet( self, arp_pkt_dest, ports[0] ) |
| 450 | #verify_no_other_packets( self ) |
| 451 | |
| 452 | # send ARP reply |
| 453 | parsed_arp_pkt = simple_arp_packet(pktlen=76, |
| 454 | eth_dst='00:66:77:88:99:aa', |
| 455 | eth_src='00:11:22:33:44:55', |
| 456 | vlan_vid=0, |
| 457 | vlan_pcp=0, |
| 458 | arp_op=2, |
| 459 | ip_snd='192.168.0.1', |
| 460 | ip_tgt='192.168.0.2', |
| 461 | hw_snd='00:11:22:33:44:55', |
| 462 | hw_tgt='00:66:77:88:99:aa') |
| 463 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 464 | logging.info( "sending arp reply to port %d", ports[0] ) |
| 465 | self.dataplane.send( ports[0], arp_pkt_to_send ) |
| 466 | verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION ) |
| 467 | parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80, |
| 468 | eth_dst='00:66:77:88:99:aa', |
| 469 | eth_src='00:11:22:33:44:55', |
| 470 | vlan_vid=vlan_p1_tagged, |
| 471 | vlan_pcp=0, |
| 472 | arp_op=2, |
| 473 | ip_snd='192.168.0.1', |
| 474 | ip_tgt='192.168.0.2', |
| 475 | hw_snd='00:11:22:33:44:55', |
| 476 | hw_tgt='00:66:77:88:99:aa') |
| 477 | arp_pkt_dest = str( parsed_arp_pkt_tagged ) |
| 478 | verify_packet( self, arp_pkt_dest, ports[1] ) |
| 479 | |
| 480 | finally: |
| 481 | delete_all_flows( self.controller ) |
| 482 | delete_all_groups( self.controller ) |
| 483 | print("done") |
| 484 | |
| 485 | |
| 486 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 487 | class Mtu1500( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 488 | """ |
| 489 | Verifies basic mtu limits |
| 490 | """ |
| 491 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 492 | def runTest( self ): |
| 493 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 494 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 495 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 496 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 497 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 498 | 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] | 499 | 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] | 500 | Groups.put( L2gid ) |
| 501 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 502 | True ) |
| 503 | do_barrier( self.controller ) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 504 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 505 | for out_port in ports: |
| 506 | # change dest based on port number |
| 507 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 508 | for in_port in ports: |
| 509 | if in_port == out_port: |
| 510 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 511 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 512 | eth_dst=mac_dst ) ) |
| 513 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 514 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 515 | if ofport in [ out_port ]: |
| 516 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 517 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 518 | verify_no_packet( self, pkt, ofport ) |
| 519 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 520 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 521 | delete_all_flows( self.controller ) |
| 522 | delete_groups( self.controller, Groups ) |
| 523 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 524 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 525 | |
| 526 | class _32UcastTagged( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 527 | """ Verify /32 IP forwarding to L3 Unicast-> L2Interface""" |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 528 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 529 | def runTest( self ): |
| 530 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 531 | try: |
| 532 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 533 | if len( config[ "port_map" ] ) < 2: |
| 534 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 535 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 536 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 537 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 538 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 539 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 540 | for port in ports: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 541 | vlan_id = port + test_id |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 542 | # add l2 interface group and l3 unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 543 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 544 | is_tagged=True, send_barrier=False ) |
| 545 | dst_mac[ 5 ] = vlan_id |
| 546 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 547 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 548 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 549 | 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] | 550 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 551 | if config["switch_type"] == "qmx": |
| 552 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 553 | else: |
| 554 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 555 | # add unicast routing flow |
| 556 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 557 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 558 | Groups.put( l2gid ) |
| 559 | Groups.put( l3_msg.group_id ) |
| 560 | do_barrier( self.controller ) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 561 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 562 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 563 | for in_port in ports: |
| 564 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 565 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 566 | for out_port in ports: |
| 567 | if in_port == out_port: |
| 568 | continue |
| 569 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 570 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 571 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 572 | ip_src=ip_src, ip_dst=ip_dst ) |
| 573 | pkt = str( parsed_pkt ) |
| 574 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 575 | # build expected packet |
| 576 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 577 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 578 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 579 | ip_src=ip_src, ip_dst=ip_dst ) |
| 580 | pkt = str( exp_pkt ) |
| 581 | verify_packet( self, pkt, out_port ) |
| 582 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 583 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 584 | delete_all_flows( self.controller ) |
| 585 | delete_groups( self.controller, Groups ) |
| 586 | delete_all_groups( self.controller ) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 587 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 588 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 589 | class _32VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 590 | """ |
| 591 | Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 592 | No ECMP group used |
| 593 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 594 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 595 | def runTest( self ): |
| 596 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 597 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 598 | if len( config[ "port_map" ] ) < 2: |
| 599 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 600 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 601 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 602 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 603 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 604 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 605 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 606 | for port in ports: |
| 607 | # add l2 interface group |
| 608 | id = port |
| 609 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 610 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 611 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 612 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 613 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 614 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 615 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 616 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 617 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 618 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 619 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 620 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 621 | 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] | 622 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 623 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 624 | if config["switch_type"] == "qmx": |
| 625 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 626 | else: |
| 627 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 628 | # add routing flow |
| 629 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 630 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 631 | Groups._put( l2_gid ) |
| 632 | Groups._put( mpls_gid ) |
| 633 | Groups._put( mpls_label_gid ) |
| 634 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 635 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 636 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 637 | for in_port in ports: |
| 638 | ip_src = '192.168.%02d.1' % (in_port) |
| 639 | for out_port in ports: |
| 640 | if in_port == out_port: |
| 641 | continue |
| 642 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 643 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 644 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 645 | pkt = str( parsed_pkt ) |
| 646 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 647 | # build expect packet |
| 648 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 649 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 650 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 651 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 652 | label=[ label ] ) |
| 653 | pkt = str( exp_pkt ) |
| 654 | verify_packet( self, pkt, out_port ) |
| 655 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 656 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 657 | delete_all_flows( self.controller ) |
| 658 | delete_groups( self.controller, Groups ) |
| 659 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 660 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 661 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 662 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 663 | """ |
| 664 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 665 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 666 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 667 | def runTest( self ): |
| 668 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 669 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 670 | if len( config[ "port_map" ] ) < 2: |
| 671 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 672 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 673 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 674 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 675 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 676 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 677 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 678 | for port in ports: |
| 679 | # add l2 interface group |
| 680 | id = port |
| 681 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 682 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 683 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 684 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 685 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 686 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 687 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 688 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 689 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 690 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 691 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 692 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 693 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 694 | 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] | 695 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 696 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 697 | if config["switch_type"] == "qmx": |
| 698 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 699 | else: |
| 700 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 701 | # add routing flow |
| 702 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 703 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 704 | Groups._put( l2_gid ) |
| 705 | Groups._put( mpls_gid ) |
| 706 | Groups._put( mpls_label_gid ) |
| 707 | Groups._put( ecmp_msg.group_id ) |
| 708 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 709 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 710 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 711 | for in_port in ports: |
| 712 | ip_src = '192.168.%02d.1' % (in_port) |
| 713 | for out_port in ports: |
| 714 | if in_port == out_port: |
| 715 | continue |
| 716 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 717 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 718 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 719 | pkt = str( parsed_pkt ) |
| 720 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 721 | # build expect packet |
| 722 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 723 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 724 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 725 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 726 | label=[ label ] ) |
| 727 | pkt = str( exp_pkt ) |
| 728 | verify_packet( self, pkt, out_port ) |
| 729 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 730 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 731 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 732 | delete_all_flows( self.controller ) |
| 733 | delete_groups( self.controller, Groups ) |
| 734 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 735 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 736 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 737 | @disabled |
| 738 | class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| 739 | """ |
| 740 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 741 | in only one direction |
| 742 | """ |
| 743 | |
| 744 | def runTest( self ): |
| 745 | Groups = Queue.LifoQueue( ) |
| 746 | try: |
| 747 | if len( config[ "port_map" ] ) < 2: |
| 748 | logging.info( "Port count less than 2, can't run this case" ) |
| 749 | return |
| 750 | |
| 751 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 752 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 753 | dip = 0xc0a80001 |
| 754 | ports = config[ "port_map" ].keys( ) |
| 755 | # add l2 interface group |
| 756 | id = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 757 | in_offset = 19 |
| 758 | out_offset = 20 |
| 759 | vlan_id = ports[1] + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 760 | 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] | 761 | dst_mac[ 5 ] = ports[1] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 762 | # add MPLS interface group |
| 763 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 764 | vlan_id, id ) |
| 765 | # add MPLS L3 VPN group |
| 766 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 767 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 768 | 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] | 769 | # add ECMP group |
| 770 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 771 | do_barrier( self.controller ) |
| 772 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 773 | 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] | 774 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 775 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 776 | if config["switch_type"] == "qmx": |
| 777 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| 778 | else: |
| 779 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 780 | # add routing flow |
| 781 | dst_ip = dip + (vlan_id << 8) |
| 782 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 783 | Groups._put( l2_gid ) |
| 784 | Groups._put( mpls_gid ) |
| 785 | Groups._put( mpls_label_gid ) |
| 786 | Groups._put( ecmp_msg.group_id ) |
| 787 | |
| 788 | |
| 789 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 790 | in_port = ports[0] |
| 791 | out_port = ports[1] |
| 792 | ip_src = '192.168.%02d.1' % (in_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 793 | ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| 794 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 795 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 796 | pkt = str( parsed_pkt ) |
| 797 | self.dataplane.send( in_port, pkt ) |
| 798 | # build expect packet |
| 799 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 800 | label = (out_port+out_offset, 0, 1, 32) |
| 801 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 802 | 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] | 803 | label=[ label ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 804 | pkt = str( exp_pkt ) |
| 805 | verify_packet( self, pkt, out_port ) |
| 806 | #verify_no_other_packets( self ) |
| 807 | |
| 808 | finally: |
| 809 | delete_all_flows( self.controller ) |
| 810 | delete_group(self.controller, ecmp_msg.group_id) |
| 811 | delete_group(self.controller, mpls_label_gid) |
| 812 | delete_group(self.controller, mpls_gid) |
| 813 | delete_group(self.controller, l2_gid) |
| 814 | |
| 815 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 816 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 817 | """ |
| 818 | Verifies /32 IP routing and ECMP with no label push |
| 819 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 820 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 821 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 822 | def runTest( self ): |
| 823 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 824 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 825 | if len( config[ "port_map" ] ) < 2: |
| 826 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 827 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 828 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 829 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 830 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 831 | dip = 0xc0a80001 |
| 832 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 833 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 834 | for port in ports: |
| 835 | vlan_id = port |
| 836 | id = port |
| 837 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 838 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 839 | is_tagged=True, send_barrier=False ) |
| 840 | dst_mac[ 5 ] = vlan_id |
| 841 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 842 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 843 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 844 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 845 | 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] | 846 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 847 | if config["switch_type"] == "qmx": |
| 848 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 849 | else: |
| 850 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 851 | # add unicast routing flow |
| 852 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 853 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 854 | Groups._put( l2_gid ) |
| 855 | Groups._put( l3_msg.group_id ) |
| 856 | Groups._put( ecmp_msg.group_id ) |
| 857 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 858 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 859 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 860 | for in_port in ports: |
| 861 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 862 | ip_src = '192.168.%02d.1' % in_port |
| 863 | for out_port in ports: |
| 864 | if in_port == out_port: |
| 865 | continue |
| 866 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 867 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 868 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 869 | pkt = str( parsed_pkt ) |
| 870 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 871 | # build expected packet |
| 872 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 873 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 874 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 875 | pkt = str( exp_pkt ) |
| 876 | verify_packet( self, pkt, out_port ) |
| 877 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 878 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 879 | delete_all_flows( self.controller ) |
| 880 | delete_groups( self.controller, Groups ) |
| 881 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 882 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 883 | @disabled |
| 884 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 885 | """ |
| 886 | Verifies /32 IP routing and ECMP with no label push |
| 887 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 888 | in only one direction |
| 889 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 890 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 891 | def runTest( self ): |
| 892 | Groups = Queue.LifoQueue( ) |
| 893 | try: |
| 894 | if len( config[ "port_map" ] ) < 2: |
| 895 | logging.info( "Port count less than 2, can't run this case" ) |
| 896 | return |
| 897 | |
| 898 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 899 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 900 | dip = 0xc0a80001 |
| 901 | # Hashes Test Name and uses it as id for installing unique groups |
| 902 | ports = config[ "port_map" ].keys( ) |
| 903 | inport = ports[0] |
| 904 | outport = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 905 | in_offset = 19 |
| 906 | out_offset = 20 |
| 907 | vlan_id = outport + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 908 | id = outport |
| 909 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 910 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 911 | is_tagged=True, send_barrier=False ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 912 | dst_mac[ 5 ] = outport |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 913 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 914 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 915 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 916 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 917 | 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] | 918 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 919 | if config["switch_type"] == "qmx": |
| 920 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset ) |
| 921 | else: |
| 922 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 923 | # add unicast routing flow |
| 924 | dst_ip = dip + (vlan_id << 8) |
| 925 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 926 | Groups._put( l2_gid ) |
| 927 | Groups._put( l3_msg.group_id ) |
| 928 | Groups._put( ecmp_msg.group_id ) |
| 929 | |
| 930 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 931 | mac_src = '00:00:00:22:22:%02X' % inport |
| 932 | ip_src = '192.168.%02d.1' % inport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 933 | ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| 934 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 935 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 936 | pkt = str( parsed_pkt ) |
| 937 | self.dataplane.send( inport, pkt ) |
| 938 | # build expected packet |
| 939 | mac_dst = '00:00:00:22:22:%02X' % outport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 940 | 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] | 941 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 942 | pkt = str( exp_pkt ) |
| 943 | verify_packet( self, pkt, outport ) |
| 944 | verify_no_other_packets( self ) |
| 945 | finally: |
| 946 | delete_all_flows( self.controller ) |
| 947 | delete_groups( self.controller, Groups ) |
| 948 | delete_all_groups( self.controller ) |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 954 | class _24VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 955 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 956 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 957 | def runTest( self ): |
| 958 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 959 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 960 | if len( config[ "port_map" ] ) < 2: |
| 961 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 962 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 963 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 964 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 965 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 966 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 967 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 968 | for port in ports: |
| 969 | # add l2 interface group |
| 970 | id = port |
| 971 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 972 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 973 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 974 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 975 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 976 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 977 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 978 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 979 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 980 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 981 | # 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] | 982 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 983 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 984 | 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] | 985 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 986 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 987 | if config["switch_type"] == "qmx": |
| 988 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 989 | else: |
| 990 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 991 | # add routing flow |
| 992 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 993 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 994 | Groups._put( l2_gid ) |
| 995 | Groups._put( mpls_gid ) |
| 996 | Groups._put( mpls_label_gid ) |
| 997 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 998 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 999 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1000 | for in_port in ports: |
| 1001 | ip_src = '192.168.%02d.1' % (in_port) |
| 1002 | for out_port in ports: |
| 1003 | if in_port == out_port: |
| 1004 | continue |
| 1005 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1006 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1007 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1008 | pkt = str( parsed_pkt ) |
| 1009 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1010 | # build expect packet |
| 1011 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1012 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1013 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1014 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1015 | label=[ label ] ) |
| 1016 | pkt = str( exp_pkt ) |
| 1017 | verify_packet( self, pkt, out_port ) |
| 1018 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1019 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1020 | delete_all_flows( self.controller ) |
| 1021 | delete_groups( self.controller, Groups ) |
| 1022 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 1023 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1024 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1025 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1026 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1027 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1028 | def runTest( self ): |
| 1029 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1030 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1031 | if len( config[ "port_map" ] ) < 2: |
| 1032 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1033 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1034 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1035 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1036 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1037 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1038 | for port in ports: |
| 1039 | # add l2 interface group |
| 1040 | id = port |
| 1041 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1042 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 1043 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1044 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1045 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1046 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1047 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1048 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1049 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 1050 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 1051 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 1052 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1053 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1054 | 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] | 1055 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1056 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1057 | if config["switch_type"] == "qmx": |
| 1058 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1059 | else: |
| 1060 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1061 | # add routing flow |
| 1062 | dst_ip = dip + (vlan_id << 8) |
| 1063 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1064 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 1065 | vrf=0 ) |
| 1066 | Groups._put( l2_gid ) |
| 1067 | Groups._put( mpls_gid ) |
| 1068 | Groups._put( mpls_label_gid ) |
| 1069 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1070 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1071 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1072 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1073 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1074 | for in_port in ports: |
| 1075 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1076 | ip_src = '192.168.%02d.1' % (in_port) |
| 1077 | for out_port in ports: |
| 1078 | if in_port == out_port: |
| 1079 | continue |
| 1080 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1081 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1082 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1083 | pkt = str( parsed_pkt ) |
| 1084 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1085 | # build expect packet |
| 1086 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1087 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1088 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1089 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1090 | label=[ label ] ) |
| 1091 | pkt = str( exp_pkt ) |
| 1092 | verify_packet( self, pkt, out_port ) |
| 1093 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1094 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1095 | delete_all_flows( self.controller ) |
| 1096 | delete_groups( self.controller, Groups ) |
| 1097 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1098 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1099 | |
| 1100 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1101 | """ Modify a referenced flood group """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1102 | |
| 1103 | def runTest( self ): |
| 1104 | Groups = Queue.LifoQueue( ) |
| 1105 | try: |
| 1106 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 1107 | vlan_id = 1 |
| 1108 | |
| 1109 | for port in ports: |
| 1110 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1111 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1112 | Groups.put( L2gid ) |
| 1113 | |
| 1114 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 1115 | Groups.put( msg.group_id ) |
| 1116 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 1117 | do_barrier( self.controller ) |
| 1118 | # verify flood |
| 1119 | for ofport in ports: |
| 1120 | # change dest based on port number |
| 1121 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 1122 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1123 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 1124 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 1125 | pkt = str( parsed_pkt ) |
| 1126 | self.dataplane.send( ofport, pkt ) |
| 1127 | # self won't rx packet |
| 1128 | verify_no_packet( self, pkt, ofport ) |
| 1129 | # others will rx packet |
| 1130 | tmp_ports = list( ports ) |
| 1131 | tmp_ports.remove( ofport ) |
| 1132 | verify_packets( self, pkt, tmp_ports ) |
| 1133 | verify_no_other_packets( self ) |
| 1134 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 1135 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 1136 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1137 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 1138 | eth_src=mac_src ) |
| 1139 | pkt = str( parsed_pkt ) |
| 1140 | self.dataplane.send( ports[ 1 ], pkt ) |
| 1141 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 1142 | finally: |
| 1143 | delete_all_flows( self.controller ) |
| 1144 | delete_groups( self.controller, Groups ) |
| 1145 | delete_all_groups( self.controller ) |
| 1146 | |
| 1147 | |
| 1148 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1149 | """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1150 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1151 | def runTest( self ): |
| 1152 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1153 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1154 | if len( config[ "port_map" ] ) < 2: |
| 1155 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1156 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1157 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1158 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1159 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1160 | dip = 0xc0a80001 |
| 1161 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1162 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1163 | for port in ports: |
| 1164 | vlan_id = port |
| 1165 | id = port |
| 1166 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1167 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1168 | is_tagged=True, send_barrier=False ) |
| 1169 | dst_mac[ 5 ] = vlan_id |
| 1170 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1171 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1172 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1173 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1174 | 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] | 1175 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1176 | if config["switch_type"] == "qmx": |
| 1177 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1178 | else: |
| 1179 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1180 | # add unicast routing flow |
| 1181 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1182 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1183 | Groups._put( l2_gid ) |
| 1184 | Groups._put( l3_msg.group_id ) |
| 1185 | Groups._put( ecmp_msg.group_id ) |
| 1186 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1187 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1188 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1189 | for in_port in ports: |
| 1190 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1191 | ip_src = '192.168.%02d.1' % in_port |
| 1192 | for out_port in ports: |
| 1193 | if in_port == out_port: |
| 1194 | continue |
| 1195 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1196 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1197 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1198 | pkt = str( parsed_pkt ) |
| 1199 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1200 | # build expected packet |
| 1201 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1202 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1203 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1204 | pkt = str( exp_pkt ) |
| 1205 | verify_packet( self, pkt, out_port ) |
| 1206 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1207 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1208 | delete_all_flows( self.controller ) |
| 1209 | delete_groups( self.controller, Groups ) |
| 1210 | delete_all_groups( self.controller ) |
| 1211 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1212 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 1213 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1214 | class MPLSBUG( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1215 | """ |
| 1216 | Needs a description or needs to be removed |
| 1217 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1218 | def runTest( self ): |
| 1219 | if len( config[ "port_map" ] ) < 2: |
| 1220 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1221 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1222 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1223 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1224 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1225 | Groups = Queue.LifoQueue( ) |
| 1226 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1227 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1228 | # add l2 interface group |
| 1229 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1230 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1231 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1232 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1233 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1234 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1235 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1236 | 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] | 1237 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1238 | if config["switch_type"] == "qmx": |
| 1239 | add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1240 | else: |
| 1241 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1242 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1243 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1244 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1245 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1246 | # add unicast routing flow |
| 1247 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1248 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1249 | Groups._put( l2_gid ) |
| 1250 | Groups._put( l3_msg.group_id ) |
| 1251 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1252 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1253 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1254 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1255 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1256 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1257 | for out_port in ports: |
| 1258 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1259 | continue |
| 1260 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1261 | switch_mac = "00:00:00:cc:cc:cc" |
| 1262 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1263 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1264 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1265 | pkt = str( parsed_pkt ) |
| 1266 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1267 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1268 | # build expect packet |
| 1269 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1270 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1271 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1272 | pkt = str( exp_pkt ) |
| 1273 | verify_packet( self, pkt, out_port ) |
| 1274 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1275 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1276 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1277 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1278 | pkt = str( parsed_pkt ) |
| 1279 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1280 | # build expected packet |
| 1281 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1282 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1283 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1284 | pkt = str( exp_pkt ) |
| 1285 | verify_packet( self, pkt, out_port ) |
| 1286 | verify_no_other_packets( self ) |
| 1287 | delete_all_flows( self.controller ) |
| 1288 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1289 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1290 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1291 | """ |
| 1292 | Mcast routing, in this test case the traffic comes in tagged. |
| 1293 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1294 | different ports. 4094-port is used as egress vlan_id. |
| 1295 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1296 | def runTest( self ): |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1297 | """ |
| 1298 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1299 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1300 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1301 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1302 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1303 | if len( config[ "port_map" ] ) < 1: |
| 1304 | logging.info( "Port count less than 1, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1305 | assert (False) |
| 1306 | return |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1307 | ports = config[ "port_map" ].keys( ) |
| 1308 | dst_ip_str = "224.0.0.1" |
| 1309 | ( |
| 1310 | port_to_in_vlan, |
| 1311 | port_to_out_vlan, |
| 1312 | port_to_src_mac_str, |
| 1313 | port_to_dst_mac_str, |
| 1314 | port_to_src_ip_str, |
| 1315 | port_to_intf_src_mac_str, |
| 1316 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1317 | self.controller, |
| 1318 | logging, |
| 1319 | ports, |
| 1320 | is_ingress_tagged = True, |
| 1321 | is_egress_tagged = True, |
| 1322 | is_vlan_translated = True, |
| 1323 | is_max_vlan = False |
| 1324 | ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1325 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1326 | for in_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1327 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1328 | parsed_pkt = simple_udp_packet( |
| 1329 | pktlen = 100, |
| 1330 | dl_vlan_enable = True, |
| 1331 | vlan_vid = port_to_in_vlan[in_port], |
| 1332 | eth_dst = port_to_dst_mac_str[in_port], |
| 1333 | eth_src = port_to_src_mac_str[in_port], |
| 1334 | ip_ttl = 64, |
| 1335 | ip_src = port_to_src_ip_str[in_port], |
| 1336 | ip_dst = dst_ip_str |
| 1337 | ) |
| 1338 | pkt = str( parsed_pkt ) |
| 1339 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1340 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1341 | for out_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1342 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1343 | parsed_pkt = simple_udp_packet( |
| 1344 | pktlen = 100, |
| 1345 | dl_vlan_enable = True, |
| 1346 | vlan_vid = port_to_out_vlan[out_port], |
| 1347 | eth_dst = port_to_dst_mac_str[in_port], |
| 1348 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1349 | ip_ttl = 63, |
| 1350 | ip_src = port_to_src_ip_str[in_port], |
| 1351 | ip_dst = dst_ip_str |
| 1352 | ) |
| 1353 | pkt = str( parsed_pkt ) |
| 1354 | verify_packet( self, pkt, out_port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1355 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1356 | verify_no_other_packets( self ) |
| 1357 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1358 | finally: |
| 1359 | delete_all_flows( self.controller ) |
| 1360 | delete_groups( self.controller, Groups ) |
| 1361 | delete_all_groups( self.controller ) |
| 1362 | |
| 1363 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1364 | """ |
| 1365 | Mcast routing, in this test case the traffic is untagged. |
| 1366 | 4094 is used as internal vlan_id. The packet goes out |
| 1367 | untagged. |
| 1368 | """ |
| 1369 | def runTest( self ): |
| 1370 | Groups = Queue.LifoQueue( ) |
| 1371 | try: |
| 1372 | if len( config[ "port_map" ] ) < 2: |
| 1373 | logging.info( "Port count less than 2, can't run this case" ) |
| 1374 | assert (False) |
| 1375 | return |
| 1376 | ports = config[ "port_map" ].keys( ) |
| 1377 | dst_ip_str = "224.0.0.1" |
| 1378 | ( |
| 1379 | port_to_in_vlan, |
| 1380 | port_to_out_vlan, |
| 1381 | port_to_src_mac_str, |
| 1382 | port_to_dst_mac_str, |
| 1383 | port_to_src_ip_str, |
| 1384 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1385 | self.controller, |
| 1386 | logging, |
| 1387 | ports, |
| 1388 | is_ingress_tagged = False, |
| 1389 | is_egress_tagged = False, |
| 1390 | is_vlan_translated = False, |
| 1391 | is_max_vlan = True |
| 1392 | ) |
| 1393 | |
| 1394 | for in_port in ports: |
| 1395 | |
| 1396 | parsed_pkt = simple_udp_packet( |
| 1397 | pktlen = 96, |
| 1398 | eth_dst = port_to_dst_mac_str[in_port], |
| 1399 | eth_src = port_to_src_mac_str[in_port], |
| 1400 | ip_ttl = 64, |
| 1401 | ip_src = port_to_src_ip_str[in_port], |
| 1402 | ip_dst = dst_ip_str |
| 1403 | ) |
| 1404 | pkt = str( parsed_pkt ) |
| 1405 | self.dataplane.send( in_port, pkt ) |
| 1406 | |
| 1407 | for out_port in ports: |
| 1408 | |
| 1409 | parsed_pkt = simple_udp_packet( |
| 1410 | pktlen = 96, |
| 1411 | eth_dst = port_to_dst_mac_str[in_port], |
| 1412 | eth_src = port_to_src_mac_str[in_port], |
| 1413 | ip_ttl = 64, |
| 1414 | ip_src = port_to_src_ip_str[in_port], |
| 1415 | ip_dst = dst_ip_str |
| 1416 | ) |
| 1417 | pkt = str( parsed_pkt ) |
| 1418 | if out_port == in_port: |
| 1419 | verify_no_packet( self, pkt, in_port ) |
| 1420 | continue |
| 1421 | verify_packet( self, pkt, out_port ) |
| 1422 | verify_no_other_packets( self ) |
| 1423 | finally: |
| 1424 | delete_all_flows( self.controller ) |
| 1425 | delete_groups( self.controller, Groups ) |
| 1426 | delete_all_groups( self.controller ) |
| 1427 | |
| 1428 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1429 | """ |
| 1430 | Mcast routing, in this test case the traffic is untagged. |
| 1431 | 300 is used as vlan_id. The packet goes out |
| 1432 | tagged. |
| 1433 | """ |
| 1434 | def runTest( self ): |
| 1435 | Groups = Queue.LifoQueue( ) |
| 1436 | try: |
| 1437 | if len( config[ "port_map" ] ) < 2: |
| 1438 | logging.info( "Port count less than 2, can't run this case" ) |
| 1439 | assert (False) |
| 1440 | return |
| 1441 | ports = config[ "port_map" ].keys( ) |
| 1442 | dst_ip_str = "224.0.0.1" |
| 1443 | ( |
| 1444 | port_to_in_vlan, |
| 1445 | port_to_out_vlan, |
| 1446 | port_to_src_mac_str, |
| 1447 | port_to_dst_mac_str, |
| 1448 | port_to_src_ip_str, |
| 1449 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1450 | self.controller, |
| 1451 | logging, |
| 1452 | ports, |
| 1453 | is_ingress_tagged = False, |
| 1454 | is_egress_tagged = True, |
| 1455 | is_vlan_translated = False, |
| 1456 | is_max_vlan = False |
| 1457 | ) |
| 1458 | |
| 1459 | for in_port in ports: |
| 1460 | |
| 1461 | parsed_pkt = simple_udp_packet( |
| 1462 | pktlen = 96, |
| 1463 | eth_dst = port_to_dst_mac_str[in_port], |
| 1464 | eth_src = port_to_src_mac_str[in_port], |
| 1465 | ip_ttl = 64, |
| 1466 | ip_src = port_to_src_ip_str[in_port], |
| 1467 | ip_dst = dst_ip_str |
| 1468 | ) |
| 1469 | pkt = str( parsed_pkt ) |
| 1470 | self.dataplane.send( in_port, pkt ) |
| 1471 | |
| 1472 | for out_port in ports: |
| 1473 | |
| 1474 | parsed_pkt = simple_udp_packet( |
| 1475 | pktlen = 100, |
| 1476 | dl_vlan_enable = True, |
| 1477 | vlan_vid = port_to_out_vlan[in_port], |
| 1478 | eth_dst = port_to_dst_mac_str[in_port], |
| 1479 | eth_src = port_to_src_mac_str[in_port], |
| 1480 | ip_ttl = 64, |
| 1481 | ip_src = port_to_src_ip_str[in_port], |
| 1482 | ip_dst = dst_ip_str |
| 1483 | ) |
| 1484 | pkt = str( parsed_pkt ) |
| 1485 | if out_port == in_port: |
| 1486 | verify_no_packet( self, pkt, in_port ) |
| 1487 | continue |
| 1488 | verify_packet( self, pkt, out_port ) |
| 1489 | verify_no_other_packets( self ) |
| 1490 | finally: |
| 1491 | delete_all_flows( self.controller ) |
| 1492 | delete_groups( self.controller, Groups ) |
| 1493 | delete_all_groups( self.controller ) |
| 1494 | |
| 1495 | |
| 1496 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1497 | """ |
| 1498 | Mcast routing, in this test case the traffic is tagged. |
| 1499 | 300 is used as vlan_id. The packet goes out |
| 1500 | untagged. |
| 1501 | """ |
| 1502 | def runTest( self ): |
| 1503 | Groups = Queue.LifoQueue( ) |
| 1504 | try: |
| 1505 | if len( config[ "port_map" ] ) < 2: |
| 1506 | logging.info( "Port count less than 2, can't run this case" ) |
| 1507 | assert (False) |
| 1508 | return |
| 1509 | ports = config[ "port_map" ].keys( ) |
| 1510 | dst_ip_str = "224.0.0.1" |
| 1511 | ( |
| 1512 | port_to_in_vlan, |
| 1513 | port_to_out_vlan, |
| 1514 | port_to_src_mac_str, |
| 1515 | port_to_dst_mac_str, |
| 1516 | port_to_src_ip_str, |
| 1517 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1518 | self.controller, |
| 1519 | logging, |
| 1520 | ports, |
| 1521 | is_ingress_tagged = True, |
| 1522 | is_egress_tagged = False, |
| 1523 | is_vlan_translated = False, |
| 1524 | is_max_vlan = False |
| 1525 | ) |
| 1526 | |
| 1527 | for in_port in ports: |
| 1528 | |
| 1529 | parsed_pkt = simple_udp_packet( |
| 1530 | pktlen = 100, |
| 1531 | dl_vlan_enable = True, |
| 1532 | vlan_vid = port_to_in_vlan[in_port], |
| 1533 | eth_dst = port_to_dst_mac_str[in_port], |
| 1534 | eth_src = port_to_src_mac_str[in_port], |
| 1535 | ip_ttl = 64, |
| 1536 | ip_src = port_to_src_ip_str[in_port], |
| 1537 | ip_dst = dst_ip_str |
| 1538 | ) |
| 1539 | pkt = str( parsed_pkt ) |
| 1540 | self.dataplane.send( in_port, pkt ) |
| 1541 | |
| 1542 | for out_port in ports: |
| 1543 | |
| 1544 | parsed_pkt = simple_udp_packet( |
| 1545 | pktlen = 96, |
| 1546 | eth_dst = port_to_dst_mac_str[in_port], |
| 1547 | eth_src = port_to_src_mac_str[in_port], |
| 1548 | ip_ttl = 64, |
| 1549 | ip_src = port_to_src_ip_str[in_port], |
| 1550 | ip_dst = dst_ip_str |
| 1551 | ) |
| 1552 | pkt = str( parsed_pkt ) |
| 1553 | if out_port == in_port: |
| 1554 | verify_no_packet( self, pkt, in_port ) |
| 1555 | continue |
| 1556 | verify_packet( self, pkt, out_port ) |
| 1557 | verify_no_other_packets( self ) |
| 1558 | finally: |
| 1559 | delete_all_flows( self.controller ) |
| 1560 | delete_groups( self.controller, Groups ) |
| 1561 | delete_all_groups( self.controller ) |
| 1562 | |
| 1563 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1564 | """ |
| 1565 | Mcast routing, in this test case the traffic is tagged. |
| 1566 | 300 is used as vlan_id. The packet goes out tagged. |
| 1567 | """ |
| 1568 | def runTest( self ): |
| 1569 | Groups = Queue.LifoQueue( ) |
| 1570 | try: |
| 1571 | if len( config[ "port_map" ] ) < 2: |
| 1572 | logging.info( "Port count less than 2, can't run this case" ) |
| 1573 | assert (False) |
| 1574 | return |
| 1575 | ports = config[ "port_map" ].keys( ) |
| 1576 | dst_ip_str = "224.0.0.1" |
| 1577 | ( |
| 1578 | port_to_in_vlan, |
| 1579 | port_to_out_vlan, |
| 1580 | port_to_src_mac_str, |
| 1581 | port_to_dst_mac_str, |
| 1582 | port_to_src_ip_str, |
| 1583 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1584 | self.controller, |
| 1585 | logging, |
| 1586 | ports, |
| 1587 | is_ingress_tagged = True, |
| 1588 | is_egress_tagged = True, |
| 1589 | is_vlan_translated = False, |
| 1590 | is_max_vlan = False |
| 1591 | ) |
| 1592 | |
| 1593 | for in_port in ports: |
| 1594 | |
| 1595 | parsed_pkt = simple_udp_packet( |
| 1596 | pktlen = 100, |
| 1597 | dl_vlan_enable = True, |
| 1598 | vlan_vid = port_to_in_vlan[in_port], |
| 1599 | eth_dst = port_to_dst_mac_str[in_port], |
| 1600 | eth_src = port_to_src_mac_str[in_port], |
| 1601 | ip_ttl = 64, |
| 1602 | ip_src = port_to_src_ip_str[in_port], |
| 1603 | ip_dst = dst_ip_str |
| 1604 | ) |
| 1605 | pkt = str( parsed_pkt ) |
| 1606 | self.dataplane.send( in_port, pkt ) |
| 1607 | |
| 1608 | for out_port in ports: |
| 1609 | |
| 1610 | parsed_pkt = simple_udp_packet( |
| 1611 | pktlen = 100, |
| 1612 | dl_vlan_enable = True, |
| 1613 | vlan_vid = port_to_in_vlan[in_port], |
| 1614 | eth_dst = port_to_dst_mac_str[in_port], |
| 1615 | eth_src = port_to_src_mac_str[in_port], |
| 1616 | ip_ttl = 64, |
| 1617 | ip_src = port_to_src_ip_str[in_port], |
| 1618 | ip_dst = dst_ip_str |
| 1619 | ) |
| 1620 | pkt = str( parsed_pkt ) |
| 1621 | if out_port == in_port: |
| 1622 | verify_no_packet( self, pkt, in_port ) |
| 1623 | continue |
| 1624 | verify_packet( self, pkt, out_port ) |
| 1625 | verify_no_other_packets( self ) |
| 1626 | finally: |
| 1627 | delete_all_flows( self.controller ) |
| 1628 | delete_groups( self.controller, Groups ) |
| 1629 | delete_all_groups( self.controller ) |
| 1630 | |
| 1631 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1632 | """ |
| 1633 | Mcast routing, in this test case the traffic is tagged. |
| 1634 | port+1 is used as ingress vlan_id. The packet goes out |
| 1635 | tagged. 4094-port is used as egress vlan_id |
| 1636 | """ |
| 1637 | def runTest( self ): |
| 1638 | Groups = Queue.LifoQueue( ) |
| 1639 | try: |
| 1640 | if len( config[ "port_map" ] ) < 2: |
| 1641 | logging.info( "Port count less than 2, can't run this case" ) |
| 1642 | assert (False) |
| 1643 | return |
| 1644 | ports = config[ "port_map" ].keys( ) |
| 1645 | dst_ip_str = "224.0.0.1" |
| 1646 | ( |
| 1647 | port_to_in_vlan, |
| 1648 | port_to_out_vlan, |
| 1649 | port_to_src_mac_str, |
| 1650 | port_to_dst_mac_str, |
| 1651 | port_to_src_ip_str, |
| 1652 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1653 | self.controller, |
| 1654 | logging, |
| 1655 | ports, |
| 1656 | is_ingress_tagged = True, |
| 1657 | is_egress_tagged = True, |
| 1658 | is_vlan_translated = True, |
| 1659 | is_max_vlan = False |
| 1660 | ) |
| 1661 | |
| 1662 | for in_port in ports: |
| 1663 | |
| 1664 | parsed_pkt = simple_udp_packet( |
| 1665 | pktlen = 100, |
| 1666 | dl_vlan_enable = True, |
| 1667 | vlan_vid = port_to_in_vlan[in_port], |
| 1668 | eth_dst = port_to_dst_mac_str[in_port], |
| 1669 | eth_src = port_to_src_mac_str[in_port], |
| 1670 | ip_ttl = 64, |
| 1671 | ip_src = port_to_src_ip_str[in_port], |
| 1672 | ip_dst = dst_ip_str |
| 1673 | ) |
| 1674 | pkt = str( parsed_pkt ) |
| 1675 | self.dataplane.send( in_port, pkt ) |
| 1676 | |
| 1677 | for out_port in ports: |
| 1678 | |
| 1679 | parsed_pkt = simple_udp_packet( |
| 1680 | pktlen = 100, |
| 1681 | dl_vlan_enable = True, |
| 1682 | vlan_vid = port_to_out_vlan[in_port], |
| 1683 | eth_dst = port_to_dst_mac_str[in_port], |
| 1684 | eth_src = port_to_src_mac_str[in_port], |
| 1685 | ip_ttl = 64, |
| 1686 | ip_src = port_to_src_ip_str[in_port], |
| 1687 | ip_dst = dst_ip_str |
| 1688 | ) |
| 1689 | pkt = str( parsed_pkt ) |
| 1690 | if out_port == in_port: |
| 1691 | verify_no_packet( self, pkt, in_port ) |
| 1692 | continue |
| 1693 | verify_packet( self, pkt, out_port ) |
| 1694 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1695 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1696 | delete_all_flows( self.controller ) |
| 1697 | delete_groups( self.controller, Groups ) |
| 1698 | delete_all_groups( self.controller ) |
| 1699 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1700 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1701 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1702 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1703 | |
| 1704 | def runTest( self ): |
| 1705 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1706 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1707 | if len( config[ "port_map" ] ) < 2: |
| 1708 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1709 | return |
| 1710 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1711 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1712 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1713 | # 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] | 1714 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1715 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1716 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1717 | vlan_id = port + 16 |
| 1718 | mpls_label = port + 16 |
| 1719 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1720 | # add l2 interface group |
| 1721 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1722 | 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] | 1723 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1724 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1725 | vlan_id, id ) |
| 1726 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1727 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1728 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1729 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1730 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1731 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1732 | 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] | 1733 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1734 | if config["switch_type"] == "qmx": |
| 1735 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1736 | else: |
| 1737 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1738 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1739 | if config["switch_type"] != 'xpliant': |
| 1740 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| 1741 | else: |
| 1742 | xpliant_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] | 1743 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1744 | Groups._put( l2_gid ) |
| 1745 | Groups._put( mpls_gid ) |
| 1746 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1747 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1748 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1749 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1750 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1751 | for in_port in ports: |
| 1752 | ip_src = '192.168.%02d.1' % (in_port) |
| 1753 | for out_port in ports: |
| 1754 | if in_port == out_port: |
| 1755 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1756 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1757 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1758 | out_mpls_label = out_port + 16 |
| 1759 | in_vlan_vid = in_port + 16 |
| 1760 | out_vlan_vid = out_port + 16 |
| 1761 | |
| 1762 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1763 | label = (out_mpls_label, 0, 1, 32) |
| 1764 | 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] | 1765 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1766 | pkt = str( parsed_pkt ) |
| 1767 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1768 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1769 | # build expect packet |
| 1770 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1771 | label = (out_mpls_label, 0, 1, 31) |
| 1772 | 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] | 1773 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1774 | label=[ label ] ) |
| 1775 | pkt = str( exp_pkt ) |
| 1776 | verify_packet( self, pkt, out_port ) |
| 1777 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1778 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1779 | delete_all_flows( self.controller ) |
| 1780 | delete_groups( self.controller, Groups ) |
| 1781 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1782 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1783 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1784 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1785 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1786 | |
| 1787 | def runTest( self ): |
| 1788 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1789 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1790 | if len( config[ "port_map" ] ) < 2: |
| 1791 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1792 | return |
| 1793 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1794 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1795 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1796 | # 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] | 1797 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1798 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1799 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1800 | vlan_id = port + 16 |
| 1801 | mpls_label = port + 16 |
| 1802 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1803 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1804 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1805 | 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] | 1806 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1807 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1808 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1809 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1810 | 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] | 1811 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1812 | 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] | 1813 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1814 | if config["switch_type"] == "qmx": |
| 1815 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1816 | else: |
| 1817 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1818 | |
| 1819 | if config["switch_type"] != 'xpliant': |
| 1820 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1821 | else: |
| 1822 | xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1823 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1824 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1825 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1826 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1827 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1828 | Groups._put( l2_gid ) |
| 1829 | Groups._put( l3_msg.group_id ) |
| 1830 | Groups._put( ecmp_msg.group_id ) |
| 1831 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1832 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1833 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1834 | for in_port in ports: |
| 1835 | ip_src = '192.168.%02d.1' % (in_port) |
| 1836 | for out_port in ports: |
| 1837 | if in_port == out_port: |
| 1838 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1839 | |
| 1840 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1841 | out_mpls_label = out_port + 16 |
| 1842 | in_vlan_vid = in_port + 16 |
| 1843 | out_vlan_vid = out_port + 16 |
| 1844 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1845 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1846 | label = (out_mpls_label, 0, 1, 32) |
| 1847 | 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] | 1848 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1849 | pkt = str( parsed_pkt ) |
| 1850 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1851 | # build expect packet |
| 1852 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1853 | if config["switch_type"] != 'xpliant': |
| 1854 | ip_ttl=31 |
| 1855 | else: |
| 1856 | ip_ttl=64 |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1857 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1858 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=ip_ttl, ip_src=ip_src, ip_dst=ip_dst ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1859 | pkt = str( exp_pkt ) |
| 1860 | verify_packet( self, pkt, out_port ) |
| 1861 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1862 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1863 | delete_all_flows( self.controller ) |
| 1864 | delete_groups( self.controller, Groups ) |
| 1865 | delete_all_groups( self.controller ) |
Saurav Das | 15c2c26 | 2017-05-06 18:12:38 -0700 | [diff] [blame] | 1866 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1867 | |
| 1868 | @disabled |
| 1869 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1870 | """ |
| 1871 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1872 | """ |
| 1873 | |
| 1874 | def runTest( self ): |
| 1875 | Groups = Queue.LifoQueue( ) |
| 1876 | try: |
| 1877 | if len( config[ "port_map" ] ) < 2: |
| 1878 | logging.info( "Port count less than 2, can't run this case" ) |
| 1879 | return |
| 1880 | dip = 0xc0a80001 |
| 1881 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1882 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1883 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1884 | ports = config[ "port_map" ].keys( ) |
| 1885 | inport = ports[0] |
| 1886 | outport = ports[1] |
| 1887 | |
| 1888 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1889 | invlan_id = inport + 16 |
| 1890 | outvlan_id = outport + 16 |
| 1891 | mpls_label = outport + 16 |
| 1892 | |
| 1893 | # add l2 interface group |
| 1894 | id, dst_mac[ 5 ] = inport, outport |
| 1895 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 1896 | # add L3 Unicast group |
| 1897 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 1898 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1899 | # add L3 ecmp group |
| 1900 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1901 | # add vlan flow table |
| 1902 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1903 | # add tmac flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1904 | if config["switch_type"] == "qmx": |
| 1905 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 1906 | else: |
| 1907 | 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] | 1908 | # add mpls termination flow |
| 1909 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 1910 | Groups._put( l2_gid ) |
| 1911 | Groups._put( l3_msg.group_id ) |
| 1912 | Groups._put( ecmp_msg.group_id ) |
| 1913 | |
| 1914 | time.sleep(0.1) |
| 1915 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1916 | ip_src = '192.168.%02d.1' % (inport) |
| 1917 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1918 | out_mpls_label = outport + 16 |
| 1919 | in_vlan_vid = inport + 16 |
| 1920 | out_vlan_vid = outport + 16 |
| 1921 | |
| 1922 | ip_dst = '192.168.%02d.1' % (outport) |
| 1923 | label = (out_mpls_label, 0, 1, 32) |
| 1924 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 1925 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1926 | pkt = str( parsed_pkt ) |
| 1927 | self.dataplane.send( inport, pkt ) |
| 1928 | # build expect packet |
| 1929 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 1930 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 1931 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1932 | pkt = str( exp_pkt ) |
| 1933 | verify_packet( self, pkt, outport ) |
| 1934 | verify_no_other_packets( self ) |
| 1935 | finally: |
| 1936 | delete_all_flows( self.controller ) |
| 1937 | delete_groups( self.controller, Groups ) |
| 1938 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1939 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1940 | |
| 1941 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1942 | """ Verify /24 IP forwarding to L3 Interface """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1943 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1944 | def runTest( self ): |
| 1945 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1946 | try: |
| 1947 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1948 | if len( config[ "port_map" ] ) < 2: |
| 1949 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1950 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1951 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1952 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1953 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1954 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1955 | for port in ports: |
| 1956 | # add l2 interface group |
| 1957 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1958 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1959 | is_tagged=True, send_barrier=False ) |
| 1960 | dst_mac[ 5 ] = vlan_id |
| 1961 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1962 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1963 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1964 | 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] | 1965 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1966 | if config["switch_type"] == "qmx": |
| 1967 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1968 | else: |
| 1969 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1970 | # add unicast routing flow |
| 1971 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1972 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1973 | Groups.put( l2gid ) |
| 1974 | Groups.put( l3_msg.group_id ) |
| 1975 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1976 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1977 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1978 | for in_port in ports: |
| 1979 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1980 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1981 | for out_port in ports: |
| 1982 | if in_port == out_port: |
| 1983 | continue |
| 1984 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1985 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1986 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1987 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1988 | pkt = str( parsed_pkt ) |
| 1989 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1990 | # build expected packet |
| 1991 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1992 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1993 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1994 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1995 | pkt = str( exp_pkt ) |
| 1996 | verify_packet( self, pkt, out_port ) |
| 1997 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1998 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1999 | delete_all_flows( self.controller ) |
| 2000 | delete_groups( self.controller, Groups ) |
| 2001 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2002 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2003 | |
| 2004 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2005 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2006 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2007 | def runTest( self ): |
| 2008 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2009 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2010 | if len( config[ "port_map" ] ) < 2: |
| 2011 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2012 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2013 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2014 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2015 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2016 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2017 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2018 | for port in ports: |
| 2019 | # add l2 interface group |
| 2020 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2021 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 2022 | is_tagged=True, send_barrier=False ) |
| 2023 | dst_mac[ 5 ] = vlan_id |
| 2024 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 2025 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2026 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2027 | 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] | 2028 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2029 | if config["switch_type"] == "qmx": |
| 2030 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2031 | else: |
| 2032 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2033 | # add unicast routing flow |
| 2034 | dst_ip = dip + (vlan_id << 8) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2035 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id, priority=2 ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2036 | Groups.put( l2gid ) |
| 2037 | Groups.put( l3_msg.group_id ) |
| 2038 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2039 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2040 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 2041 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2042 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2043 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2044 | for in_port in ports: |
| 2045 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 2046 | ip_src = '192.168.%02d.1' % (in_port) |
| 2047 | for out_port in ports: |
| 2048 | if in_port == out_port: |
| 2049 | continue |
| 2050 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2051 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 2052 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2053 | pkt = str( parsed_pkt ) |
| 2054 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2055 | # build expected packet |
| 2056 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2057 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 2058 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2059 | pkt = str( exp_pkt ) |
| 2060 | verify_packet( self, pkt, out_port ) |
| 2061 | verify_no_other_packets( self ) |
| 2062 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 2063 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 2064 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2065 | pkt = str( parsed_pkt ) |
| 2066 | self.dataplane.send( in_port, pkt ) |
| 2067 | # build expect packet |
| 2068 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2069 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 2070 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 2071 | pkt = str( exp_pkt ) |
| 2072 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2073 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2074 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2075 | delete_all_flows( self.controller ) |
| 2076 | delete_groups( self.controller, Groups ) |
| 2077 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2078 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2079 | |
| 2080 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2081 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2082 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2083 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2084 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2085 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2086 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2087 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2088 | vlan_id = 1; |
| 2089 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2090 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 2091 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2092 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2093 | delete_all_flows( self.controller ) |
| 2094 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2095 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2096 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2097 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2098 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2099 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2100 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2101 | |
| 2102 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2103 | """ |
| 2104 | port1 (vlan 1)-> port 2 (vlan 2) |
| 2105 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2106 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2107 | delete_all_flows( self.controller ) |
| 2108 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2109 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2110 | if len( config[ "port_map" ] ) < 3: |
| 2111 | logging.info( "Port count less than 3, can't run this case" ) |
| 2112 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2113 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2114 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2115 | vlan_id = 1 |
| 2116 | port2_out_vlan = 2 |
| 2117 | port3_out_vlan = 3 |
| 2118 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 2119 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2120 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2121 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2122 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 2123 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 2124 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 2125 | src_ip = 0xc0a80101 |
| 2126 | src_ip_str = "192.168.1.1" |
| 2127 | dst_ip = 0xe0010101 |
| 2128 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2129 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2130 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 2131 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 2132 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2133 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2134 | # add l2 interface group |
| 2135 | for port in config[ "port_map" ].keys( ): |
| 2136 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 2137 | send_barrier=False ) |
| 2138 | # add vlan flow table |
| 2139 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2140 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2141 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2142 | # add termination flow |
| 2143 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 2144 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2145 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2146 | # add MPLS interface group |
| 2147 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 2148 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 2149 | port2_out_vlan, port2 ) |
| 2150 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 2151 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 2152 | # add L3VPN groups |
| 2153 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2154 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 2155 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 2156 | # 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] | 2157 | # 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] | 2158 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2159 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 2160 | 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] | 2161 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2162 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 2163 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 2164 | pkt = str( parsed_pkt ) |
| 2165 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2166 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2167 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 2168 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 2169 | pkt = str( exp_pkt ) |
| 2170 | verify_packet( self, pkt, port2 ) |
| 2171 | # verify_packet(self, pkt, port3) |
| 2172 | verify_no_other_packets( self ) |
| 2173 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2174 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2175 | delete_all_flows( self.controller ) |
| 2176 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2177 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2178 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2179 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2180 | """ |
| 2181 | Test packet in function on a src-mac miss |
| 2182 | Send a packet to each dataplane port and verify that a packet |
| 2183 | in message is received from the controller for each |
| 2184 | #todo verify you stop receiving after adding rule |
| 2185 | """ |
| 2186 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2187 | def runTest( self ): |
| 2188 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2189 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2190 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2191 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2192 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2193 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2194 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 2195 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2196 | Groups.put( L2gid ) |
| 2197 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 2198 | vlan_pkt = str( parsed_vlan_pkt ) |
| 2199 | for of_port in config[ "port_map" ].keys( ): |
| 2200 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 2201 | self.dataplane.send( of_port, vlan_pkt ) |
| 2202 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 2203 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2204 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2205 | delete_all_flows( self.controller ) |
| 2206 | delete_all_groups( self.controller ) |
| 2207 | |
| 2208 | |
| 2209 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 2210 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2211 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2212 | """ |
| 2213 | |
| 2214 | def runTest( self ): |
| 2215 | Groups = Queue.LifoQueue( ) |
| 2216 | try: |
| 2217 | if len( config[ "port_map" ] ) < 2: |
| 2218 | logging.info( "Port count less than 2, can't run this case" ) |
| 2219 | return |
| 2220 | |
| 2221 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2222 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2223 | dip = 0xc0a80001 |
| 2224 | # Hashes Test Name and uses it as id for installing unique groups |
| 2225 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2226 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2227 | dst_ips = [] |
| 2228 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2229 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2230 | for port in ports: |
| 2231 | vlan_id = port |
| 2232 | id = port |
| 2233 | # add l2 interface group |
| 2234 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2235 | is_tagged=True, send_barrier=False ) |
| 2236 | dst_mac[ 5 ] = vlan_id |
| 2237 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2238 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2239 | if port == ports[1]: |
| 2240 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2241 | Groups._put( l2_gid ) |
| 2242 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2243 | 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] | 2244 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2245 | 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] | 2246 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2247 | if config["switch_type"] == "qmx": |
| 2248 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2249 | else: |
| 2250 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2251 | # add unicast routing flow |
| 2252 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2253 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2254 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2255 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2256 | for dst_ip in dst_ips: |
| 2257 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2258 | time.sleep(0.1) |
| 2259 | # 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] | 2260 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2261 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2262 | in_port = ports[0] |
| 2263 | out_port = ports[1] |
| 2264 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2265 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2266 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2267 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2268 | tcp = out_port if out_port == 24 else 25 |
| 2269 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2270 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2271 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2272 | pkt = str( parsed_pkt ) |
| 2273 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2274 | # build expected packet at egress switchport |
| 2275 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2276 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2277 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2278 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2279 | pkt = str( exp_pkt ) |
| 2280 | verify_packet( self, pkt, out_port ) |
| 2281 | verify_no_other_packets( self ) |
| 2282 | |
| 2283 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2284 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2285 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2286 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2287 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2288 | time.sleep(0.1) |
| 2289 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2290 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2291 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2292 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2293 | tcp = port if port == 24 else 25 |
| 2294 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2295 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2296 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2297 | pkt = str( parsed_pkt ) |
| 2298 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2299 | # build expected packet |
| 2300 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2301 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2302 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2303 | ip_dst=ip_dst,tcp_dport=tcp ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2304 | # Expects packet on the input port |
| 2305 | if config["switch_type"] != 'xpliant': |
| 2306 | pkt = str( exp_pkt ) |
| 2307 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2308 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2309 | |
| 2310 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2311 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2312 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2313 | time.sleep(0.1) |
| 2314 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2315 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2316 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2317 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2318 | tcp = port if port == 24 else 25 |
| 2319 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2320 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2321 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2322 | pkt = str( parsed_pkt ) |
| 2323 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2324 | verify_no_other_packets( self ) |
| 2325 | |
| 2326 | # final part of the test - edit the empty group to add back the bucket for the |
| 2327 | # original egress port, and verify packet is received on egress switch port |
| 2328 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2329 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2330 | do_barrier(self.controller) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2331 | in_port = ports[0] |
| 2332 | out_port = ports[1] |
| 2333 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2334 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2335 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2336 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2337 | tcp = out_port if out_port == 24 else 25 |
| 2338 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2339 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2340 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2341 | pkt = str( parsed_pkt ) |
| 2342 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2343 | # build expected packet at egress switchport |
| 2344 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2345 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2346 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2347 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2348 | pkt = str( exp_pkt ) |
| 2349 | verify_packet( self, pkt, out_port ) |
| 2350 | verify_no_other_packets( self ) |
| 2351 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2352 | finally: |
| 2353 | delete_all_flows( self.controller ) |
| 2354 | delete_groups( self.controller, Groups ) |
| 2355 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2356 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2357 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2358 | class Untagged( base_tests.SimpleDataPlane ): |
| 2359 | """ |
| 2360 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2361 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2362 | previous versions of the OFDPA. |
| 2363 | |
| 2364 | Two rules are necessary in VLAN table (10): |
| 2365 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2366 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2367 | |
| 2368 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2369 | The remaining part of the test is based on the use of the bridging table |
| 2370 | """ |
| 2371 | |
| 2372 | MAX_INTERNAL_VLAN = 4094 |
| 2373 | |
| 2374 | def runTest( self ): |
| 2375 | groups = Queue.LifoQueue( ) |
| 2376 | try: |
| 2377 | if len( config[ "port_map" ] ) < 2: |
| 2378 | logging.info( "Port count less than 2, can't run this case" ) |
| 2379 | return |
| 2380 | |
| 2381 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2382 | for port in ports: |
| 2383 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2384 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2385 | 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] | 2386 | for other_port in ports: |
| 2387 | if other_port == port: |
| 2388 | continue |
| 2389 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2390 | groups.put( L2gid ) |
| 2391 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2392 | |
| 2393 | do_barrier( self.controller ) |
| 2394 | |
| 2395 | for out_port in ports: |
| 2396 | # change dest based on port number |
| 2397 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2398 | for in_port in ports: |
| 2399 | if in_port == out_port: |
| 2400 | continue |
| 2401 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2402 | self.dataplane.send( in_port, pkt ) |
| 2403 | for ofport in ports: |
| 2404 | if ofport in [ out_port ]: |
| 2405 | verify_packet( self, pkt, ofport ) |
| 2406 | else: |
| 2407 | verify_no_packet( self, pkt, ofport ) |
| 2408 | verify_no_other_packets( self ) |
| 2409 | finally: |
| 2410 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2411 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2412 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 2413 | |
| 2414 | class MPLSSwapTest( base_tests.SimpleDataPlane ): |
| 2415 | """ |
| 2416 | MPLS switching with the same label used. |
| 2417 | Used for interconnecting spines between different fabrics where |
| 2418 | the label should not be popped, but swapepd with the same label. |
| 2419 | """ |
| 2420 | |
| 2421 | def runTest( self ): |
| 2422 | try: |
| 2423 | delete_all_flows( self.controller ) |
| 2424 | delete_all_groups( self.controller ) |
| 2425 | |
| 2426 | if len( config[ "port_map" ] ) < 2: |
| 2427 | logging.info( "Port count less than 3, can't run this case" ) |
| 2428 | assert (False) |
| 2429 | return |
| 2430 | |
| 2431 | input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2432 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2433 | |
| 2434 | input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ] |
| 2435 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2436 | |
| 2437 | output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ] |
| 2438 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2439 | |
| 2440 | mpls_label = 1000 |
| 2441 | |
| 2442 | src_ip = 0xc0a80101 |
| 2443 | src_ip_str = "192.168.1.1" |
| 2444 | dst_ip = 0xe0010101 |
| 2445 | dst_ip_str = "224.1.1.1" |
| 2446 | |
| 2447 | src_port = config[ "port_map" ].keys( )[ 0 ] |
| 2448 | dst_port = config[ "port_map" ].keys( )[ 1 ] |
| 2449 | |
| 2450 | out_vlan = 4094 |
| 2451 | |
| 2452 | add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False, |
| 2453 | send_barrier=True ) |
| 2454 | |
| 2455 | # add vlan flow table |
| 2456 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2457 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2458 | |
| 2459 | # add termination flow |
| 2460 | |
| 2461 | if config["switch_type"] == "qmx": |
| 2462 | logging.debug("MPLSSwitching : Adding flow for qmx, without input port") |
| 2463 | add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2464 | else: |
| 2465 | add_termination_flow( self.controller, in_port=src_port, |
| 2466 | eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2467 | |
| 2468 | # add groups that will be used now |
| 2469 | l2_gid = encode_l2_interface_group_id( out_vlan, dst_port) |
| 2470 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, |
| 2471 | output_dst_mac, input_dst_mac, |
| 2472 | out_vlan, dst_port, send_barrier=True) |
| 2473 | index = 60 |
| 2474 | mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid, |
| 2475 | 5, index, mpls_label) |
| 2476 | |
| 2477 | # add flow to mpls table |
| 2478 | add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True) |
| 2479 | |
| 2480 | # we generate the packet which carries a single label |
| 2481 | label = (mpls_label, 0, 1, 63) |
| 2482 | parsed_pkt = mpls_packet( |
| 2483 | pktlen=104, |
| 2484 | label=[label], |
| 2485 | eth_src=input_src_mac_str, |
| 2486 | eth_dst=input_dst_mac_str, |
| 2487 | ) |
| 2488 | pkt = str( parsed_pkt ) |
| 2489 | self.dataplane.send( src_port, pkt ) |
| 2490 | |
| 2491 | label = (mpls_label, 0, 1, 62) |
| 2492 | parsed_pkt = mpls_packet( |
| 2493 | pktlen=104, |
| 2494 | label=[label], |
| 2495 | eth_src=input_dst_mac_str, |
| 2496 | eth_dst=output_dst_mac_str, |
| 2497 | ) |
| 2498 | pkt = str( parsed_pkt ) |
| 2499 | |
| 2500 | verify_packet( self, pkt, dst_port ) |
| 2501 | verify_no_packet( self, pkt, src_port ) |
| 2502 | verify_no_other_packets( self ) |
| 2503 | |
| 2504 | delete_all_flows( self.controller ) |
| 2505 | delete_all_groups( self.controller ) |
| 2506 | |
| 2507 | finally: |
| 2508 | delete_all_flows( self.controller ) |
| 2509 | delete_all_groups( self.controller ) |
| 2510 | |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame^] | 2511 | class DoubleToUntagged( base_tests.SimpleDataPlane ): |
| 2512 | """ |
| 2513 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2514 | where we receive double tagged packets and output untagged |
| 2515 | packets. |
| 2516 | |
| 2517 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2518 | and inner tag is the subrscriber tag. |
| 2519 | """ |
| 2520 | |
| 2521 | def runTest( self ): |
| 2522 | Groups = Queue.LifoQueue( ) |
| 2523 | try: |
| 2524 | if len( config[ "port_map" ] ) < 2: |
| 2525 | logging.info( "Port count less than 2, can't run this case" ) |
| 2526 | return |
| 2527 | |
| 2528 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2529 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2530 | |
| 2531 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2532 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2533 | |
| 2534 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2535 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2536 | |
| 2537 | dip = 0xc0a80001 |
| 2538 | ports = config[ "port_map" ].keys( ) |
| 2539 | |
| 2540 | inner_vlan = 66 |
| 2541 | outer_vlan = 77 |
| 2542 | id = 10 |
| 2543 | mpls_label = 152 |
| 2544 | |
| 2545 | port = ports[0] |
| 2546 | out_port = ports[1] |
| 2547 | |
| 2548 | # add l2 interface group |
| 2549 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2550 | |
| 2551 | # add MPLS interface group |
| 2552 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2553 | inner_vlan, id ) |
| 2554 | |
| 2555 | # add MPLS L3 VPN group |
| 2556 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2557 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2558 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2559 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2560 | |
| 2561 | do_barrier( self.controller ) |
| 2562 | |
| 2563 | # add vlan flow table |
| 2564 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2565 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2566 | |
| 2567 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2568 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2569 | |
| 2570 | # add termination flow |
| 2571 | if config["switch_type"] == "qmx": |
| 2572 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2573 | else: |
| 2574 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2575 | |
| 2576 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2577 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2578 | vrf=0 ) |
| 2579 | Groups._put( l2_gid ) |
| 2580 | Groups._put( mpls_gid ) |
| 2581 | Groups._put( mpls_label_gid ) |
| 2582 | Groups._put( ecmp_msg.group_id ) |
| 2583 | |
| 2584 | do_barrier( self.controller ) |
| 2585 | |
| 2586 | ip_src = '192.168.5.5' |
| 2587 | ip_dst = '192.168.0.5' |
| 2588 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2589 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2590 | pkt = str( parsed_pkt ) |
| 2591 | |
| 2592 | # print("Expected %s" % format_packet(pkt)) |
| 2593 | |
| 2594 | self.dataplane.send( port, pkt ) |
| 2595 | |
| 2596 | # build expect packet |
| 2597 | label = (mpls_label, 0, 1, 32) |
| 2598 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2599 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2600 | label=[ label ] ) |
| 2601 | pkt = str( exp_pkt ) |
| 2602 | verify_packet( self, pkt, out_port ) |
| 2603 | verify_no_other_packets( self ) |
| 2604 | |
| 2605 | finally: |
| 2606 | delete_all_flows( self.controller ) |
| 2607 | delete_groups( self.controller, Groups ) |
| 2608 | delete_all_groups( self.controller ) |
| 2609 | |
| 2610 | class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ): |
| 2611 | """ |
| 2612 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2613 | where we receive double tagged packets and output untagged |
| 2614 | packets. |
| 2615 | |
| 2616 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2617 | and inner tag is the subrscriber tag. |
| 2618 | """ |
| 2619 | |
| 2620 | def runTest( self ): |
| 2621 | Groups = Queue.LifoQueue( ) |
| 2622 | try: |
| 2623 | if len( config[ "port_map" ] ) < 2: |
| 2624 | logging.info( "Port count less than 2, can't run this case" ) |
| 2625 | return |
| 2626 | |
| 2627 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 2628 | subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"], |
| 2629 | [20, 0xc0a80002, 10, 101, "192.168.0.2"], |
| 2630 | [30, 0xc0a80003, 11, 100, "192.168.0.3"], |
| 2631 | [40, 0xc0a80004, 11, 101, "192.168.0.4"]] |
| 2632 | |
| 2633 | print("") |
| 2634 | |
| 2635 | for sub_info in subscriber_info: |
| 2636 | |
| 2637 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 2638 | |
| 2639 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2640 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2641 | |
| 2642 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2643 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2644 | |
| 2645 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2646 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2647 | |
| 2648 | dip = sub_info[1] |
| 2649 | ports = config[ "port_map" ].keys( ) |
| 2650 | |
| 2651 | inner_vlan = sub_info[2] |
| 2652 | outer_vlan = sub_info[3] |
| 2653 | id = 10 |
| 2654 | mpls_label = 152 |
| 2655 | |
| 2656 | port = ports[0] |
| 2657 | out_port = ports[1] |
| 2658 | |
| 2659 | # add l2 interface group |
| 2660 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2661 | |
| 2662 | # add MPLS interface group |
| 2663 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2664 | inner_vlan, id ) |
| 2665 | |
| 2666 | # add MPLS L3 VPN group |
| 2667 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2668 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2669 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2670 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2671 | |
| 2672 | do_barrier( self.controller ) |
| 2673 | |
| 2674 | # add vlan flow table |
| 2675 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2676 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2677 | |
| 2678 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2679 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2680 | |
| 2681 | # add termination flow |
| 2682 | if config["switch_type"] == "qmx": |
| 2683 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2684 | else: |
| 2685 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2686 | |
| 2687 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2688 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2689 | vrf=0 ) |
| 2690 | Groups._put( l2_gid ) |
| 2691 | Groups._put( mpls_gid ) |
| 2692 | Groups._put( mpls_label_gid ) |
| 2693 | Groups._put( ecmp_msg.group_id ) |
| 2694 | |
| 2695 | do_barrier( self.controller ) |
| 2696 | |
| 2697 | for sub_info in subscriber_info: |
| 2698 | |
| 2699 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 2700 | |
| 2701 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2702 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2703 | |
| 2704 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2705 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2706 | |
| 2707 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2708 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2709 | |
| 2710 | dip = sub_info[1] |
| 2711 | ports = config[ "port_map" ].keys( ) |
| 2712 | |
| 2713 | inner_vlan = sub_info[2] |
| 2714 | outer_vlan = sub_info[3] |
| 2715 | id = 10 |
| 2716 | mpls_label = 152 |
| 2717 | |
| 2718 | port = ports[0] |
| 2719 | out_port = ports[1] |
| 2720 | |
| 2721 | ip_src = sub_info[4] |
| 2722 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 2723 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2724 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2725 | pkt = str( parsed_pkt ) |
| 2726 | |
| 2727 | # print("Sent %s" % format_packet(pkt)) |
| 2728 | |
| 2729 | self.dataplane.send( port, pkt ) |
| 2730 | |
| 2731 | # build expect packet |
| 2732 | label = (mpls_label, 0, 1, 32) |
| 2733 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2734 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2735 | label=[ label ] ) |
| 2736 | pkt = str( exp_pkt ) |
| 2737 | verify_packet( self, pkt, out_port ) |
| 2738 | verify_no_other_packets( self ) |
| 2739 | |
| 2740 | finally: |
| 2741 | delete_all_flows( self.controller ) |
| 2742 | delete_groups( self.controller, Groups ) |
| 2743 | delete_all_groups( self.controller ) |
| 2744 | |
| 2745 | |
| 2746 | class UntaggedToDouble ( base_tests.SimpleDataPlane ): |
| 2747 | """ |
| 2748 | Verify google senario where we need to go from |
| 2749 | an untagged packet to a double tagged packet. |
| 2750 | |
| 2751 | This is used for a single subscriber. |
| 2752 | """ |
| 2753 | |
| 2754 | def runTest( self ): |
| 2755 | Groups = Queue.LifoQueue( ) |
| 2756 | try: |
| 2757 | if len( config[ "port_map" ] ) < 2: |
| 2758 | logging.info( "Port count less than 2, can't run this case" ) |
| 2759 | return |
| 2760 | |
| 2761 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2762 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2763 | |
| 2764 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2765 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2766 | |
| 2767 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2768 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2769 | |
| 2770 | dip = 0xc0a80001 |
| 2771 | ports = config[ "port_map" ].keys( ) |
| 2772 | |
| 2773 | inner_vlan = 66 |
| 2774 | outer_vlan = 77 |
| 2775 | id = 10 |
| 2776 | mpls_label = 152 |
| 2777 | |
| 2778 | port = ports[0] |
| 2779 | out_port = ports[1] |
| 2780 | |
| 2781 | # add l2 unfiltered interface group |
| 2782 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 2783 | |
| 2784 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 2785 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 2786 | |
| 2787 | do_barrier( self.controller ) |
| 2788 | |
| 2789 | # add vlan flow table |
| 2790 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 2791 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 2792 | |
| 2793 | # add termination flow |
| 2794 | if config["switch_type"] == "qmx": |
| 2795 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 2796 | else: |
| 2797 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 2798 | |
| 2799 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 2800 | vrf=0 ) |
| 2801 | |
| 2802 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 2803 | |
| 2804 | Groups._put( l2_gid ) |
| 2805 | Groups._put( l3_msg.group_id ) |
| 2806 | |
| 2807 | do_barrier( self.controller ) |
| 2808 | |
| 2809 | ip_src = '192.168.5.5' |
| 2810 | ip_dst = '192.168.0.1' |
| 2811 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 2812 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2813 | pkt = str( parsed_pkt ) |
| 2814 | |
| 2815 | # print("Input Packet %s" % format_packet(pkt)) |
| 2816 | |
| 2817 | self.dataplane.send( port, pkt ) |
| 2818 | |
| 2819 | # build expect packet |
| 2820 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2821 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2822 | pkt = str( exp_pkt ) |
| 2823 | |
| 2824 | # print("Expected Packet %s" % format_packet(pkt)) |
| 2825 | |
| 2826 | verify_packet( self, pkt, out_port ) |
| 2827 | verify_no_other_packets( self ) |
| 2828 | finally: |
| 2829 | delete_all_flows( self.controller ) |
| 2830 | delete_groups( self.controller, Groups ) |
| 2831 | delete_all_groups( self.controller ) |
| 2832 | |
| 2833 | class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ): |
| 2834 | """ |
| 2835 | Verify google senario where we need to go from |
| 2836 | an untagged packet to a double tagged packet. |
| 2837 | |
| 2838 | This is used for multiple subscribers. |
| 2839 | |
| 2840 | However, this solution does not scale, since we assign an internal vlan to each subscriber |
| 2841 | used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table. |
| 2842 | """ |
| 2843 | |
| 2844 | def runTest( self ): |
| 2845 | Groups = Queue.LifoQueue( ) |
| 2846 | try: |
| 2847 | if len( config[ "port_map" ] ) < 2: |
| 2848 | logging.info( "Port count less than 2, can't run this case" ) |
| 2849 | return |
| 2850 | |
| 2851 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan] |
| 2852 | subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000], |
| 2853 | [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001], |
| 2854 | [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002], |
| 2855 | [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]] |
| 2856 | |
| 2857 | print("") |
| 2858 | |
| 2859 | for sub_info in subscriber_info: |
| 2860 | |
| 2861 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 2862 | |
| 2863 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2864 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2865 | |
| 2866 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2867 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2868 | |
| 2869 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2870 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2871 | |
| 2872 | dip = sub_info[1] |
| 2873 | ports = config[ "port_map" ].keys( ) |
| 2874 | |
| 2875 | inner_vlan = sub_info[2] |
| 2876 | outer_vlan = sub_info[3] |
| 2877 | internal_vlan = sub_info[5] |
| 2878 | id = sub_info[0] + 10 |
| 2879 | |
| 2880 | port = ports[0] |
| 2881 | out_port = ports[1] |
| 2882 | |
| 2883 | # add l2 unfiltered interface group |
| 2884 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 2885 | |
| 2886 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id, |
| 2887 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 2888 | |
| 2889 | do_barrier( self.controller ) |
| 2890 | |
| 2891 | # add vlan flow table |
| 2892 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 2893 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 2894 | |
| 2895 | # add termination flow |
| 2896 | if config["switch_type"] == "qmx": |
| 2897 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 2898 | else: |
| 2899 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 2900 | |
| 2901 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 2902 | vrf=0 ) |
| 2903 | |
| 2904 | add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan) |
| 2905 | |
| 2906 | Groups._put( l2_gid ) |
| 2907 | Groups._put( l3_msg.group_id ) |
| 2908 | do_barrier( self.controller ) |
| 2909 | |
| 2910 | for sub_info in subscriber_info: |
| 2911 | |
| 2912 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 2913 | |
| 2914 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2915 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2916 | |
| 2917 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2918 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2919 | |
| 2920 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2921 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2922 | |
| 2923 | dip = sub_info[1] |
| 2924 | ports = config[ "port_map" ].keys( ) |
| 2925 | |
| 2926 | inner_vlan = sub_info[2] |
| 2927 | outer_vlan = sub_info[3] |
| 2928 | internal_vlan = sub_info[5] |
| 2929 | |
| 2930 | id = sub_info[0] + 10 |
| 2931 | ip_src = '192.168.5.5' |
| 2932 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 2933 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 2934 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2935 | pkt = str( parsed_pkt ) |
| 2936 | |
| 2937 | # print("Input Packet %s" % format_packet(pkt)) |
| 2938 | |
| 2939 | self.dataplane.send( port, pkt ) |
| 2940 | |
| 2941 | # build expect packet |
| 2942 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2943 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2944 | pkt = str( exp_pkt ) |
| 2945 | |
| 2946 | # print("Expected Packet %s" % format_packet(pkt)) |
| 2947 | |
| 2948 | verify_packet( self, pkt, out_port ) |
| 2949 | verify_no_other_packets( self ) |
| 2950 | finally: |
| 2951 | delete_all_flows( self.controller ) |
| 2952 | delete_groups( self.controller, Groups ) |
| 2953 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 2954 | |