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 ) |
| 484 | print("done") |
| 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 | |
| 1365 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1366 | """ |
| 1367 | Mcast routing, in this test case the traffic is untagged. |
| 1368 | 4094 is used as internal vlan_id. The packet goes out |
| 1369 | untagged. |
| 1370 | """ |
| 1371 | def runTest( self ): |
| 1372 | Groups = Queue.LifoQueue( ) |
| 1373 | try: |
| 1374 | if len( config[ "port_map" ] ) < 2: |
| 1375 | logging.info( "Port count less than 2, can't run this case" ) |
| 1376 | assert (False) |
| 1377 | return |
| 1378 | ports = config[ "port_map" ].keys( ) |
| 1379 | dst_ip_str = "224.0.0.1" |
| 1380 | ( |
| 1381 | port_to_in_vlan, |
| 1382 | port_to_out_vlan, |
| 1383 | port_to_src_mac_str, |
| 1384 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1385 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1386 | port_to_src_ip_str, |
| 1387 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1388 | self.controller, |
| 1389 | logging, |
| 1390 | ports, |
| 1391 | is_ingress_tagged = False, |
| 1392 | is_egress_tagged = False, |
| 1393 | is_vlan_translated = False, |
| 1394 | is_max_vlan = True |
| 1395 | ) |
| 1396 | |
| 1397 | for in_port in ports: |
| 1398 | |
| 1399 | parsed_pkt = simple_udp_packet( |
| 1400 | pktlen = 96, |
| 1401 | eth_dst = port_to_dst_mac_str[in_port], |
| 1402 | eth_src = port_to_src_mac_str[in_port], |
| 1403 | ip_ttl = 64, |
| 1404 | ip_src = port_to_src_ip_str[in_port], |
| 1405 | ip_dst = dst_ip_str |
| 1406 | ) |
| 1407 | pkt = str( parsed_pkt ) |
| 1408 | self.dataplane.send( in_port, pkt ) |
| 1409 | |
| 1410 | for out_port in ports: |
| 1411 | |
| 1412 | parsed_pkt = simple_udp_packet( |
| 1413 | pktlen = 96, |
| 1414 | eth_dst = port_to_dst_mac_str[in_port], |
| 1415 | eth_src = port_to_src_mac_str[in_port], |
| 1416 | ip_ttl = 64, |
| 1417 | ip_src = port_to_src_ip_str[in_port], |
| 1418 | ip_dst = dst_ip_str |
| 1419 | ) |
| 1420 | pkt = str( parsed_pkt ) |
| 1421 | if out_port == in_port: |
| 1422 | verify_no_packet( self, pkt, in_port ) |
| 1423 | continue |
| 1424 | verify_packet( self, pkt, out_port ) |
| 1425 | verify_no_other_packets( self ) |
| 1426 | finally: |
| 1427 | delete_all_flows( self.controller ) |
| 1428 | delete_groups( self.controller, Groups ) |
| 1429 | delete_all_groups( self.controller ) |
| 1430 | |
| 1431 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1432 | """ |
| 1433 | Mcast routing, in this test case the traffic is untagged. |
| 1434 | 300 is used as vlan_id. The packet goes out |
| 1435 | tagged. |
| 1436 | """ |
| 1437 | def runTest( self ): |
| 1438 | Groups = Queue.LifoQueue( ) |
| 1439 | try: |
| 1440 | if len( config[ "port_map" ] ) < 2: |
| 1441 | logging.info( "Port count less than 2, can't run this case" ) |
| 1442 | assert (False) |
| 1443 | return |
| 1444 | ports = config[ "port_map" ].keys( ) |
| 1445 | dst_ip_str = "224.0.0.1" |
| 1446 | ( |
| 1447 | port_to_in_vlan, |
| 1448 | port_to_out_vlan, |
| 1449 | port_to_src_mac_str, |
| 1450 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1451 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1452 | port_to_src_ip_str, |
| 1453 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1454 | self.controller, |
| 1455 | logging, |
| 1456 | ports, |
| 1457 | is_ingress_tagged = False, |
| 1458 | is_egress_tagged = True, |
| 1459 | is_vlan_translated = False, |
| 1460 | is_max_vlan = False |
| 1461 | ) |
| 1462 | |
| 1463 | for in_port in ports: |
| 1464 | |
| 1465 | parsed_pkt = simple_udp_packet( |
| 1466 | pktlen = 96, |
| 1467 | eth_dst = port_to_dst_mac_str[in_port], |
| 1468 | eth_src = port_to_src_mac_str[in_port], |
| 1469 | ip_ttl = 64, |
| 1470 | ip_src = port_to_src_ip_str[in_port], |
| 1471 | ip_dst = dst_ip_str |
| 1472 | ) |
| 1473 | pkt = str( parsed_pkt ) |
| 1474 | self.dataplane.send( in_port, pkt ) |
| 1475 | |
| 1476 | for out_port in ports: |
| 1477 | |
| 1478 | parsed_pkt = simple_udp_packet( |
| 1479 | pktlen = 100, |
| 1480 | dl_vlan_enable = True, |
| 1481 | vlan_vid = port_to_out_vlan[in_port], |
| 1482 | eth_dst = port_to_dst_mac_str[in_port], |
| 1483 | eth_src = port_to_src_mac_str[in_port], |
| 1484 | ip_ttl = 64, |
| 1485 | ip_src = port_to_src_ip_str[in_port], |
| 1486 | ip_dst = dst_ip_str |
| 1487 | ) |
| 1488 | pkt = str( parsed_pkt ) |
| 1489 | if out_port == in_port: |
| 1490 | verify_no_packet( self, pkt, in_port ) |
| 1491 | continue |
| 1492 | verify_packet( self, pkt, out_port ) |
| 1493 | verify_no_other_packets( self ) |
| 1494 | finally: |
| 1495 | delete_all_flows( self.controller ) |
| 1496 | delete_groups( self.controller, Groups ) |
| 1497 | delete_all_groups( self.controller ) |
| 1498 | |
| 1499 | |
| 1500 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1501 | """ |
| 1502 | Mcast routing, in this test case the traffic is tagged. |
| 1503 | 300 is used as vlan_id. The packet goes out |
| 1504 | untagged. |
| 1505 | """ |
| 1506 | def runTest( self ): |
| 1507 | Groups = Queue.LifoQueue( ) |
| 1508 | try: |
| 1509 | if len( config[ "port_map" ] ) < 2: |
| 1510 | logging.info( "Port count less than 2, can't run this case" ) |
| 1511 | assert (False) |
| 1512 | return |
| 1513 | ports = config[ "port_map" ].keys( ) |
| 1514 | dst_ip_str = "224.0.0.1" |
| 1515 | ( |
| 1516 | port_to_in_vlan, |
| 1517 | port_to_out_vlan, |
| 1518 | port_to_src_mac_str, |
| 1519 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1520 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1521 | port_to_src_ip_str, |
| 1522 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1523 | self.controller, |
| 1524 | logging, |
| 1525 | ports, |
| 1526 | is_ingress_tagged = True, |
| 1527 | is_egress_tagged = False, |
| 1528 | is_vlan_translated = False, |
| 1529 | is_max_vlan = False |
| 1530 | ) |
| 1531 | |
| 1532 | for in_port in ports: |
| 1533 | |
| 1534 | parsed_pkt = simple_udp_packet( |
| 1535 | pktlen = 100, |
| 1536 | dl_vlan_enable = True, |
| 1537 | vlan_vid = port_to_in_vlan[in_port], |
| 1538 | eth_dst = port_to_dst_mac_str[in_port], |
| 1539 | eth_src = port_to_src_mac_str[in_port], |
| 1540 | ip_ttl = 64, |
| 1541 | ip_src = port_to_src_ip_str[in_port], |
| 1542 | ip_dst = dst_ip_str |
| 1543 | ) |
| 1544 | pkt = str( parsed_pkt ) |
| 1545 | self.dataplane.send( in_port, pkt ) |
| 1546 | |
| 1547 | for out_port in ports: |
| 1548 | |
| 1549 | parsed_pkt = simple_udp_packet( |
| 1550 | pktlen = 96, |
| 1551 | eth_dst = port_to_dst_mac_str[in_port], |
| 1552 | eth_src = port_to_src_mac_str[in_port], |
| 1553 | ip_ttl = 64, |
| 1554 | ip_src = port_to_src_ip_str[in_port], |
| 1555 | ip_dst = dst_ip_str |
| 1556 | ) |
| 1557 | pkt = str( parsed_pkt ) |
| 1558 | if out_port == in_port: |
| 1559 | verify_no_packet( self, pkt, in_port ) |
| 1560 | continue |
| 1561 | verify_packet( self, pkt, out_port ) |
| 1562 | verify_no_other_packets( self ) |
| 1563 | finally: |
| 1564 | delete_all_flows( self.controller ) |
| 1565 | delete_groups( self.controller, Groups ) |
| 1566 | delete_all_groups( self.controller ) |
| 1567 | |
| 1568 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1569 | """ |
| 1570 | Mcast routing, in this test case the traffic is tagged. |
| 1571 | 300 is used as vlan_id. The packet goes out tagged. |
| 1572 | """ |
| 1573 | def runTest( self ): |
| 1574 | Groups = Queue.LifoQueue( ) |
| 1575 | try: |
| 1576 | if len( config[ "port_map" ] ) < 2: |
| 1577 | logging.info( "Port count less than 2, can't run this case" ) |
| 1578 | assert (False) |
| 1579 | return |
| 1580 | ports = config[ "port_map" ].keys( ) |
| 1581 | dst_ip_str = "224.0.0.1" |
| 1582 | ( |
| 1583 | port_to_in_vlan, |
| 1584 | port_to_out_vlan, |
| 1585 | port_to_src_mac_str, |
| 1586 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1587 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1588 | port_to_src_ip_str, |
| 1589 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1590 | self.controller, |
| 1591 | logging, |
| 1592 | ports, |
| 1593 | is_ingress_tagged = True, |
| 1594 | is_egress_tagged = True, |
| 1595 | is_vlan_translated = False, |
| 1596 | is_max_vlan = False |
| 1597 | ) |
| 1598 | |
| 1599 | for in_port in ports: |
| 1600 | |
| 1601 | parsed_pkt = simple_udp_packet( |
| 1602 | pktlen = 100, |
| 1603 | dl_vlan_enable = True, |
| 1604 | vlan_vid = port_to_in_vlan[in_port], |
| 1605 | eth_dst = port_to_dst_mac_str[in_port], |
| 1606 | eth_src = port_to_src_mac_str[in_port], |
| 1607 | ip_ttl = 64, |
| 1608 | ip_src = port_to_src_ip_str[in_port], |
| 1609 | ip_dst = dst_ip_str |
| 1610 | ) |
| 1611 | pkt = str( parsed_pkt ) |
| 1612 | self.dataplane.send( in_port, pkt ) |
| 1613 | |
| 1614 | for out_port in ports: |
| 1615 | |
| 1616 | parsed_pkt = simple_udp_packet( |
| 1617 | pktlen = 100, |
| 1618 | dl_vlan_enable = True, |
| 1619 | vlan_vid = port_to_in_vlan[in_port], |
| 1620 | eth_dst = port_to_dst_mac_str[in_port], |
| 1621 | eth_src = port_to_src_mac_str[in_port], |
| 1622 | ip_ttl = 64, |
| 1623 | ip_src = port_to_src_ip_str[in_port], |
| 1624 | ip_dst = dst_ip_str |
| 1625 | ) |
| 1626 | pkt = str( parsed_pkt ) |
| 1627 | if out_port == in_port: |
| 1628 | verify_no_packet( self, pkt, in_port ) |
| 1629 | continue |
| 1630 | verify_packet( self, pkt, out_port ) |
| 1631 | verify_no_other_packets( self ) |
| 1632 | finally: |
| 1633 | delete_all_flows( self.controller ) |
| 1634 | delete_groups( self.controller, Groups ) |
| 1635 | delete_all_groups( self.controller ) |
| 1636 | |
| 1637 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1638 | """ |
| 1639 | Mcast routing, in this test case the traffic is tagged. |
| 1640 | port+1 is used as ingress vlan_id. The packet goes out |
| 1641 | tagged. 4094-port is used as egress vlan_id |
| 1642 | """ |
| 1643 | def runTest( self ): |
| 1644 | Groups = Queue.LifoQueue( ) |
| 1645 | try: |
| 1646 | if len( config[ "port_map" ] ) < 2: |
| 1647 | logging.info( "Port count less than 2, can't run this case" ) |
| 1648 | assert (False) |
| 1649 | return |
| 1650 | ports = config[ "port_map" ].keys( ) |
| 1651 | dst_ip_str = "224.0.0.1" |
| 1652 | ( |
| 1653 | port_to_in_vlan, |
| 1654 | port_to_out_vlan, |
| 1655 | port_to_src_mac_str, |
| 1656 | port_to_dst_mac_str, |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1657 | port_to_src_ip, |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1658 | port_to_src_ip_str, |
| 1659 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1660 | self.controller, |
| 1661 | logging, |
| 1662 | ports, |
| 1663 | is_ingress_tagged = True, |
| 1664 | is_egress_tagged = True, |
| 1665 | is_vlan_translated = True, |
| 1666 | is_max_vlan = False |
| 1667 | ) |
| 1668 | |
| 1669 | for in_port in ports: |
| 1670 | |
| 1671 | parsed_pkt = simple_udp_packet( |
| 1672 | pktlen = 100, |
| 1673 | dl_vlan_enable = True, |
| 1674 | vlan_vid = port_to_in_vlan[in_port], |
| 1675 | eth_dst = port_to_dst_mac_str[in_port], |
| 1676 | eth_src = port_to_src_mac_str[in_port], |
| 1677 | ip_ttl = 64, |
| 1678 | ip_src = port_to_src_ip_str[in_port], |
| 1679 | ip_dst = dst_ip_str |
| 1680 | ) |
| 1681 | pkt = str( parsed_pkt ) |
| 1682 | self.dataplane.send( in_port, pkt ) |
| 1683 | |
| 1684 | for out_port in ports: |
| 1685 | |
| 1686 | parsed_pkt = simple_udp_packet( |
| 1687 | pktlen = 100, |
| 1688 | dl_vlan_enable = True, |
| 1689 | vlan_vid = port_to_out_vlan[in_port], |
| 1690 | eth_dst = port_to_dst_mac_str[in_port], |
| 1691 | eth_src = port_to_src_mac_str[in_port], |
| 1692 | ip_ttl = 64, |
| 1693 | ip_src = port_to_src_ip_str[in_port], |
| 1694 | ip_dst = dst_ip_str |
| 1695 | ) |
| 1696 | pkt = str( parsed_pkt ) |
| 1697 | if out_port == in_port: |
| 1698 | verify_no_packet( self, pkt, in_port ) |
| 1699 | continue |
| 1700 | verify_packet( self, pkt, out_port ) |
| 1701 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1702 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1703 | delete_all_flows( self.controller ) |
| 1704 | delete_groups( self.controller, Groups ) |
| 1705 | delete_all_groups( self.controller ) |
| 1706 | |
Andrea Campanella | 0ea9632 | 2018-04-19 19:11:49 +0200 | [diff] [blame] | 1707 | class L3McastTrafficThenDrop( base_tests.SimpleDataPlane ): |
| 1708 | """ |
| 1709 | Mcast routing, in this test case the traffic is untagged. |
| 1710 | 4094 is used as internal vlan_id. We first install aa full pipeline, |
| 1711 | test that it forwards properly then remove all rules on table 40 and |
| 1712 | mcast groups and ensure traffic is dropped. Blackhole of mcast traffic |
| 1713 | if no tree is programmed on the switch. |
| 1714 | """ |
| 1715 | def runTest( self ): |
| 1716 | Groups = Queue.LifoQueue( ) |
| 1717 | try: |
| 1718 | if len( config[ "port_map" ] ) < 2: |
| 1719 | logging.info( "Port count less than 2, can't run this case" ) |
| 1720 | assert (False) |
| 1721 | return |
| 1722 | ports = config[ "port_map" ].keys( ) |
| 1723 | dst_ip_str = "224.0.0.1" |
| 1724 | ( |
| 1725 | port_to_in_vlan, |
| 1726 | port_to_out_vlan, |
| 1727 | port_to_src_mac_str, |
| 1728 | port_to_dst_mac_str, |
| 1729 | port_to_src_ip, |
| 1730 | port_to_src_ip_str, |
| 1731 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1732 | self.controller, |
| 1733 | logging, |
| 1734 | ports, |
| 1735 | is_ingress_tagged = False, |
| 1736 | is_egress_tagged = False, |
| 1737 | is_vlan_translated = False, |
| 1738 | is_max_vlan = True |
| 1739 | ) |
| 1740 | |
| 1741 | for in_port in ports: |
| 1742 | |
| 1743 | parsed_pkt = simple_udp_packet( |
| 1744 | pktlen = 96, |
| 1745 | eth_dst = port_to_dst_mac_str[in_port], |
| 1746 | eth_src = port_to_src_mac_str[in_port], |
| 1747 | ip_ttl = 64, |
| 1748 | ip_src = port_to_src_ip_str[in_port], |
| 1749 | ip_dst = dst_ip_str |
| 1750 | ) |
| 1751 | pkt = str( parsed_pkt ) |
| 1752 | self.dataplane.send( in_port, pkt ) |
| 1753 | |
| 1754 | for out_port in ports: |
| 1755 | |
| 1756 | parsed_pkt = simple_udp_packet( |
| 1757 | pktlen = 96, |
| 1758 | eth_dst = port_to_dst_mac_str[in_port], |
| 1759 | eth_src = port_to_src_mac_str[in_port], |
| 1760 | ip_ttl = 64, |
| 1761 | ip_src = port_to_src_ip_str[in_port], |
| 1762 | ip_dst = dst_ip_str |
| 1763 | ) |
| 1764 | pkt = str( parsed_pkt ) |
| 1765 | if out_port == in_port: |
| 1766 | verify_no_packet( self, pkt, in_port ) |
| 1767 | continue |
| 1768 | verify_packet( self, pkt, out_port ) |
| 1769 | verify_no_other_packets( self ) |
| 1770 | |
| 1771 | delete_all_flows_one_table(ctrl=self.controller, logger=logging, table_id=40); |
| 1772 | delete_all_groups(self.controller) |
| 1773 | |
| 1774 | for in_port in ports: |
| 1775 | |
| 1776 | parsed_pkt = simple_udp_packet( |
| 1777 | pktlen = 96, |
| 1778 | eth_dst = port_to_dst_mac_str[in_port], |
| 1779 | eth_src = port_to_src_mac_str[in_port], |
| 1780 | ip_ttl = 64, |
| 1781 | ip_src = port_to_src_ip_str[in_port], |
| 1782 | ip_dst = dst_ip_str |
| 1783 | ) |
| 1784 | pkt = str( parsed_pkt ) |
| 1785 | self.dataplane.send( in_port, pkt ) |
| 1786 | |
| 1787 | for out_port in ports: |
| 1788 | |
| 1789 | parsed_pkt = simple_udp_packet( |
| 1790 | pktlen = 96, |
| 1791 | eth_dst = port_to_dst_mac_str[in_port], |
| 1792 | eth_src = port_to_src_mac_str[in_port], |
| 1793 | ip_ttl = 64, |
| 1794 | ip_src = port_to_src_ip_str[in_port], |
| 1795 | ip_dst = dst_ip_str |
| 1796 | ) |
| 1797 | pkt = str( parsed_pkt ) |
| 1798 | if out_port == in_port: |
| 1799 | verify_no_packet( self, pkt, in_port ) |
| 1800 | continue |
| 1801 | verify_no_packet( self, pkt, out_port ) |
| 1802 | verify_no_other_packets( self ) |
| 1803 | finally: |
| 1804 | delete_all_flows( self.controller ) |
| 1805 | delete_groups( self.controller, Groups ) |
| 1806 | delete_all_groups( self.controller ) |
| 1807 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1808 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1809 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1810 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1811 | |
| 1812 | def runTest( self ): |
| 1813 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1814 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1815 | if len( config[ "port_map" ] ) < 2: |
| 1816 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1817 | return |
| 1818 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1819 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1820 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1821 | # 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] | 1822 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1823 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1824 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1825 | vlan_id = port + 16 |
| 1826 | mpls_label = port + 16 |
| 1827 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1828 | # add l2 interface group |
| 1829 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1830 | 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] | 1831 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1832 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1833 | vlan_id, id ) |
| 1834 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1835 | 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] | 1836 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1837 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1838 | # 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] | 1839 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1840 | 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] | 1841 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1842 | if config["switch_type"] == "qmx": |
| 1843 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1844 | else: |
| 1845 | 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] | 1846 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1847 | if config["switch_type"] != 'xpliant': |
| 1848 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| 1849 | else: |
| 1850 | 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] | 1851 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1852 | Groups._put( l2_gid ) |
| 1853 | Groups._put( mpls_gid ) |
| 1854 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1855 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1856 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1857 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1858 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1859 | for in_port in ports: |
| 1860 | ip_src = '192.168.%02d.1' % (in_port) |
| 1861 | for out_port in ports: |
| 1862 | if in_port == out_port: |
| 1863 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1864 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1865 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1866 | out_mpls_label = out_port + 16 |
| 1867 | in_vlan_vid = in_port + 16 |
| 1868 | out_vlan_vid = out_port + 16 |
| 1869 | |
| 1870 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1871 | label = (out_mpls_label, 0, 1, 32) |
| 1872 | 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] | 1873 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1874 | pkt = str( parsed_pkt ) |
| 1875 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1876 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1877 | # build expect packet |
| 1878 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1879 | label = (out_mpls_label, 0, 1, 31) |
| 1880 | 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] | 1881 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1882 | label=[ label ] ) |
| 1883 | pkt = str( exp_pkt ) |
| 1884 | verify_packet( self, pkt, out_port ) |
| 1885 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1886 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1887 | delete_all_flows( self.controller ) |
| 1888 | delete_groups( self.controller, Groups ) |
| 1889 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1890 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1891 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1892 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1893 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1894 | |
| 1895 | def runTest( self ): |
| 1896 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1897 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1898 | if len( config[ "port_map" ] ) < 2: |
| 1899 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1900 | return |
| 1901 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1902 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1903 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1904 | # 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] | 1905 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1906 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1907 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1908 | vlan_id = port + 16 |
| 1909 | mpls_label = port + 16 |
| 1910 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1911 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1912 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1913 | 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] | 1914 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1915 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1916 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1917 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1918 | 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] | 1919 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1920 | 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] | 1921 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 1922 | if config["switch_type"] == "qmx": |
| 1923 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1924 | else: |
| 1925 | 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] | 1926 | |
| 1927 | if config["switch_type"] != 'xpliant': |
| 1928 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1929 | else: |
| 1930 | xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| 1931 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1932 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1933 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1934 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1935 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1936 | Groups._put( l2_gid ) |
| 1937 | Groups._put( l3_msg.group_id ) |
| 1938 | Groups._put( ecmp_msg.group_id ) |
| 1939 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1940 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1941 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1942 | for in_port in ports: |
| 1943 | ip_src = '192.168.%02d.1' % (in_port) |
| 1944 | for out_port in ports: |
| 1945 | if in_port == out_port: |
| 1946 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1947 | |
| 1948 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1949 | out_mpls_label = out_port + 16 |
| 1950 | in_vlan_vid = in_port + 16 |
| 1951 | out_vlan_vid = out_port + 16 |
| 1952 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1953 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1954 | label = (out_mpls_label, 0, 1, 32) |
| 1955 | 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] | 1956 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1957 | pkt = str( parsed_pkt ) |
| 1958 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1959 | # build expect packet |
| 1960 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 1961 | if config["switch_type"] != 'xpliant': |
| 1962 | ip_ttl=31 |
| 1963 | else: |
| 1964 | ip_ttl=64 |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1965 | 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] | 1966 | 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] | 1967 | pkt = str( exp_pkt ) |
| 1968 | verify_packet( self, pkt, out_port ) |
| 1969 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1970 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1971 | delete_all_flows( self.controller ) |
| 1972 | delete_groups( self.controller, Groups ) |
| 1973 | delete_all_groups( self.controller ) |
Saurav Das | 15c2c26 | 2017-05-06 18:12:38 -0700 | [diff] [blame] | 1974 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1975 | |
| 1976 | @disabled |
| 1977 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1978 | """ |
| 1979 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1980 | """ |
| 1981 | |
| 1982 | def runTest( self ): |
| 1983 | Groups = Queue.LifoQueue( ) |
| 1984 | try: |
| 1985 | if len( config[ "port_map" ] ) < 2: |
| 1986 | logging.info( "Port count less than 2, can't run this case" ) |
| 1987 | return |
| 1988 | dip = 0xc0a80001 |
| 1989 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1990 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1991 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1992 | ports = config[ "port_map" ].keys( ) |
| 1993 | inport = ports[0] |
| 1994 | outport = ports[1] |
| 1995 | |
| 1996 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1997 | invlan_id = inport + 16 |
| 1998 | outvlan_id = outport + 16 |
| 1999 | mpls_label = outport + 16 |
| 2000 | |
| 2001 | # add l2 interface group |
| 2002 | id, dst_mac[ 5 ] = inport, outport |
| 2003 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 2004 | # add L3 Unicast group |
| 2005 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 2006 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 2007 | # add L3 ecmp group |
| 2008 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 2009 | # add vlan flow table |
| 2010 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2011 | # add tmac flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2012 | if config["switch_type"] == "qmx": |
| 2013 | add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 2014 | else: |
| 2015 | 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] | 2016 | # add mpls termination flow |
| 2017 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 2018 | Groups._put( l2_gid ) |
| 2019 | Groups._put( l3_msg.group_id ) |
| 2020 | Groups._put( ecmp_msg.group_id ) |
| 2021 | |
| 2022 | time.sleep(0.1) |
| 2023 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2024 | ip_src = '192.168.%02d.1' % (inport) |
| 2025 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 2026 | out_mpls_label = outport + 16 |
| 2027 | in_vlan_vid = inport + 16 |
| 2028 | out_vlan_vid = outport + 16 |
| 2029 | |
| 2030 | ip_dst = '192.168.%02d.1' % (outport) |
| 2031 | label = (out_mpls_label, 0, 1, 32) |
| 2032 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 2033 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 2034 | pkt = str( parsed_pkt ) |
| 2035 | self.dataplane.send( inport, pkt ) |
| 2036 | # build expect packet |
| 2037 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 2038 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 2039 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 2040 | pkt = str( exp_pkt ) |
| 2041 | verify_packet( self, pkt, outport ) |
| 2042 | verify_no_other_packets( self ) |
| 2043 | finally: |
| 2044 | delete_all_flows( self.controller ) |
| 2045 | delete_groups( self.controller, Groups ) |
| 2046 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 2047 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2048 | |
| 2049 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2050 | """ Verify /24 IP forwarding to L3 Interface """ |
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 | def runTest( self ): |
| 2053 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2054 | try: |
| 2055 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2056 | if len( config[ "port_map" ] ) < 2: |
| 2057 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2058 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2059 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2060 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2061 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2062 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2063 | for port in ports: |
| 2064 | # add l2 interface group |
| 2065 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2066 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2067 | is_tagged=True, send_barrier=False ) |
| 2068 | dst_mac[ 5 ] = vlan_id |
| 2069 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 2070 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2071 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2072 | 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] | 2073 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2074 | if config["switch_type"] == "qmx": |
| 2075 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2076 | else: |
| 2077 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2078 | # add unicast routing flow |
| 2079 | dst_ip = dip + (vlan_id << 8) |
Andrea Campanella | bfb42b3 | 2018-04-26 10:57:23 +0200 | [diff] [blame] | 2080 | # 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] | 2081 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 2082 | Groups.put( l2gid ) |
| 2083 | Groups.put( l3_msg.group_id ) |
| 2084 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 2085 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2086 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2087 | for in_port in ports: |
| 2088 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2089 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 2090 | for out_port in ports: |
| 2091 | if in_port == out_port: |
| 2092 | continue |
| 2093 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2094 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2095 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2096 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2097 | pkt = str( parsed_pkt ) |
| 2098 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2099 | # build expected packet |
| 2100 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2101 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2102 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2103 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2104 | pkt = str( exp_pkt ) |
| 2105 | verify_packet( self, pkt, out_port ) |
| 2106 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2107 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2108 | delete_all_flows( self.controller ) |
| 2109 | delete_groups( self.controller, Groups ) |
| 2110 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2111 | |
Andrea Campanella | bfb42b3 | 2018-04-26 10:57:23 +0200 | [diff] [blame] | 2112 | class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ): |
| 2113 | """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0""" |
| 2114 | |
| 2115 | def runTest( self ): |
| 2116 | Groups = Queue.LifoQueue( ) |
| 2117 | try: |
| 2118 | test_id = 27 |
| 2119 | if len( config[ "port_map" ] ) < 2: |
| 2120 | logging.info( "Port count less than 2, can't run this case" ) |
| 2121 | return |
| 2122 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2123 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2124 | dip = 0xc0a80001 |
| 2125 | ports = config[ "port_map" ].keys( ) |
| 2126 | for port in ports: |
| 2127 | # add l2 interface group |
| 2128 | vlan_id = port + test_id |
| 2129 | # add vlan flow table |
| 2130 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2131 | # add termination flow |
| 2132 | if config["switch_type"] == "qmx": |
| 2133 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2134 | else: |
| 2135 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2136 | # add unicast routing flow |
| 2137 | #dst ip = 10.0.0.0/8 |
| 2138 | dst_ip = 0x0a000000 |
| 2139 | add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 ) |
| 2140 | do_barrier( self.controller ) |
| 2141 | |
| 2142 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2143 | for in_port in ports: |
| 2144 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 2145 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 2146 | for out_port in ports: |
| 2147 | if in_port == out_port: |
| 2148 | continue |
| 2149 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 2150 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2151 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 2152 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2153 | pkt = str( parsed_pkt ) |
| 2154 | self.dataplane.send( in_port, pkt ) |
| 2155 | # build expected packet |
| 2156 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 2157 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 2158 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 2159 | ip_src=ip_src, ip_dst=ip_dst ) |
| 2160 | pkt = str( exp_pkt ) |
| 2161 | verify_no_packet( self, pkt, out_port ) |
| 2162 | verify_no_other_packets( self ) |
| 2163 | finally: |
| 2164 | delete_all_flows( self.controller ) |
| 2165 | delete_groups( self.controller, Groups ) |
| 2166 | delete_all_groups( self.controller ) |
| 2167 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2168 | |
| 2169 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2170 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2171 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2172 | def runTest( self ): |
| 2173 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2174 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2175 | if len( config[ "port_map" ] ) < 2: |
| 2176 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2177 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2178 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2179 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2180 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2181 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2182 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2183 | for port in ports: |
| 2184 | # add l2 interface group |
| 2185 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2186 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 2187 | is_tagged=True, send_barrier=False ) |
| 2188 | dst_mac[ 5 ] = vlan_id |
| 2189 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 2190 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2191 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2192 | 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] | 2193 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2194 | if config["switch_type"] == "qmx": |
| 2195 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2196 | else: |
| 2197 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2198 | # add unicast routing flow |
| 2199 | dst_ip = dip + (vlan_id << 8) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2200 | 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] | 2201 | Groups.put( l2gid ) |
| 2202 | Groups.put( l3_msg.group_id ) |
| 2203 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2204 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2205 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 2206 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2207 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2208 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2209 | for in_port in ports: |
| 2210 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 2211 | ip_src = '192.168.%02d.1' % (in_port) |
| 2212 | for out_port in ports: |
| 2213 | if in_port == out_port: |
| 2214 | continue |
| 2215 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2216 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 2217 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2218 | pkt = str( parsed_pkt ) |
| 2219 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2220 | # build expected packet |
| 2221 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2222 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 2223 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2224 | pkt = str( exp_pkt ) |
| 2225 | verify_packet( self, pkt, out_port ) |
| 2226 | verify_no_other_packets( self ) |
| 2227 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 2228 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 2229 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2230 | pkt = str( parsed_pkt ) |
| 2231 | self.dataplane.send( in_port, pkt ) |
| 2232 | # build expect packet |
| 2233 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2234 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 2235 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 2236 | pkt = str( exp_pkt ) |
| 2237 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2238 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2239 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2240 | delete_all_flows( self.controller ) |
| 2241 | delete_groups( self.controller, Groups ) |
| 2242 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2243 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2244 | |
| 2245 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2246 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2247 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2248 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2249 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2250 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2251 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2252 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2253 | vlan_id = 1; |
| 2254 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2255 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 2256 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2257 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2258 | delete_all_flows( self.controller ) |
| 2259 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 2260 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2261 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2262 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2263 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 2264 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2265 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2266 | |
| 2267 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2268 | """ |
| 2269 | port1 (vlan 1)-> port 2 (vlan 2) |
| 2270 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2271 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2272 | delete_all_flows( self.controller ) |
| 2273 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2274 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2275 | if len( config[ "port_map" ] ) < 3: |
| 2276 | logging.info( "Port count less than 3, can't run this case" ) |
| 2277 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2278 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2279 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2280 | vlan_id = 1 |
| 2281 | port2_out_vlan = 2 |
| 2282 | port3_out_vlan = 3 |
| 2283 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 2284 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2285 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 2286 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2287 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 2288 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 2289 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 2290 | src_ip = 0xc0a80101 |
| 2291 | src_ip_str = "192.168.1.1" |
| 2292 | dst_ip = 0xe0010101 |
| 2293 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2294 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2295 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 2296 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 2297 | # port3=config["port_map"].keys()[2] |
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 | # add l2 interface group |
| 2300 | for port in config[ "port_map" ].keys( ): |
| 2301 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 2302 | send_barrier=False ) |
| 2303 | # add vlan flow table |
| 2304 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2305 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2306 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2307 | # add termination flow |
| 2308 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 2309 | vlan_id ) |
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 MPLS interface group |
| 2312 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 2313 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 2314 | port2_out_vlan, port2 ) |
| 2315 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 2316 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 2317 | # add L3VPN groups |
| 2318 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2319 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 2320 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 2321 | # 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] | 2322 | # 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] | 2323 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2324 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 2325 | 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] | 2326 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2327 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 2328 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 2329 | pkt = str( parsed_pkt ) |
| 2330 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2331 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2332 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 2333 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 2334 | pkt = str( exp_pkt ) |
| 2335 | verify_packet( self, pkt, port2 ) |
| 2336 | # verify_packet(self, pkt, port3) |
| 2337 | verify_no_other_packets( self ) |
| 2338 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2339 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2340 | delete_all_flows( self.controller ) |
| 2341 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2342 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2343 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2344 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2345 | """ |
| 2346 | Test packet in function on a src-mac miss |
| 2347 | Send a packet to each dataplane port and verify that a packet |
| 2348 | in message is received from the controller for each |
| 2349 | #todo verify you stop receiving after adding rule |
| 2350 | """ |
| 2351 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2352 | def runTest( self ): |
| 2353 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2354 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2355 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2356 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2357 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2358 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2359 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 2360 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2361 | Groups.put( L2gid ) |
| 2362 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 2363 | vlan_pkt = str( parsed_vlan_pkt ) |
| 2364 | for of_port in config[ "port_map" ].keys( ): |
| 2365 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 2366 | self.dataplane.send( of_port, vlan_pkt ) |
| 2367 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 2368 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 2369 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2370 | delete_all_flows( self.controller ) |
| 2371 | delete_all_groups( self.controller ) |
| 2372 | |
| 2373 | |
| 2374 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 2375 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2376 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2377 | """ |
| 2378 | |
| 2379 | def runTest( self ): |
| 2380 | Groups = Queue.LifoQueue( ) |
| 2381 | try: |
| 2382 | if len( config[ "port_map" ] ) < 2: |
| 2383 | logging.info( "Port count less than 2, can't run this case" ) |
| 2384 | return |
| 2385 | |
| 2386 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2387 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2388 | dip = 0xc0a80001 |
| 2389 | # Hashes Test Name and uses it as id for installing unique groups |
| 2390 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2391 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2392 | dst_ips = [] |
| 2393 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2394 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2395 | for port in ports: |
| 2396 | vlan_id = port |
| 2397 | id = port |
| 2398 | # add l2 interface group |
| 2399 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2400 | is_tagged=True, send_barrier=False ) |
| 2401 | dst_mac[ 5 ] = vlan_id |
| 2402 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2403 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2404 | if port == ports[1]: |
| 2405 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2406 | Groups._put( l2_gid ) |
| 2407 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2408 | 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] | 2409 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2410 | 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] | 2411 | # add termination flow |
Saurav Das | e94ba57 | 2017-04-28 17:47:21 -0700 | [diff] [blame] | 2412 | if config["switch_type"] == "qmx": |
| 2413 | add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| 2414 | else: |
| 2415 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2416 | # add unicast routing flow |
| 2417 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2418 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2419 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2420 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2421 | for dst_ip in dst_ips: |
| 2422 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2423 | time.sleep(0.1) |
| 2424 | # 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] | 2425 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2426 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2427 | in_port = ports[0] |
| 2428 | out_port = ports[1] |
| 2429 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2430 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2431 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2432 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2433 | tcp = out_port if out_port == 24 else 25 |
| 2434 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2435 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2436 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2437 | pkt = str( parsed_pkt ) |
| 2438 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2439 | # build expected packet at egress switchport |
| 2440 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2441 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2442 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2443 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2444 | pkt = str( exp_pkt ) |
| 2445 | verify_packet( self, pkt, out_port ) |
| 2446 | verify_no_other_packets( self ) |
| 2447 | |
| 2448 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2449 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2450 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2451 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2452 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2453 | time.sleep(0.1) |
| 2454 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2455 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2456 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2457 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2458 | tcp = port if port == 24 else 25 |
| 2459 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2460 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2461 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2462 | pkt = str( parsed_pkt ) |
| 2463 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2464 | # build expected packet |
| 2465 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2466 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2467 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2468 | ip_dst=ip_dst,tcp_dport=tcp ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2469 | # Expects packet on the input port |
| 2470 | if config["switch_type"] != 'xpliant': |
| 2471 | pkt = str( exp_pkt ) |
| 2472 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2473 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2474 | |
| 2475 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2476 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2477 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2478 | time.sleep(0.1) |
| 2479 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2480 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2481 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2482 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2483 | tcp = port if port == 24 else 25 |
| 2484 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2485 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2486 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2487 | pkt = str( parsed_pkt ) |
| 2488 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2489 | verify_no_other_packets( self ) |
| 2490 | |
| 2491 | # final part of the test - edit the empty group to add back the bucket for the |
| 2492 | # original egress port, and verify packet is received on egress switch port |
| 2493 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2494 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Alex Yashchuk | 9f44946 | 2017-12-09 18:27:19 +0200 | [diff] [blame] | 2495 | do_barrier(self.controller) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2496 | in_port = ports[0] |
| 2497 | out_port = ports[1] |
| 2498 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2499 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2500 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2501 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2502 | tcp = out_port if out_port == 24 else 25 |
| 2503 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2504 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2505 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2506 | pkt = str( parsed_pkt ) |
| 2507 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2508 | # build expected packet at egress switchport |
| 2509 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2510 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2511 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2512 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2513 | pkt = str( exp_pkt ) |
| 2514 | verify_packet( self, pkt, out_port ) |
| 2515 | verify_no_other_packets( self ) |
| 2516 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2517 | finally: |
| 2518 | delete_all_flows( self.controller ) |
| 2519 | delete_groups( self.controller, Groups ) |
| 2520 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2521 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2522 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2523 | class Untagged( base_tests.SimpleDataPlane ): |
| 2524 | """ |
| 2525 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2526 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2527 | previous versions of the OFDPA. |
| 2528 | |
| 2529 | Two rules are necessary in VLAN table (10): |
| 2530 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2531 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2532 | |
| 2533 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2534 | The remaining part of the test is based on the use of the bridging table |
| 2535 | """ |
| 2536 | |
| 2537 | MAX_INTERNAL_VLAN = 4094 |
| 2538 | |
| 2539 | def runTest( self ): |
| 2540 | groups = Queue.LifoQueue( ) |
| 2541 | try: |
| 2542 | if len( config[ "port_map" ] ) < 2: |
| 2543 | logging.info( "Port count less than 2, can't run this case" ) |
| 2544 | return |
| 2545 | |
| 2546 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2547 | for port in ports: |
| 2548 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2549 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2550 | 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] | 2551 | for other_port in ports: |
| 2552 | if other_port == port: |
| 2553 | continue |
| 2554 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2555 | groups.put( L2gid ) |
| 2556 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2557 | |
| 2558 | do_barrier( self.controller ) |
| 2559 | |
| 2560 | for out_port in ports: |
| 2561 | # change dest based on port number |
| 2562 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2563 | for in_port in ports: |
| 2564 | if in_port == out_port: |
| 2565 | continue |
| 2566 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2567 | self.dataplane.send( in_port, pkt ) |
| 2568 | for ofport in ports: |
| 2569 | if ofport in [ out_port ]: |
| 2570 | verify_packet( self, pkt, ofport ) |
| 2571 | else: |
| 2572 | verify_no_packet( self, pkt, ofport ) |
| 2573 | verify_no_other_packets( self ) |
| 2574 | finally: |
| 2575 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2576 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2577 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 2578 | |
| 2579 | class MPLSSwapTest( base_tests.SimpleDataPlane ): |
| 2580 | """ |
| 2581 | MPLS switching with the same label used. |
| 2582 | Used for interconnecting spines between different fabrics where |
| 2583 | the label should not be popped, but swapepd with the same label. |
| 2584 | """ |
| 2585 | |
| 2586 | def runTest( self ): |
| 2587 | try: |
| 2588 | delete_all_flows( self.controller ) |
| 2589 | delete_all_groups( self.controller ) |
| 2590 | |
| 2591 | if len( config[ "port_map" ] ) < 2: |
| 2592 | logging.info( "Port count less than 3, can't run this case" ) |
| 2593 | assert (False) |
| 2594 | return |
| 2595 | |
| 2596 | input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 2597 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2598 | |
| 2599 | input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ] |
| 2600 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2601 | |
| 2602 | output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ] |
| 2603 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2604 | |
| 2605 | mpls_label = 1000 |
| 2606 | |
| 2607 | src_ip = 0xc0a80101 |
| 2608 | src_ip_str = "192.168.1.1" |
| 2609 | dst_ip = 0xe0010101 |
| 2610 | dst_ip_str = "224.1.1.1" |
| 2611 | |
| 2612 | src_port = config[ "port_map" ].keys( )[ 0 ] |
| 2613 | dst_port = config[ "port_map" ].keys( )[ 1 ] |
| 2614 | |
| 2615 | out_vlan = 4094 |
| 2616 | |
| 2617 | add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False, |
| 2618 | send_barrier=True ) |
| 2619 | |
| 2620 | # add vlan flow table |
| 2621 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2622 | add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2623 | |
| 2624 | # add termination flow |
| 2625 | |
| 2626 | if config["switch_type"] == "qmx": |
| 2627 | logging.debug("MPLSSwitching : Adding flow for qmx, without input port") |
| 2628 | add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2629 | else: |
| 2630 | add_termination_flow( self.controller, in_port=src_port, |
| 2631 | eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23) |
| 2632 | |
| 2633 | # add groups that will be used now |
| 2634 | l2_gid = encode_l2_interface_group_id( out_vlan, dst_port) |
| 2635 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, |
| 2636 | output_dst_mac, input_dst_mac, |
| 2637 | out_vlan, dst_port, send_barrier=True) |
| 2638 | index = 60 |
| 2639 | mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid, |
| 2640 | 5, index, mpls_label) |
| 2641 | |
| 2642 | # add flow to mpls table |
| 2643 | add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True) |
| 2644 | |
| 2645 | # we generate the packet which carries a single label |
| 2646 | label = (mpls_label, 0, 1, 63) |
| 2647 | parsed_pkt = mpls_packet( |
| 2648 | pktlen=104, |
| 2649 | label=[label], |
| 2650 | eth_src=input_src_mac_str, |
| 2651 | eth_dst=input_dst_mac_str, |
| 2652 | ) |
| 2653 | pkt = str( parsed_pkt ) |
| 2654 | self.dataplane.send( src_port, pkt ) |
| 2655 | |
| 2656 | label = (mpls_label, 0, 1, 62) |
| 2657 | parsed_pkt = mpls_packet( |
| 2658 | pktlen=104, |
| 2659 | label=[label], |
| 2660 | eth_src=input_dst_mac_str, |
| 2661 | eth_dst=output_dst_mac_str, |
| 2662 | ) |
| 2663 | pkt = str( parsed_pkt ) |
| 2664 | |
| 2665 | verify_packet( self, pkt, dst_port ) |
| 2666 | verify_no_packet( self, pkt, src_port ) |
| 2667 | verify_no_other_packets( self ) |
| 2668 | |
| 2669 | delete_all_flows( self.controller ) |
| 2670 | delete_all_groups( self.controller ) |
| 2671 | |
| 2672 | finally: |
| 2673 | delete_all_flows( self.controller ) |
| 2674 | delete_all_groups( self.controller ) |
| 2675 | |
Andreas Pantelopoulos | f83e021 | 2018-03-18 20:44:05 -0700 | [diff] [blame] | 2676 | class DoubleToUntagged( base_tests.SimpleDataPlane ): |
| 2677 | """ |
| 2678 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2679 | where we receive double tagged packets and output untagged |
| 2680 | packets. |
| 2681 | |
| 2682 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2683 | and inner tag is the subrscriber tag. |
| 2684 | """ |
| 2685 | |
| 2686 | def runTest( self ): |
| 2687 | Groups = Queue.LifoQueue( ) |
| 2688 | try: |
| 2689 | if len( config[ "port_map" ] ) < 2: |
| 2690 | logging.info( "Port count less than 2, can't run this case" ) |
| 2691 | return |
| 2692 | |
| 2693 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2694 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2695 | |
| 2696 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2697 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2698 | |
| 2699 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2700 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2701 | |
| 2702 | dip = 0xc0a80001 |
| 2703 | ports = config[ "port_map" ].keys( ) |
| 2704 | |
| 2705 | inner_vlan = 66 |
| 2706 | outer_vlan = 77 |
| 2707 | id = 10 |
| 2708 | mpls_label = 152 |
| 2709 | |
| 2710 | port = ports[0] |
| 2711 | out_port = ports[1] |
| 2712 | |
| 2713 | # add l2 interface group |
| 2714 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2715 | |
| 2716 | # add MPLS interface group |
| 2717 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2718 | inner_vlan, id ) |
| 2719 | |
| 2720 | # add MPLS L3 VPN group |
| 2721 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2722 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2723 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2724 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2725 | |
| 2726 | do_barrier( self.controller ) |
| 2727 | |
| 2728 | # add vlan flow table |
| 2729 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2730 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2731 | |
| 2732 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2733 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2734 | |
| 2735 | # add termination flow |
| 2736 | if config["switch_type"] == "qmx": |
| 2737 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2738 | else: |
| 2739 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2740 | |
| 2741 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2742 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2743 | vrf=0 ) |
| 2744 | Groups._put( l2_gid ) |
| 2745 | Groups._put( mpls_gid ) |
| 2746 | Groups._put( mpls_label_gid ) |
| 2747 | Groups._put( ecmp_msg.group_id ) |
| 2748 | |
| 2749 | do_barrier( self.controller ) |
| 2750 | |
| 2751 | ip_src = '192.168.5.5' |
| 2752 | ip_dst = '192.168.0.5' |
| 2753 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2754 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2755 | pkt = str( parsed_pkt ) |
| 2756 | |
| 2757 | # print("Expected %s" % format_packet(pkt)) |
| 2758 | |
| 2759 | self.dataplane.send( port, pkt ) |
| 2760 | |
| 2761 | # build expect packet |
| 2762 | label = (mpls_label, 0, 1, 32) |
| 2763 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2764 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2765 | label=[ label ] ) |
| 2766 | pkt = str( exp_pkt ) |
| 2767 | verify_packet( self, pkt, out_port ) |
| 2768 | verify_no_other_packets( self ) |
| 2769 | |
| 2770 | finally: |
| 2771 | delete_all_flows( self.controller ) |
| 2772 | delete_groups( self.controller, Groups ) |
| 2773 | delete_all_groups( self.controller ) |
| 2774 | |
| 2775 | class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ): |
| 2776 | """ |
| 2777 | Verify MPLS IP VPN Initiation from /24 rule using ECMP |
| 2778 | where we receive double tagged packets and output untagged |
| 2779 | packets. |
| 2780 | |
| 2781 | Each double tagged packet represents a subscriber where Outer tag is pon |
| 2782 | and inner tag is the subrscriber tag. |
| 2783 | """ |
| 2784 | |
| 2785 | def runTest( self ): |
| 2786 | Groups = Queue.LifoQueue( ) |
| 2787 | try: |
| 2788 | if len( config[ "port_map" ] ) < 2: |
| 2789 | logging.info( "Port count less than 2, can't run this case" ) |
| 2790 | return |
| 2791 | |
| 2792 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form] |
| 2793 | subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"], |
| 2794 | [20, 0xc0a80002, 10, 101, "192.168.0.2"], |
| 2795 | [30, 0xc0a80003, 11, 100, "192.168.0.3"], |
| 2796 | [40, 0xc0a80004, 11, 101, "192.168.0.4"]] |
| 2797 | |
| 2798 | print("") |
| 2799 | |
| 2800 | for sub_info in subscriber_info: |
| 2801 | |
| 2802 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 2803 | |
| 2804 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2805 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2806 | |
| 2807 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2808 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2809 | |
| 2810 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2811 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2812 | |
| 2813 | dip = sub_info[1] |
| 2814 | ports = config[ "port_map" ].keys( ) |
| 2815 | |
| 2816 | inner_vlan = sub_info[2] |
| 2817 | outer_vlan = sub_info[3] |
| 2818 | id = 10 |
| 2819 | mpls_label = 152 |
| 2820 | |
| 2821 | port = ports[0] |
| 2822 | out_port = ports[1] |
| 2823 | |
| 2824 | # add l2 interface group |
| 2825 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True ) |
| 2826 | |
| 2827 | # add MPLS interface group |
| 2828 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac, |
| 2829 | inner_vlan, id ) |
| 2830 | |
| 2831 | # add MPLS L3 VPN group |
| 2832 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 2833 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 2834 | push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 ) |
| 2835 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 2836 | |
| 2837 | do_barrier( self.controller ) |
| 2838 | |
| 2839 | # add vlan flow table |
| 2840 | add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0, |
| 2841 | flag=VLAN_TABLE_FLAG_ONLY_STACKED ) |
| 2842 | |
| 2843 | add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, |
| 2844 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| 2845 | |
| 2846 | # add termination flow |
| 2847 | if config["switch_type"] == "qmx": |
| 2848 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan ) |
| 2849 | else: |
| 2850 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan ) |
| 2851 | |
| 2852 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 2853 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id, |
| 2854 | vrf=0 ) |
| 2855 | Groups._put( l2_gid ) |
| 2856 | Groups._put( mpls_gid ) |
| 2857 | Groups._put( mpls_label_gid ) |
| 2858 | Groups._put( ecmp_msg.group_id ) |
| 2859 | |
| 2860 | do_barrier( self.controller ) |
| 2861 | |
| 2862 | for sub_info in subscriber_info: |
| 2863 | |
| 2864 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 2865 | |
| 2866 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 2867 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2868 | |
| 2869 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2870 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2871 | |
| 2872 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2873 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2874 | |
| 2875 | dip = sub_info[1] |
| 2876 | ports = config[ "port_map" ].keys( ) |
| 2877 | |
| 2878 | inner_vlan = sub_info[2] |
| 2879 | outer_vlan = sub_info[3] |
| 2880 | id = 10 |
| 2881 | mpls_label = 152 |
| 2882 | |
| 2883 | port = ports[0] |
| 2884 | out_port = ports[1] |
| 2885 | |
| 2886 | ip_src = sub_info[4] |
| 2887 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 2888 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2889 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2890 | pkt = str( parsed_pkt ) |
| 2891 | |
| 2892 | # print("Sent %s" % format_packet(pkt)) |
| 2893 | |
| 2894 | self.dataplane.send( port, pkt ) |
| 2895 | |
| 2896 | # build expect packet |
| 2897 | label = (mpls_label, 0, 1, 32) |
| 2898 | exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63, |
| 2899 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, |
| 2900 | label=[ label ] ) |
| 2901 | pkt = str( exp_pkt ) |
| 2902 | verify_packet( self, pkt, out_port ) |
| 2903 | verify_no_other_packets( self ) |
| 2904 | |
| 2905 | finally: |
| 2906 | delete_all_flows( self.controller ) |
| 2907 | delete_groups( self.controller, Groups ) |
| 2908 | delete_all_groups( self.controller ) |
| 2909 | |
| 2910 | |
| 2911 | class UntaggedToDouble ( base_tests.SimpleDataPlane ): |
| 2912 | """ |
| 2913 | Verify google senario where we need to go from |
| 2914 | an untagged packet to a double tagged packet. |
| 2915 | |
| 2916 | This is used for a single subscriber. |
| 2917 | """ |
| 2918 | |
| 2919 | def runTest( self ): |
| 2920 | Groups = Queue.LifoQueue( ) |
| 2921 | try: |
| 2922 | if len( config[ "port_map" ] ) < 2: |
| 2923 | logging.info( "Port count less than 2, can't run this case" ) |
| 2924 | return |
| 2925 | |
| 2926 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2927 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 2928 | |
| 2929 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2930 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 2931 | |
| 2932 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 2933 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 2934 | |
| 2935 | dip = 0xc0a80001 |
| 2936 | ports = config[ "port_map" ].keys( ) |
| 2937 | |
| 2938 | inner_vlan = 66 |
| 2939 | outer_vlan = 77 |
| 2940 | id = 10 |
| 2941 | mpls_label = 152 |
| 2942 | |
| 2943 | port = ports[0] |
| 2944 | out_port = ports[1] |
| 2945 | |
| 2946 | # add l2 unfiltered interface group |
| 2947 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 2948 | |
| 2949 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 2950 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 2951 | |
| 2952 | do_barrier( self.controller ) |
| 2953 | |
| 2954 | # add vlan flow table |
| 2955 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 2956 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 2957 | |
| 2958 | # add termination flow |
| 2959 | if config["switch_type"] == "qmx": |
| 2960 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 2961 | else: |
| 2962 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 2963 | |
| 2964 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 2965 | vrf=0 ) |
| 2966 | |
| 2967 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 2968 | |
| 2969 | Groups._put( l2_gid ) |
| 2970 | Groups._put( l3_msg.group_id ) |
| 2971 | |
| 2972 | do_barrier( self.controller ) |
| 2973 | |
| 2974 | ip_src = '192.168.5.5' |
| 2975 | ip_dst = '192.168.0.1' |
| 2976 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 2977 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 2978 | pkt = str( parsed_pkt ) |
| 2979 | |
| 2980 | # print("Input Packet %s" % format_packet(pkt)) |
| 2981 | |
| 2982 | self.dataplane.send( port, pkt ) |
| 2983 | |
| 2984 | # build expect packet |
| 2985 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 2986 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 2987 | pkt = str( exp_pkt ) |
| 2988 | |
| 2989 | # print("Expected Packet %s" % format_packet(pkt)) |
| 2990 | |
| 2991 | verify_packet( self, pkt, out_port ) |
| 2992 | verify_no_other_packets( self ) |
| 2993 | finally: |
| 2994 | delete_all_flows( self.controller ) |
| 2995 | delete_groups( self.controller, Groups ) |
| 2996 | delete_all_groups( self.controller ) |
| 2997 | |
| 2998 | class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ): |
| 2999 | """ |
| 3000 | Verify google senario where we need to go from |
| 3001 | an untagged packet to a double tagged packet. |
| 3002 | |
| 3003 | This is used for multiple subscribers. |
| 3004 | |
| 3005 | However, this solution does not scale, since we assign an internal vlan to each subscriber |
| 3006 | used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table. |
| 3007 | """ |
| 3008 | |
| 3009 | def runTest( self ): |
| 3010 | Groups = Queue.LifoQueue( ) |
| 3011 | try: |
| 3012 | if len( config[ "port_map" ] ) < 2: |
| 3013 | logging.info( "Port count less than 2, can't run this case" ) |
| 3014 | return |
| 3015 | |
| 3016 | # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan] |
| 3017 | subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000], |
| 3018 | [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001], |
| 3019 | [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002], |
| 3020 | [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]] |
| 3021 | |
| 3022 | print("") |
| 3023 | |
| 3024 | for sub_info in subscriber_info: |
| 3025 | |
| 3026 | print("Initializing rules for subscriber with id {0}".format(sub_info[0])) |
| 3027 | |
| 3028 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3029 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3030 | |
| 3031 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3032 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3033 | |
| 3034 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3035 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3036 | |
| 3037 | dip = sub_info[1] |
| 3038 | ports = config[ "port_map" ].keys( ) |
| 3039 | |
| 3040 | inner_vlan = sub_info[2] |
| 3041 | outer_vlan = sub_info[3] |
| 3042 | internal_vlan = sub_info[5] |
| 3043 | id = sub_info[0] + 10 |
| 3044 | |
| 3045 | port = ports[0] |
| 3046 | out_port = ports[1] |
| 3047 | |
| 3048 | # add l2 unfiltered interface group |
| 3049 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3050 | |
| 3051 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id, |
| 3052 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3053 | |
| 3054 | do_barrier( self.controller ) |
| 3055 | |
| 3056 | # add vlan flow table |
| 3057 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3058 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3059 | |
| 3060 | # add termination flow |
| 3061 | if config["switch_type"] == "qmx": |
| 3062 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3063 | else: |
| 3064 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3065 | |
| 3066 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3067 | vrf=0 ) |
| 3068 | |
| 3069 | add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan) |
| 3070 | |
| 3071 | Groups._put( l2_gid ) |
| 3072 | Groups._put( l3_msg.group_id ) |
| 3073 | do_barrier( self.controller ) |
| 3074 | |
| 3075 | for sub_info in subscriber_info: |
| 3076 | |
| 3077 | print("Sending packet for subscriber with id {0}".format(sub_info[0])) |
| 3078 | |
| 3079 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ] |
| 3080 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3081 | |
| 3082 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3083 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3084 | |
| 3085 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3086 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3087 | |
| 3088 | dip = sub_info[1] |
| 3089 | ports = config[ "port_map" ].keys( ) |
| 3090 | |
| 3091 | inner_vlan = sub_info[2] |
| 3092 | outer_vlan = sub_info[3] |
| 3093 | internal_vlan = sub_info[5] |
| 3094 | |
| 3095 | id = sub_info[0] + 10 |
| 3096 | ip_src = '192.168.5.5' |
| 3097 | ip_dst = '192.168.0.{}'.format(sub_info[0]) |
| 3098 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False, |
| 3099 | eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 3100 | pkt = str( parsed_pkt ) |
| 3101 | |
| 3102 | # print("Input Packet %s" % format_packet(pkt)) |
| 3103 | |
| 3104 | self.dataplane.send( port, pkt ) |
| 3105 | |
| 3106 | # build expect packet |
| 3107 | exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan, |
| 3108 | eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 3109 | pkt = str( exp_pkt ) |
| 3110 | |
| 3111 | # print("Expected Packet %s" % format_packet(pkt)) |
| 3112 | |
| 3113 | verify_packet( self, pkt, out_port ) |
| 3114 | verify_no_other_packets( self ) |
| 3115 | finally: |
| 3116 | delete_all_flows( self.controller ) |
| 3117 | delete_groups( self.controller, Groups ) |
| 3118 | delete_all_groups( self.controller ) |
Andreas Pantelopoulos | 6c76b94 | 2018-01-22 10:03:02 -0800 | [diff] [blame] | 3119 | |
Jonghwan Hyun | ff0dfd5 | 2018-03-20 15:04:35 -0700 | [diff] [blame] | 3120 | class UntaggedToDoubleChangeEthertype ( base_tests.SimpleDataPlane ): |
| 3121 | |
| 3122 | def runTest( self ): |
| 3123 | Groups = Queue.LifoQueue() |
| 3124 | try: |
| 3125 | if len( config[ "port_map" ] ) < 2: |
| 3126 | logging.info( "Port count less than 2, can't run this case" ) |
| 3127 | return |
| 3128 | |
| 3129 | input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 3130 | input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] ) |
| 3131 | |
| 3132 | input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 3133 | input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] ) |
| 3134 | |
| 3135 | output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ] |
| 3136 | output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] ) |
| 3137 | |
| 3138 | dip = 0xc0a80001 |
| 3139 | ports = config[ "port_map" ].keys( ) |
| 3140 | |
| 3141 | inner_vlan = 66 |
| 3142 | outer_vlan = 77 |
| 3143 | id = 10 |
| 3144 | |
| 3145 | port = ports[0] |
| 3146 | out_port = ports[1] |
| 3147 | |
| 3148 | # add l2 unfiltered interface group |
| 3149 | l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True) |
| 3150 | |
| 3151 | l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id, |
| 3152 | src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid) |
| 3153 | |
| 3154 | do_barrier( self.controller ) |
| 3155 | |
| 3156 | # add vlan flow table |
| 3157 | add_one_vlan_table_flow( self.controller, port, 1, 4094, |
| 3158 | flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 3159 | |
| 3160 | # add termination flow |
| 3161 | if config["switch_type"] == "qmx": |
| 3162 | add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 ) |
| 3163 | else: |
| 3164 | add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 ) |
| 3165 | |
| 3166 | add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id, |
| 3167 | vrf=0 ) |
| 3168 | |
| 3169 | add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan) |
| 3170 | |
| 3171 | Groups._put( l2_gid ) |
| 3172 | Groups._put( l3_msg.group_id ) |
| 3173 | |
| 3174 | # add vlan flow table |
| 3175 | add_one_egress_vlan_tpid_table_flow( self.controller, out_port, outer_vlan+0x1000 ) |
| 3176 | do_barrier( self.controller ) |
| 3177 | |
| 3178 | ip_src = '192.168.5.5' |
| 3179 | ip_dst = '192.168.0.1' |
| 3180 | parsed_pkt = simple_tcp_packet( pktlen=100, |
| 3181 | dl_vlan_enable=False, |
| 3182 | eth_dst=input_dst_mac_str, |
| 3183 | eth_src=input_src_mac_str, |
| 3184 | ip_ttl=64, |
| 3185 | ip_src=ip_src, |
| 3186 | ip_dst=ip_dst ) |
| 3187 | pkt = str( parsed_pkt ) |
| 3188 | |
| 3189 | print("Input Packet %s" % format_packet(pkt)) |
| 3190 | |
| 3191 | self.dataplane.send( port, pkt ) |
| 3192 | |
| 3193 | # build expect packet |
| 3194 | exp_pkt = simple_tcp_packet_two_vlan( pktlen=108, |
| 3195 | out_dl_vlan_enable=True, |
| 3196 | out_vlan_vid=outer_vlan, |
| 3197 | out_vlan_tpid=0x88a8, |
| 3198 | in_dl_vlan_enable=True, |
| 3199 | in_vlan_vid=inner_vlan, |
| 3200 | eth_dst=output_dst_mac_str, |
| 3201 | eth_src=input_dst_mac_str, |
| 3202 | ip_ttl=63, |
| 3203 | ip_src=ip_src, |
| 3204 | ip_dst=ip_dst ) |
| 3205 | pkt = str( exp_pkt ) |
| 3206 | |
| 3207 | print("Expected Packet %s" % format_packet(pkt)) |
| 3208 | |
| 3209 | verify_packet( self, pkt, out_port ) |
| 3210 | verify_no_other_packets( self ) |
| 3211 | finally: |
| 3212 | delete_all_flows( self.controller ) |
| 3213 | delete_groups( self.controller, Groups ) |
| 3214 | delete_all_groups( self.controller ) |