DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1 0/2] dts: add promiscuous mode verification test
@ 2025-01-16 13:16 Thomas Wilks
  2025-01-16 13:16 ` [PATCH v1 1/2] " Thomas Wilks
  2025-01-16 13:16 ` [PATCH v1 2/2] dts: add verify to match all packets Thomas Wilks
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Wilks @ 2025-01-16 13:16 UTC (permalink / raw)
  To: dev; +Cc: Paul Szczepanek, Luca Vizzarro, Patrick Robb, Thomas Wilks

v1:
- Added testsuite that verifies promiscuous mode.
- Added verify to match_all_packets function.

Depends-on: patch-149773 ("dts: allow expected packets to come from the TG")

Thomas Wilks (2):
  dts: add promiscuous mode verification test
  dts: add verify to match all packets

 dts/framework/test_suite.py            | 23 +++++++---
 dts/tests/TestSuite_promisc_support.py | 63 ++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 6 deletions(-)
 create mode 100644 dts/tests/TestSuite_promisc_support.py

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 1/2] dts: add promiscuous mode verification test
  2025-01-16 13:16 [PATCH v1 0/2] dts: add promiscuous mode verification test Thomas Wilks
@ 2025-01-16 13:16 ` Thomas Wilks
  2025-01-16 13:16 ` [PATCH v1 2/2] dts: add verify to match all packets Thomas Wilks
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Wilks @ 2025-01-16 13:16 UTC (permalink / raw)
  To: dev; +Cc: Paul Szczepanek, Luca Vizzarro, Patrick Robb, Thomas Wilks

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 <thomas.wilks@arm.com>
---
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 2/2] dts: add verify to match all packets
  2025-01-16 13:16 [PATCH v1 0/2] dts: add promiscuous mode verification test Thomas Wilks
  2025-01-16 13:16 ` [PATCH v1 1/2] " Thomas Wilks
@ 2025-01-16 13:16 ` Thomas Wilks
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Wilks @ 2025-01-16 13:16 UTC (permalink / raw)
  To: dev; +Cc: Paul Szczepanek, Luca Vizzarro, Patrick Robb, Thomas Wilks

Added verify to match_all_packets function
that if False and there are missing packets
causes the function to return False, if all
packets are present it returns True.

Signed-off-by: Thomas Wilks <thomas.wilks@arm.com>
---
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
---
 dts/framework/test_suite.py | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index de9f871b3f..f5d3e3e545 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -422,8 +422,11 @@ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]
             self._fail_test_case_verify("An expected packet not found among received packets.")
 
     def match_all_packets(
-        self, expected_packets: list[Packet], received_packets: list[Packet]
-    ) -> None:
+        self,
+        expected_packets: list[Packet],
+        received_packets: list[Packet],
+        verify: bool = True,
+    ) -> bool:
         """Matches all the expected packets against the received ones.
 
         Matching is performed by counting down the occurrences in a dictionary which keys are the
@@ -433,10 +436,14 @@ def match_all_packets(
         Args:
             expected_packets: The packets we are expecting to receive.
             received_packets: All the packets that were received.
+            verify: If :data:`True`, and there are missing packets an exception will be raised.
 
         Raises:
             TestCaseVerifyError: if and not all the `expected_packets` were found in
                 `received_packets`.
+
+        Returns:
+            :data:`True` If there are no missing packets.
         """
         expected_packets_counters = Counter(map(raw, expected_packets))
         received_packets_counters = Counter(map(raw, received_packets))
@@ -450,10 +457,14 @@ def match_all_packets(
         )
 
         if missing_packets_count != 0:
-            self._fail_test_case_verify(
-                f"Not all packets were received, expected {len(expected_packets)} "
-                f"but {missing_packets_count} were missing."
-            )
+            if verify:
+                self._fail_test_case_verify(
+                    f"Not all packets were received, expected {len(expected_packets)} "
+                    f"but {missing_packets_count} were missing."
+                )
+            return False
+
+        return True
 
     def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
         self._logger.debug(
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-16 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-16 13:16 [PATCH v1 0/2] dts: add promiscuous mode verification test Thomas Wilks
2025-01-16 13:16 ` [PATCH v1 1/2] " Thomas Wilks
2025-01-16 13:16 ` [PATCH v1 2/2] dts: add verify to match all packets Thomas Wilks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).