def test_everflow_neighbor_mac_change(self, duthosts,
                                          rand_one_dut_hostname, setup_info,
                                          setup_mirror_session, dest_port_type,
                                          ptfadapter, tbinfo):
        """Verify that session destination MAC address is changed after neighbor MAC address update."""
        duthost = duthosts[rand_one_dut_hostname]
        try:
            # Add a route to the mirror session destination IP
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip, _ = everflow_utils.get_neighbor_info(
                duthost, tx_port, tbinfo)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic is sent along the route we installed
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Update the MAC on the neighbor interface for the route we installed
            if setup_info[dest_port_type]["dest_port_lag_name"][
                    0] != "Not Applicable":
                tx_port = setup_info[dest_port_type]["dest_port_lag_name"][0]

            duthost.shell(
                "ip neigh replace {} lladdr 00:11:22:33:44:55 nud permanent dev {}"
                .format(peer_ip, tx_port))
            time.sleep(3)

            # Verify that everything still works
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Clean up the test
            duthost.shell("ip neigh del {} dev {}".format(peer_ip, tx_port))
            duthost.shell("ping {} -c3".format(peer_ip))
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)

        except Exception:
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip, _ = everflow_utils.get_neighbor_info(
                duthost, tx_port, tbinfo)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)

            raise
示例#2
0
    def dest_port_type(self, duthosts, rand_one_dut_hostname, setup_info,
                       setup_mirror_session, tbinfo, request):
        """
        This fixture parametrize  dest_port_type and can perform action based
        on that. As of now cleanup is being done here.
        """
        duthost = duthosts[rand_one_dut_hostname]

        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"redistribute static\"",
                setup_info[request.param]["namespace"]))
        yield request.param

        for index in range(0,
                           min(3,
                               len(setup_info[request.param]["dest_port"]))):
            tx_port = setup_info[request.param]["dest_port"][index]
            peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port,
                                                       tbinfo)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip,
                setup_info[request.param]["namespace"])
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip,
                setup_info[request.param]["namespace"])

        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"no redistribute static\"",
                setup_info[request.param]["namespace"]))
        time.sleep(15)
    def setup_mirror_session_dest_ip_route(self, duthosts,
                                           rand_one_dut_hostname, tbinfo,
                                           setup_info, setup_mirror_session):
        """
        Setup the route for mirror session destination ip and update monitor port list.
        Remove the route as part of cleanup.
        """

        duthost = duthosts[rand_one_dut_hostname]
        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"redistribute static\"",
                setup_info["tor"]["namespace"]))
        tx_port = setup_info["tor"]["dest_port"][0]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost,
                                 setup_mirror_session["session_prefixes"][0],
                                 peer_ip, setup_info["tor"]["namespace"])
        self.tx_port_ids = self._get_tx_port_id_list(
            [setup_info["tor"]["dest_port_ptf_id"][0]])
        time.sleep(5)
        yield
        everflow_utils.remove_route(
            duthost, setup_mirror_session["session_prefixes"][0], peer_ip,
            setup_info["tor"]["namespace"])
        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"no redistribute static\"",
                setup_info["tor"]["namespace"]))
示例#4
0
    def test_everflow_dscp_with_policer(self, duthost, setup_info,
                                        policer_mirror_session, dest_port_type,
                                        partial_ptf_runner):
        """Verify that we can rate-limit mirrored traffic from the MIRROR_DSCP table."""

        # Add explicit route for the mirror session
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
        everflow_utils.add_route(duthost,
                                 policer_mirror_session["session_prefixes"][0],
                                 peer_ip)

        try:
            # Add MIRROR_DSCP table for test
            duthost.command(
                "config acl add table EVERFLOW_DSCP MIRROR_DSCP --stage={}".
                format(self.acl_stage()))

            # Add rule to match on DSCP
            mirror_action = "MIRROR_INGRESS_ACTION" if self.mirror_type(
            ) == 'ingress' else "MIRROR_EGRESS_ACTION"
            duthost.command(
                "redis-cli -n 4 hmset \"ACL_RULE|EVERFLOW_DSCP|RULE_1\" PRIORITY 9999 {} {} DSCP 8/56"
                .format(mirror_action, policer_mirror_session["session_name"]))

            # Sync rule
            time.sleep(3)

            # Run test with expected CIR/CBS in packets/sec and tolerance %
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]

            partial_ptf_runner(
                setup_info,
                policer_mirror_session,
                self.acl_stage(),
                self.mirror_type(),
                expect_receive=True,
                test_name="everflow_policer_test.EverflowPolicerTest",
                src_port=rx_port_ptf_id,
                dst_mirror_ports=tx_port_ptf_id,
                dst_ports=tx_port_ptf_id,
                meter_type="packets",
                cir="100",
                cbs="100",
                tolerance="10")
        finally:
            # Clean up ACL rules and routes
            duthost.command(
                "redis-cli -n 4 del \"ACL_RULE|EVERFLOW_DSCP|RULE_1\"")
            duthost.command("config acl remove table EVERFLOW_DSCP")
            everflow_utils.remove_route(
                duthost, policer_mirror_session["session_prefixes"][0],
                peer_ip)
    def test_everflow_dscp_with_policer(self, duthost, setup_info,
                                        policer_mirror_session, dest_port_type,
                                        partial_ptf_runner, config_method,
                                        tbinfo):
        """Verify that we can rate-limit mirrored traffic from the MIRROR_DSCP table."""

        # Add explicit route for the mirror session
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost,
                                 policer_mirror_session["session_prefixes"][0],
                                 peer_ip)

        try:
            # Add MIRROR_DSCP table for test
            table_name = "EVERFLOW_DSCP"
            table_type = "MIRROR_DSCP"
            self.apply_acl_table_config(duthost, table_name, table_type,
                                        config_method)

            # Add rule to match on DSCP
            self.apply_acl_rule_config(duthost,
                                       table_name,
                                       policer_mirror_session["session_name"],
                                       config_method,
                                       rules=EVERFLOW_DSCP_RULES)

            # Run test with expected CIR/CBS in packets/sec and tolerance %
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]

            partial_ptf_runner(
                setup_info,
                policer_mirror_session,
                self.acl_stage(),
                self.mirror_type(),
                expect_receive=True,
                test_name="everflow_policer_test.EverflowPolicerTest",
                src_port=rx_port_ptf_id,
                dst_mirror_ports=tx_port_ptf_id,
                dst_ports=tx_port_ptf_id,
                meter_type="packets",
                cir="100",
                cbs="100",
                tolerance="10")
        finally:
            # Clean up ACL rules and routes
            self.remove_acl_rule_config(duthost, table_name, config_method)
            self.remove_acl_table_config(duthost, table_name, config_method)
            everflow_utils.remove_route(
                duthost, policer_mirror_session["session_prefixes"][0],
                peer_ip)
示例#6
0
    def dest_port_type(self, duthosts, rand_one_dut_hostname, setup_info, setup_mirror_session, tbinfo, request):
        """
        This fixture parametrize  dest_port_type and can perform action based
        on that. As of now cleanup is being done here.
        """
        yield request.param
        
        duthost = duthosts[rand_one_dut_hostname]

        for index in range(0, min(3, len(setup_info[request.param]["dest_port"]))):
            tx_port = setup_info[request.param]["dest_port"][index]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
            everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][1], peer_ip)
示例#7
0
    def test_everflow_case2(self, duthost, setup_info, setup_mirror_session,
                            dest_port_type, partial_ptf_runner):
        """Test case 2 - Change neighbor MAC address.
        Verify that session destination MAC address is changed after neighbor MAC address update."""

        rx_port_ptf_id = setup_info[dest_port_type]['src_port_ptf_id']
        tx_port = setup_info[dest_port_type]['dest_port'][0]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        if setup_info[dest_port_type]['dest_port_lag_name'][
                0] != 'Not Applicable':
            tx_port = setup_info[dest_port_type]['dest_port_lag_name'][0]

        duthost.shell(
            "ip neigh replace {} lladdr 00:11:22:33:44:55 nud permanent dev {}"
            .format(peer_ip, tx_port))

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id,
                           expected_dst_mac='00:11:22:33:44:55')

        duthost.shell("ip neigh del {} dev {}".format(peer_ip, tx_port))

        duthost.shell("ping {} -c3".format(peer_ip))

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip)
示例#8
0
    def add_dest_routes(self, duthosts, rand_one_dut_hostname, setup_info,
                        tbinfo, dest_port_type):
        if self.acl_stage() != 'egress':
            yield
            return
        duthost = duthosts[rand_one_dut_hostname]

        default_traffic_port_type = DOWN_STREAM if dest_port_type == UP_STREAM else UP_STREAM
        rx_port = setup_info[default_traffic_port_type]["dest_port"][0]
        nexthop_ip = everflow_utils.get_neighbor_info(duthost, rx_port, tbinfo)

        ns = setup_info[default_traffic_port_type]["namespace"]
        dst_mask = "30.0.0.0/28"

        everflow_utils.add_route(duthost, dst_mask, nexthop_ip, ns)

        yield

        everflow_utils.remove_route(duthost, dst_mask, nexthop_ip, ns)
示例#9
0
    def setup_mirror_session_dest_ip_route(self, duthosts,
                                           rand_one_dut_hostname, tbinfo,
                                           setup_info, setup_mirror_session):
        """
        Setup the route for mirror session destination ip and update monitor port list.
        Remove the route as part of cleanup.
        """
        duthost = duthosts[rand_one_dut_hostname]
        if setup_info['topo'] == 't0':
            # On T0 testbed, the collector IP is routed to T1
            namespace = setup_info[UP_STREAM]['namespace']
            tx_port = setup_info[UP_STREAM]["dest_port"][0]
            dest_port_ptf_id_list = [
                setup_info[UP_STREAM]["dest_port_ptf_id"][0]
            ]
        else:
            namespace = setup_info[DOWN_STREAM]['namespace']
            tx_port = setup_info[DOWN_STREAM]["dest_port"][0]
            dest_port_ptf_id_list = [
                setup_info[DOWN_STREAM]["dest_port_ptf_id"][0]
            ]
        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"redistribute static\"",
                namespace))
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost,
                                 setup_mirror_session["session_prefixes"][0],
                                 peer_ip, namespace)
        EverflowIPv6Tests.tx_port_ids = self._get_tx_port_id_list(
            dest_port_ptf_id_list)
        time.sleep(5)

        yield

        everflow_utils.remove_route(
            duthost, setup_mirror_session["session_prefixes"][0], peer_ip,
            namespace)
        duthost.shell(
            duthost.get_vtysh_cmd_for_namespace(
                "vtysh -c \"config\" -c \"router bgp\" -c \"address-family ipv4\" -c \"no redistribute static\"",
                namespace))
示例#10
0
    def setup_mirror_session_dest_ip_route(self, duthosts,
                                           rand_one_dut_hostname, tbinfo,
                                           setup_info, setup_mirror_session):
        """
        Setup the route for mirror session destination ip and update monitor port list.
        Remove the route as part of cleanup.
        """

        duthost = duthosts[rand_one_dut_hostname]
        tx_port = setup_info["tor"]["dest_port"][0]
        peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost,
                                 setup_mirror_session["session_prefixes"][0],
                                 peer_ip)
        self.tx_port_ids = self._get_tx_port_id_list(
            [setup_info["tor"]["dest_port_ptf_id"][0]])
        time.sleep(5)
        yield
        everflow_utils.remove_route(
            duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
示例#11
0
    def test_everflow_case1(self, duthost, setup_info, setup_mirror_session,
                            dest_port_type, partial_ptf_runner):
        """  Test on Resolved route, unresolved route, best prefix match route creation and removal flows """

        rx_port_ptf_id = setup_info[dest_port_type]['src_port_ptf_id']
        tx_port = setup_info[dest_port_type]['dest_port'][0]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        # call the function return by pytest fixture and pass arguments needed for
        # ptf test case like src port, dest port, acl_stage, mirror_type.
        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        peer_ip, peer_mac = everflow_utils.get_neighbor_info(
            duthost, tx_port, False)

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][1],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][1], peer_ip)

        tx_port = setup_info[dest_port_type]['dest_port'][1]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][1]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][1],
                                 peer_ip)
        time.sleep(3)
        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][1], peer_ip)
        time.sleep(3)
        tx_port = setup_info[dest_port_type]['dest_port'][0]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip)
示例#12
0
    def test_everflow_case3(self, duthost, setup_info, setup_mirror_session,
                            dest_port_type, partial_ptf_runner):
        """Test case 3 -  ECMP route change (remove next hop not used by session).
        Verify that after removal of next hop that was used by session from ECMP route session state is active."""

        rx_port_ptf_id = setup_info[dest_port_type]['src_port_ptf_id']
        tx_port = setup_info[dest_port_type]['dest_port'][0]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        peer_ip0 = peer_ip

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        tx_port = setup_info[dest_port_type]['dest_port'][1]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][1]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        peer_ip1 = peer_ip

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id + ',' +
                           setup_info[dest_port_type]['dest_port_ptf_id'][0])

        tx_port = setup_info[dest_port_type]['dest_port'][2]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][2]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           expect_receive=False,
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip)

        time.sleep(3)

        partial_ptf_runner(
            setup_info,
            setup_mirror_session,
            self.acl_stage(),
            self.mirror_type(),
            src_port=rx_port_ptf_id,
            dst_ports=setup_info[dest_port_type]['dest_port_ptf_id'][0] + ',' +
            setup_info[dest_port_type]['dest_port_ptf_id'][1])

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           expect_receive=False,
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip0)
        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip1)
示例#13
0
    def test_everflow_dscp_with_policer(self, duthost, setup_info,
                                        policer_mirror_session, dest_port_type,
                                        partial_ptf_runner, config_method,
                                        tbinfo):
        """Verify that we can rate-limit mirrored traffic from the MIRROR_DSCP table.
        This tests single rate three color policer mode and specifically checks CIR value
        and switch behaviour under condition when CBS is assumed to be fully absorbed while
        sending traffic over a period of time. Received packets are accumulated and actual
        receive rate is calculated and compared with CIR value with tollerance range 10%.
        """
        # Add explicit for regular packet so that it's dest port is different then mirror port
        # NOTE: This is important to add since for the Policer test case regular packets
        # and mirror packets can go to same interface, which causes tail drop of
        # police packets and impacts test case cir/cbs calculation.

        vendor = duthost.facts["asic_type"]
        hostvars = duthost.host.options['variable_manager']._hostvars[
            duthost.hostname]
        for asic in self.MIRROR_POLICER_UNSUPPORTED_ASIC_LIST:
            vendorAsic = "{0}_{1}_hwskus".format(vendor, asic)
            if vendorAsic in hostvars.keys(
            ) and duthost.facts['hwsku'] in hostvars[vendorAsic]:
                pytest.skip(
                    "Skipping test since mirror policing is not supported on {0} {1} platforms"
                    .format(vendor, asic))
        if setup_info['topo'] == 't0':
            default_tarffic_port_type = dest_port_type
            # Use the second portchannel as missor session nexthop
            tx_port = setup_info[dest_port_type]["dest_port"][1]
        else:
            default_tarffic_port_type = DOWN_STREAM if dest_port_type == UP_STREAM else UP_STREAM
            tx_port = setup_info[dest_port_type]["dest_port"][0]
        default_traffic_tx_port = setup_info[default_tarffic_port_type][
            "dest_port"][0]
        default_traffic_peer_ip = everflow_utils.get_neighbor_info(
            duthost, default_traffic_tx_port, tbinfo)
        everflow_utils.add_route(
            duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip,
            setup_info[default_tarffic_port_type]["namespace"])
        time.sleep(15)

        # Add explicit route for the mirror session
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost,
                                 policer_mirror_session["session_prefixes"][0],
                                 peer_ip,
                                 setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        try:
            # Add MIRROR_DSCP table for test
            table_name = "EVERFLOW_DSCP"
            table_type = "MIRROR_DSCP"
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            if setup_info['topo'] == 't0' and self.acl_stage() == "egress":
                # For T0 upstream, the EVERFLOW_DSCP table is binded to one of portchannels
                bind_interface = setup_info[dest_port_type][
                    "dest_port_lag_name"][0]
                mirror_port_id = setup_info[dest_port_type][
                    "dest_port_ptf_id"][1]
            else:
                bind_interface = setup_info[dest_port_type]["src_port"]
                mirror_port_id = tx_port_ptf_id
                if setup_info[dest_port_type][
                        "src_port_lag_name"] != "Not Applicable":
                    bind_interface = setup_info[dest_port_type][
                        "src_port_lag_name"]

            # Temp change for multi-asic to create acl table in host and namespace
            # Will be removed once CLI is command is enahnced to work across all namespaces.
            self.apply_acl_table_config(duthost, table_name, table_type,
                                        config_method, [bind_interface])
            bind_interface_namespace = self._get_port_namespace(
                setup_info, int(rx_port_ptf_id))
            if bind_interface_namespace:
                self.apply_acl_table_config(duthost, table_name, table_type,
                                            config_method, [bind_interface],
                                            bind_interface_namespace)
            # Add rule to match on DSCP
            self.apply_acl_rule_config(duthost,
                                       table_name,
                                       policer_mirror_session["session_name"],
                                       config_method,
                                       rules=EVERFLOW_DSCP_RULES)

            # Run test with expected CIR/CBS in packets/sec and tolerance %
            partial_ptf_runner(
                setup_info,
                policer_mirror_session,
                self.acl_stage(),
                self.mirror_type(),
                expect_receive=True,
                test_name="everflow_policer_test.EverflowPolicerTest",
                src_port=rx_port_ptf_id,
                dst_mirror_ports=mirror_port_id,
                dst_ports=tx_port_ptf_id,
                meter_type="packets",
                cir="100",
                cbs="100",
                send_time="10",
                tolerance="10")
        finally:
            # Clean up ACL rules and routes
            BaseEverflowTest.remove_acl_rule_config(duthost, table_name,
                                                    config_method)
            self.remove_acl_table_config(duthost, table_name, config_method)
            if bind_interface_namespace:
                self.remove_acl_table_config(duthost, table_name,
                                             config_method,
                                             bind_interface_namespace)
            everflow_utils.remove_route(
                duthost, policer_mirror_session["session_prefixes"][0],
                peer_ip, setup_info[dest_port_type]["namespace"])
            everflow_utils.remove_route(
                duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip,
                setup_info[default_tarffic_port_type]["namespace"])
示例#14
0
    def test_everflow_case4(self, duthost, setup_info, setup_mirror_session,
                            dest_port_type, partial_ptf_runner):
        """Test case 4 - ECMP route change (remove next hop used by session).
        Verify that removal of next hop that is not used by session doesn't cause DST port and MAC change."""

        rx_port_ptf_id = setup_info[dest_port_type]['src_port_ptf_id']
        tx_port = setup_info[dest_port_type]['dest_port'][0]
        tx_port_ptf_id = setup_info[dest_port_type]['dest_port_ptf_id'][0]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        peer_ip0 = peer_ip

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(setup_info,
                           setup_mirror_session,
                           self.acl_stage(),
                           self.mirror_type(),
                           src_port=rx_port_ptf_id,
                           dst_ports=tx_port_ptf_id)

        tx_port = setup_info[dest_port_type]['dest_port'][1]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        peer_ip1 = peer_ip

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        tx_port = setup_info[dest_port_type]['dest_port'][2]
        peer_ip, peer_mac = everflow_utils.get_neighbor_info(duthost, tx_port)
        peer_ip2 = peer_ip

        everflow_utils.add_route(duthost,
                                 setup_mirror_session['session_prefixes'][0],
                                 peer_ip)

        time.sleep(3)

        partial_ptf_runner(
            setup_info,
            setup_mirror_session,
            self.acl_stage(),
            self.mirror_type(),
            src_port=rx_port_ptf_id,
            dst_ports=setup_info[dest_port_type]['dest_port_ptf_id'][0])

        partial_ptf_runner(
            setup_info,
            setup_mirror_session,
            self.acl_stage(),
            self.mirror_type(),
            expect_receive=False,
            src_port=rx_port_ptf_id,
            dst_ports=setup_info[dest_port_type]['dest_port_ptf_id'][1] + ',' +
            setup_info[dest_port_type]['dest_port_ptf_id'][2])

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip0)

        time.sleep(3)

        partial_ptf_runner(
            setup_info,
            setup_mirror_session,
            self.acl_stage(),
            self.mirror_type(),
            expect_receive=False,
            src_port=rx_port_ptf_id,
            dst_ports=setup_info[dest_port_type]['dest_port_ptf_id'][0])

        partial_ptf_runner(
            setup_info,
            setup_mirror_session,
            self.acl_stage(),
            self.mirror_type(),
            src_port=rx_port_ptf_id,
            dst_ports=setup_info[dest_port_type]['dest_port_ptf_id'][1] + ',' +
            setup_info[dest_port_type]['dest_port_ptf_id'][2])

        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip1)
        everflow_utils.remove_route(
            duthost, setup_mirror_session['session_prefixes'][0], peer_ip2)
示例#15
0
    def test_everflow_basic_forwarding(self, duthost, setup_info,
                                       setup_mirror_session, dest_port_type,
                                       ptfadapter):
        """
        Verify basic forwarding scenarios for the Everflow feature.

        Scenarios covered include:
            - Resolved route
            - Unresolved route
            - LPM (longest prefix match)
            - Route creation and removal
        """
        try:
            # Add a route to the mirror session destination IP
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic is sent along the route we installed
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Add a (better) unresolved route to the mirror session destination IP
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost,
                                                          tx_port,
                                                          resolved=False)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic is still sent along the original route
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Remove the unresolved route
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip)

            # Add a better route to the mirror session destination IP
            tx_port = setup_info[dest_port_type]["dest_port"][1]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session['session_prefixes'][1], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic uses the new route
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][1]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Remove the better route.
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic switches back to the original route
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Clean up the test
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.remove_route(
                duthost, setup_mirror_session['session_prefixes'][0], peer_ip)

        except Exception:
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip)

            tx_port = setup_info[dest_port_type]["dest_port"][1]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][1], peer_ip)

            raise
示例#16
0
    def test_everflow_remove_used_ecmp_next_hop(self, duthost, setup_info,
                                                setup_mirror_session,
                                                dest_port_type, ptfadapter):
        """Verify that session is still active after removal of next hop from ECMP route that was in use."""
        try:
            # Add a route to the mirror session destination IP
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip_0, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            time.sleep(3)

            # Verify that mirrored traffic is sent along the route we installed
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Add two new ECMP next hops
            tx_port = setup_info[dest_port_type]["dest_port"][1]
            peer_ip_1, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)

            tx_port = setup_info[dest_port_type]["dest_port"][2]
            peer_ip_2, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_2)
            time.sleep(3)

            # Verify that traffic is still sent along the original next hop
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id])

            # Verify that traffic is not sent along either of the new next hops
            tx_port_ptf_ids = [
                setup_info[dest_port_type]["dest_port_ptf_id"][1],
                setup_info[dest_port_type]["dest_port_ptf_id"][2]
            ]
            self._run_everflow_test_scenarios(ptfadapter,
                                              setup_info,
                                              setup_mirror_session,
                                              duthost,
                                              rx_port_ptf_id,
                                              tx_port_ptf_ids,
                                              expect_recv=False)

            # Remove the original next hop
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            time.sleep(3)

            # Verify that mirrored traffic is no longer sent along the original next hop
            self._run_everflow_test_scenarios(ptfadapter,
                                              setup_info,
                                              setup_mirror_session,
                                              duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id],
                                              expect_recv=False)

            # Verify that mirrored traffis is now sent along either of the new next hops
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, tx_port_ptf_ids)

            # Clean up the tests
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_2)
        except Exception:
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_2)

            raise
示例#17
0
    def test_everflow_dscp_with_policer(
            self,
            duthost,
            setup_info,
            policer_mirror_session,
            dest_port_type,
            partial_ptf_runner,
            config_method,
            tbinfo
    ):
        """Verify that we can rate-limit mirrored traffic from the MIRROR_DSCP table."""
        # Add explicit for regular packet so that it's dest port is different then mirror port
        # NOTE: This is important to add since for the Policer test case regular packets
        # and mirror packets can go to same interface, which causes tail drop of
        # police packets and impacts test case cir/cbs calculation.
        default_tarffic_port_type = "tor" if dest_port_type == "spine" else "spine"
        default_traffic_tx_port = setup_info[default_tarffic_port_type]["dest_port"][0]
        default_traffic_peer_ip = everflow_utils.get_neighbor_info(duthost, default_traffic_tx_port, tbinfo)
        everflow_utils.add_route(duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip, setup_info[default_tarffic_port_type]["namespace"])
        time.sleep(15)

        # Add explicit route for the mirror session
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, policer_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        try:
            # Add MIRROR_DSCP table for test
            table_name = "EVERFLOW_DSCP"
            table_type = "MIRROR_DSCP"
            self.apply_acl_table_config(duthost, table_name, table_type, config_method)

            # Add rule to match on DSCP
            self.apply_acl_rule_config(duthost,
                                       table_name,
                                       policer_mirror_session["session_name"],
                                       config_method,
                                       rules=EVERFLOW_DSCP_RULES)

            # Run test with expected CIR/CBS in packets/sec and tolerance %
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]

            partial_ptf_runner(setup_info,
                               policer_mirror_session,
                               self.acl_stage(),
                               self.mirror_type(),
                               expect_receive=True,
                               test_name="everflow_policer_test.EverflowPolicerTest",
                               src_port=rx_port_ptf_id,
                               dst_mirror_ports=tx_port_ptf_id,
                               dst_ports=tx_port_ptf_id,
                               meter_type="packets",
                               cir="100",
                               cbs="100",
                               tolerance="10")
        finally:
            # Clean up ACL rules and routes
            self.remove_acl_rule_config(duthost, table_name, config_method)
            self.remove_acl_table_config(duthost, table_name, config_method)
            everflow_utils.remove_route(duthost, policer_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
            everflow_utils.remove_route(duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip, setup_info[default_tarffic_port_type]["namespace"])
示例#18
0
    def test_everflow_remove_unused_ecmp_next_hop(self, duthosts, rand_one_dut_hostname, setup_info, setup_mirror_session, dest_port_type, ptfadapter, tbinfo):
        """Verify that session is still active after removal of next hop from ECMP route that was not in use."""
        duthost = duthosts[rand_one_dut_hostname]
        # Create two ECMP next hops
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip_0 = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_0, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        tx_port = setup_info[dest_port_type]["dest_port"][1]
        peer_ip_1 = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_1, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is sent to one of the next hops
        rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
        tx_port_ptf_ids = [
            setup_info[dest_port_type]["dest_port_ptf_id"][0],
            setup_info[dest_port_type]["dest_port_ptf_id"][1]
        ]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            tx_port_ptf_ids
        )

        # Add another ECMP next hop
        tx_port = setup_info[dest_port_type]["dest_port"][2]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is not sent to this new next hop
        tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][2]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id],
            expect_recv=False
        )

        # Remove the extra hop
        everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is not sent to the deleted next hop
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id],
            expect_recv=False
        )

        # Verify that mirrored traffic is still sent to one of the original next hops
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            tx_port_ptf_ids
        )
示例#19
0
    def test_everflow_remove_used_ecmp_next_hop(self, duthosts, rand_one_dut_hostname, setup_info, setup_mirror_session, dest_port_type, ptfadapter, tbinfo):
        """Verify that session is still active after removal of next hop from ECMP route that was in use."""
        duthost = duthosts[rand_one_dut_hostname]
        # Add a route to the mirror session destination IP
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip_0 = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_0, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is sent along the route we installed
        rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
        tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id]
        )

        # Add two new ECMP next hops
        tx_port = setup_info[dest_port_type]["dest_port"][1]
        peer_ip_1 = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_1, setup_info[dest_port_type]["namespace"])

        tx_port = setup_info[dest_port_type]["dest_port"][2]
        peer_ip_2 = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_2, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that traffic is still sent along the original next hop
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id],
            valid_across_namespace=False
        )

        # Verify that traffic is not sent along either of the new next hops
        tx_port_ptf_ids = [
            setup_info[dest_port_type]["dest_port_ptf_id"][1],
            setup_info[dest_port_type]["dest_port_ptf_id"][2]
        ]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            tx_port_ptf_ids,
            expect_recv=False,
            valid_across_namespace=False
        )

        # Remove the original next hop
        everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip_0, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is no longer sent along the original next hop
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id],
            expect_recv=False
        )

        # Verify that mirrored traffis is now sent along either of the new next hops
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            tx_port_ptf_ids
        )
    def test_everflow_dscp_with_policer(
            self,
            duthost,
            setup_info,
            policer_mirror_session,
            dest_port_type,
            partial_ptf_runner,
            config_method,
            tbinfo
    ):
        """Verify that we can rate-limit mirrored traffic from the MIRROR_DSCP table.
        This tests single rate three color policer mode and specifically checks CIR value
        and switch behaviour under condition when CBS is assumed to be fully absorbed while
        sending traffic over a period of time. Received packets are accumulated and actual
        receive rate is calculated and compared with CIR value with tollerance range 10%.
        """
        # Add explicit for regular packet so that it's dest port is different then mirror port
        # NOTE: This is important to add since for the Policer test case regular packets
        # and mirror packets can go to same interface, which causes tail drop of
        # police packets and impacts test case cir/cbs calculation.
        default_tarffic_port_type = "tor" if dest_port_type == "spine" else "spine"
        default_traffic_tx_port = setup_info[default_tarffic_port_type]["dest_port"][0]
        default_traffic_peer_ip = everflow_utils.get_neighbor_info(duthost, default_traffic_tx_port, tbinfo)
        everflow_utils.add_route(duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip, setup_info[default_tarffic_port_type]["namespace"])
        time.sleep(15)

        # Add explicit route for the mirror session
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, policer_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        try:
            # Add MIRROR_DSCP table for test
            table_name = "EVERFLOW_DSCP"
            table_type = "MIRROR_DSCP"
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
            bind_interface = setup_info[dest_port_type]["src_port"]
            if setup_info[dest_port_type]["src_port_lag_name"] != "Not Applicable":
                bind_interface = setup_info[dest_port_type]["src_port_lag_name"]

            # Temp change for multi-asic to create acl table in host and namespace
            # Will be removed once CLI is command is enahnced to work across all namespaces.
            self.apply_acl_table_config(duthost, table_name, table_type, config_method, [bind_interface])
            bind_interface_namespace = self._get_port_namespace(setup_info, int(rx_port_ptf_id))
            if bind_interface_namespace:
                self.apply_acl_table_config(duthost, table_name, table_type, config_method, [bind_interface], bind_interface_namespace) 
            # Add rule to match on DSCP
            self.apply_acl_rule_config(duthost,
                                       table_name,
                                       policer_mirror_session["session_name"],
                                       config_method,
                                       rules=EVERFLOW_DSCP_RULES)

            # Run test with expected CIR/CBS in packets/sec and tolerance %
            partial_ptf_runner(setup_info,
                               policer_mirror_session,
                               self.acl_stage(),
                               self.mirror_type(),
                               expect_receive=True,
                               test_name="everflow_policer_test.EverflowPolicerTest",
                               src_port=rx_port_ptf_id,
                               dst_mirror_ports=tx_port_ptf_id,
                               dst_ports=tx_port_ptf_id,
                               meter_type="packets",
                               cir="100",
                               cbs="100",
                               send_time="10",
                               tolerance="10")
        finally:
            # Clean up ACL rules and routes
            self.remove_acl_rule_config(duthost, table_name, config_method)
            self.remove_acl_table_config(duthost, table_name, config_method)
            if bind_interface_namespace:
                self.remove_acl_table_config(duthost, table_name, config_method, bind_interface_namespace)
            everflow_utils.remove_route(duthost, policer_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
            everflow_utils.remove_route(duthost, self.DEFAULT_DST_IP + "/32", default_traffic_peer_ip, setup_info[default_tarffic_port_type]["namespace"])
示例#21
0
    def test_everflow_basic_forwarding(self, duthosts, rand_one_dut_hostname, setup_info, setup_mirror_session, dest_port_type, ptfadapter, tbinfo):
        """
        Verify basic forwarding scenarios for the Everflow feature.

        Scenarios covered include:
            - Resolved route
            - Unresolved route
            - LPM (longest prefix match)
            - Route creation and removal
        """
        duthost = duthosts[rand_one_dut_hostname]
        duthost.shell(duthost.get_vtysh_cmd_for_namespace("vtysh -c \"configure terminal\" -c \"no ip nht resolve-via-default\"", setup_info[dest_port_type]["namespace"]))

        # Add a route to the mirror session destination IP
        tx_port = setup_info[dest_port_type]["dest_port"][0]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][0], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is sent along the route we installed
        rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
        tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id]
        )

        # Add a (better) unresolved route to the mirror session destination IP
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo, resolved=False)
        everflow_utils.add_route(duthost, setup_mirror_session["session_prefixes"][1], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic is still sent along the original route
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id]
        )

        # Remove the unresolved route
        everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][1], peer_ip, setup_info[dest_port_type]["namespace"])

        # Add a better route to the mirror session destination IP
        tx_port = setup_info[dest_port_type]["dest_port"][1]
        peer_ip = everflow_utils.get_neighbor_info(duthost, tx_port, tbinfo)
        everflow_utils.add_route(duthost, setup_mirror_session['session_prefixes'][1], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic uses the new route
        tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][1]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id]
        )

        # Remove the better route.
        everflow_utils.remove_route(duthost, setup_mirror_session["session_prefixes"][1], peer_ip, setup_info[dest_port_type]["namespace"])
        time.sleep(15)

        # Verify that mirrored traffic switches back to the original route
        tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][0]
        self._run_everflow_test_scenarios(
            ptfadapter,
            setup_info,
            setup_mirror_session,
            duthost,
            rx_port_ptf_id,
            [tx_port_ptf_id]
        )
        duthost.shell(duthost.get_vtysh_cmd_for_namespace("vtysh -c \"configure terminal\" -c \"ip nht resolve-via-default\"", setup_info[dest_port_type]["namespace"]))
示例#22
0
    def test_everflow_remove_unused_ecmp_next_hop(self, duthost, setup_info,
                                                  setup_mirror_session,
                                                  dest_port_type, ptfadapter):
        """Verify that session is still active after removal of next hop from ECMP route that was not in use."""
        try:
            # Create two ECMP next hops
            tx_port = setup_info[dest_port_type]["dest_port"][0]
            peer_ip_0, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            time.sleep(3)

            tx_port = setup_info[dest_port_type]["dest_port"][1]
            peer_ip_1, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)
            time.sleep(3)

            # Verify that mirrored traffic is sent to one of the next hops
            rx_port_ptf_id = setup_info[dest_port_type]["src_port_ptf_id"]
            tx_port_ptf_ids = [
                setup_info[dest_port_type]["dest_port_ptf_id"][0],
                setup_info[dest_port_type]["dest_port_ptf_id"][1]
            ]
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, tx_port_ptf_ids)

            # Add another ECMP next hop
            tx_port = setup_info[dest_port_type]["dest_port"][2]
            peer_ip, _ = everflow_utils.get_neighbor_info(duthost, tx_port)
            everflow_utils.add_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic is not sent to this new next hop
            tx_port_ptf_id = setup_info[dest_port_type]["dest_port_ptf_id"][2]
            self._run_everflow_test_scenarios(ptfadapter,
                                              setup_info,
                                              setup_mirror_session,
                                              duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id],
                                              expect_recv=False)

            # Remove the extra hop
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)
            time.sleep(3)

            # Verify that mirrored traffic is not sent to the deleted next hop
            self._run_everflow_test_scenarios(ptfadapter,
                                              setup_info,
                                              setup_mirror_session,
                                              duthost,
                                              rx_port_ptf_id, [tx_port_ptf_id],
                                              expect_recv=False)

            # Verify that mirrored traffic is still sent to one of the original next hops
            self._run_everflow_test_scenarios(ptfadapter, setup_info,
                                              setup_mirror_session, duthost,
                                              rx_port_ptf_id, tx_port_ptf_ids)

            # Clean up the test
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)

        except Exception:
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_0)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0],
                peer_ip_1)
            everflow_utils.remove_route(
                duthost, setup_mirror_session["session_prefixes"][0], peer_ip)

            raise