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