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