From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5FD354609E; Thu, 16 Jan 2025 14:16:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D33CA406B6; Thu, 16 Jan 2025 14:16:26 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id D784640668 for ; Thu, 16 Jan 2025 14:16:24 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B62F011FB; Thu, 16 Jan 2025 05:16:52 -0800 (PST) Received: from e132991.cambridge.arm.com (unknown [10.1.195.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 788BA3F673; Thu, 16 Jan 2025 05:16:23 -0800 (PST) From: Thomas Wilks To: dev@dpdk.org Cc: Paul Szczepanek , Luca Vizzarro , Patrick Robb , Thomas Wilks Subject: [PATCH v1 1/2] dts: add promiscuous mode verification test Date: Thu, 16 Jan 2025 13:16:14 +0000 Message-ID: <20250116131615.196053-2-thomas.wilks@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250116131615.196053-1-thomas.wilks@arm.com> References: <20250116131615.196053-1-thomas.wilks@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added verification that enables promiscuous mode, sends a packet with a different destination mac address and then disables promiscuous mode, sends the same packet and checks if the packet was filtered out. Signed-off-by: Thomas Wilks --- Reviewed-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- dts/tests/TestSuite_promisc_support.py | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 dts/tests/TestSuite_promisc_support.py diff --git a/dts/tests/TestSuite_promisc_support.py b/dts/tests/TestSuite_promisc_support.py new file mode 100644 index 0000000000..a3ea2461f0 --- /dev/null +++ b/dts/tests/TestSuite_promisc_support.py @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""Promiscuous mode support test suite. + +Test promiscuous support by sending a packet with a different destination +mac address from the TG to the SUT. +""" + +from scapy.layers.inet import IP +from scapy.layers.l2 import Ether +from scapy.packet import Raw + +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test + + +class TestPromiscSupport(TestSuite): + """Promiscuous mode support test suite.""" + + #: Alternate MAC address. + ALTERNATIVE_MAC_ADDRESS: str = "02:00:00:00:00:00" + + @func_test + def test_promisc_packets(self) -> None: + """Verify that promiscuous mode works. + + Steps: + Create a packet with a different mac address to the destination. + Enable promiscuous mode. + Send and receive packet. + Disable promiscuous mode. + Send and receive packet. + Verify: + Packet sent with the wrong address is received in promiscuous mode and filtered out + otherwise. + + """ + packet = [Ether(dst=self.ALTERNATIVE_MAC_ADDRESS) / IP() / Raw(load=b"\x00" * 64)] + + with TestPmdShell( + self.sut_node, + ) as testpmd: + for port_id in range(len(self.sut_node.ports)): + testpmd.set_promisc(port=port_id, enable=True, verify=True) + testpmd.start() + + received_packets = self.send_packets_and_capture(packet) + expected_packets = self.get_expected_packets(packet, sent_from_tg=True) + self.match_all_packets(expected_packets, received_packets) + + testpmd.stop() + + for port_id in range(len(self.sut_node.ports)): + testpmd.set_promisc(port=port_id, enable=False, verify=True) + testpmd.start() + + received_packets = self.send_packets_and_capture(packet) + expected_packets = self.get_expected_packets(packet, sent_from_tg=True) + self.verify( + not self.match_all_packets(expected_packets, received_packets, verify=False), + "Invalid packet wasn't filtered out.", + ) -- 2.43.0