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 |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 28 | from oftest.oft12.testutils import delete_all_flows_one_table |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 29 | from oftest.testutils import * |
| 30 | from accton_util import * |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 31 | from utils import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 32 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 33 | class PacketInUDP( base_tests.SimpleDataPlane ): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 34 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 35 | 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] | 36 | """ |
| 37 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 38 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 39 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 40 | parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 41 | vlan_pkt = str( parsed_vlan_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 42 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 43 | match = ofp.match( ) |
| 44 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 45 | match.oxm_list.append( ofp.oxm.ip_proto( 2 ) ) |
| 46 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 47 | ofp.instruction.apply_actions( actions=[ |
| 48 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 49 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 50 | logging.info( "Inserting packet in flow to controller" ) |
| 51 | self.controller.message_send( request ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 52 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 53 | for of_port in config[ "port_map" ].keys( ): |
| 54 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 55 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 56 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 57 | verify_no_packet_in( self, vlan_pkt, of_port ) |
| 58 | delete_all_flows( self.controller ) |
| 59 | do_barrier( self.controller ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 60 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 61 | match = ofp.match( ) |
| 62 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 63 | match.oxm_list.append( ofp.oxm.ip_proto( 17 ) ) |
| 64 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 65 | ofp.instruction.apply_actions( actions=[ |
| 66 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 67 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 68 | logging.info( "Inserting packet in flow to controller" ) |
| 69 | self.controller.message_send( request ) |
| 70 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 71 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 72 | for of_port in config[ "port_map" ].keys( ): |
| 73 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 74 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 75 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 76 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 77 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 78 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 79 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 80 | delete_all_flows( self.controller ) |
| 81 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 82 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 83 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 84 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 85 | class ArpNL2( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 86 | """ |
| 87 | Needs a description, disabled for now. Also needs try/finally |
| 88 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 89 | def runTest( self ): |
| 90 | delete_all_flows( self.controller ) |
| 91 | delete_all_groups( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 92 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 93 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 94 | match = ofp.match( ) |
| 95 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 96 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 97 | ofp.instruction.apply_actions( actions=[ |
| 98 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 99 | buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| 100 | self.controller.message_send( request ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 101 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 102 | add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| 103 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 104 | group_id = encode_l2_interface_group_id( 1, port ) |
| 105 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| 106 | do_barrier( self.controller ) |
| 107 | parsed_arp_pkt = simple_arp_packet( ) |
| 108 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 109 | |
| 110 | for out_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 111 | self.dataplane.send( out_port, arp_pkt ) |
| 112 | verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 113 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 114 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 115 | for in_port in ports: |
| 116 | if in_port == out_port: |
| 117 | continue |
| 118 | # change source based on port number to avoid packet-ins from learning |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 119 | mac_src = '00:12:34:56:78:%02X' % in_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 120 | parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| 121 | pkt = str( parsed_pkt ) |
| 122 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 123 | |
| 124 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 125 | if ofport in [ out_port ]: |
| 126 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 127 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 128 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 129 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 130 | verify_no_other_packets( self ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 131 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 132 | class PacketInArp( base_tests.SimpleDataPlane ): |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 133 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 134 | Verify Packet-in message from eth_type 0x806 on ACL table |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 135 | """ |
| 136 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 137 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 138 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 139 | parsed_arp_pkt = simple_arp_packet( ) |
| 140 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 141 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 142 | match = ofp.match( ) |
| 143 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 144 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 145 | ofp.instruction.apply_actions( actions=[ |
| 146 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 147 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 148 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 149 | logging.info( "Inserting arp flow " ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 150 | self.controller.message_send( request ) |
| 151 | do_barrier( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 152 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 153 | for of_port in config[ "port_map" ].keys( ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 154 | logging.info( "PacketInArp test, sending arp packet to port %d", of_port ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 155 | self.dataplane.send( of_port, arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 156 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 157 | verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 158 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 159 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 160 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 161 | delete_all_flows( self.controller ) |
| 162 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 163 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 164 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 165 | class PacketInIPTable( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 166 | """ |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 167 | Verify Packet-in message from IP table when controller action is used |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 168 | Send a packet to each dataplane port and verify that a packet |
| 169 | in message is received from the controller for each |
| 170 | #todo verify you stop receiving after adding rule |
| 171 | """ |
| 172 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 173 | def runTest( self ): |
| 174 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 175 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 176 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 177 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 178 | dip = 0xc0a80001 |
| 179 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 180 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 181 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 182 | # add l2 interface group |
| 183 | vlan_id = port |
| 184 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| 185 | send_barrier=False ) |
| 186 | dst_mac[ 5 ] = vlan_id |
| 187 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 188 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 189 | # add vlan flow table |
TonyChou | af5505c | 2017-08-24 09:11:19 +0800 | [diff] [blame] | 190 | 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] | 191 | # add termination flow |
| 192 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 193 | # add unicast routing flow |
| 194 | dst_ip = dip + (vlan_id << 8) |
| 195 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| 196 | send_ctrl=True ) |
| 197 | Groups.put( l3_msg.group_id ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 198 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 199 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 200 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 201 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 202 | for in_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 203 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 204 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 205 | for out_port in ports: |
| 206 | if in_port == out_port: |
| 207 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 208 | ip_dst = '192.168.%02d.1' % out_port |
| 209 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 210 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 211 | pkt = str( parsed_pkt ) |
| 212 | self.dataplane.send( in_port, pkt ) |
| 213 | verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| 214 | # verify_no_other_packets(self) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 215 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 216 | delete_all_flows( self.controller ) |
| 217 | delete_groups( self.controller, Groups ) |
| 218 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 219 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 220 | |
| 221 | class L2FloodQinQ( base_tests.SimpleDataPlane ): |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 222 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 223 | Verify Vlan based flooding of QinQ based on its outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 224 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 225 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 226 | def runTest( self ): |
| 227 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 228 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 229 | ports = sorted( config[ "port_map" ].keys( ) ) |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 230 | vlan_id = 100 |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 231 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 232 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 233 | 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] | 234 | 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] | 235 | Groups.put( L2gid ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 236 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 237 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 238 | Groups.put( msg.group_id ) |
| 239 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 240 | do_barrier( self.controller ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 241 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 242 | # verify flood |
| 243 | for ofport in ports: |
| 244 | # change dest based on port number |
| 245 | mac_src = '00:12:34:56:78:%02X' % ofport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 246 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 247 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 248 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 249 | pkt = str( parsed_pkt ) |
| 250 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 251 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 252 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 253 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 254 | tmp_ports = list( ports ) |
| 255 | tmp_ports.remove( ofport ) |
| 256 | verify_packets( self, pkt, tmp_ports ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 257 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 258 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 259 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 260 | delete_all_flows( self.controller ) |
| 261 | delete_groups( self.controller, Groups ) |
| 262 | delete_all_groups( self.controller ) |
| 263 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 264 | |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 265 | |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 266 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 267 | class L2FloodTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 268 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 269 | currently disabled; fix with try/finally |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 270 | Test L2 flood to a vlan |
| 271 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 272 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 273 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 274 | def runTest( self ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 275 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 276 | vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 277 | print vlan_id |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 278 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 279 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 280 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 281 | delete_all_flows( self.controller ) |
| 282 | delete_all_groups( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 283 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 284 | # Installing flows to avoid packet-in |
| 285 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 286 | add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 287 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 288 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 289 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 290 | do_barrier( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 291 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 292 | # verify flood |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 293 | for ofport in ports: |
| 294 | # change dest based on port number |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 295 | pkt = str( |
| 296 | simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| 297 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 298 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 299 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 300 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 301 | tmp_ports = list( ports ) |
| 302 | tmp_ports.remove( ofport ) |
| 303 | verify_packets( self, pkt, tmp_ports ) |
| 304 | verify_no_other_packets( self ) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 305 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 306 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 307 | class L2UnicastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 308 | """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 309 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 310 | def runTest( self ): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 311 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 312 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 313 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 314 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 315 | vlan_id = 1; |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 316 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 317 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 318 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 319 | Groups.put( L2gid ) |
| 320 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 321 | True ) |
| 322 | do_barrier( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 323 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 324 | for out_port in ports: |
| 325 | # change dest based on port number |
| 326 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 327 | for in_port in ports: |
| 328 | if in_port == out_port: |
| 329 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 330 | pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 331 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 332 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 333 | if ofport in [ out_port ]: |
| 334 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 335 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 336 | verify_no_packet( self, pkt, ofport ) |
| 337 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 338 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 339 | delete_all_flows( self.controller ) |
| 340 | delete_groups( self.controller, Groups ) |
| 341 | delete_all_groups( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 342 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 343 | |
Saurav Das | 59fae5e | 2017-12-07 12:02:02 -0800 | [diff] [blame] | 344 | class Bridging( base_tests.SimpleDataPlane ): |
| 345 | """ |
| 346 | Verify bridging works including flooding with different vlans |
| 347 | ports[0] has vlan 31 untagged |
| 348 | ports[1] has vlan 31 untagged (native) and vlan 41 tagged |
| 349 | ARP request should be flooded |
| 350 | ARP reply should be forwarded by bridging rule |
| 351 | Both arp messages should also be copied to controller |
| 352 | """ |
| 353 | |
| 354 | def runTest( self ): |
| 355 | Groupd = Queue.LifoQueue() |
| 356 | try: |
| 357 | if len( config[ "port_map" ] ) < 2: |
| 358 | logging.info( "Port count less than 2, can't run this case" ) |
| 359 | return |
| 360 | ports = sorted( config[ "port_map" ].keys() ) |
| 361 | vlan_p0_untagged = 31 |
| 362 | vlan_p1_tagged = 31 |
| 363 | vlan_p1_native = 41 |
| 364 | |
| 365 | #l2 interface groups and table 10 flows |
| 366 | L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged, |
| 367 | is_tagged=False, send_barrier=False ) |
| 368 | add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 369 | send_barrier=True) |
| 370 | L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged, |
| 371 | is_tagged=True, send_barrier=False ) |
| 372 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 373 | send_barrier=True) |
| 374 | L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native, |
| 375 | is_tagged=False, send_barrier=False ) |
| 376 | add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 377 | send_barrier=True) |
| 378 | #flooding groups |
| 379 | Floodmsg31 = add_l2_flood_group( self.controller, ports, vlan_p0_untagged, id=0 ) |
| 380 | Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 ) |
| 381 | |
| 382 | #add bridging flows for flooding groups |
| 383 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id ) |
| 384 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id ) |
| 385 | do_barrier( self.controller ) |
| 386 | |
| 387 | # add bridging flows for dstMac+vlan |
| 388 | add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True ) |
| 389 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True ) |
| 390 | add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True ) |
| 391 | |
| 392 | # add terminationMac flow |
| 393 | router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 394 | if config["switch_type"] == "qmx": |
| 395 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged ) |
| 396 | add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native ) |
| 397 | else: |
| 398 | add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged ) |
| 399 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged ) |
| 400 | add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native ) |
| 401 | |
| 402 | # add acl rule for arp |
| 403 | match = ofp.match( ) |
| 404 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 405 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 406 | ofp.instruction.apply_actions( actions=[ |
| 407 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 408 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 409 | self.controller.message_send( request ) |
| 410 | do_barrier( self.controller ) |
| 411 | |
| 412 | #acl rule for gateway ip |
| 413 | match = ofp.match( ) |
| 414 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 415 | match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) ) |
| 416 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 417 | ofp.instruction.apply_actions( actions=[ |
| 418 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), |
| 419 | ofp.instruction.clear_actions() ], |
| 420 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 421 | self.controller.message_send( request ) |
| 422 | do_barrier( self.controller ) |
| 423 | |
| 424 | # send ARP request |
| 425 | parsed_arp_pkt = simple_arp_packet(pktlen=80, |
| 426 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 427 | eth_src='00:66:77:88:99:aa', |
| 428 | vlan_vid=vlan_p1_tagged, |
| 429 | vlan_pcp=0, |
| 430 | arp_op=1, |
| 431 | ip_snd='192.168.0.2', |
| 432 | ip_tgt='192.168.0.1', |
| 433 | hw_snd='00:66:77:88:99:aa', |
| 434 | hw_tgt='00:00:00:00:00:00') |
| 435 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 436 | logging.info( "sending arp request to port %d", ports[1] ) |
| 437 | self.dataplane.send( ports[1], arp_pkt_to_send ) |
| 438 | verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION ) |
| 439 | parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76, |
| 440 | eth_dst='ff:ff:ff:ff:ff:ff', |
| 441 | eth_src='00:66:77:88:99:aa', |
| 442 | vlan_vid=0, |
| 443 | vlan_pcp=0, |
| 444 | arp_op=1, |
| 445 | ip_snd='192.168.0.2', |
| 446 | ip_tgt='192.168.0.1', |
| 447 | hw_snd='00:66:77:88:99:aa', |
| 448 | hw_tgt='00:00:00:00:00:00') |
| 449 | arp_pkt_dest = str( parsed_arp_pkt_untagged ) |
| 450 | verify_packet( self, arp_pkt_dest, ports[0] ) |
| 451 | #verify_no_other_packets( self ) |
| 452 | |
| 453 | # send ARP reply |
| 454 | parsed_arp_pkt = simple_arp_packet(pktlen=76, |
| 455 | eth_dst='00:66:77:88:99:aa', |
| 456 | eth_src='00:11:22:33:44:55', |
| 457 | vlan_vid=0, |
| 458 | vlan_pcp=0, |
| 459 | arp_op=2, |
| 460 | ip_snd='192.168.0.1', |
| 461 | ip_tgt='192.168.0.2', |
| 462 | hw_snd='00:11:22:33:44:55', |
| 463 | hw_tgt='00:66:77:88:99:aa') |
| 464 | arp_pkt_to_send = str( parsed_arp_pkt ) |
| 465 | logging.info( "sending arp reply to port %d", ports[0] ) |
| 466 | self.dataplane.send( ports[0], arp_pkt_to_send ) |
| 467 | verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION ) |
| 468 | parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80, |
| 469 | eth_dst='00:66:77:88:99:aa', |
| 470 | eth_src='00:11:22:33:44:55', |
| 471 | vlan_vid=vlan_p1_tagged, |
| 472 | vlan_pcp=0, |
| 473 | arp_op=2, |
| 474 | ip_snd='192.168.0.1', |
| 475 | ip_tgt='192.168.0.2', |
| 476 | hw_snd='00:11:22:33:44:55', |
| 477 | hw_tgt='00:66:77:88:99:aa') |
| 478 | arp_pkt_dest = str( parsed_arp_pkt_tagged ) |
| 479 | verify_packet( self, arp_pkt_dest, ports[1] ) |
| 480 | |
| 481 | finally: |
| 482 | delete_all_flows( self.controller ) |
| 483 | delete_all_groups( self.controller ) |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 484 | #print("done") |
Saurav Das | 59fae5e | 2017-12-07 12:02:02 -0800 | [diff] [blame] | 485 | |
| 486 | |
| 487 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 488 | class Mtu1500( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 489 | """ |
| 490 | Verifies basic mtu limits |
| 491 | """ |
| 492 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 493 | def runTest( self ): |
| 494 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 495 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 496 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 497 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 498 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 499 | 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] | 500 | 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] | 501 | Groups.put( L2gid ) |
| 502 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 503 | True ) |
| 504 | do_barrier( self.controller ) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 505 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 506 | for out_port in ports: |
| 507 | # change dest based on port number |
| 508 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 509 | for in_port in ports: |
| 510 | if in_port == out_port: |
| 511 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 512 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 513 | eth_dst=mac_dst ) ) |
| 514 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 515 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 516 | if ofport in [ out_port ]: |
| 517 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 518 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 519 | verify_no_packet( self, pkt, ofport ) |
| 520 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 521 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 522 | delete_all_flows( self.controller ) |
| 523 | delete_groups( self.controller, Groups ) |
| 524 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 525 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 526 | |
| 527 | class _32UcastTagged( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 528 | """ Verify /32 IP forwarding to L3 Unicast-> L2Interface""" |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 529 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 530 | def runTest( self ): |
| 531 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 532 | try: |
| 533 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 534 | if len( config[ "port_map" ] ) < 2: |
| 535 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 536 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 537 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 538 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 539 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 540 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 541 | for port in ports: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 542 | vlan_id = port + test_id |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 543 | # add l2 interface group and l3 unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 544 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 545 | is_tagged=True, send_barrier=False ) |
| 546 | dst_mac[ 5 ] = vlan_id |
| 547 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 548 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 549 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 550 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 551 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 552 | if config["switch_type"] == "qmx": |
| 553 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 554 | else: |
| 555 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 556 | # add unicast routing flow |
| 557 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 558 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 559 | Groups.put( l2gid ) |
| 560 | Groups.put( l3_msg.group_id ) |
| 561 | do_barrier( self.controller ) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 562 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 563 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 564 | for in_port in ports: |
| 565 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 566 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 567 | for out_port in ports: |
| 568 | if in_port == out_port: |
| 569 | continue |
| 570 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 571 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 572 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 573 | ip_src=ip_src, ip_dst=ip_dst ) |
| 574 | pkt = str( parsed_pkt ) |
| 575 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 576 | # build expected packet |
| 577 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 578 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 579 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 580 | ip_src=ip_src, ip_dst=ip_dst ) |
| 581 | pkt = str( exp_pkt ) |
| 582 | verify_packet( self, pkt, out_port ) |
| 583 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 584 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 585 | delete_all_flows( self.controller ) |
| 586 | delete_groups( self.controller, Groups ) |
| 587 | delete_all_groups( self.controller ) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 588 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 589 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 590 | class _32VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 591 | """ |
| 592 | Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 593 | No ECMP group used |
| 594 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 595 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 596 | def runTest( self ): |
| 597 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 598 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 599 | if len( config[ "port_map" ] ) < 2: |
| 600 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 601 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 602 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 603 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 604 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 605 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 606 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 607 | for port in ports: |
| 608 | # add l2 interface group |
| 609 | id = port |
| 610 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 611 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 612 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 613 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 614 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 615 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 616 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 617 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 618 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 619 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 620 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 621 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 622 | 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] | 623 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 624 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 625 | if config["switch_type"] == "qmx": |
| 626 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 627 | else: |
| 628 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 629 | # add routing flow |
| 630 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 631 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 632 | Groups._put( l2_gid ) |
| 633 | Groups._put( mpls_gid ) |
| 634 | Groups._put( mpls_label_gid ) |
| 635 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 636 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 637 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 638 | for in_port in ports: |
| 639 | ip_src = '192.168.%02d.1' % (in_port) |
| 640 | for out_port in ports: |
| 641 | if in_port == out_port: |
| 642 | continue |
| 643 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 644 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 645 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 646 | pkt = str( parsed_pkt ) |
| 647 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 648 | # build expect packet |
| 649 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 650 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 651 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 652 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 653 | label=[ label ] ) |
| 654 | pkt = str( exp_pkt ) |
| 655 | verify_packet( self, pkt, out_port ) |
| 656 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 657 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 658 | delete_all_flows( self.controller ) |
| 659 | delete_groups( self.controller, Groups ) |
| 660 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 661 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 662 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 663 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 664 | """ |
| 665 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 666 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 667 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 668 | def runTest( self ): |
| 669 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 670 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 671 | if len( config[ "port_map" ] ) < 2: |
| 672 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 673 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 674 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 675 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 676 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 677 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 678 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 679 | for port in ports: |
| 680 | # add l2 interface group |
| 681 | id = port |
| 682 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 683 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 684 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 685 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 686 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 687 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 688 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 689 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 690 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 691 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 692 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 693 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 694 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 695 | 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] | 696 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 697 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 698 | if config["switch_type"] == "qmx": |
| 699 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 700 | else: |
| 701 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 702 | # add routing flow |
| 703 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 704 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 705 | Groups._put( l2_gid ) |
| 706 | Groups._put( mpls_gid ) |
| 707 | Groups._put( mpls_label_gid ) |
| 708 | Groups._put( ecmp_msg.group_id ) |
| 709 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 710 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 711 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 712 | for in_port in ports: |
| 713 | ip_src = '192.168.%02d.1' % (in_port) |
| 714 | for out_port in ports: |
| 715 | if in_port == out_port: |
| 716 | continue |
| 717 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 718 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 719 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 720 | pkt = str( parsed_pkt ) |
| 721 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 722 | # build expect packet |
| 723 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 724 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 725 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 726 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 727 | label=[ label ] ) |
| 728 | pkt = str( exp_pkt ) |
| 729 | verify_packet( self, pkt, out_port ) |
| 730 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 731 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 732 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 733 | delete_all_flows( self.controller ) |
| 734 | delete_groups( self.controller, Groups ) |
| 735 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 736 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 737 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 738 | @disabled |
| 739 | class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| 740 | """ |
| 741 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 742 | in only one direction |
| 743 | """ |
| 744 | |
| 745 | def runTest( self ): |
| 746 | Groups = Queue.LifoQueue( ) |
| 747 | try: |
| 748 | if len( config[ "port_map" ] ) < 2: |
| 749 | logging.info( "Port count less than 2, can't run this case" ) |
| 750 | return |
| 751 | |
| 752 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 753 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 754 | dip = 0xc0a80001 |
| 755 | ports = config[ "port_map" ].keys( ) |
| 756 | # add l2 interface group |
| 757 | id = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 758 | in_offset = 19 |
| 759 | out_offset = 20 |
| 760 | vlan_id = ports[1] + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 761 | 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] | 762 | dst_mac[ 5 ] = ports[1] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 763 | # add MPLS interface group |
| 764 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 765 | vlan_id, id ) |
| 766 | # add MPLS L3 VPN group |
| 767 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 768 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 769 | 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] | 770 | # add ECMP group |
| 771 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 772 | do_barrier( self.controller ) |
| 773 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 774 | 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] | 775 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 776 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 777 | if config["switch_type"] == "qmx": |
| 778 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| 779 | else: |
| 780 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 781 | # add routing flow |
| 782 | dst_ip = dip + (vlan_id << 8) |
| 783 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 784 | Groups._put( l2_gid ) |
| 785 | Groups._put( mpls_gid ) |
| 786 | Groups._put( mpls_label_gid ) |
| 787 | Groups._put( ecmp_msg.group_id ) |
| 788 | |
| 789 | |
| 790 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 791 | in_port = ports[0] |
| 792 | out_port = ports[1] |
| 793 | ip_src = '192.168.%02d.1' % (in_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 794 | ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| 795 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 796 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 797 | pkt = str( parsed_pkt ) |
| 798 | self.dataplane.send( in_port, pkt ) |
| 799 | # build expect packet |
| 800 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 801 | label = (out_port+out_offset, 0, 1, 32) |
| 802 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 803 | 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] | 804 | label=[ label ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 805 | pkt = str( exp_pkt ) |
| 806 | verify_packet( self, pkt, out_port ) |
| 807 | #verify_no_other_packets( self ) |
| 808 | |
| 809 | finally: |
| 810 | delete_all_flows( self.controller ) |
| 811 | delete_group(self.controller, ecmp_msg.group_id) |
| 812 | delete_group(self.controller, mpls_label_gid) |
| 813 | delete_group(self.controller, mpls_gid) |
| 814 | delete_group(self.controller, l2_gid) |
| 815 | |
| 816 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 817 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 818 | """ |
| 819 | Verifies /32 IP routing and ECMP with no label push |
| 820 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 821 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 822 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 823 | def runTest( self ): |
| 824 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 825 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 826 | if len( config[ "port_map" ] ) < 2: |
| 827 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 828 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 829 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 830 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 831 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 832 | dip = 0xc0a80001 |
| 833 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 834 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 835 | for port in ports: |
| 836 | vlan_id = port |
| 837 | id = port |
| 838 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 839 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 840 | is_tagged=True, send_barrier=False ) |
| 841 | dst_mac[ 5 ] = vlan_id |
| 842 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 843 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 844 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 845 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 846 | 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] | 847 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 848 | if config["switch_type"] == "qmx": |
| 849 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 850 | else: |
| 851 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 852 | # add unicast routing flow |
| 853 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 854 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 855 | Groups._put( l2_gid ) |
| 856 | Groups._put( l3_msg.group_id ) |
| 857 | Groups._put( ecmp_msg.group_id ) |
| 858 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 859 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 860 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 861 | for in_port in ports: |
| 862 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 863 | ip_src = '192.168.%02d.1' % in_port |
| 864 | for out_port in ports: |
| 865 | if in_port == out_port: |
| 866 | continue |
| 867 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 868 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 869 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 870 | pkt = str( parsed_pkt ) |
| 871 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 872 | # build expected packet |
| 873 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 874 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 875 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 876 | pkt = str( exp_pkt ) |
| 877 | verify_packet( self, pkt, out_port ) |
| 878 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 879 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 880 | delete_all_flows( self.controller ) |
| 881 | delete_groups( self.controller, Groups ) |
| 882 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 883 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 884 | @disabled |
| 885 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 886 | """ |
| 887 | Verifies /32 IP routing and ECMP with no label push |
| 888 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 889 | in only one direction |
| 890 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 891 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 892 | def runTest( self ): |
| 893 | Groups = Queue.LifoQueue( ) |
| 894 | try: |
| 895 | if len( config[ "port_map" ] ) < 2: |
| 896 | logging.info( "Port count less than 2, can't run this case" ) |
| 897 | return |
| 898 | |
| 899 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 900 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 901 | dip = 0xc0a80001 |
| 902 | # Hashes Test Name and uses it as id for installing unique groups |
| 903 | ports = config[ "port_map" ].keys( ) |
| 904 | inport = ports[0] |
| 905 | outport = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 906 | in_offset = 19 |
| 907 | out_offset = 20 |
| 908 | vlan_id = outport + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 909 | id = outport |
| 910 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 911 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 912 | is_tagged=True, send_barrier=False ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 913 | dst_mac[ 5 ] = outport |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 914 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 915 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 916 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 917 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 918 | 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] | 919 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 920 | if config["switch_type"] == "qmx": |
| 921 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset ) |
| 922 | else: |
| 923 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 924 | # add unicast routing flow |
| 925 | dst_ip = dip + (vlan_id << 8) |
| 926 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 927 | Groups._put( l2_gid ) |
| 928 | Groups._put( l3_msg.group_id ) |
| 929 | Groups._put( ecmp_msg.group_id ) |
| 930 | |
| 931 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 932 | mac_src = '00:00:00:22:22:%02X' % inport |
| 933 | ip_src = '192.168.%02d.1' % inport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 934 | ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| 935 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 936 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 937 | pkt = str( parsed_pkt ) |
| 938 | self.dataplane.send( inport, pkt ) |
| 939 | # build expected packet |
| 940 | mac_dst = '00:00:00:22:22:%02X' % outport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame] | 941 | 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] | 942 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 943 | pkt = str( exp_pkt ) |
| 944 | verify_packet( self, pkt, outport ) |
| 945 | verify_no_other_packets( self ) |
| 946 | finally: |
| 947 | delete_all_flows( self.controller ) |
| 948 | delete_groups( self.controller, Groups ) |
| 949 | delete_all_groups( self.controller ) |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 955 | class _24VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 956 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 957 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 958 | def runTest( self ): |
| 959 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 960 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 961 | if len( config[ "port_map" ] ) < 2: |
| 962 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 963 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 964 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 965 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 966 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 967 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 968 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 969 | for port in ports: |
| 970 | # add l2 interface group |
| 971 | id = port |
| 972 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 973 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 974 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 975 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 976 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 977 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 978 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 979 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 980 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 981 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 982 | # 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] | 983 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 984 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 985 | 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] | 986 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 987 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 988 | if config["switch_type"] == "qmx": |
| 989 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 990 | else: |
| 991 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 992 | # add routing flow |
| 993 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 994 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 995 | Groups._put( l2_gid ) |
| 996 | Groups._put( mpls_gid ) |
| 997 | Groups._put( mpls_label_gid ) |
| 998 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 999 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1000 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1001 | for in_port in ports: |
| 1002 | ip_src = '192.168.%02d.1' % (in_port) |
| 1003 | for out_port in ports: |
| 1004 | if in_port == out_port: |
| 1005 | continue |
| 1006 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1007 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1008 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1009 | pkt = str( parsed_pkt ) |
| 1010 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1011 | # build expect packet |
| 1012 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1013 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1014 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1015 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1016 | label=[ label ] ) |
| 1017 | pkt = str( exp_pkt ) |
| 1018 | verify_packet( self, pkt, out_port ) |
| 1019 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1020 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1021 | delete_all_flows( self.controller ) |
| 1022 | delete_groups( self.controller, Groups ) |
| 1023 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 1024 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1025 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1026 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1027 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1028 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1029 | def runTest( self ): |
| 1030 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1031 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1032 | if len( config[ "port_map" ] ) < 2: |
| 1033 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1034 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1035 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1036 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1037 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1038 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1039 | for port in ports: |
| 1040 | # add l2 interface group |
| 1041 | id = port |
| 1042 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1043 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 1044 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1045 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1046 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1047 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1048 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1049 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1050 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 1051 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 1052 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 1053 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1054 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1055 | 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] | 1056 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1057 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1058 | if config["switch_type"] == "qmx": |
| 1059 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1060 | else: |
| 1061 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1062 | # add routing flow |
| 1063 | dst_ip = dip + (vlan_id << 8) |
| 1064 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1065 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 1066 | vrf=0 ) |
| 1067 | Groups._put( l2_gid ) |
| 1068 | Groups._put( mpls_gid ) |
| 1069 | Groups._put( mpls_label_gid ) |
| 1070 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1071 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1072 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1073 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1074 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1075 | for in_port in ports: |
| 1076 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1077 | ip_src = '192.168.%02d.1' % (in_port) |
| 1078 | for out_port in ports: |
| 1079 | if in_port == out_port: |
| 1080 | continue |
| 1081 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1082 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1083 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1084 | pkt = str( parsed_pkt ) |
| 1085 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1086 | # build expect packet |
| 1087 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1088 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1089 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 1090 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 1091 | label=[ label ] ) |
| 1092 | pkt = str( exp_pkt ) |
| 1093 | verify_packet( self, pkt, out_port ) |
| 1094 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1095 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1096 | delete_all_flows( self.controller ) |
| 1097 | delete_groups( self.controller, Groups ) |
| 1098 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1099 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1100 | |
| 1101 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1102 | """ Modify a referenced flood group """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1103 | |
| 1104 | def runTest( self ): |
| 1105 | Groups = Queue.LifoQueue( ) |
| 1106 | try: |
| 1107 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 1108 | vlan_id = 1 |
| 1109 | |
| 1110 | for port in ports: |
| 1111 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1112 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1113 | Groups.put( L2gid ) |
| 1114 | |
| 1115 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 1116 | Groups.put( msg.group_id ) |
| 1117 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 1118 | do_barrier( self.controller ) |
| 1119 | # verify flood |
| 1120 | for ofport in ports: |
| 1121 | # change dest based on port number |
| 1122 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 1123 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1124 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 1125 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 1126 | pkt = str( parsed_pkt ) |
| 1127 | self.dataplane.send( ofport, pkt ) |
| 1128 | # self won't rx packet |
| 1129 | verify_no_packet( self, pkt, ofport ) |
| 1130 | # others will rx packet |
| 1131 | tmp_ports = list( ports ) |
| 1132 | tmp_ports.remove( ofport ) |
| 1133 | verify_packets( self, pkt, tmp_ports ) |
| 1134 | verify_no_other_packets( self ) |
| 1135 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 1136 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 1137 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 1138 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 1139 | eth_src=mac_src ) |
| 1140 | pkt = str( parsed_pkt ) |
| 1141 | self.dataplane.send( ports[ 1 ], pkt ) |
| 1142 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 1143 | finally: |
| 1144 | delete_all_flows( self.controller ) |
| 1145 | delete_groups( self.controller, Groups ) |
| 1146 | delete_all_groups( self.controller ) |
| 1147 | |
| 1148 | |
| 1149 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1150 | """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1151 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1152 | def runTest( self ): |
| 1153 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1154 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1155 | if len( config[ "port_map" ] ) < 2: |
| 1156 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1157 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1158 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1159 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1160 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1161 | dip = 0xc0a80001 |
| 1162 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1163 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1164 | for port in ports: |
| 1165 | vlan_id = port |
| 1166 | id = port |
| 1167 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1168 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1169 | is_tagged=True, send_barrier=False ) |
| 1170 | dst_mac[ 5 ] = vlan_id |
| 1171 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1172 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1173 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1174 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1175 | 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] | 1176 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1177 | if config["switch_type"] == "qmx": |
| 1178 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 1179 | else: |
| 1180 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1181 | # add unicast routing flow |
| 1182 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1183 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1184 | Groups._put( l2_gid ) |
| 1185 | Groups._put( l3_msg.group_id ) |
| 1186 | Groups._put( ecmp_msg.group_id ) |
| 1187 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1188 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1189 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1190 | for in_port in ports: |
| 1191 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1192 | ip_src = '192.168.%02d.1' % in_port |
| 1193 | for out_port in ports: |
| 1194 | if in_port == out_port: |
| 1195 | continue |
| 1196 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1197 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1198 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1199 | pkt = str( parsed_pkt ) |
| 1200 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1201 | # build expected packet |
| 1202 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1203 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1204 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1205 | pkt = str( exp_pkt ) |
| 1206 | verify_packet( self, pkt, out_port ) |
| 1207 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1208 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1209 | delete_all_flows( self.controller ) |
| 1210 | delete_groups( self.controller, Groups ) |
| 1211 | delete_all_groups( self.controller ) |
| 1212 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1213 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 1214 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1215 | class MPLSBUG( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1216 | """ |
| 1217 | Needs a description or needs to be removed |
| 1218 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1219 | def runTest( self ): |
| 1220 | if len( config[ "port_map" ] ) < 2: |
| 1221 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1222 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1223 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1224 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1225 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1226 | Groups = Queue.LifoQueue( ) |
| 1227 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1228 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1229 | # add l2 interface group |
| 1230 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1231 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1232 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1233 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1234 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1235 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1236 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1237 | 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] | 1238 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1239 | if config["switch_type"] == "qmx": |
| 1240 | add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1241 | else: |
| 1242 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1243 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1244 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1245 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1246 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1247 | # add unicast routing flow |
| 1248 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1249 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1250 | Groups._put( l2_gid ) |
| 1251 | Groups._put( l3_msg.group_id ) |
| 1252 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1253 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1254 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1255 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1256 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1257 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1258 | for out_port in ports: |
| 1259 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1260 | continue |
| 1261 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1262 | switch_mac = "00:00:00:cc:cc:cc" |
| 1263 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1264 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1265 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1266 | pkt = str( parsed_pkt ) |
| 1267 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1268 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1269 | # build expect packet |
| 1270 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1271 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1272 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1273 | pkt = str( exp_pkt ) |
| 1274 | verify_packet( self, pkt, out_port ) |
| 1275 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1276 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1277 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1278 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1279 | pkt = str( parsed_pkt ) |
| 1280 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1281 | # build expected packet |
| 1282 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1283 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1284 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1285 | pkt = str( exp_pkt ) |
| 1286 | verify_packet( self, pkt, out_port ) |
| 1287 | verify_no_other_packets( self ) |
| 1288 | delete_all_flows( self.controller ) |
| 1289 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1290 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1291 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1292 | """ |
| 1293 | Mcast routing, in this test case the traffic comes in tagged. |
| 1294 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1295 | different ports. 4094-port is used as egress vlan_id. |
| 1296 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1297 | def runTest( self ): |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1298 | """ |
| 1299 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1300 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1301 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1302 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1303 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1304 | if len( config[ "port_map" ] ) < 1: |
| 1305 | logging.info( "Port count less than 1, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1306 | assert (False) |
| 1307 | return |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1308 | ports = config[ "port_map" ].keys( ) |
| 1309 | dst_ip_str = "224.0.0.1" |
| 1310 | ( |
| 1311 | port_to_in_vlan, |
| 1312 | port_to_out_vlan, |
| 1313 | port_to_src_mac_str, |
| 1314 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1315 | port_to_src_ip, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1316 | port_to_src_ip_str, |
| 1317 | port_to_intf_src_mac_str, |
| 1318 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1319 | self.controller, |
| 1320 | logging, |
| 1321 | ports, |
| 1322 | is_ingress_tagged = True, |
| 1323 | is_egress_tagged = True, |
| 1324 | is_vlan_translated = True, |
| 1325 | is_max_vlan = False |
| 1326 | ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1327 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1328 | for in_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1329 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1330 | parsed_pkt = simple_udp_packet( |
| 1331 | pktlen = 100, |
| 1332 | dl_vlan_enable = True, |
| 1333 | vlan_vid = port_to_in_vlan[in_port], |
| 1334 | eth_dst = port_to_dst_mac_str[in_port], |
| 1335 | eth_src = port_to_src_mac_str[in_port], |
| 1336 | ip_ttl = 64, |
| 1337 | ip_src = port_to_src_ip_str[in_port], |
| 1338 | ip_dst = dst_ip_str |
| 1339 | ) |
| 1340 | pkt = str( parsed_pkt ) |
| 1341 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1342 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1343 | for out_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1344 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1345 | parsed_pkt = simple_udp_packet( |
| 1346 | pktlen = 100, |
| 1347 | dl_vlan_enable = True, |
| 1348 | vlan_vid = port_to_out_vlan[out_port], |
| 1349 | eth_dst = port_to_dst_mac_str[in_port], |
| 1350 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1351 | ip_ttl = 63, |
| 1352 | ip_src = port_to_src_ip_str[in_port], |
| 1353 | ip_dst = dst_ip_str |
| 1354 | ) |
| 1355 | pkt = str( parsed_pkt ) |
| 1356 | verify_packet( self, pkt, out_port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1357 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1358 | verify_no_other_packets( self ) |
| 1359 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1360 | finally: |
| 1361 | delete_all_flows( self.controller ) |
| 1362 | delete_groups( self.controller, Groups ) |
| 1363 | delete_all_groups( self.controller ) |
| 1364 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 1365 | @disabled |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1366 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1367 | """ |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 1368 | Fails on alternate runs |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1369 | Mcast routing, in this test case the traffic is untagged. |
| 1370 | 4094 is used as internal vlan_id. The packet goes out |
| 1371 | untagged. |
| 1372 | """ |
| 1373 | def runTest( self ): |
| 1374 | Groups = Queue.LifoQueue( ) |
| 1375 | try: |
| 1376 | if len( config[ "port_map" ] ) < 2: |
| 1377 | logging.info( "Port count less than 2, can't run this case" ) |
| 1378 | assert (False) |
| 1379 | return |
| 1380 | ports = config[ "port_map" ].keys( ) |
| 1381 | dst_ip_str = "224.0.0.1" |
| 1382 | ( |
| 1383 | port_to_in_vlan, |
| 1384 | port_to_out_vlan, |
| 1385 | port_to_src_mac_str, |
| 1386 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1387 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1388 | port_to_src_ip_str, |
| 1389 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1390 | self.controller, |
| 1391 | logging, |
| 1392 | ports, |
| 1393 | is_ingress_tagged = False, |
| 1394 | is_egress_tagged = False, |
| 1395 | is_vlan_translated = False, |
| 1396 | is_max_vlan = True |
| 1397 | ) |
| 1398 | |
| 1399 | for in_port in ports: |
| 1400 | |
| 1401 | parsed_pkt = simple_udp_packet( |
| 1402 | pktlen = 96, |
| 1403 | eth_dst = port_to_dst_mac_str[in_port], |
| 1404 | eth_src = port_to_src_mac_str[in_port], |
| 1405 | ip_ttl = 64, |
| 1406 | ip_src = port_to_src_ip_str[in_port], |
| 1407 | ip_dst = dst_ip_str |
| 1408 | ) |
| 1409 | pkt = str( parsed_pkt ) |
| 1410 | self.dataplane.send( in_port, pkt ) |
| 1411 | |
| 1412 | for out_port in ports: |
| 1413 | |
| 1414 | parsed_pkt = simple_udp_packet( |
| 1415 | pktlen = 96, |
| 1416 | eth_dst = port_to_dst_mac_str[in_port], |
| 1417 | eth_src = port_to_src_mac_str[in_port], |
| 1418 | ip_ttl = 64, |
| 1419 | ip_src = port_to_src_ip_str[in_port], |
| 1420 | ip_dst = dst_ip_str |
| 1421 | ) |
| 1422 | pkt = str( parsed_pkt ) |
| 1423 | if out_port == in_port: |
| 1424 | verify_no_packet( self, pkt, in_port ) |
| 1425 | continue |
| 1426 | verify_packet( self, pkt, out_port ) |
| 1427 | verify_no_other_packets( self ) |
| 1428 | finally: |
| 1429 | delete_all_flows( self.controller ) |
| 1430 | delete_groups( self.controller, Groups ) |
| 1431 | delete_all_groups( self.controller ) |
| 1432 | |
| 1433 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1434 | """ |
| 1435 | Mcast routing, in this test case the traffic is untagged. |
| 1436 | 300 is used as vlan_id. The packet goes out |
| 1437 | tagged. |
| 1438 | """ |
| 1439 | def runTest( self ): |
| 1440 | Groups = Queue.LifoQueue( ) |
| 1441 | try: |
| 1442 | if len( config[ "port_map" ] ) < 2: |
| 1443 | logging.info( "Port count less than 2, can't run this case" ) |
| 1444 | assert (False) |
| 1445 | return |
| 1446 | ports = config[ "port_map" ].keys( ) |
| 1447 | dst_ip_str = "224.0.0.1" |
| 1448 | ( |
| 1449 | port_to_in_vlan, |
| 1450 | port_to_out_vlan, |
| 1451 | port_to_src_mac_str, |
| 1452 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1453 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1454 | port_to_src_ip_str, |
| 1455 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1456 | self.controller, |
| 1457 | logging, |
| 1458 | ports, |
| 1459 | is_ingress_tagged = False, |
| 1460 | is_egress_tagged = True, |
| 1461 | is_vlan_translated = False, |
| 1462 | is_max_vlan = False |
| 1463 | ) |
| 1464 | |
| 1465 | for in_port in ports: |
| 1466 | |
| 1467 | parsed_pkt = simple_udp_packet( |
| 1468 | pktlen = 96, |
| 1469 | eth_dst = port_to_dst_mac_str[in_port], |
| 1470 | eth_src = port_to_src_mac_str[in_port], |
| 1471 | ip_ttl = 64, |
| 1472 | ip_src = port_to_src_ip_str[in_port], |
| 1473 | ip_dst = dst_ip_str |
| 1474 | ) |
| 1475 | pkt = str( parsed_pkt ) |
| 1476 | self.dataplane.send( in_port, pkt ) |
| 1477 | |
| 1478 | for out_port in ports: |
| 1479 | |
| 1480 | parsed_pkt = simple_udp_packet( |
| 1481 | pktlen = 100, |
| 1482 | dl_vlan_enable = True, |
| 1483 | vlan_vid = port_to_out_vlan[in_port], |
| 1484 | eth_dst = port_to_dst_mac_str[in_port], |
| 1485 | eth_src = port_to_src_mac_str[in_port], |
| 1486 | ip_ttl = 64, |
| 1487 | ip_src = port_to_src_ip_str[in_port], |
| 1488 | ip_dst = dst_ip_str |
| 1489 | ) |
| 1490 | pkt = str( parsed_pkt ) |
| 1491 | if out_port == in_port: |
| 1492 | verify_no_packet( self, pkt, in_port ) |
| 1493 | continue |
| 1494 | verify_packet( self, pkt, out_port ) |
| 1495 | verify_no_other_packets( self ) |
| 1496 | finally: |
| 1497 | delete_all_flows( self.controller ) |
| 1498 | delete_groups( self.controller, Groups ) |
| 1499 | delete_all_groups( self.controller ) |
| 1500 | |
| 1501 | |
| 1502 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1503 | """ |
| 1504 | Mcast routing, in this test case the traffic is tagged. |
| 1505 | 300 is used as vlan_id. The packet goes out |
| 1506 | untagged. |
| 1507 | """ |
| 1508 | def runTest( self ): |
| 1509 | Groups = Queue.LifoQueue( ) |
| 1510 | try: |
| 1511 | if len( config[ "port_map" ] ) < 2: |
| 1512 | logging.info( "Port count less than 2, can't run this case" ) |
| 1513 | assert (False) |
| 1514 | return |
| 1515 | ports = config[ "port_map" ].keys( ) |
| 1516 | dst_ip_str = "224.0.0.1" |
| 1517 | ( |
| 1518 | port_to_in_vlan, |
| 1519 | port_to_out_vlan, |
| 1520 | port_to_src_mac_str, |
| 1521 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1522 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1523 | port_to_src_ip_str, |
| 1524 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1525 | self.controller, |
| 1526 | logging, |
| 1527 | ports, |
| 1528 | is_ingress_tagged = True, |
| 1529 | is_egress_tagged = False, |
| 1530 | is_vlan_translated = False, |
| 1531 | is_max_vlan = False |
| 1532 | ) |
| 1533 | |
| 1534 | for in_port in ports: |
| 1535 | |
| 1536 | parsed_pkt = simple_udp_packet( |
| 1537 | pktlen = 100, |
| 1538 | dl_vlan_enable = True, |
| 1539 | vlan_vid = port_to_in_vlan[in_port], |
| 1540 | eth_dst = port_to_dst_mac_str[in_port], |
| 1541 | eth_src = port_to_src_mac_str[in_port], |
| 1542 | ip_ttl = 64, |
| 1543 | ip_src = port_to_src_ip_str[in_port], |
| 1544 | ip_dst = dst_ip_str |
| 1545 | ) |
| 1546 | pkt = str( parsed_pkt ) |
| 1547 | self.dataplane.send( in_port, pkt ) |
| 1548 | |
| 1549 | for out_port in ports: |
| 1550 | |
| 1551 | parsed_pkt = simple_udp_packet( |
| 1552 | pktlen = 96, |
| 1553 | eth_dst = port_to_dst_mac_str[in_port], |
| 1554 | eth_src = port_to_src_mac_str[in_port], |
| 1555 | ip_ttl = 64, |
| 1556 | ip_src = port_to_src_ip_str[in_port], |
| 1557 | ip_dst = dst_ip_str |
| 1558 | ) |
| 1559 | pkt = str( parsed_pkt ) |
| 1560 | if out_port == in_port: |
| 1561 | verify_no_packet( self, pkt, in_port ) |
| 1562 | continue |
| 1563 | verify_packet( self, pkt, out_port ) |
| 1564 | verify_no_other_packets( self ) |
| 1565 | finally: |
| 1566 | delete_all_flows( self.controller ) |
| 1567 | delete_groups( self.controller, Groups ) |
| 1568 | delete_all_groups( self.controller ) |
| 1569 | |
| 1570 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1571 | """ |
| 1572 | Mcast routing, in this test case the traffic is tagged. |
| 1573 | 300 is used as vlan_id. The packet goes out tagged. |
| 1574 | """ |
| 1575 | def runTest( self ): |
| 1576 | Groups = Queue.LifoQueue( ) |
| 1577 | try: |
| 1578 | if len( config[ "port_map" ] ) < 2: |
| 1579 | logging.info( "Port count less than 2, can't run this case" ) |
| 1580 | assert (False) |
| 1581 | return |
| 1582 | ports = config[ "port_map" ].keys( ) |
| 1583 | dst_ip_str = "224.0.0.1" |
| 1584 | ( |
| 1585 | port_to_in_vlan, |
| 1586 | port_to_out_vlan, |
| 1587 | port_to_src_mac_str, |
| 1588 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1589 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1590 | port_to_src_ip_str, |
| 1591 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1592 | self.controller, |
| 1593 | logging, |
| 1594 | ports, |
| 1595 | is_ingress_tagged = True, |
| 1596 | is_egress_tagged = True, |
| 1597 | is_vlan_translated = False, |
| 1598 | is_max_vlan = False |
| 1599 | ) |
| 1600 | |
| 1601 | for in_port in ports: |
| 1602 | |
| 1603 | parsed_pkt = simple_udp_packet( |
| 1604 | pktlen = 100, |
| 1605 | dl_vlan_enable = True, |
| 1606 | vlan_vid = port_to_in_vlan[in_port], |
| 1607 | eth_dst = port_to_dst_mac_str[in_port], |
| 1608 | eth_src = port_to_src_mac_str[in_port], |
| 1609 | ip_ttl = 64, |
| 1610 | ip_src = port_to_src_ip_str[in_port], |
| 1611 | ip_dst = dst_ip_str |
| 1612 | ) |
| 1613 | pkt = str( parsed_pkt ) |
| 1614 | self.dataplane.send( in_port, pkt ) |
| 1615 | |
| 1616 | for out_port in ports: |
| 1617 | |
| 1618 | parsed_pkt = simple_udp_packet( |
| 1619 | pktlen = 100, |
| 1620 | dl_vlan_enable = True, |
| 1621 | vlan_vid = port_to_in_vlan[in_port], |
| 1622 | eth_dst = port_to_dst_mac_str[in_port], |
| 1623 | eth_src = port_to_src_mac_str[in_port], |
| 1624 | ip_ttl = 64, |
| 1625 | ip_src = port_to_src_ip_str[in_port], |
| 1626 | ip_dst = dst_ip_str |
| 1627 | ) |
| 1628 | pkt = str( parsed_pkt ) |
| 1629 | if out_port == in_port: |
| 1630 | verify_no_packet( self, pkt, in_port ) |
| 1631 | continue |
| 1632 | verify_packet( self, pkt, out_port ) |
| 1633 | verify_no_other_packets( self ) |
| 1634 | finally: |
| 1635 | delete_all_flows( self.controller ) |
| 1636 | delete_groups( self.controller, Groups ) |
| 1637 | delete_all_groups( self.controller ) |
| 1638 | |
| 1639 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1640 | """ |
| 1641 | Mcast routing, in this test case the traffic is tagged. |
| 1642 | port+1 is used as ingress vlan_id. The packet goes out |
| 1643 | tagged. 4094-port is used as egress vlan_id |
| 1644 | """ |
| 1645 | def runTest( self ): |
| 1646 | Groups = Queue.LifoQueue( ) |
| 1647 | try: |
| 1648 | if len( config[ "port_map" ] ) < 2: |
| 1649 | logging.info( "Port count less than 2, can't run this case" ) |
| 1650 | assert (False) |
| 1651 | return |
| 1652 | ports = config[ "port_map" ].keys( ) |
| 1653 | dst_ip_str = "224.0.0.1" |
| 1654 | ( |
| 1655 | port_to_in_vlan, |
| 1656 | port_to_out_vlan, |
| 1657 | port_to_src_mac_str, |
| 1658 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1659 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1660 | port_to_src_ip_str, |
| 1661 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1662 | self.controller, |
| 1663 | logging, |
| 1664 | ports, |
| 1665 | is_ingress_tagged = True, |
| 1666 | is_egress_tagged = True, |
| 1667 | is_vlan_translated = True, |
| 1668 | is_max_vlan = False |
| 1669 | ) |
| 1670 | |
| 1671 | for in_port in ports: |
| 1672 | |
| 1673 | parsed_pkt = simple_udp_packet( |
| 1674 | pktlen = 100, |
| 1675 | dl_vlan_enable = True, |
| 1676 | vlan_vid = port_to_in_vlan[in_port], |
| 1677 | eth_dst = port_to_dst_mac_str[in_port], |
| 1678 | eth_src = port_to_src_mac_str[in_port], |
| 1679 | ip_ttl = 64, |
| 1680 | ip_src = port_to_src_ip_str[in_port], |
| 1681 | ip_dst = dst_ip_str |
| 1682 | ) |
| 1683 | pkt = str( parsed_pkt ) |
| 1684 | self.dataplane.send( in_port, pkt ) |
| 1685 | |
| 1686 | for out_port in ports: |
| 1687 | |
| 1688 | parsed_pkt = simple_udp_packet( |
| 1689 | pktlen = 100, |
| 1690 | dl_vlan_enable = True, |
| 1691 | vlan_vid = port_to_out_vlan[in_port], |
| 1692 | eth_dst = port_to_dst_mac_str[in_port], |
| 1693 | eth_src = port_to_src_mac_str[in_port], |
| 1694 | ip_ttl = 64, |
| 1695 | ip_src = port_to_src_ip_str[in_port], |
| 1696 | ip_dst = dst_ip_str |
| 1697 | ) |
| 1698 | pkt = str( parsed_pkt ) |
| 1699 | if out_port == in_port: |
| 1700 | verify_no_packet( self, pkt, in_port ) |
| 1701 | continue |
| 1702 | verify_packet( self, pkt, out_port ) |
| 1703 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1704 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1705 | delete_all_flows( self.controller ) |
| 1706 | delete_groups( self.controller, Groups ) |
| 1707 | delete_all_groups( self.controller ) |
| 1708 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 1709 | @disabled |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1710 | class L3McastTrafficThenDrop( base_tests.SimpleDataPlane ): |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 1711 | # fails on alternate repeated runs |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1712 | """ |
| 1713 | Mcast routing, in this test case the traffic is untagged. |
| 1714 | 4094 is used as internal vlan_id. We first install aa full pipeline, |
| 1715 | test that it forwards properly then remove all rules on table 40 and |
| 1716 | mcast groups and ensure traffic is dropped. Blackhole of mcast traffic |
| 1717 | if no tree is programmed on the switch. |
| 1718 | """ |
| 1719 | def runTest( self ): |
| 1720 | Groups = Queue.LifoQueue( ) |
| 1721 | try: |
| 1722 | if len( config[ "port_map" ] ) < 2: |
| 1723 | logging.info( "Port count less than 2, can't run this case" ) |
| 1724 | assert (False) |
| 1725 | return |
| 1726 | ports = config[ "port_map" ].keys( ) |
| 1727 | dst_ip_str = "224.0.0.1" |
| 1728 | ( |
| 1729 | port_to_in_vlan, |
| 1730 | port_to_out_vlan, |
| 1731 | port_to_src_mac_str, |
| 1732 | port_to_dst_mac_str, |
| 1733 | port_to_src_ip, |
| 1734 | port_to_src_ip_str, |
| 1735 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1736 | self.controller, |
| 1737 | logging, |
| 1738 | ports, |
| 1739 | is_ingress_tagged = False, |
| 1740 | is_egress_tagged = False, |
| 1741 | is_vlan_translated = False, |
| 1742 | is_max_vlan = True |
| 1743 | ) |
| 1744 | |
| 1745 | for in_port in ports: |
| 1746 | |
| 1747 | parsed_pkt = simple_udp_packet( |
| 1748 | pktlen = 96, |
| 1749 | eth_dst = port_to_dst_mac_str[in_port], |
| 1750 | eth_src = port_to_src_mac_str[in_port], |
| 1751 | ip_ttl = 64, |
| 1752 | ip_src = port_to_src_ip_str[in_port], |
| 1753 | ip_dst = dst_ip_str |
| 1754 | ) |
| 1755 | pkt = str( parsed_pkt ) |
| 1756 | self.dataplane.send( in_port, pkt ) |
| 1757 | |
| 1758 | for out_port in ports: |
| 1759 | |
| 1760 | parsed_pkt = simple_udp_packet( |
| 1761 | pktlen = 96, |
| 1762 | eth_dst = port_to_dst_mac_str[in_port], |
| 1763 | eth_src = port_to_src_mac_str[in_port], |
| 1764 | ip_ttl = 64, |
| 1765 | ip_src = port_to_src_ip_str[in_port], |
| 1766 | ip_dst = dst_ip_str |
| 1767 | ) |
| 1768 | pkt = str( parsed_pkt ) |
| 1769 | if out_port == in_port: |
| 1770 | verify_no_packet( self, pkt, in_port ) |
| 1771 | continue |
| 1772 | verify_packet( self, pkt, out_port ) |
| 1773 | verify_no_other_packets( self ) |
| 1774 | |
| 1775 | delete_all_flows_one_table(ctrl=self.controller, logger=logging, table_id=40); |
| 1776 | delete_all_groups(self.controller) |
| 1777 | |
| 1778 | for in_port in ports: |
| 1779 | |
| 1780 | parsed_pkt = simple_udp_packet( |
| 1781 | pktlen = 96, |
| 1782 | eth_dst = port_to_dst_mac_str[in_port], |
| 1783 | eth_src = port_to_src_mac_str[in_port], |
| 1784 | ip_ttl = 64, |
| 1785 | ip_src = port_to_src_ip_str[in_port], |
| 1786 | ip_dst = dst_ip_str |
| 1787 | ) |
| 1788 | pkt = str( parsed_pkt ) |
| 1789 | self.dataplane.send( in_port, pkt ) |
| 1790 | |
| 1791 | for out_port in ports: |
| 1792 | |
| 1793 | parsed_pkt = simple_udp_packet( |
| 1794 | pktlen = 96, |
| 1795 | eth_dst = port_to_dst_mac_str[in_port], |
| 1796 | eth_src = port_to_src_mac_str[in_port], |
| 1797 | ip_ttl = 64, |
| 1798 | ip_src = port_to_src_ip_str[in_port], |
| 1799 | ip_dst = dst_ip_str |
| 1800 | ) |
| 1801 | pkt = str( parsed_pkt ) |
| 1802 | if out_port == in_port: |
| 1803 | verify_no_packet( self, pkt, in_port ) |
| 1804 | continue |
| 1805 | verify_no_packet( self, pkt, out_port ) |
| 1806 | verify_no_other_packets( self ) |
| 1807 | finally: |
| 1808 | delete_all_flows( self.controller ) |
| 1809 | delete_groups( self.controller, Groups ) |
| 1810 | delete_all_groups( self.controller ) |
| 1811 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1812 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1813 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1814 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1815 | |
| 1816 | def runTest( self ): |
| 1817 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1818 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1819 | if len( config[ "port_map" ] ) < 2: |
| 1820 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1821 | return |
| 1822 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1823 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1824 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1825 | # 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] | 1826 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1827 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1828 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1829 | vlan_id = port + 16 |
| 1830 | mpls_label = port + 16 |
| 1831 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1832 | # add l2 interface group |
| 1833 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1834 | 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] | 1835 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1836 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1837 | vlan_id, id ) |
| 1838 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1839 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1840 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1841 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1842 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1843 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1844 | 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] | 1845 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1846 | if config["switch_type"] == "qmx": |
| 1847 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1848 | else: |
| 1849 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1850 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1851 | if config["switch_type"] != 'xpliant': |
| 1852 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| 1853 | else: |
| 1854 | xpliant_add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1855 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1856 | Groups._put( l2_gid ) |
| 1857 | Groups._put( mpls_gid ) |
| 1858 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1859 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1860 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1861 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1862 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1863 | for in_port in ports: |
| 1864 | ip_src = '192.168.%02d.1' % (in_port) |
| 1865 | for out_port in ports: |
| 1866 | if in_port == out_port: |
| 1867 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1868 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1869 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1870 | out_mpls_label = out_port + 16 |
| 1871 | in_vlan_vid = in_port + 16 |
| 1872 | out_vlan_vid = out_port + 16 |
| 1873 | |
| 1874 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1875 | label = (out_mpls_label, 0, 1, 32) |
| 1876 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1877 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1878 | pkt = str( parsed_pkt ) |
| 1879 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1880 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1881 | # build expect packet |
| 1882 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1883 | label = (out_mpls_label, 0, 1, 31) |
| 1884 | 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] | 1885 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1886 | label=[ label ] ) |
| 1887 | pkt = str( exp_pkt ) |
| 1888 | verify_packet( self, pkt, out_port ) |
| 1889 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1890 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1891 | delete_all_flows( self.controller ) |
| 1892 | delete_groups( self.controller, Groups ) |
| 1893 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1894 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1895 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1896 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1897 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1898 | |
| 1899 | def runTest( self ): |
| 1900 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1901 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1902 | if len( config[ "port_map" ] ) < 2: |
| 1903 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1904 | return |
| 1905 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1906 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1907 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1908 | # 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] | 1909 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1910 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1911 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1912 | vlan_id = port + 16 |
| 1913 | mpls_label = port + 16 |
| 1914 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1915 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1916 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1917 | 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] | 1918 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1919 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1920 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1921 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1922 | 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] | 1923 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1924 | 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] | 1925 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1926 | if config["switch_type"] == "qmx": |
| 1927 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1928 | else: |
| 1929 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1930 | |
| 1931 | if config["switch_type"] != 'xpliant': |
| 1932 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1933 | else: |
| 1934 | xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1935 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1936 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1937 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1938 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1939 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1940 | Groups._put( l2_gid ) |
| 1941 | Groups._put( l3_msg.group_id ) |
| 1942 | Groups._put( ecmp_msg.group_id ) |
| 1943 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1944 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1945 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1946 | for in_port in ports: |
| 1947 | ip_src = '192.168.%02d.1' % (in_port) |
| 1948 | for out_port in ports: |
| 1949 | if in_port == out_port: |
| 1950 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1951 | |
| 1952 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1953 | out_mpls_label = out_port + 16 |
| 1954 | in_vlan_vid = in_port + 16 |
| 1955 | out_vlan_vid = out_port + 16 |
| 1956 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1957 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1958 | label = (out_mpls_label, 0, 1, 32) |
| 1959 | 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] | 1960 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1961 | pkt = str( parsed_pkt ) |
| 1962 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1963 | # build expect packet |
| 1964 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1965 | if config["switch_type"] != 'xpliant': |
| 1966 | ip_ttl=31 |
| 1967 | else: |
| 1968 | ip_ttl=64 |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1969 | 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] | 1970 | 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] | 1971 | pkt = str( exp_pkt ) |
| 1972 | verify_packet( self, pkt, out_port ) |
| 1973 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1974 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1975 | delete_all_flows( self.controller ) |
| 1976 | delete_groups( self.controller, Groups ) |
| 1977 | delete_all_groups( self.controller ) |
Saurav Das | 15c2c26 | 2017-05-06 18:12:38 -0700 | [diff] [blame] | 1978 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1979 | |
| 1980 | @disabled |
| 1981 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1982 | """ |
| 1983 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1984 | """ |
| 1985 | |
| 1986 | def runTest( self ): |
| 1987 | Groups = Queue.LifoQueue( ) |
| 1988 | try: |
| 1989 | if len( config[ "port_map" ] ) < 2: |
| 1990 | logging.info( "Port count less than 2, can't run this case" ) |
| 1991 | return |
| 1992 | dip = 0xc0a80001 |
| 1993 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1994 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1995 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1996 | ports = config[ "port_map" ].keys( ) |
| 1997 | inport = ports[0] |
| 1998 | outport = ports[1] |
| 1999 | |
| 2000 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2001 | invlan_id = inport + 16 |
| 2002 | outvlan_id = outport + 16 |
| 2003 | mpls_label = outport + 16 |
| 2004 | |
| 2005 | # add l2 interface group |
| 2006 | id, dst_mac[ 5 ] = inport, outport |
| 2007 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 2008 | # add L3 Unicast group |
| 2009 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 2010 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2011 | # add L3 ecmp group |
| 2012 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 2013 | # add vlan flow table |
| 2014 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2015 | # add tmac flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2016 | if config["switch_type"] == "qmx": |
| 2017 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 2018 | else: |
| 2019 | add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2020 | # add mpls termination flow |
| 2021 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 2022 | Groups._put( l2_gid ) |
| 2023 | Groups._put( l3_msg.group_id ) |
| 2024 | Groups._put( ecmp_msg.group_id ) |
| 2025 | |
| 2026 | time.sleep(0.1) |
| 2027 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2028 | ip_src = '192.168.%02d.1' % (inport) |
| 2029 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2030 | out_mpls_label = outport + 16 |
| 2031 | in_vlan_vid = inport + 16 |
| 2032 | out_vlan_vid = outport + 16 |
| 2033 | |
| 2034 | ip_dst = '192.168.%02d.1' % (outport) |
| 2035 | label = (out_mpls_label, 0, 1, 32) |
| 2036 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 2037 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 2038 | pkt = str( parsed_pkt ) |
| 2039 | self.dataplane.send( inport, pkt ) |
| 2040 | # build expect packet |
| 2041 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 2042 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 2043 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 2044 | pkt = str( exp_pkt ) |
| 2045 | verify_packet( self, pkt, outport ) |
| 2046 | verify_no_other_packets( self ) |
| 2047 | finally: |
| 2048 | delete_all_flows( self.controller ) |
| 2049 | delete_groups( self.controller, Groups ) |
| 2050 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 2051 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2052 | |
| 2053 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2054 | """ Verify /24 IP forwarding to L3 Interface """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 2055 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2056 | def runTest( self ): |
| 2057 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2058 | try: |
| 2059 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2060 | if len( config[ "port_map" ] ) < 2: |
| 2061 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2062 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2063 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2064 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2065 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2066 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2067 | for port in ports: |
| 2068 | # add l2 interface group |
| 2069 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2070 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2071 | is_tagged=True, send_barrier=False ) |
| 2072 | dst_mac[ 5 ] = vlan_id |
| 2073 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 2074 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2075 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2076 | 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] | 2077 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2078 | if config["switch_type"] == "qmx": |
| 2079 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2080 | else: |
| 2081 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2082 | # add unicast routing flow |
| 2083 | dst_ip = dip + (vlan_id << 8) |
Andrea Campanella | bfb42b3 | 2018-04-26 10:57:23 +0200 | [diff] [blame] | 2084 | # def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False, priority = 1): |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2085 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 2086 | Groups.put( l2gid ) |
| 2087 | Groups.put( l3_msg.group_id ) |
| 2088 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 2089 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2090 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2091 | for in_port in ports: |
| 2092 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2093 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 2094 | for out_port in ports: |
| 2095 | if in_port == out_port: |
| 2096 | continue |
| 2097 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2098 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2099 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2100 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2101 | pkt = str( parsed_pkt ) |
| 2102 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2103 | # build expected packet |
| 2104 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2105 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2106 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2107 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2108 | pkt = str( exp_pkt ) |
| 2109 | verify_packet( self, pkt, out_port ) |
| 2110 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2111 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2112 | delete_all_flows( self.controller ) |
| 2113 | delete_groups( self.controller, Groups ) |
| 2114 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2115 | |
Andrea Campanella | bfb42b3 | 2018-04-26 10:57:23 +0200 | [diff] [blame] | 2116 | class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ): |
| 2117 | """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0""" |
| 2118 | |
| 2119 | def runTest( self ): |
| 2120 | Groups = Queue.LifoQueue( ) |
| 2121 | try: |
| 2122 | test_id = 27 |
| 2123 | if len( config[ "port_map" ] ) < 2: |
| 2124 | logging.info( "Port count less than 2, can't run this case" ) |
| 2125 | return |
| 2126 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2127 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2128 | dip = 0xc0a80001 |
| 2129 | ports = config[ "port_map" ].keys( ) |
| 2130 | for port in ports: |
| 2131 | # add l2 interface group |
| 2132 | vlan_id = port + test_id |
| 2133 | # add vlan flow table |
| 2134 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2135 | # add termination flow |
| 2136 | if config["switch_type"] == "qmx": |
| 2137 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2138 | else: |
| 2139 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2140 | # add unicast routing flow |
| 2141 | #dst ip = 10.0.0.0/8 |
| 2142 | dst_ip = 0x0a000000 |
| 2143 | add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 ) |
| 2144 | do_barrier( self.controller ) |
| 2145 | |
| 2146 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2147 | for in_port in ports: |
| 2148 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2149 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 2150 | for out_port in ports: |
| 2151 | if in_port == out_port: |
| 2152 | continue |
| 2153 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 2154 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2155 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2156 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2157 | pkt = str( parsed_pkt ) |
| 2158 | self.dataplane.send( in_port, pkt ) |
| 2159 | # build expected packet |
| 2160 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 2161 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2162 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2163 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2164 | pkt = str( exp_pkt ) |
| 2165 | verify_no_packet( self, pkt, out_port ) |
| 2166 | verify_no_other_packets( self ) |
| 2167 | finally: |
| 2168 | delete_all_flows( self.controller ) |
| 2169 | delete_groups( self.controller, Groups ) |
| 2170 | delete_all_groups( self.controller ) |
| 2171 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2172 | |
| 2173 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2174 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2175 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2176 | def runTest( self ): |
| 2177 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2178 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2179 | if len( config[ "port_map" ] ) < 2: |
| 2180 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2181 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2182 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2183 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2184 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2185 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2186 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2187 | for port in ports: |
| 2188 | # add l2 interface group |
| 2189 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2190 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 2191 | is_tagged=True, send_barrier=False ) |
| 2192 | dst_mac[ 5 ] = vlan_id |
| 2193 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 2194 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2195 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2196 | 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] | 2197 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2198 | if config["switch_type"] == "qmx": |
| 2199 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2200 | else: |
| 2201 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2202 | # add unicast routing flow |
| 2203 | dst_ip = dip + (vlan_id << 8) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2204 | 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] | 2205 | Groups.put( l2gid ) |
| 2206 | Groups.put( l3_msg.group_id ) |
| 2207 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2208 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2209 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 2210 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2211 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2212 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2213 | for in_port in ports: |
| 2214 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 2215 | ip_src = '192.168.%02d.1' % (in_port) |
| 2216 | for out_port in ports: |
| 2217 | if in_port == out_port: |
| 2218 | continue |
| 2219 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2220 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 2221 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2222 | pkt = str( parsed_pkt ) |
| 2223 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2224 | # build expected packet |
| 2225 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2226 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 2227 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2228 | pkt = str( exp_pkt ) |
| 2229 | verify_packet( self, pkt, out_port ) |
| 2230 | verify_no_other_packets( self ) |
| 2231 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 2232 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 2233 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2234 | pkt = str( parsed_pkt ) |
| 2235 | self.dataplane.send( in_port, pkt ) |
| 2236 | # build expect packet |
| 2237 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2238 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 2239 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 2240 | pkt = str( exp_pkt ) |
| 2241 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2242 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2243 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2244 | delete_all_flows( self.controller ) |
| 2245 | delete_groups( self.controller, Groups ) |
| 2246 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2247 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2248 | |
| 2249 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2250 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2251 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2252 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2253 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2254 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2255 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2256 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2257 | vlan_id = 1; |
| 2258 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2259 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 2260 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2261 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2262 | delete_all_flows( self.controller ) |
| 2263 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2264 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2265 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2266 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2267 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2268 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2269 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2270 | |
| 2271 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2272 | """ |
| 2273 | port1 (vlan 1)-> port 2 (vlan 2) |
| 2274 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2275 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2276 | delete_all_flows( self.controller ) |
| 2277 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2278 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2279 | if len( config[ "port_map" ] ) < 3: |
| 2280 | logging.info( "Port count less than 3, can't run this case" ) |
| 2281 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2282 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2283 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2284 | vlan_id = 1 |
| 2285 | port2_out_vlan = 2 |
| 2286 | port3_out_vlan = 3 |
| 2287 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 2288 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2289 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2290 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2291 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 2292 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 2293 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 2294 | src_ip = 0xc0a80101 |
| 2295 | src_ip_str = "192.168.1.1" |
| 2296 | dst_ip = 0xe0010101 |
| 2297 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2298 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2299 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 2300 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 2301 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2302 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2303 | # add l2 interface group |
| 2304 | for port in config[ "port_map" ].keys( ): |
| 2305 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 2306 | send_barrier=False ) |
| 2307 | # add vlan flow table |
| 2308 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2309 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2310 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2311 | # add termination flow |
| 2312 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 2313 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2314 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2315 | # add MPLS interface group |
| 2316 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 2317 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 2318 | port2_out_vlan, port2 ) |
| 2319 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 2320 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 2321 | # add L3VPN groups |
| 2322 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2323 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 2324 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 2325 | # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2326 | # 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] | 2327 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2328 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 2329 | add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2330 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2331 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 2332 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 2333 | pkt = str( parsed_pkt ) |
| 2334 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2335 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2336 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 2337 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 2338 | pkt = str( exp_pkt ) |
| 2339 | verify_packet( self, pkt, port2 ) |
| 2340 | # verify_packet(self, pkt, port3) |
| 2341 | verify_no_other_packets( self ) |
| 2342 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2343 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2344 | delete_all_flows( self.controller ) |
| 2345 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2346 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2347 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2348 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2349 | """ |
| 2350 | Test packet in function on a src-mac miss |
| 2351 | Send a packet to each dataplane port and verify that a packet |
| 2352 | in message is received from the controller for each |
| 2353 | #todo verify you stop receiving after adding rule |
| 2354 | """ |
| 2355 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2356 | def runTest( self ): |
| 2357 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2358 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2359 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2360 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2361 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2362 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2363 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 2364 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2365 | Groups.put( L2gid ) |
| 2366 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 2367 | vlan_pkt = str( parsed_vlan_pkt ) |
| 2368 | for of_port in config[ "port_map" ].keys( ): |
| 2369 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 2370 | self.dataplane.send( of_port, vlan_pkt ) |
| 2371 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 2372 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2373 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2374 | delete_all_flows( self.controller ) |
| 2375 | delete_all_groups( self.controller ) |
| 2376 | |
| 2377 | |
| 2378 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 2379 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2380 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2381 | """ |
| 2382 | |
| 2383 | def runTest( self ): |
| 2384 | Groups = Queue.LifoQueue( ) |
| 2385 | try: |
| 2386 | if len( config[ "port_map" ] ) < 2: |
| 2387 | logging.info( "Port count less than 2, can't run this case" ) |
| 2388 | return |
| 2389 | |
| 2390 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2391 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2392 | dip = 0xc0a80001 |
| 2393 | # Hashes Test Name and uses it as id for installing unique groups |
| 2394 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2395 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2396 | dst_ips = [] |
| 2397 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2398 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2399 | for port in ports: |
| 2400 | vlan_id = port |
| 2401 | id = port |
| 2402 | # add l2 interface group |
| 2403 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2404 | is_tagged=True, send_barrier=False ) |
| 2405 | dst_mac[ 5 ] = vlan_id |
| 2406 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2407 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2408 | if port == ports[1]: |
| 2409 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2410 | Groups._put( l2_gid ) |
| 2411 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2412 | 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] | 2413 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2414 | 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] | 2415 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2416 | if config["switch_type"] == "qmx": |
| 2417 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2418 | else: |
| 2419 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2420 | # add unicast routing flow |
| 2421 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2422 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2423 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2424 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2425 | for dst_ip in dst_ips: |
| 2426 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 2427 | do_barrier(self.controller) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2428 | time.sleep(0.1) |
| 2429 | # 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] | 2430 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2431 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2432 | in_port = ports[0] |
| 2433 | out_port = ports[1] |
| 2434 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2435 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2436 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2437 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2438 | tcp = out_port if out_port == 24 else 25 |
| 2439 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2440 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2441 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2442 | pkt = str( parsed_pkt ) |
| 2443 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2444 | # build expected packet at egress switchport |
| 2445 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2446 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2447 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2448 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2449 | pkt = str( exp_pkt ) |
| 2450 | verify_packet( self, pkt, out_port ) |
| 2451 | verify_no_other_packets( self ) |
| 2452 | |
| 2453 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2454 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2455 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2456 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2457 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2458 | time.sleep(0.1) |
| 2459 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2460 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2461 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2462 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2463 | tcp = port if port == 24 else 25 |
| 2464 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2465 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2466 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2467 | pkt = str( parsed_pkt ) |
| 2468 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2469 | # build expected packet |
| 2470 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2471 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2472 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2473 | ip_dst=ip_dst,tcp_dport=tcp ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2474 | # Expects packet on the input port |
| 2475 | if config["switch_type"] != 'xpliant': |
| 2476 | pkt = str( exp_pkt ) |
| 2477 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2478 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2479 | |
| 2480 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2481 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2482 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2483 | time.sleep(0.1) |
| 2484 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2485 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2486 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2487 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2488 | tcp = port if port == 24 else 25 |
| 2489 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2490 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2491 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2492 | pkt = str( parsed_pkt ) |
| 2493 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2494 | verify_no_other_packets( self ) |
| 2495 | |
| 2496 | # final part of the test - edit the empty group to add back the bucket for the |
| 2497 | # original egress port, and verify packet is received on egress switch port |
| 2498 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2499 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2500 | do_barrier(self.controller) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2501 | in_port = ports[0] |
| 2502 | out_port = ports[1] |
| 2503 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2504 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2505 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2506 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2507 | tcp = out_port if out_port == 24 else 25 |
| 2508 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2509 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2510 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2511 | pkt = str( parsed_pkt ) |
| 2512 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2513 | # build expected packet at egress switchport |
| 2514 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2515 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2516 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2517 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2518 | pkt = str( exp_pkt ) |
| 2519 | verify_packet( self, pkt, out_port ) |
| 2520 | verify_no_other_packets( self ) |
| 2521 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2522 | finally: |
| 2523 | delete_all_flows( self.controller ) |
| 2524 | delete_groups( self.controller, Groups ) |
| 2525 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2526 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2527 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2528 | class Untagged( base_tests.SimpleDataPlane ): |
| 2529 | """ |
| 2530 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2531 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2532 | previous versions of the OFDPA. |
| 2533 | |
| 2534 | Two rules are necessary in VLAN table (10): |
| 2535 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2536 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2537 | |
| 2538 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2539 | The remaining part of the test is based on the use of the bridging table |
| 2540 | """ |
| 2541 | |
| 2542 | MAX_INTERNAL_VLAN = 4094 |
| 2543 | |
| 2544 | def runTest( self ): |
| 2545 | groups = Queue.LifoQueue( ) |
| 2546 | try: |
| 2547 | if len( config[ "port_map" ] ) < 2: |
| 2548 | logging.info( "Port count less than 2, can't run this case" ) |
| 2549 | return |
| 2550 | |
| 2551 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2552 | for port in ports: |
| 2553 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2554 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2555 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2556 | for other_port in ports: |
| 2557 | if other_port == port: |
| 2558 | continue |
| 2559 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2560 | groups.put( L2gid ) |
| 2561 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2562 | |
| 2563 | do_barrier( self.controller ) |
| 2564 | |
| 2565 | for out_port in ports: |
| 2566 | # change dest based on port number |
| 2567 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2568 | for in_port in ports: |
| 2569 | if in_port == out_port: |
| 2570 | continue |
| 2571 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2572 | self.dataplane.send( in_port, pkt ) |
| 2573 | for ofport in ports: |
| 2574 | if ofport in [ out_port ]: |
| 2575 | verify_packet( self, pkt, ofport ) |
| 2576 | else: |
| 2577 | verify_no_packet( self, pkt, ofport ) |
| 2578 | verify_no_other_packets( self ) |
| 2579 | finally: |
| 2580 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2581 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2582 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 2583 | |
| 2584 | class MPLSSwapTest( base_tests.SimpleDataPlane ): |
| 2585 | """ |
| 2586 | MPLS switching with the same label used. |
| 2587 | Used for interconnecting spines between different fabrics where |
| 2588 | the label should not be popped, but swapepd with the same label. |
| 2589 | """ |
| 2590 | |
| 2591 | def runTest( self ): |
| 2592 | try: |
| 2593 | delete_all_flows( self.controller ) |
| 2594 | delete_all_groups( self.controller ) |
| 2595 | |
| 2596 | if len( config[ "port_map" ] ) < 2: |
| 2597 | logging.info( "Port count less than 3, can't run this case" ) |
| 2598 | assert (False) |
| 2599 | return |
| 2600 | |
| 2601 | input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2602 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2603 | |
| 2604 | input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ] |
| 2605 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2606 | |
| 2607 | output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ] |
| 2608 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2609 | |
| 2610 | mpls_label = 1000 |
| 2611 | |
| 2612 | src_ip = 0xc0a80101 |
| 2613 | src_ip_str = "192.168.1.1" |
| 2614 | dst_ip = 0xe0010101 |
| 2615 | dst_ip_str = "224.1.1.1" |
| 2616 | |
| 2617 | src_port = config[ "port_map" ].keys( )[ 0 ] |
| 2618 | dst_port = config[ "port_map" ].keys( )[ 1 ] |
| 2619 | |
| 2620 | out_vlan = 4094 |
| 2621 | |
| 2622 | add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False, |
| 2623 | send_barrier=True ) |
| 2624 | |
| 2625 | # add vlan flow table |
| 2626 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2627 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2628 | |
| 2629 | # add termination flow |
| 2630 | |
| 2631 | if config["switch_type"] == "qmx": |
| 2632 | logging.debug("MPLSSwitching : Adding flow for qmx, without input port") |
| 2633 | add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2634 | else: |
| 2635 | add_termination_flow( self.controller, in_port=src_port, |
| 2636 | eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2637 | |
| 2638 | # add groups that will be used now |
| 2639 | l2_gid = encode_l2_interface_group_id( out_vlan, dst_port) |
| 2640 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, |
| 2641 | output_dst_mac, input_dst_mac, |
| 2642 | out_vlan, dst_port, send_barrier=True) |
| 2643 | index = 60 |
| 2644 | mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid, |
| 2645 | 5, index, mpls_label) |
| 2646 | |
| 2647 | # add flow to mpls table |
| 2648 | add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True) |
| 2649 | |
| 2650 | # we generate the packet which carries a single label |
| 2651 | label = (mpls_label, 0, 1, 63) |
| 2652 | parsed_pkt = mpls_packet( |
| 2653 | pktlen=104, |
| 2654 | label=[label], |
| 2655 | eth_src=input_src_mac_str, |
| 2656 | eth_dst=input_dst_mac_str, |
| 2657 | ) |
| 2658 | pkt = str( parsed_pkt ) |
Andreas Pantelopoulos | aaa0262 | 2018-04-04 15:13:03 -0700 | [diff] [blame] | 2659 | |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 2660 | self.dataplane.send( src_port, pkt ) |
| 2661 | |
| 2662 | label = (mpls_label, 0, 1, 62) |
| 2663 | parsed_pkt = mpls_packet( |
| 2664 | pktlen=104, |
| 2665 | label=[label], |
| 2666 | eth_src=input_dst_mac_str, |
| 2667 | eth_dst=output_dst_mac_str, |
| 2668 | ) |
| 2669 | pkt = str( parsed_pkt ) |
| 2670 | |
| 2671 | verify_packet( self, pkt, dst_port ) |
| 2672 | verify_no_packet( self, pkt, src_port ) |
| 2673 | verify_no_other_packets( self ) |
| 2674 | |
| 2675 | delete_all_flows( self.controller ) |
| 2676 | delete_all_groups( self.controller ) |
| 2677 | |
| 2678 | finally: |
| 2679 | delete_all_flows( self.controller ) |
| 2680 | delete_all_groups( self.controller ) |
| 2681 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 2682 | @disabled |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame] | 2683 | class DoubleToUntagged( base_tests.SimpleDataPlane ): |
| 2684 | """ |
| 2685 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2686 | where we receive double tagged packets and output untagged |
| 2687 | packets. |
| 2688 | |
| 2689 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2690 | and inner tag is the subrscriber tag. |
| 2691 | """ |
| 2692 | |
| 2693 | def runTest( self ): |
| 2694 | Groups = Queue.LifoQueue( ) |
| 2695 | try: |
| 2696 | if len( config[ "port_map" ] ) < 2: |
| 2697 | logging.info( "Port count less than 2, can't run this case" ) |
| 2698 | return |
| 2699 | |
| 2700 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2701 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2702 | |
| 2703 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2704 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2705 | |
| 2706 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2707 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2708 | |
| 2709 | dip = 0xc0a80001 |
| 2710 | ports = config[ "port_map" ].keys( ) |
| 2711 | |
| 2712 | inner_vlan = 66 |
| 2713 | outer_vlan = 77 |
| 2714 | id = 10 |
| 2715 | mpls_label = 152 |
| 2716 | |
| 2717 | port = ports[0] |
| 2718 | out_port = ports[1] |
| 2719 | |
| 2720 | # add l2 interface group |
| 2721 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2722 | |
| 2723 | # add MPLS interface group |
| 2724 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2725 | inner_vlan, id ) |
| 2726 | |
| 2727 | # add MPLS L3 VPN group |
| 2728 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2729 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2730 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2731 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2732 | |
| 2733 | do_barrier( self.controller ) |
| 2734 | |
| 2735 | # add vlan flow table |
| 2736 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2737 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2738 | |
| 2739 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2740 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2741 | |
| 2742 | # add termination flow |
| 2743 | if config["switch_type"] == "qmx": |
| 2744 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2745 | else: |
| 2746 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2747 | |
| 2748 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2749 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2750 | vrf=0 ) |
| 2751 | Groups._put( l2_gid ) |
| 2752 | Groups._put( mpls_gid ) |
| 2753 | Groups._put( mpls_label_gid ) |
| 2754 | Groups._put( ecmp_msg.group_id ) |
| 2755 | |
| 2756 | do_barrier( self.controller ) |
| 2757 | |
| 2758 | ip_src = '192.168.5.5' |
| 2759 | ip_dst = '192.168.0.5' |
| 2760 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2761 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2762 | pkt = str( parsed_pkt ) |
| 2763 | |
| 2764 | # print("Expected %s" % format_packet(pkt)) |
| 2765 | |
| 2766 | self.dataplane.send( port, pkt ) |
| 2767 | |
| 2768 | # build expect packet |
| 2769 | label = (mpls_label, 0, 1, 32) |
| 2770 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2771 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2772 | label=[ label ] ) |
| 2773 | pkt = str( exp_pkt ) |
| 2774 | verify_packet( self, pkt, out_port ) |
| 2775 | verify_no_other_packets( self ) |
| 2776 | |
| 2777 | finally: |
| 2778 | delete_all_flows( self.controller ) |
| 2779 | delete_groups( self.controller, Groups ) |
| 2780 | delete_all_groups( self.controller ) |
| 2781 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 2782 | @disabled |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame] | 2783 | class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ): |
| 2784 | """ |
| 2785 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2786 | where we receive double tagged packets and output untagged |
| 2787 | packets. |
| 2788 | |
| 2789 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2790 | and inner tag is the subrscriber tag. |
| 2791 | """ |
| 2792 | |
| 2793 | def runTest( self ): |
| 2794 | Groups = Queue.LifoQueue( ) |
| 2795 | try: |
| 2796 | if len( config[ "port_map" ] ) < 2: |
| 2797 | logging.info( "Port count less than 2, can't run this case" ) |
| 2798 | return |
| 2799 | |
| 2800 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 2801 | subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"], |
| 2802 | [20, 0xc0a80002, 10, 101, "192.168.0.2"], |
| 2803 | [30, 0xc0a80003, 11, 100, "192.168.0.3"], |
| 2804 | [40, 0xc0a80004, 11, 101, "192.168.0.4"]] |
| 2805 | |
| 2806 | print("") |
| 2807 | |
| 2808 | for sub_info in subscriber_info: |
| 2809 | |
| 2810 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 2811 | |
| 2812 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2813 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2814 | |
| 2815 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2816 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2817 | |
| 2818 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2819 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2820 | |
| 2821 | dip = sub_info[1] |
| 2822 | ports = config[ "port_map" ].keys( ) |
| 2823 | |
| 2824 | inner_vlan = sub_info[2] |
| 2825 | outer_vlan = sub_info[3] |
| 2826 | id = 10 |
| 2827 | mpls_label = 152 |
| 2828 | |
| 2829 | port = ports[0] |
| 2830 | out_port = ports[1] |
| 2831 | |
| 2832 | # add l2 interface group |
| 2833 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2834 | |
| 2835 | # add MPLS interface group |
| 2836 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2837 | inner_vlan, id ) |
| 2838 | |
| 2839 | # add MPLS L3 VPN group |
| 2840 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2841 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2842 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2843 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2844 | |
| 2845 | do_barrier( self.controller ) |
| 2846 | |
| 2847 | # add vlan flow table |
| 2848 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2849 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2850 | |
| 2851 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2852 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2853 | |
| 2854 | # add termination flow |
| 2855 | if config["switch_type"] == "qmx": |
| 2856 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2857 | else: |
| 2858 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2859 | |
| 2860 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2861 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2862 | vrf=0 ) |
| 2863 | Groups._put( l2_gid ) |
| 2864 | Groups._put( mpls_gid ) |
| 2865 | Groups._put( mpls_label_gid ) |
| 2866 | Groups._put( ecmp_msg.group_id ) |
| 2867 | |
| 2868 | do_barrier( self.controller ) |
| 2869 | |
| 2870 | for sub_info in subscriber_info: |
| 2871 | |
| 2872 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 2873 | |
| 2874 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2875 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2876 | |
| 2877 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2878 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2879 | |
| 2880 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2881 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2882 | |
| 2883 | dip = sub_info[1] |
| 2884 | ports = config[ "port_map" ].keys( ) |
| 2885 | |
| 2886 | inner_vlan = sub_info[2] |
| 2887 | outer_vlan = sub_info[3] |
| 2888 | id = 10 |
| 2889 | mpls_label = 152 |
| 2890 | |
| 2891 | port = ports[0] |
| 2892 | out_port = ports[1] |
| 2893 | |
| 2894 | ip_src = sub_info[4] |
| 2895 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 2896 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2897 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2898 | pkt = str( parsed_pkt ) |
| 2899 | |
| 2900 | # print("Sent %s" % format_packet(pkt)) |
| 2901 | |
| 2902 | self.dataplane.send( port, pkt ) |
| 2903 | |
| 2904 | # build expect packet |
| 2905 | label = (mpls_label, 0, 1, 32) |
| 2906 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2907 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2908 | label=[ label ] ) |
| 2909 | pkt = str( exp_pkt ) |
| 2910 | verify_packet( self, pkt, out_port ) |
| 2911 | verify_no_other_packets( self ) |
| 2912 | |
| 2913 | finally: |
| 2914 | delete_all_flows( self.controller ) |
| 2915 | delete_groups( self.controller, Groups ) |
| 2916 | delete_all_groups( self.controller ) |
| 2917 | |
| 2918 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 2919 | @disabled |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame] | 2920 | class UntaggedToDouble ( base_tests.SimpleDataPlane ): |
| 2921 | """ |
| 2922 | Verify google senario where we need to go from |
| 2923 | an untagged packet to a double tagged packet. |
| 2924 | |
| 2925 | This is used for a single subscriber. |
| 2926 | """ |
| 2927 | |
| 2928 | def runTest( self ): |
| 2929 | Groups = Queue.LifoQueue( ) |
| 2930 | try: |
| 2931 | if len( config[ "port_map" ] ) < 2: |
| 2932 | logging.info( "Port count less than 2, can't run this case" ) |
| 2933 | return |
| 2934 | |
| 2935 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2936 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2937 | |
| 2938 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2939 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2940 | |
| 2941 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2942 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2943 | |
| 2944 | dip = 0xc0a80001 |
| 2945 | ports = config[ "port_map" ].keys( ) |
| 2946 | |
| 2947 | inner_vlan = 66 |
| 2948 | outer_vlan = 77 |
| 2949 | id = 10 |
| 2950 | mpls_label = 152 |
| 2951 | |
| 2952 | port = ports[0] |
| 2953 | out_port = ports[1] |
| 2954 | |
| 2955 | # add l2 unfiltered interface group |
| 2956 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 2957 | |
| 2958 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 2959 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 2960 | |
| 2961 | do_barrier( self.controller ) |
| 2962 | |
| 2963 | # add vlan flow table |
| 2964 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 2965 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 2966 | |
| 2967 | # add termination flow |
| 2968 | if config["switch_type"] == "qmx": |
| 2969 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 2970 | else: |
| 2971 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 2972 | |
| 2973 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 2974 | vrf=0 ) |
| 2975 | |
| 2976 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 2977 | |
| 2978 | Groups._put( l2_gid ) |
| 2979 | Groups._put( l3_msg.group_id ) |
| 2980 | |
| 2981 | do_barrier( self.controller ) |
| 2982 | |
| 2983 | ip_src = '192.168.5.5' |
| 2984 | ip_dst = '192.168.0.1' |
| 2985 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 2986 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2987 | pkt = str( parsed_pkt ) |
| 2988 | |
| 2989 | # print("Input Packet %s" % format_packet(pkt)) |
| 2990 | |
| 2991 | self.dataplane.send( port, pkt ) |
| 2992 | |
| 2993 | # build expect packet |
| 2994 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2995 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2996 | pkt = str( exp_pkt ) |
| 2997 | |
| 2998 | # print("Expected Packet %s" % format_packet(pkt)) |
| 2999 | |
| 3000 | verify_packet( self, pkt, out_port ) |
| 3001 | verify_no_other_packets( self ) |
| 3002 | finally: |
| 3003 | delete_all_flows( self.controller ) |
| 3004 | delete_groups( self.controller, Groups ) |
| 3005 | delete_all_groups( self.controller ) |
| 3006 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 3007 | @disabled |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame] | 3008 | class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ): |
| 3009 | """ |
| 3010 | Verify google senario where we need to go from |
| 3011 | an untagged packet to a double tagged packet. |
| 3012 | |
| 3013 | This is used for multiple subscribers. |
| 3014 | |
| 3015 | However, this solution does not scale, since we assign an internal vlan to each subscriber |
| 3016 | used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table. |
| 3017 | """ |
| 3018 | |
| 3019 | def runTest( self ): |
| 3020 | Groups = Queue.LifoQueue( ) |
| 3021 | try: |
| 3022 | if len( config[ "port_map" ] ) < 2: |
| 3023 | logging.info( "Port count less than 2, can't run this case" ) |
| 3024 | return |
| 3025 | |
| 3026 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan] |
| 3027 | subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000], |
| 3028 | [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001], |
| 3029 | [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002], |
| 3030 | [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]] |
| 3031 | |
| 3032 | print("") |
| 3033 | |
| 3034 | for sub_info in subscriber_info: |
| 3035 | |
| 3036 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 3037 | |
| 3038 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3039 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3040 | |
| 3041 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3042 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3043 | |
| 3044 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3045 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3046 | |
| 3047 | dip = sub_info[1] |
| 3048 | ports = config[ "port_map" ].keys( ) |
| 3049 | |
| 3050 | inner_vlan = sub_info[2] |
| 3051 | outer_vlan = sub_info[3] |
| 3052 | internal_vlan = sub_info[5] |
| 3053 | id = sub_info[0] + 10 |
| 3054 | |
| 3055 | port = ports[0] |
| 3056 | out_port = ports[1] |
| 3057 | |
| 3058 | # add l2 unfiltered interface group |
| 3059 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3060 | |
| 3061 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id, |
| 3062 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3063 | |
| 3064 | do_barrier( self.controller ) |
| 3065 | |
| 3066 | # add vlan flow table |
| 3067 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3068 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3069 | |
| 3070 | # add termination flow |
| 3071 | if config["switch_type"] == "qmx": |
| 3072 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3073 | else: |
| 3074 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3075 | |
| 3076 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3077 | vrf=0 ) |
| 3078 | |
| 3079 | add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan) |
| 3080 | |
| 3081 | Groups._put( l2_gid ) |
| 3082 | Groups._put( l3_msg.group_id ) |
| 3083 | do_barrier( self.controller ) |
| 3084 | |
| 3085 | for sub_info in subscriber_info: |
| 3086 | |
| 3087 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 3088 | |
| 3089 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3090 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3091 | |
| 3092 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3093 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3094 | |
| 3095 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3096 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3097 | |
| 3098 | dip = sub_info[1] |
| 3099 | ports = config[ "port_map" ].keys( ) |
| 3100 | |
| 3101 | inner_vlan = sub_info[2] |
| 3102 | outer_vlan = sub_info[3] |
| 3103 | internal_vlan = sub_info[5] |
| 3104 | |
| 3105 | id = sub_info[0] + 10 |
| 3106 | ip_src = '192.168.5.5' |
| 3107 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3108 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 3109 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3110 | pkt = str( parsed_pkt ) |
| 3111 | |
| 3112 | # print("Input Packet %s" % format_packet(pkt)) |
| 3113 | |
| 3114 | self.dataplane.send( port, pkt ) |
| 3115 | |
| 3116 | # build expect packet |
| 3117 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 3118 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 3119 | pkt = str( exp_pkt ) |
| 3120 | |
| 3121 | # print("Expected Packet %s" % format_packet(pkt)) |
| 3122 | |
| 3123 | verify_packet( self, pkt, out_port ) |
| 3124 | verify_no_other_packets( self ) |
| 3125 | finally: |
| 3126 | delete_all_flows( self.controller ) |
| 3127 | delete_groups( self.controller, Groups ) |
| 3128 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 3129 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 3130 | @disabled |
Jonghwan Hyun | ff0dfd5 | 2018-03-20 15:04:35 -0700 | [diff] [blame] | 3131 | class UntaggedToDoubleChangeEthertype ( base_tests.SimpleDataPlane ): |
| 3132 | |
| 3133 | def runTest( self ): |
| 3134 | Groups = Queue.LifoQueue() |
Andreas Pantelopoulos | aaa0262 | 2018-04-04 15:13:03 -0700 | [diff] [blame] | 3135 | |
Jonghwan Hyun | ff0dfd5 | 2018-03-20 15:04:35 -0700 | [diff] [blame] | 3136 | try: |
| 3137 | if len( config[ "port_map" ] ) < 2: |
Andreas Pantelopoulos | aaa0262 | 2018-04-04 15:13:03 -0700 | [diff] [blame] | 3138 | logging.info( "port count less than 2, can't run this case" ) |
Jonghwan Hyun | ff0dfd5 | 2018-03-20 15:04:35 -0700 | [diff] [blame] | 3139 | return |
| 3140 | |
| 3141 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3142 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3143 | |
| 3144 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3145 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3146 | |
| 3147 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3148 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3149 | |
| 3150 | dip = 0xc0a80001 |
| 3151 | ports = config[ "port_map" ].keys( ) |
| 3152 | |
| 3153 | inner_vlan = 66 |
| 3154 | outer_vlan = 77 |
| 3155 | id = 10 |
| 3156 | |
| 3157 | port = ports[0] |
| 3158 | out_port = ports[1] |
| 3159 | |
| 3160 | # add l2 unfiltered interface group |
| 3161 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3162 | |
| 3163 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 3164 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3165 | |
| 3166 | do_barrier( self.controller ) |
| 3167 | |
| 3168 | # add vlan flow table |
| 3169 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3170 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3171 | |
| 3172 | # add termination flow |
| 3173 | if config["switch_type"] == "qmx": |
| 3174 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3175 | else: |
| 3176 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3177 | |
| 3178 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3179 | vrf=0 ) |
| 3180 | |
| 3181 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 3182 | |
| 3183 | Groups._put( l2_gid ) |
| 3184 | Groups._put( l3_msg.group_id ) |
| 3185 | |
| 3186 | # add vlan flow table |
| 3187 | add_one_egress_vlan_tpid_table_flow( self.controller, out_port, outer_vlan+0x1000 ) |
| 3188 | do_barrier( self.controller ) |
| 3189 | |
| 3190 | ip_src = '192.168.5.5' |
| 3191 | ip_dst = '192.168.0.1' |
| 3192 | parsed_pkt = simple_tcp_packet( pktlen=100, |
| 3193 | dl_vlan_enable=False, |
| 3194 | eth_dst=input_dst_mac_str, |
| 3195 | eth_src=input_src_mac_str, |
| 3196 | ip_ttl=64, |
| 3197 | ip_src=ip_src, |
| 3198 | ip_dst=ip_dst ) |
| 3199 | pkt = str( parsed_pkt ) |
| 3200 | |
| 3201 | print("Input Packet %s" % format_packet(pkt)) |
| 3202 | |
| 3203 | self.dataplane.send( port, pkt ) |
| 3204 | |
| 3205 | # build expect packet |
| 3206 | exp_pkt = simple_tcp_packet_two_vlan( pktlen=108, |
| 3207 | out_dl_vlan_enable=True, |
| 3208 | out_vlan_vid=outer_vlan, |
| 3209 | out_vlan_tpid=0x88a8, |
| 3210 | in_dl_vlan_enable=True, |
| 3211 | in_vlan_vid=inner_vlan, |
| 3212 | eth_dst=output_dst_mac_str, |
| 3213 | eth_src=input_dst_mac_str, |
| 3214 | ip_ttl=63, |
| 3215 | ip_src=ip_src, |
| 3216 | ip_dst=ip_dst ) |
| 3217 | pkt = str( exp_pkt ) |
| 3218 | |
| 3219 | print("Expected Packet %s" % format_packet(pkt)) |
| 3220 | |
| 3221 | verify_packet( self, pkt, out_port ) |
| 3222 | verify_no_other_packets( self ) |
| 3223 | finally: |
| 3224 | delete_all_flows( self.controller ) |
| 3225 | delete_groups( self.controller, Groups ) |
Andreas Pantelopoulos | aaa0262 | 2018-04-04 15:13:03 -0700 | [diff] [blame] | 3226 | delete_all_groups( self.controller ) |
| 3227 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 3228 | @disabled |
Andreas Pantelopoulos | aaa0262 | 2018-04-04 15:13:03 -0700 | [diff] [blame] | 3229 | class _MplsFwdInterfaceProblem_PW( base_tests.SimpleDataPlane ): |
| 3230 | """ |
| 3231 | Reproduces the pseudowire bug with the wrongly set destination mac address. |
| 3232 | """ |
| 3233 | def runTest( self ): |
| 3234 | Groups = Queue.LifoQueue( ) |
| 3235 | try: |
| 3236 | if len( config[ "port_map" ] ) < 1: |
| 3237 | logging.info( "Port count less than 1, can't run this case" ) |
| 3238 | assert (False) |
| 3239 | return |
| 3240 | |
| 3241 | macs_to_test = [( [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x00 ], [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ], '00:00:00:11:11:00', '00:00:00:22:22:00'), |
| 3242 | ( [ 0x00, 0x00, 0x00, 0x11, 0x22, 0x00 ], [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ], '00:00:00:11:22:00', '00:00:00:33:33:00'), |
| 3243 | ( [ 0x00, 0x00, 0x00, 0x11, 0x33, 0x00 ], [ 0x00, 0x00, 0x00, 0x44, 0x44, 0x00 ], '00:00:00:11:33:00', '00:00:00:44:44:00'), |
| 3244 | ( [ 0x00, 0x00, 0x00, 0x11, 0x44, 0x00 ], [ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00 ], '00:00:00:11:44:00', '00:00:00:55:55:00'), |
| 3245 | ( [ 0x00, 0x00, 0x00, 0x11, 0x55, 0x00 ], [ 0x00, 0x00, 0x00, 0x66, 0x66, 0x00 ], '00:00:00:11:55:00', '00:00:00:66:66:00')] |
| 3246 | |
| 3247 | for dummy_dst_mac, dst_mac, mac_dst_dummy, mac_dst in macs_to_test: |
| 3248 | |
| 3249 | dip = 0xc0a80001 |
| 3250 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3251 | |
| 3252 | out_port = 12 |
| 3253 | port = 24 |
| 3254 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 3255 | vlan_id = port + 16 |
| 3256 | mpls_label = port + 16 |
| 3257 | |
| 3258 | in_port = 24 |
| 3259 | ip_src = '192.168.%02d.1' % (in_port) |
| 3260 | |
| 3261 | # create dummy groups |
| 3262 | id = port |
| 3263 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, vlan_id, False, False) |
| 3264 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dummy_dst_mac, intf_src_mac, |
| 3265 | vlan_id, id, send_barrier=True) |
| 3266 | do_barrier( self.controller ) |
| 3267 | |
| 3268 | # PW Case. |
| 3269 | raw_input("Press anything to move on with pseudowire rules, after that you should see the updated groups in the switch.") |
| 3270 | logging.info("Installing entries for pseudowire!") |
| 3271 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 3272 | mpls_label = 100 |
| 3273 | mpls_label_SR2 = 100 + 10 |
| 3274 | mpls_label_PW = 100 + 15 |
| 3275 | |
| 3276 | print("Install MPLS intf group for dst mac {0}", dst_mac) |
| 3277 | # add MPLS interface group |
| 3278 | mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group( |
| 3279 | ctrl=self.controller, |
| 3280 | ref_gid=l2_gid, |
| 3281 | dst_mac=dst_mac, |
| 3282 | src_mac=intf_src_mac, |
| 3283 | vid=vlan_id, |
| 3284 | index=id, |
| 3285 | add=False, |
| 3286 | send_barrier=True |
| 3287 | ) |
| 3288 | |
| 3289 | # add MPLS flow with BoS=0 |
| 3290 | add_mpls_flow_pw( |
| 3291 | ctrl=self.controller, |
| 3292 | action_group_id=mpls_intf_gid, |
| 3293 | label=mpls_label_SR2, |
| 3294 | ethertype=0x8847, |
| 3295 | tunnel_index=1, |
| 3296 | bos=0 |
| 3297 | ) |
| 3298 | |
| 3299 | # add Termination flow |
| 3300 | add_termination_flow( |
| 3301 | ctrl=self.controller, |
| 3302 | in_port=in_port, |
| 3303 | eth_type=0x8847, |
| 3304 | dst_mac=intf_src_mac, |
| 3305 | vlanid=vlan_id, |
| 3306 | goto_table=23 |
| 3307 | ) |
| 3308 | |
| 3309 | # add VLAN flows |
| 3310 | add_one_vlan_table_flow( |
| 3311 | ctrl=self.controller, |
| 3312 | of_port=in_port, |
| 3313 | vlan_id=vlan_id, |
| 3314 | flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 3315 | ) |
| 3316 | add_one_vlan_table_flow( |
| 3317 | ctrl=self.controller, |
| 3318 | of_port=in_port, |
| 3319 | vlan_id=vlan_id, |
| 3320 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG |
| 3321 | ) |
| 3322 | # Packet generation with sleep |
| 3323 | time.sleep(2) |
| 3324 | label_SR2 = (mpls_label_SR2, 0, 0, 32) |
| 3325 | label_2 = (mpls_label_PW, 0, 1, 32) |
| 3326 | |
| 3327 | # set to false to test if routing traffic |
| 3328 | # comes through |
| 3329 | raw_input("Press enter to send the packet, inspect the groups in the switch!") |
| 3330 | print("Sending packet with dst mac {0} and labels {1}".format(switch_mac, [label_SR2, label_2])) |
| 3331 | parsed_pkt = mpls_packet( |
| 3332 | pktlen=104, |
| 3333 | ip_ttl=63, |
| 3334 | label=[label_SR2, label_2], |
| 3335 | encapsulated_ethernet = True, |
| 3336 | eth_dst=switch_mac |
| 3337 | ) |
| 3338 | |
| 3339 | pkt = str( parsed_pkt ) |
| 3340 | self.dataplane.send( in_port, pkt ) |
| 3341 | |
| 3342 | expected_label = (mpls_label_PW, 0, 1, 31) |
| 3343 | print("Expecting packet with dst mac {0} and labels {1}".format(mac_dst, [label_2])) |
| 3344 | parsed_pkt = mpls_packet( |
| 3345 | pktlen=100, |
| 3346 | ip_ttl=63, |
| 3347 | eth_dst=mac_dst, |
| 3348 | eth_src=switch_mac, |
| 3349 | label=[ expected_label ], |
| 3350 | encapsulated_ethernet = True |
| 3351 | ) |
| 3352 | |
| 3353 | pkt = str( parsed_pkt ) |
| 3354 | verify_packet( self, pkt, out_port ) |
| 3355 | verify_no_packet( self, pkt, in_port ) |
| 3356 | |
| 3357 | delete_all_flows( self.controller ) |
| 3358 | delete_groups( self.controller, Groups ) |
| 3359 | delete_all_groups( self.controller ) |
| 3360 | |
| 3361 | finally: |
| 3362 | delete_all_flows( self.controller ) |
| 3363 | delete_groups( self.controller, Groups ) |
| 3364 | delete_all_groups( self.controller ) |
| 3365 | |
| 3366 | |
Saurav Das | 5d1473d | 2018-07-12 11:02:56 -0700 | [diff] [blame] | 3367 | class VlanCrossConnect ( base_tests.SimpleDataPlane ): |
| 3368 | """ |
| 3369 | Tries the cross connect functionality of the ofdpa switches. |
| 3370 | """ |
| 3371 | def runTest( self ): |
| 3372 | Groups = Queue.LifoQueue( ) |
| 3373 | try: |
| 3374 | if len( config[ "port_map" ] ) < 2: |
| 3375 | logging.info( "Port count less than 2, can't run this case" ) |
| 3376 | return |
| 3377 | |
| 3378 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 3379 | subscriber_info = [ [10, 0xc0a80001, 12, 11, "192.168.0.1"] ] |
| 3380 | |
| 3381 | index = 5 |
| 3382 | for sub_info in subscriber_info: |
| 3383 | |
| 3384 | #print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 3385 | |
| 3386 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3387 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3388 | |
| 3389 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3390 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3391 | |
| 3392 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3393 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3394 | |
| 3395 | dip = sub_info[1] |
| 3396 | ports = config[ "port_map" ].keys( ) |
| 3397 | |
| 3398 | inner_vlan = sub_info[2] |
| 3399 | outer_vlan = sub_info[3] |
| 3400 | |
| 3401 | index = inner_vlan |
| 3402 | |
| 3403 | port = ports[0] |
| 3404 | out_port = ports[1] |
| 3405 | |
| 3406 | # add l2 interface group, uncomment for unfiltered |
| 3407 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, outer_vlan, True, True) |
| 3408 | #i l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, 1, True) |
| 3409 | |
| 3410 | # add vlan flow table |
| 3411 | add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 3412 | add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan ,outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True) |
| 3413 | add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=l2_gid, qos_index=0, goto=ACL_FLOW_TABLE) |
| 3414 | index += 1 |
| 3415 | |
| 3416 | Groups._put( l2_gid ) |
| 3417 | do_barrier( self.controller ) |
| 3418 | |
| 3419 | for sub_info in subscriber_info: |
| 3420 | #print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 3421 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3422 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3423 | |
| 3424 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3425 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3426 | |
| 3427 | dip = sub_info[1] |
| 3428 | ports = config[ "port_map" ].keys( ) |
| 3429 | |
| 3430 | inner_vlan = sub_info[2] |
| 3431 | outer_vlan = sub_info[3] |
| 3432 | |
| 3433 | port = ports[0] |
| 3434 | out_port = ports[1] |
| 3435 | |
| 3436 | ip_src = sub_info[4] |
| 3437 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3438 | parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan, |
| 3439 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3440 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True, in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan, |
| 3441 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3442 | |
| 3443 | pkt = str( parsed_pkt ) |
| 3444 | |
| 3445 | self.dataplane.send( port, pkt ) |
| 3446 | verify_packet( self, pkt, out_port ) |
| 3447 | verify_no_other_packets( self ) |
| 3448 | |
| 3449 | finally: |
| 3450 | delete_all_flows( self.controller ) |
| 3451 | delete_groups( self.controller, Groups ) |
| 3452 | delete_all_groups( self.controller ) |
| 3453 | |
| 3454 | |
Saurav Das | b4b841e | 2018-08-17 15:51:56 -0700 | [diff] [blame] | 3455 | @disabled |
| 3456 | class Lag( base_tests.SimpleDataPlane ): |
| 3457 | """ |
| 3458 | Checks the L2 load balancing (LAG) functionality of the ofdpa switches. |
| 3459 | """ |
| 3460 | def runTest( self ): |
| 3461 | Groups = Queue.LifoQueue( ) |
| 3462 | try: |
| 3463 | if len( config[ "port_map" ] ) < 2: |
| 3464 | logging.info( "Port count less than 2, can't run this case" ) |
| 3465 | return |
| 3466 | |
| 3467 | ports = sorted(config[ "port_map" ].keys( )) |
| 3468 | in_port = ports[0] |
| 3469 | out_port = ports[1] |
| 3470 | |
| 3471 | # add l2 interface unfiltered group |
| 3472 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3473 | |
| 3474 | # create l2 load-balance group |
| 3475 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3476 | Groups.put(l2_o_gid, lag_gid) |
| 3477 | |
| 3478 | # --- TEST 1: bridging with load-bal---- |
| 3479 | vlan_in_port_untagged = 31 |
| 3480 | # table 10 flows and bridging flows for dstMac+vlan -> l2-load-bal group |
| 3481 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3482 | send_barrier=True) |
| 3483 | mac_dst = [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ] |
| 3484 | mac_dst_str = '00:11:22:33:44:55' |
| 3485 | add_bridge_flow( self.controller, mac_dst, vlan_in_port_untagged, lag_gid, True ) |
| 3486 | # untagged packet input becomes tagged packet at output |
| 3487 | time.sleep(0.1) |
| 3488 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=mac_dst_str ) ) |
| 3489 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=mac_dst_str ) ) |
| 3490 | self.dataplane.send( in_port, pkt ) |
| 3491 | verify_packet( self, exp_pkt, out_port ) |
| 3492 | verify_no_other_packets( self ) |
| 3493 | |
| 3494 | # --- TEST 2: flooding with load-bal ---- |
| 3495 | # flooding group --> load-bal group --> l2 unfiltered interface |
| 3496 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 ) |
| 3497 | Groups.put( floodmsg.group_id ) |
| 3498 | # add bridging flows for flooding groups |
| 3499 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3500 | # unknown dstmac packet input to hit flood group |
| 3501 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3502 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3503 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3504 | time.sleep(0.1) |
| 3505 | self.dataplane.send( in_port, pkt ) |
| 3506 | verify_packet( self, exp_pkt, out_port ) |
| 3507 | verify_no_other_packets( self ) |
| 3508 | |
| 3509 | # --- TEST 3: editing load-bal ---- |
| 3510 | # create and add another l2 unfiltered interface group to the load-balancing group |
| 3511 | l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True) |
| 3512 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True) |
| 3513 | self.dataplane.send( in_port, pkt ) |
| 3514 | verify_packet( self, exp_pkt, out_port ) |
| 3515 | |
| 3516 | # delete all buckets in loadbal group |
| 3517 | msg = mod_l2_loadbal_group(self.controller, 1, [], True) |
| 3518 | time.sleep(0.1) |
| 3519 | self.dataplane.send( in_port, pkt ) |
| 3520 | verify_no_other_packets( self ) # no buckets |
| 3521 | |
| 3522 | # only input port in load balancing group |
| 3523 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_i_gid], True) |
| 3524 | self.dataplane.send( in_port, pkt ) |
| 3525 | verify_no_other_packets( self ) # packet should not be sent out of in port |
| 3526 | |
| 3527 | # remove input port and add output port in lag group |
| 3528 | msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3529 | time.sleep(0.1) |
| 3530 | self.dataplane.send( in_port, pkt ) |
| 3531 | verify_packet( self, exp_pkt, out_port ) |
| 3532 | verify_no_other_packets( self ) |
| 3533 | |
| 3534 | finally: |
| 3535 | #print("done") |
| 3536 | delete_all_flows( self.controller ) |
| 3537 | delete_groups( self.controller, Groups ) |
| 3538 | delete_all_groups( self.controller ) |
| 3539 | |
| 3540 | @disabled |
Charles Chan | 00de042 | 2018-10-09 14:44:00 -0700 | [diff] [blame] | 3541 | class FloodLb( base_tests.SimpleDataPlane ): |
| 3542 | """ |
| 3543 | Checks L2 flood group pointing to L2 load balance group with 2 buckets (unfiltered). |
| 3544 | The packet from in_port should not be seen on the out_port |
| 3545 | """ |
| 3546 | def runTest( self ): |
| 3547 | Groups = Queue.LifoQueue( ) |
| 3548 | try: |
| 3549 | if len( config[ "port_map" ] ) < 2: |
| 3550 | logging.info( "Port count less than 2, can't run this case" ) |
| 3551 | return |
| 3552 | |
| 3553 | ports = sorted(config[ "port_map" ].keys( )) |
| 3554 | in_port = ports[0] |
| 3555 | out_port = ports[1] |
| 3556 | vlan_in_port_untagged = 31 |
| 3557 | |
| 3558 | # add l2 unfiltered interface group for outport |
| 3559 | l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True) |
| 3560 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3561 | |
| 3562 | # create l2 load-balance group |
| 3563 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_i_gid, l2_o_gid], True) |
| 3564 | |
| 3565 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3566 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0, send_barrier=True ) |
| 3567 | Groups.put( l2_i_gid ) |
| 3568 | Groups.put( l2_o_gid ) |
| 3569 | Groups.put( lag_gid ) |
| 3570 | Groups.put( floodmsg.group_id ) |
| 3571 | |
| 3572 | # table 10 flows for untagged input |
| 3573 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3574 | send_barrier=True) |
| 3575 | add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3576 | send_barrier=True) |
| 3577 | |
| 3578 | # add bridging flows for flooding groups |
| 3579 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3580 | # unknown dstmac packet will hit flood group |
| 3581 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3582 | |
| 3583 | # check one direction -> packet enters through inport should not be seen on the outport |
| 3584 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3585 | self.dataplane.send( in_port, pkt ) |
| 3586 | verify_no_other_packets( self ) |
| 3587 | |
| 3588 | # check other direction -> packet enters through outport should not be seen on the inport |
| 3589 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3590 | self.dataplane.send( out_port, pkt ) |
| 3591 | verify_no_other_packets( self ) |
| 3592 | |
| 3593 | finally: |
| 3594 | #print("done") |
| 3595 | delete_all_flows( self.controller ) |
| 3596 | delete_groups( self.controller, Groups ) |
| 3597 | delete_all_groups( self.controller ) |
| 3598 | |
| 3599 | @disabled |
Charles Chan | 4bda39f | 2018-11-08 14:11:34 -0800 | [diff] [blame] | 3600 | class FloodMixUntagged( base_tests.SimpleDataPlane ): |
Saurav Das | b4b841e | 2018-08-17 15:51:56 -0700 | [diff] [blame] | 3601 | """ |
| 3602 | Checks the combination of L2 filtered and L2 load balancing (LAG) groups |
| 3603 | in a flooding group |
| 3604 | """ |
| 3605 | def runTest( self ): |
| 3606 | Groups = Queue.LifoQueue( ) |
| 3607 | try: |
| 3608 | if len( config[ "port_map" ] ) < 2: |
| 3609 | logging.info( "Port count less than 2, can't run this case" ) |
| 3610 | return |
| 3611 | |
| 3612 | ports = sorted(config[ "port_map" ].keys( )) |
| 3613 | in_port = ports[0] |
| 3614 | out_port = ports[1] |
| 3615 | vlan_in_port_untagged = 31 |
| 3616 | |
| 3617 | # add l2 unfiltered interface group for outport |
| 3618 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3619 | |
| 3620 | # create l2 load-balance group |
| 3621 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3622 | |
| 3623 | # create l2 interface (filtered) group for inport |
| 3624 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3625 | is_tagged=False, send_barrier=True) |
| 3626 | |
| 3627 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3628 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 ) |
| 3629 | Groups.put( l2_o_gid ) |
| 3630 | Groups.put( lag_gid ) |
| 3631 | Groups.put( l2_i_gid ) |
| 3632 | Groups.put( floodmsg.group_id ) |
| 3633 | |
| 3634 | # table 10 flows for untagged input |
| 3635 | add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3636 | send_barrier=True) |
| 3637 | |
| 3638 | # add bridging flows for flooding groups |
| 3639 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3640 | # unknown dstmac packet will hit flood group |
| 3641 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3642 | |
| 3643 | # check one direction -> packet enters through filtered port (inport) and exits through |
| 3644 | # unfiltered port (outport) via the flood and lag groups |
| 3645 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3646 | exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3647 | self.dataplane.send( in_port, pkt ) |
| 3648 | verify_packet( self, exp_pkt, out_port ) |
| 3649 | verify_no_other_packets( self ) |
| 3650 | |
| 3651 | # check other direction -> packet enters through unfiltered port (outport) and exits through |
| 3652 | # filtered port (inport) via the flood group |
| 3653 | add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH, |
| 3654 | send_barrier=True) |
| 3655 | pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) ) |
| 3656 | exp_pkt = pkt # ingress packet gets internal vlan 31 which gets popped at l2 interface group before egress |
| 3657 | self.dataplane.send( out_port, pkt ) |
| 3658 | verify_packet( self, exp_pkt, in_port ) |
| 3659 | verify_no_other_packets( self ) |
| 3660 | |
| 3661 | finally: |
| 3662 | print("done") |
| 3663 | delete_all_flows( self.controller ) |
| 3664 | delete_groups( self.controller, Groups ) |
| 3665 | delete_all_groups( self.controller ) |
| 3666 | |
| 3667 | @disabled |
Charles Chan | 4bda39f | 2018-11-08 14:11:34 -0800 | [diff] [blame] | 3668 | class FloodMixTagged( base_tests.SimpleDataPlane ): |
| 3669 | """ |
| 3670 | Checks the combination of L2 filtered and L2 load balancing (LAG) groups |
| 3671 | in a flooding group |
| 3672 | """ |
| 3673 | def runTest( self ): |
| 3674 | Groups = Queue.LifoQueue( ) |
| 3675 | try: |
| 3676 | if len( config[ "port_map" ] ) < 2: |
| 3677 | logging.info( "Port count less than 2, can't run this case" ) |
| 3678 | return |
| 3679 | |
| 3680 | ports = sorted(config[ "port_map" ].keys( )) |
| 3681 | in_port = ports[0] |
| 3682 | out_port = ports[1] |
| 3683 | vlan_in_port_untagged = 31 |
| 3684 | |
| 3685 | # add l2 unfiltered interface group for outport |
| 3686 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3687 | |
| 3688 | # create l2 load-balance group |
| 3689 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3690 | |
| 3691 | # create l2 interface (filtered) group for inport |
| 3692 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3693 | is_tagged=True, send_barrier=True) |
| 3694 | |
| 3695 | # create l2 flood group with mix of l2i and l2-loadbal |
| 3696 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 ) |
| 3697 | Groups.put( l2_o_gid ) |
| 3698 | Groups.put( lag_gid ) |
| 3699 | Groups.put( l2_i_gid ) |
| 3700 | Groups.put( floodmsg.group_id ) |
| 3701 | |
| 3702 | # table 10 flows for tagged in_port. Note: VLAN in table 10 must be wildcarded for an unfiltered port |
| 3703 | add_vlan_table_flow_allow_all_vlan(self.controller, in_port, send_barrier=True) |
| 3704 | |
| 3705 | # add bridging flows for flooding groups |
| 3706 | add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id ) |
| 3707 | # unknown dstmac packet will hit flood group |
| 3708 | un_mac_dst_str = '00:11:22:ff:ff:ff' |
| 3709 | |
| 3710 | # check one direction -> packet enters through unfiltered port (inport) and exits through |
| 3711 | # unfiltered port (outport) via the flood and lag groups |
| 3712 | pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3713 | exp_pkt = pkt |
| 3714 | self.dataplane.send( in_port, pkt ) |
| 3715 | verify_packet( self, exp_pkt, out_port ) |
| 3716 | verify_no_other_packets( self ) |
| 3717 | |
| 3718 | # check other direction -> packet enters through unfiltered port (outport) and exits through |
| 3719 | # unfiltered port (inport) via the flood group |
| 3720 | |
| 3721 | # table 10 flows for tagged out_port. Note: VLAN must be wildcarded for an unfiltered port |
| 3722 | add_vlan_table_flow_allow_all_vlan(self.controller, out_port, send_barrier=True) |
| 3723 | pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) ) |
| 3724 | exp_pkt = pkt |
| 3725 | self.dataplane.send( out_port, pkt ) |
| 3726 | verify_packet( self, exp_pkt, in_port ) |
| 3727 | verify_no_other_packets( self ) |
| 3728 | |
| 3729 | finally: |
| 3730 | print("done") |
| 3731 | delete_all_flows( self.controller ) |
| 3732 | delete_groups( self.controller, Groups ) |
| 3733 | delete_all_groups( self.controller ) |
| 3734 | |
| 3735 | @disabled |
Saurav Das | b4b841e | 2018-08-17 15:51:56 -0700 | [diff] [blame] | 3736 | class LagMix( base_tests.SimpleDataPlane ): |
| 3737 | """ |
| 3738 | Checks the combination of L2 filtered and unfiltered interface groups |
| 3739 | in a L2 load balancing (LAG) group - this should not work according to spec |
| 3740 | """ |
| 3741 | def runTest( self ): |
| 3742 | Groups = Queue.LifoQueue( ) |
| 3743 | try: |
| 3744 | if len( config[ "port_map" ] ) < 2: |
| 3745 | logging.info( "Port count less than 2, can't run this case" ) |
| 3746 | return |
| 3747 | |
| 3748 | ports = sorted(config[ "port_map" ].keys( )) |
| 3749 | in_port = ports[0] |
| 3750 | out_port = ports[1] |
| 3751 | vlan_in_port_untagged = 31 |
| 3752 | |
| 3753 | # add l2 unfiltered interface group |
| 3754 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3755 | |
| 3756 | # create l2 interface (filtered) group |
| 3757 | l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged, |
| 3758 | is_tagged=False, send_barrier=True) |
| 3759 | |
| 3760 | # create l2 load-balance group with a mix of filtered and unfiltered groups |
| 3761 | """ |
| 3762 | XXX the following does not work - the group does not get created but curiously we don't get an openflow |
| 3763 | error message. The ofdpa logs show |
| 3764 | ofdbGroupBucketValidate: Referenced Group Id 0x1f000c not of type L2 Unfiltered Interface. |
| 3765 | We do get an openflow error message for the flood group that follows because it cannot |
| 3766 | find the lag group it points to (because it did not get created). |
| 3767 | """ |
| 3768 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True) |
| 3769 | |
| 3770 | # create l2 flood group to point to lag group |
| 3771 | floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 ) |
| 3772 | Groups.put( floodmsg.group_id, l2_i_gid, lag_gid ) |
| 3773 | Groups.put( l2_o_gid ) |
| 3774 | |
| 3775 | finally: |
| 3776 | #print("done") |
| 3777 | delete_all_flows( self.controller ) |
| 3778 | delete_groups( self.controller, Groups ) |
| 3779 | delete_all_groups( self.controller ) |
| 3780 | |
| 3781 | |
| 3782 | @disabled |
| 3783 | class LagXconn( base_tests.SimpleDataPlane ): |
| 3784 | """ |
| 3785 | Checks the L2 load balancing (LAG) with vlan crossconnects. |
| 3786 | Note that for this to work, basic VlanCrossConnect test above (without LAG) should work first |
| 3787 | Note: this doesn't work on XGS or QMX yet with premium 1.1.7 |
| 3788 | """ |
| 3789 | def runTest( self ): |
| 3790 | Groups = Queue.LifoQueue( ) |
| 3791 | try: |
| 3792 | if len( config[ "port_map" ] ) < 2: |
| 3793 | logging.info( "Port count less than 2, can't run this case" ) |
| 3794 | return |
| 3795 | |
| 3796 | ports = sorted(config[ "port_map" ].keys( )) |
| 3797 | in_port = ports[0] |
| 3798 | out_port = ports[1] |
| 3799 | |
| 3800 | # add l2 interface unfiltered group |
| 3801 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3802 | |
| 3803 | # create l2 load-balance group |
| 3804 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3805 | Groups.put(l2_o_gid, lag_gid) |
| 3806 | |
| 3807 | # a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 3808 | sub_info = [10, 0xc0a80001, 12, 11, "192.168.0.1"] |
| 3809 | |
| 3810 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3811 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3812 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3813 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3814 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3815 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3816 | |
| 3817 | dip = sub_info[1] |
| 3818 | ports = config[ "port_map" ].keys( ) |
| 3819 | inner_vlan = sub_info[2] |
| 3820 | outer_vlan = sub_info[3] |
| 3821 | index = inner_vlan |
| 3822 | port = ports[0] |
| 3823 | out_port = ports[1] |
| 3824 | |
| 3825 | # add vlan flow table |
| 3826 | add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 3827 | add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan, outer_vlan_id=outer_vlan, |
| 3828 | inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True) |
| 3829 | """ |
| 3830 | XXX The following flow in table 13 is rejected by the switch (qmx) probably due to the reference to lag group |
| 3831 | ofdpa logs say: 08-22 00:43:10.344338 [ofstatemanager] Error from Forwarding while inserting flow: Unknown error |
| 3832 | """ |
| 3833 | add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=lag_gid, |
| 3834 | qos_index=0, goto=ACL_FLOW_TABLE) |
| 3835 | do_barrier( self.controller ) |
| 3836 | |
| 3837 | ip_src = sub_info[4] |
| 3838 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3839 | parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan, |
| 3840 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3841 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True, |
| 3842 | in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan, |
| 3843 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, |
| 3844 | ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3845 | |
| 3846 | pkt = str( parsed_pkt ) |
| 3847 | self.dataplane.send( port, pkt ) |
| 3848 | verify_packet( self, pkt, out_port ) |
| 3849 | verify_no_other_packets( self ) |
| 3850 | |
| 3851 | finally: |
| 3852 | #print("done") |
| 3853 | delete_all_flows( self.controller ) |
| 3854 | delete_groups( self.controller, Groups ) |
| 3855 | delete_all_groups( self.controller ) |
| 3856 | |
| 3857 | @disabled |
| 3858 | class LagRouting( base_tests.SimpleDataPlane ): |
| 3859 | """ |
| 3860 | Checks the L2 load balancing (LAG) with routing flows. |
| 3861 | Specifically route -> L3Unicast -> Lag -> L2 Unfiltered interface |
| 3862 | """ |
| 3863 | def runTest( self ): |
| 3864 | Groups = Queue.LifoQueue( ) |
| 3865 | try: |
| 3866 | if len( config[ "port_map" ] ) < 2: |
| 3867 | logging.info( "Port count less than 2, can't run this case" ) |
| 3868 | return |
| 3869 | |
| 3870 | ports = sorted(config[ "port_map" ].keys( )) |
| 3871 | in_port = ports[0] |
| 3872 | out_port = ports[1] |
| 3873 | |
| 3874 | # add l2 interface unfiltered group |
| 3875 | l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3876 | |
| 3877 | # create l2 load-balance group |
| 3878 | lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True) |
| 3879 | Groups.put(l2_o_gid, lag_gid) |
| 3880 | |
| 3881 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3882 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3883 | dip = 0xc0a80001 |
| 3884 | vlan_id = 31 |
| 3885 | |
| 3886 | # create L3 Unicast group to point to Lag group |
| 3887 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=vlan_id, id=vlan_id, |
| 3888 | src_mac=intf_src_mac, dst_mac=dst_mac, gid=lag_gid ) |
| 3889 | # add vlan flow table |
| 3890 | add_one_vlan_table_flow( self.controller, in_port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 3891 | # add termination flow |
| 3892 | if config["switch_type"] == "qmx": |
| 3893 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 3894 | else: |
| 3895 | add_termination_flow( self.controller, in_port, 0x0800, intf_src_mac, vlan_id ) |
| 3896 | # add unicast routing flow |
| 3897 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id ) |
| 3898 | |
| 3899 | Groups.put( l3_msg.group_id ) |
| 3900 | do_barrier( self.controller ) |
| 3901 | |
| 3902 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 3903 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 3904 | ip_src = '192.168.0.2' |
| 3905 | ip_dst = '192.168.0.1' |
| 3906 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 3907 | vlan_vid=vlan_id, eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 3908 | ip_src=ip_src, ip_dst=ip_dst ) |
| 3909 | pkt = str( parsed_pkt ) |
| 3910 | self.dataplane.send( in_port, pkt ) |
| 3911 | # build expected packet |
| 3912 | mac_dst = '00:00:00:22:22:00' |
| 3913 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 3914 | vlan_vid=vlan_id, eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 3915 | ip_src=ip_src, ip_dst=ip_dst ) |
| 3916 | pkt = str( exp_pkt ) |
| 3917 | verify_packet( self, pkt, out_port ) |
| 3918 | verify_no_other_packets( self ) |
| 3919 | |
| 3920 | finally: |
| 3921 | #print("done") |
| 3922 | delete_all_flows( self.controller ) |
| 3923 | delete_groups( self.controller, Groups ) |
| 3924 | delete_all_groups( self.controller ) |