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