| """ |
| Check README file |
| """ |
| import Queue |
| |
| from oftest import config |
| import inspect |
| import logging |
| import oftest.base_tests as base_tests |
| import ofp |
| import time |
| from oftest.testutils import * |
| from accton_util import * |
| from utils import * |
| |
| class PacketInUDP( base_tests.SimpleDataPlane ): |
| """ |
| Verify ACL rule for IP_PROTO=2 wont match a UDP packet and a rule for IP_PROTO=17 WILL match a UDP packet. |
| """ |
| |
| def runTest( self ): |
| try: |
| parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| vlan_pkt = str( parsed_vlan_pkt ) |
| # create match |
| match = ofp.match( ) |
| match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| match.oxm_list.append( ofp.oxm.ip_proto( 2 ) ) |
| request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| ofp.instruction.apply_actions( actions=[ |
| ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| logging.info( "Inserting packet in flow to controller" ) |
| self.controller.message_send( request ) |
| |
| for of_port in config[ "port_map" ].keys( ): |
| logging.info( "PacketInMiss test, port %d", of_port ) |
| self.dataplane.send( of_port, vlan_pkt ) |
| |
| verify_no_packet_in( self, vlan_pkt, of_port ) |
| delete_all_flows( self.controller ) |
| do_barrier( self.controller ) |
| |
| match = ofp.match( ) |
| match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| match.oxm_list.append( ofp.oxm.ip_proto( 17 ) ) |
| request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| ofp.instruction.apply_actions( actions=[ |
| ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| logging.info( "Inserting packet in flow to controller" ) |
| self.controller.message_send( request ) |
| do_barrier( self.controller ) |
| |
| for of_port in config[ "port_map" ].keys( ): |
| logging.info( "PacketInMiss test, port %d", of_port ) |
| self.dataplane.send( of_port, vlan_pkt ) |
| |
| verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION ) |
| |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| |
| @disabled |
| class ArpNL2( base_tests.SimpleDataPlane ): |
| """ |
| Needs a description, disabled for now. Also needs try/finally |
| """ |
| def runTest( self ): |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| match = ofp.match( ) |
| match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| ofp.instruction.apply_actions( actions=[ |
| ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| self.controller.message_send( request ) |
| for port in ports: |
| add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| group_id = encode_l2_interface_group_id( 1, port ) |
| add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| do_barrier( self.controller ) |
| parsed_arp_pkt = simple_arp_packet( ) |
| arp_pkt = str( parsed_arp_pkt ) |
| |
| for out_port in ports: |
| self.dataplane.send( out_port, arp_pkt ) |
| verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
| # change dest based on port number |
| mac_dst = '00:12:34:56:78:%02X' % out_port |
| for in_port in ports: |
| if in_port == out_port: |
| continue |
| # change source based on port number to avoid packet-ins from learning |
| mac_src = '00:12:34:56:78:%02X' % in_port |
| parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for ofport in ports: |
| if ofport in [ out_port ]: |
| verify_packet( self, pkt, ofport ) |
| else: |
| verify_no_packet( self, pkt, ofport ) |
| |
| verify_no_other_packets( self ) |
| |
| class PacketInArp( base_tests.SimpleDataPlane ): |
| """ |
| Verify Packet-in message from eth_type 0x806 on ACL table |
| """ |
| |
| def runTest( self ): |
| try: |
| parsed_arp_pkt = simple_arp_packet( ) |
| arp_pkt = str( parsed_arp_pkt ) |
| # create match |
| match = ofp.match( ) |
| match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| ofp.instruction.apply_actions( actions=[ |
| ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| |
| logging.info( "Inserting arp flow " ) |
| self.controller.message_send( request ) |
| do_barrier( self.controller ) |
| |
| for of_port in config[ "port_map" ].keys( ): |
| logging.info( "PacketInArp test, sending arp packet to port %d", of_port ) |
| self.dataplane.send( of_port, arp_pkt ) |
| |
| verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
| |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class PacketInIPTable( base_tests.SimpleDataPlane ): |
| """ |
| Verify Packet-in message from IP table when controller action is used |
| Send a packet to each dataplane port and verify that a packet |
| in message is received from the controller for each |
| #todo verify you stop receiving after adding rule |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| |
| for port in ports: |
| # add l2 interface group |
| vlan_id = port |
| add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| send_ctrl=True ) |
| Groups.put( l3_msg.group_id ) |
| |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % in_port |
| ip_src = '192.168.%02d.1' % in_port |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % out_port |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| # verify_no_other_packets(self) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class L2FloodQinQ( base_tests.SimpleDataPlane ): |
| """ |
| Verify Vlan based flooding of QinQ based on its outer vlan |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| vlan_id = 100 |
| |
| for port in ports: |
| L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| Groups.put( L2gid ) |
| |
| msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| Groups.put( msg.group_id ) |
| add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| do_barrier( self.controller ) |
| |
| # verify flood |
| for ofport in ports: |
| # change dest based on port number |
| mac_src = '00:12:34:56:78:%02X' % ofport |
| parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ofport, pkt ) |
| # self won't rx packet |
| verify_no_packet( self, pkt, ofport ) |
| # others will rx packet |
| tmp_ports = list( ports ) |
| tmp_ports.remove( ofport ) |
| verify_packets( self, pkt, tmp_ports ) |
| |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| |
| @disabled |
| class L2FloodTagged( base_tests.SimpleDataPlane ): |
| """ |
| currently disabled; fix with try/finally |
| Test L2 flood to a vlan |
| Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| """ |
| |
| def runTest( self ): |
| # Hashes Test Name and uses it as id for installing unique groups |
| vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
| print vlan_id |
| |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| # Installing flows to avoid packet-in |
| for port in ports: |
| add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| do_barrier( self.controller ) |
| |
| # verify flood |
| for ofport in ports: |
| # change dest based on port number |
| pkt = str( |
| simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| self.dataplane.send( ofport, pkt ) |
| # self won't rx packet |
| verify_no_packet( self, pkt, ofport ) |
| # others will rx packet |
| tmp_ports = list( ports ) |
| tmp_ports.remove( ofport ) |
| verify_packets( self, pkt, tmp_ports ) |
| verify_no_other_packets( self ) |
| |
| |
| class L2UnicastTagged( base_tests.SimpleDataPlane ): |
| """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """ |
| |
| def runTest( self ): |
| |
| Groups = Queue.LifoQueue( ) |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| vlan_id = 1; |
| for port in ports: |
| L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| Groups.put( L2gid ) |
| add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| True ) |
| do_barrier( self.controller ) |
| |
| for out_port in ports: |
| # change dest based on port number |
| mac_dst = '00:12:34:56:78:%02X' % out_port |
| for in_port in ports: |
| if in_port == out_port: |
| continue |
| pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| self.dataplane.send( in_port, pkt ) |
| for ofport in ports: |
| if ofport in [ out_port ]: |
| verify_packet( self, pkt, ofport ) |
| else: |
| verify_no_packet( self, pkt, ofport ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class Mtu1500( base_tests.SimpleDataPlane ): |
| """ |
| Verifies basic mtu limits |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| vlan_id = 18 |
| for port in ports: |
| L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| Groups.put( L2gid ) |
| add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| True ) |
| do_barrier( self.controller ) |
| |
| for out_port in ports: |
| # change dest based on port number |
| mac_dst = '00:12:34:56:78:%02X' % out_port |
| for in_port in ports: |
| if in_port == out_port: |
| continue |
| pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| eth_dst=mac_dst ) ) |
| self.dataplane.send( in_port, pkt ) |
| for ofport in ports: |
| if ofport in [ out_port ]: |
| verify_packet( self, pkt, ofport ) |
| else: |
| verify_no_packet( self, pkt, ofport ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class _32UcastTagged( base_tests.SimpleDataPlane ): |
| """ Verify /32 IP forwarding to L3 Unicast-> L2Interface""" |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| test_id = 26 |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| vlan_id = port + test_id |
| # add l2 interface group and l3 unicast group |
| l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| Groups.put( l2gid ) |
| Groups.put( l3_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| ip_src = '192.168.%02d.1' % (test_id + in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class _32VPN( base_tests.SimpleDataPlane ): |
| """ |
| Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| No ECMP group used |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| id = port |
| vlan_id = port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| dst_mac[ 5 ] = vlan_id |
| # add MPLS interface group |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| # add MPLS L3 VPN group |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| do_barrier( self.controller ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2, |
| flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| label = (out_port, 0, 1, 32) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class _32EcmpVpn( base_tests.SimpleDataPlane ): |
| """ |
| Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| id = port |
| vlan_id = port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| dst_mac[ 5 ] = vlan_id |
| # add MPLS interface group |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| # add MPLS L3 VPN group |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| do_barrier( self.controller ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| Groups._put( ecmp_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| label = (out_port, 0, 1, 32) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| @disabled |
| class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| """ |
| Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| in only one direction |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| # add l2 interface group |
| id = ports[1] |
| in_offset = 19 |
| out_offset = 20 |
| vlan_id = ports[1] + out_offset |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True ) |
| dst_mac[ 5 ] = ports[1] |
| # add MPLS interface group |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| # add MPLS L3 VPN group |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 ) |
| # add ECMP group |
| ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| do_barrier( self.controller ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0, |
| flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| else: |
| add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
| # add routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| Groups._put( ecmp_msg.group_id ) |
| |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| in_port = ports[0] |
| out_port = ports[1] |
| ip_src = '192.168.%02d.1' % (in_port) |
| ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
| eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| label = (out_port+out_offset, 0, 1, 32) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| #verify_no_other_packets( self ) |
| |
| finally: |
| delete_all_flows( self.controller ) |
| delete_group(self.controller, ecmp_msg.group_id) |
| delete_group(self.controller, mpls_label_gid) |
| delete_group(self.controller, mpls_gid) |
| delete_group(self.controller, l2_gid) |
| |
| |
| class _32ECMPL3( base_tests.SimpleDataPlane ): |
| """ |
| Verifies /32 IP routing and ECMP with no label push |
| IP -> L3ECMP -> L3Unicast -> L2Interface |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| # Hashes Test Name and uses it as id for installing unique groups |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| vlan_id = port |
| id = port |
| # add l2 interface group |
| l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| Groups._put( ecmp_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % in_port |
| ip_src = '192.168.%02d.1' % in_port |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % out_port |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| """ |
| Verifies /32 IP routing and ECMP with no label push |
| IP -> L3ECMP -> L3Unicast -> L2Interface |
| in only one direction |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| # Hashes Test Name and uses it as id for installing unique groups |
| ports = config[ "port_map" ].keys( ) |
| inport = ports[0] |
| outport = ports[1] |
| in_offset = 19 |
| out_offset = 20 |
| vlan_id = outport + out_offset |
| id = outport |
| # add l2 interface group, l3 unicast and ecmp group for outport |
| l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = outport |
| l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset ) |
| else: |
| add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| Groups._put( ecmp_msg.group_id ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| mac_src = '00:00:00:22:22:%02X' % inport |
| ip_src = '192.168.%02d.1' % inport |
| ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( inport, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % outport |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, outport ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| |
| |
| @disabled |
| class _24VPN( base_tests.SimpleDataPlane ): |
| """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| id = port |
| vlan_id = port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| dst_mac[ 5 ] = vlan_id |
| # add MPLS interface group |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| # add MPLS L3 VPN group |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| do_barrier( self.controller ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| label = (out_port, 0, 1, 32) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class _24EcmpVpn( base_tests.SimpleDataPlane ): |
| """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| id = port |
| vlan_id = id |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| dst_mac[ 5 ] = vlan_id |
| # add MPLS interface group |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| # add MPLS L3 VPN group |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| do_barrier( self.controller ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
| flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add routing flow |
| dst_ip = dip + (vlan_id << 8) |
| # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| vrf=0 ) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| Groups._put( ecmp_msg.group_id ) |
| |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % (in_port) |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| label = (out_port, 0, 1, 32) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class FloodGroupMod( base_tests.SimpleDataPlane ): |
| """ Modify a referenced flood group """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| vlan_id = 1 |
| |
| for port in ports: |
| L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| Groups.put( L2gid ) |
| |
| msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| Groups.put( msg.group_id ) |
| add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| do_barrier( self.controller ) |
| # verify flood |
| for ofport in ports: |
| # change dest based on port number |
| mac_src = '00:12:34:56:78:%02X' % ofport |
| parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ofport, pkt ) |
| # self won't rx packet |
| verify_no_packet( self, pkt, ofport ) |
| # others will rx packet |
| tmp_ports = list( ports ) |
| tmp_ports.remove( ofport ) |
| verify_packets( self, pkt, tmp_ports ) |
| verify_no_other_packets( self ) |
| msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| eth_src=mac_src ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ports[ 1 ], pkt ) |
| verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class _24ECMPL3( base_tests.SimpleDataPlane ): |
| """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| # Hashes Test Name and uses it as id for installing unique groups |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| vlan_id = port |
| id = port |
| # add l2 interface group |
| l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| Groups._put( ecmp_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % in_port |
| ip_src = '192.168.%02d.1' % in_port |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % out_port |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| @disabled |
| class MPLSBUG( base_tests.SimpleDataPlane ): |
| """ |
| Needs a description or needs to be removed |
| """ |
| def runTest( self ): |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| Groups = Queue.LifoQueue( ) |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| vlan_id = port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| dst_mac[ 5 ] = vlan_id |
| # add L3 Unicast group |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 ) |
| else: |
| add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| # add mpls flow |
| add_mpls_flow( self.controller, l3_msg.group_id, port ) |
| # add termination flow |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % in_port |
| ip_src = '192.168.%02d.1' % in_port |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % out_port |
| switch_mac = "00:00:00:cc:cc:cc" |
| label = (out_port, 0, 1, 32) |
| parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| |
| class L3McastToL3( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic comes in tagged. |
| port+1 is used as ingress vlan_id. The packet goes out tagged on |
| different ports. 4094-port is used as egress vlan_id. |
| """ |
| def runTest( self ): |
| """ |
| port1 (vlan 300)-> All Ports (vlan 300) |
| """ |
| Groups = Queue.LifoQueue( ) |
| try: |
| # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| if len( config[ "port_map" ] ) < 1: |
| logging.info( "Port count less than 1, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| port_to_intf_src_mac_str, |
| Groups) = fill_mcast_pipeline_L3toL3( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = True, |
| is_egress_tagged = True, |
| is_vlan_translated = True, |
| is_max_vlan = False |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_in_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_out_vlan[out_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_intf_src_mac_str[out_port], |
| ip_ttl = 63, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| verify_packet( self, pkt, out_port ) |
| |
| verify_no_other_packets( self ) |
| |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic is untagged. |
| 4094 is used as internal vlan_id. The packet goes out |
| untagged. |
| """ |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| Groups) = fill_mcast_pipeline_L3toL2( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = False, |
| is_egress_tagged = False, |
| is_vlan_translated = False, |
| is_max_vlan = True |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 96, |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 96, |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| if out_port == in_port: |
| verify_no_packet( self, pkt, in_port ) |
| continue |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic is untagged. |
| 300 is used as vlan_id. The packet goes out |
| tagged. |
| """ |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| Groups) = fill_mcast_pipeline_L3toL2( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = False, |
| is_egress_tagged = True, |
| is_vlan_translated = False, |
| is_max_vlan = False |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 96, |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_out_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| if out_port == in_port: |
| verify_no_packet( self, pkt, in_port ) |
| continue |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic is tagged. |
| 300 is used as vlan_id. The packet goes out |
| untagged. |
| """ |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| Groups) = fill_mcast_pipeline_L3toL2( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = True, |
| is_egress_tagged = False, |
| is_vlan_translated = False, |
| is_max_vlan = False |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_in_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 96, |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| if out_port == in_port: |
| verify_no_packet( self, pkt, in_port ) |
| continue |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic is tagged. |
| 300 is used as vlan_id. The packet goes out tagged. |
| """ |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| Groups) = fill_mcast_pipeline_L3toL2( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = True, |
| is_egress_tagged = True, |
| is_vlan_translated = False, |
| is_max_vlan = False |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_in_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_in_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| if out_port == in_port: |
| verify_no_packet( self, pkt, in_port ) |
| continue |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing, in this test case the traffic is tagged. |
| port+1 is used as ingress vlan_id. The packet goes out |
| tagged. 4094-port is used as egress vlan_id |
| """ |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| assert (False) |
| return |
| ports = config[ "port_map" ].keys( ) |
| dst_ip_str = "224.0.0.1" |
| ( |
| port_to_in_vlan, |
| port_to_out_vlan, |
| port_to_src_mac_str, |
| port_to_dst_mac_str, |
| port_to_src_ip_str, |
| Groups) = fill_mcast_pipeline_L3toL2( |
| self.controller, |
| logging, |
| ports, |
| is_ingress_tagged = True, |
| is_egress_tagged = True, |
| is_vlan_translated = True, |
| is_max_vlan = False |
| ) |
| |
| for in_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_in_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| for out_port in ports: |
| |
| parsed_pkt = simple_udp_packet( |
| pktlen = 100, |
| dl_vlan_enable = True, |
| vlan_vid = port_to_out_vlan[in_port], |
| eth_dst = port_to_dst_mac_str[in_port], |
| eth_src = port_to_src_mac_str[in_port], |
| ip_ttl = 64, |
| ip_src = port_to_src_ip_str[in_port], |
| ip_dst = dst_ip_str |
| ) |
| pkt = str( parsed_pkt ) |
| if out_port == in_port: |
| verify_no_packet( self, pkt, in_port ) |
| continue |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class _MplsFwd( base_tests.SimpleDataPlane ): |
| """ Verify basic MPLS forwarding: Label switch router """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| dip = 0xc0a80001 |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| vlan_id = port + 16 |
| mpls_label = port + 16 |
| |
| # add l2 interface group |
| id = port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| dst_mac[ 5 ] = port |
| mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| vlan_id, id ) |
| mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
| push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
| #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| else: |
| add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
| add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
| dst_ip = dip + (vlan_id << 8) |
| Groups._put( l2_gid ) |
| Groups._put( mpls_gid ) |
| Groups._put( mpls_label_gid ) |
| #Groups._put( ecmp_gid ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| out_mpls_label = out_port + 16 |
| in_vlan_vid = in_port + 16 |
| out_vlan_vid = out_port + 16 |
| |
| ip_dst = '192.168.%02d.1' % (out_port) |
| label = (out_mpls_label, 0, 1, 32) |
| parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| label = (out_mpls_label, 0, 1, 31) |
| exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| label=[ label ] ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class _MplsTermination( base_tests.SimpleDataPlane ): |
| """ Verify MPLS VPN Termination at penultimate hop """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| dip = 0xc0a80001 |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| vlan_id = port + 16 |
| mpls_label = port + 16 |
| |
| # add l2 interface group |
| id, dst_mac[ 5 ] = port, port |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| # add L3 Unicast group |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add L3 ecmp group |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| else: |
| add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
| # add_mpls_flow(self.controller, label=port) |
| dst_ip = dip + (vlan_id << 8) |
| # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
| # ecmp_msg.group_id, 1) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| Groups._put( ecmp_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| out_mpls_label = out_port + 16 |
| in_vlan_vid = in_port + 16 |
| out_vlan_vid = out_port + 16 |
| |
| ip_dst = '192.168.%02d.1' % (out_port) |
| label = (out_mpls_label, 0, 1, 32) |
| parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| @disabled |
| class One_MplsTermination( base_tests.SimpleDataPlane ): |
| """ |
| Verify MPLS VPN Termination at penultimate hop in only one direction |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| dip = 0xc0a80001 |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| ports = config[ "port_map" ].keys( ) |
| inport = ports[0] |
| outport = ports[1] |
| |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| invlan_id = inport + 16 |
| outvlan_id = outport + 16 |
| mpls_label = outport + 16 |
| |
| # add l2 interface group |
| id, dst_mac[ 5 ] = inport, outport |
| l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| # add L3 Unicast group |
| l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add L3 ecmp group |
| ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add tmac flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| else: |
| add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| # add mpls termination flow |
| add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| Groups._put( ecmp_msg.group_id ) |
| |
| time.sleep(0.1) |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| ip_src = '192.168.%02d.1' % (inport) |
| # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| out_mpls_label = outport + 16 |
| in_vlan_vid = inport + 16 |
| out_vlan_vid = outport + 16 |
| |
| ip_dst = '192.168.%02d.1' % (outport) |
| label = (out_mpls_label, 0, 1, 32) |
| parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( inport, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % (outport) |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, outport ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class _24UcastTagged( base_tests.SimpleDataPlane ): |
| """ Verify /24 IP forwarding to L3 Interface """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| test_id = 26 |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| vlan_id = port + test_id |
| l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| Groups.put( l2gid ) |
| Groups.put( l3_msg.group_id ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| ip_src = '192.168.%02d.1' % (test_id + in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class _0Ucast( base_tests.SimpleDataPlane ): |
| """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| ports = config[ "port_map" ].keys( ) |
| for port in ports: |
| # add l2 interface group |
| vlan_id = port |
| l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| Groups.put( l2gid ) |
| Groups.put( l3_msg.group_id ) |
| l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| dst_ip = 0x0 |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| do_barrier( self.controller ) |
| |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| for in_port in ports: |
| mac_src = '00:00:00:22:22:%02X' % (in_port) |
| ip_src = '192.168.%02d.1' % (in_port) |
| for out_port in ports: |
| if in_port == out_port: |
| continue |
| ip_dst = '192.168.%02d.1' % (out_port) |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( in_port, pkt ) |
| # build expect packet |
| mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, ports[ 0 ] ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class Unfiltered( base_tests.SimpleDataPlane ): |
| """ |
| Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
| """ |
| |
| def runTest( self ): |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| vlan_id = 1; |
| for port in ports: |
| add_l2_unfiltered_group( self.controller, [ port ], False ) |
| do_barrier( self.controller ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class L3McastToVPN( base_tests.SimpleDataPlane ): |
| """ |
| Mcast routing and VPN initiation |
| """ |
| |
| def runTest( self ): |
| """ |
| port1 (vlan 1)-> port 2 (vlan 2) |
| """ |
| try: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| if len( config[ "port_map" ] ) < 3: |
| logging.info( "Port count less than 3, can't run this case" ) |
| assert (False) |
| return |
| |
| vlan_id = 1 |
| port2_out_vlan = 2 |
| port3_out_vlan = 3 |
| in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| src_ip = 0xc0a80101 |
| src_ip_str = "192.168.1.1" |
| dst_ip = 0xe0010101 |
| dst_ip_str = "224.1.1.1" |
| |
| port1 = config[ "port_map" ].keys( )[ 0 ] |
| port2 = config[ "port_map" ].keys( )[ 1 ] |
| # port3=config["port_map"].keys()[2] |
| |
| # add l2 interface group |
| for port in config[ "port_map" ].keys( ): |
| add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| send_barrier=False ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| vlan_id += 1 |
| |
| # add termination flow |
| add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| vlan_id ) |
| |
| # add MPLS interface group |
| l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| port2_out_vlan, port2 ) |
| # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| # add L3VPN groups |
| mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
| |
| mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
| |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( port1, pkt ) |
| label = (12, 0, 1, 63) |
| exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, port2 ) |
| # verify_packet(self, pkt, port3) |
| verify_no_other_packets( self ) |
| delete_all_groups( self.controller ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| @disabled |
| class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
| """ |
| Test packet in function on a src-mac miss |
| Send a packet to each dataplane port and verify that a packet |
| in message is received from the controller for each |
| #todo verify you stop receiving after adding rule |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| |
| Groups = Queue.LifoQueue( ) |
| for port in ports: |
| L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| Groups.put( L2gid ) |
| parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| vlan_pkt = str( parsed_vlan_pkt ) |
| for of_port in config[ "port_map" ].keys( ): |
| logging.info( "PacketInMiss test, port %d", of_port ) |
| self.dataplane.send( of_port, vlan_pkt ) |
| verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_all_groups( self.controller ) |
| |
| |
| class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| """ |
| Verify referenced group can be modified by adding or removing buckets |
| """ |
| |
| def runTest( self ): |
| Groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| dip = 0xc0a80001 |
| # Hashes Test Name and uses it as id for installing unique groups |
| ports = config[ "port_map" ].keys( ) |
| ecmp = [ ] |
| dst_ips = [] |
| # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| # in the ecmp group |
| for port in ports: |
| vlan_id = port |
| id = port |
| # add l2 interface group |
| l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| is_tagged=True, send_barrier=False ) |
| dst_mac[ 5 ] = vlan_id |
| l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| src_mac=intf_src_mac, dst_mac=dst_mac ) |
| if port == ports[1]: |
| ecmp += [ l3_msg.group_id ] |
| Groups._put( l2_gid ) |
| Groups._put( l3_msg.group_id ) |
| ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] ) |
| # add vlan flow table |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| # add termination flow |
| if config["switch_type"] == "qmx": |
| add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id ) |
| else: |
| add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| # add unicast routing flow |
| dst_ip = dip + (vlan_id << 8) |
| dst_ips += [dst_ip] |
| Groups._put( ecmp_msg.group_id ) |
| mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
| for dst_ip in dst_ips: |
| add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| time.sleep(0.1) |
| # first part of the test: send packet from ingress switchport and expect it at egress switchport |
| switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| parsed_pkt = exp_pkt = 0 |
| in_port = ports[0] |
| out_port = ports[1] |
| logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| tcp = out_port if out_port == 24 else 25 |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| ip_dst=ip_dst, tcp_dport=tcp ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ports[ 0 ], pkt ) |
| # build expected packet at egress switchport |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| ip_dst=ip_dst, tcp_dport=tcp ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| |
| # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| # it back on the ingress switchport |
| l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
| time.sleep(0.1) |
| logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| tcp = port if port == 24 else 25 |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| ip_dst=ip_dst,tcp_dport=tcp ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ports[ 0 ], pkt ) |
| # build expected packet |
| mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| ip_dst=ip_dst,tcp_dport=tcp ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, ports[ 0 ] ) |
| verify_no_other_packets( self ) |
| |
| # third part of the test - edit the group to completely remove bucket. Packet sent |
| # should be dropped by the switch |
| mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
| time.sleep(0.1) |
| logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| tcp = port if port == 24 else 25 |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| ip_dst=ip_dst,tcp_dport=tcp ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ports[ 0 ], pkt ) |
| verify_no_other_packets( self ) |
| |
| # final part of the test - edit the empty group to add back the bucket for the |
| # original egress port, and verify packet is received on egress switch port |
| l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
| time.sleep(0.1) |
| in_port = ports[0] |
| out_port = ports[1] |
| logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| tcp = out_port if out_port == 24 else 25 |
| parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| ip_dst=ip_dst, tcp_dport=tcp ) |
| pkt = str( parsed_pkt ) |
| self.dataplane.send( ports[ 0 ], pkt ) |
| # build expected packet at egress switchport |
| mac_dst = '00:00:00:22:22:%02X' % out_port |
| exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| ip_dst=ip_dst, tcp_dport=tcp ) |
| pkt = str( exp_pkt ) |
| verify_packet( self, pkt, out_port ) |
| verify_no_other_packets( self ) |
| |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, Groups ) |
| delete_all_groups( self.controller ) |
| |
| |
| class Untagged( base_tests.SimpleDataPlane ): |
| """ |
| Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| previous versions of the OFDPA. |
| |
| Two rules are necessary in VLAN table (10): |
| 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| |
| In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| The remaining part of the test is based on the use of the bridging table |
| """ |
| |
| MAX_INTERNAL_VLAN = 4094 |
| |
| def runTest( self ): |
| groups = Queue.LifoQueue( ) |
| try: |
| if len( config[ "port_map" ] ) < 2: |
| logging.info( "Port count less than 2, can't run this case" ) |
| return |
| |
| ports = sorted( config[ "port_map" ].keys( ) ) |
| for port in ports: |
| vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
| for other_port in ports: |
| if other_port == port: |
| continue |
| L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| groups.put( L2gid ) |
| add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| |
| do_barrier( self.controller ) |
| |
| for out_port in ports: |
| # change dest based on port number |
| mac_dst = '00:12:34:56:78:%02X' % out_port |
| for in_port in ports: |
| if in_port == out_port: |
| continue |
| pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| self.dataplane.send( in_port, pkt ) |
| for ofport in ports: |
| if ofport in [ out_port ]: |
| verify_packet( self, pkt, ofport ) |
| else: |
| verify_no_packet( self, pkt, ofport ) |
| verify_no_other_packets( self ) |
| finally: |
| delete_all_flows( self.controller ) |
| delete_groups( self.controller, groups ) |
| delete_all_groups( self.controller ) |