* [PATCH v2 1/4] dts: add multicast set function to shell
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
@ 2024-07-08 19:19 ` Dean Marx
2024-07-10 16:44 ` Jeremy Spewock
2024-07-08 19:19 ` [PATCH v2 2/4] dts: add toggle option to send and capture Dean Marx
` (5 subsequent siblings)
6 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:19 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
added set multicast function for changing allmulticast mode within testpmd.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index ec22f72221..a0be0bd09d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -806,6 +806,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_promisc(self, port: int, on: bool, verify: bool = True):
+ """Turns promiscuous mode on/off for the specified port.
+
+ Args:
+ port: Port number to use, should be within 0-32.
+ on: If :data:`True`, turn promisc mode on, otherwise turn off.
+ verify: If :data:`True` an additional command will be sent to verify that promisc mode
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
+ is not correctly set.
+ """
+ promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
+ if verify:
+ stats = self.show_port_info(port_id=port)
+ if on ^ stats.is_promiscuous_mode_enabled:
+ self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set promisc mode on port {port}."
+ )
+
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
def close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.send_command("quit", "")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 1/4] dts: add multicast set function to shell
2024-07-08 19:19 ` [PATCH v2 1/4] dts: add multicast set function to shell Dean Marx
@ 2024-07-10 16:44 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-10 16:44 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 8, 2024 at 3:19 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> added set multicast function for changing allmulticast mode within testpmd.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
> dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
> index ec22f72221..a0be0bd09d 100644
> --- a/dts/framework/remote_session/testpmd_shell.py
> +++ b/dts/framework/remote_session/testpmd_shell.py
> @@ -806,6 +806,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
>
> return TestPmdPortStats.parse(output)
>
> + def set_promisc(self, port: int, on: bool, verify: bool = True):
This public method seems to be missing the return type, it should
probably specify that it doesn't return anything with a None-type.
> + """Turns promiscuous mode on/off for the specified port.
> +
> + Args:
> + port: Port number to use, should be within 0-32.
> + on: If :data:`True`, turn promisc mode on, otherwise turn off.
> + verify: If :data:`True` an additional command will be sent to verify that promisc mode
> + is properly set. Defaults to :data:`True`.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
> + is not correctly set.
> + """
> + promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
> + if verify:
> + stats = self.show_port_info(port_id=port)
> + if on ^ stats.is_promiscuous_mode_enabled:
> + self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
> + raise InteractiveCommandExecutionError(
> + f"Testpmd failed to set promisc mode on port {port}."
> + )
> +
> + def set_multicast_all(self, on: bool, verify: bool = True):
This method also should probably have a typehint for the return type.
> + """Turns multicast mode on/off for the specified port.
> +
> + Args:
> + on: If :data:`True`, turns multicast mode on, otherwise turns off.
> + verify: If :data:`True` an additional command will be sent to verify
> + that multicast mode is properly set. Defaults to :data:`True`.
I'm surprised the formatting script doesn't complain about a
mismatched indent here, I thought it normally did for doc-strings. The
second line of this verify argument should probably be indented just
to better show that it is a continuation of the previous line.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
> + mode is not properly set.
> + """
> + multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
> + if verify:
> + stats0 = self.show_port_info(port_id=0)
> + stats1 = self.show_port_info(port_id=1)
Getting the stats for port 0 and port 1 limit this method to only
working when there are exactly 2 ports. Right now in DTS this is a
restriction, but we should be able to make this robust enough to work
with any number of ports using self.show_port_info_all().
> + if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
If you used the show port info all command, you could then just
replace this `and` statement with something like this:
all(info.is_allmulticast_mode_enabled for info in all_stats)
if `all_stats` was the name of the list you stored the port stats in.
> + self._logger.debug(
> + f"Failed to set multicast mode on all ports.: \n{multicast_output}"
> + )
> + raise InteractiveCommandExecutionError(
> + "Testpmd failed to set multicast mode on all ports."
> + )
> +
> def close(self) -> None:
> """Overrides :meth:`~.interactive_shell.close`."""
> self.send_command("quit", "")
> --
> 2.44.0
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 2/4] dts: add toggle option to send and capture
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
2024-07-08 19:19 ` [PATCH v2 1/4] dts: add multicast set function to shell Dean Marx
@ 2024-07-08 19:19 ` Dean Marx
2024-07-08 19:19 ` [PATCH v2 3/4] dts: dynamic config conf schema Dean Marx
` (4 subsequent siblings)
6 siblings, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:19 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
add option to skip _adjust_addresses method in send_packet_and_capture
when test cases involve sending packets with a preset MAC address.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/test_suite.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 694b2eba65..551a587525 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -185,6 +185,7 @@ def send_packet_and_capture(
packet: Packet,
filter_config: PacketFilteringConfig = PacketFilteringConfig(),
duration: float = 1,
+ adjust_addresses: bool = True,
) -> list[Packet]:
"""Send and receive `packet` using the associated TG.
@@ -195,11 +196,15 @@ def send_packet_and_capture(
packet: The packet to send.
filter_config: The filter to use when capturing packets.
duration: Capture traffic for this amount of time after sending `packet`.
+ adjust_addresses: If :data:'True', adjust addresses of the egressing packet with
+ a default addressing scheme. If :data:'False', do not adjust the addresses of
+ egressing packet.
Returns:
A list of received packets.
"""
- packet = self._adjust_addresses(packet)
+ if adjust_addresses:
+ packet = self._adjust_addresses(packet)
return self.tg_node.send_packet_and_capture(
packet,
self._tg_port_egress,
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 3/4] dts: dynamic config conf schema
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
2024-07-08 19:19 ` [PATCH v2 1/4] dts: add multicast set function to shell Dean Marx
2024-07-08 19:19 ` [PATCH v2 2/4] dts: add toggle option to send and capture Dean Marx
@ 2024-07-08 19:19 ` Dean Marx
2024-07-08 19:19 ` [PATCH v2 4/4] dts: dynamic config test suite Dean Marx
` (3 subsequent siblings)
6 siblings, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:19 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
configuration schema to run dynamic configuration test suite.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..d7b4afed7d 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 4/4] dts: dynamic config test suite
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
` (2 preceding siblings ...)
2024-07-08 19:19 ` [PATCH v2 3/4] dts: dynamic config conf schema Dean Marx
@ 2024-07-08 19:19 ` Dean Marx
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
` (2 subsequent siblings)
6 siblings, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:19 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/tests/TestSuite_dynamic_config.py | 149 ++++++++++++++++++++++++++
1 file changed, 149 insertions(+)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..326a57d60f
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from time import sleep
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verfiy that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def set_up_suite(self) -> None:
+ """Set up the test suite.
+
+ Setup:
+ Verify that at least two ports are open for session.
+ """
+ self.verify(len(self._port_links) > 1, "Not enough ports")
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet=packet, adjust_addresses=False)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ shell: interactive testpmd shell object.
+ """
+ shell = TestPmdShell(node=self.sut_node)
+ shell.start()
+ shell.set_promisc(port=port_id, on=False)
+ shell.set_forward_mode(SimpleForwardingModes.io)
+ return shell
+
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ testpmd = TestPmdShell(node=self.sut_node)
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:00")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:00")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
+ testpmd.close()
+ sleep(6)
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 1/4] dts: add multicast set function to shell
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
` (3 preceding siblings ...)
2024-07-08 19:19 ` [PATCH v2 4/4] dts: dynamic config test suite Dean Marx
@ 2024-07-08 19:30 ` Dean Marx
2024-07-08 19:30 ` [PATCH v3 2/4] dts: add toggle option to send and capture Dean Marx
` (2 more replies)
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
6 siblings, 3 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:30 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
added set multicast function for changing allmulticast mode within testpmd.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index ec22f72221..a0be0bd09d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -806,6 +806,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_promisc(self, port: int, on: bool, verify: bool = True):
+ """Turns promiscuous mode on/off for the specified port.
+
+ Args:
+ port: Port number to use, should be within 0-32.
+ on: If :data:`True`, turn promisc mode on, otherwise turn off.
+ verify: If :data:`True` an additional command will be sent to verify that promisc mode
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
+ is not correctly set.
+ """
+ promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
+ if verify:
+ stats = self.show_port_info(port_id=port)
+ if on ^ stats.is_promiscuous_mode_enabled:
+ self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set promisc mode on port {port}."
+ )
+
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
def close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.send_command("quit", "")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 2/4] dts: add toggle option to send and capture
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
@ 2024-07-08 19:30 ` Dean Marx
2024-07-10 16:13 ` Jeremy Spewock
2024-07-08 19:30 ` [PATCH v3 3/4] dts: dynamic config conf schema Dean Marx
2024-07-08 19:30 ` [PATCH v3 4/4] dts: dynamic config test suite Dean Marx
2 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:30 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
add option to skip _adjust_addresses method in send_packet_and_capture
when test cases involve sending packets with a preset MAC address.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/test_suite.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 694b2eba65..551a587525 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -185,6 +185,7 @@ def send_packet_and_capture(
packet: Packet,
filter_config: PacketFilteringConfig = PacketFilteringConfig(),
duration: float = 1,
+ adjust_addresses: bool = True,
) -> list[Packet]:
"""Send and receive `packet` using the associated TG.
@@ -195,11 +196,15 @@ def send_packet_and_capture(
packet: The packet to send.
filter_config: The filter to use when capturing packets.
duration: Capture traffic for this amount of time after sending `packet`.
+ adjust_addresses: If :data:'True', adjust addresses of the egressing packet with
+ a default addressing scheme. If :data:'False', do not adjust the addresses of
+ egressing packet.
Returns:
A list of received packets.
"""
- packet = self._adjust_addresses(packet)
+ if adjust_addresses:
+ packet = self._adjust_addresses(packet)
return self.tg_node.send_packet_and_capture(
packet,
self._tg_port_egress,
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 3/4] dts: dynamic config conf schema
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
2024-07-08 19:30 ` [PATCH v3 2/4] dts: add toggle option to send and capture Dean Marx
@ 2024-07-08 19:30 ` Dean Marx
2024-07-10 16:45 ` Jeremy Spewock
2024-07-08 19:30 ` [PATCH v3 4/4] dts: dynamic config test suite Dean Marx
2 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:30 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
configuration schema to run dynamic configuration test suite.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..d7b4afed7d 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 3/4] dts: dynamic config conf schema
2024-07-08 19:30 ` [PATCH v3 3/4] dts: dynamic config conf schema Dean Marx
@ 2024-07-10 16:45 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-10 16:45 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 8, 2024 at 3:30 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> configuration schema to run dynamic configuration test suite.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 4/4] dts: dynamic config test suite
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
2024-07-08 19:30 ` [PATCH v3 2/4] dts: add toggle option to send and capture Dean Marx
2024-07-08 19:30 ` [PATCH v3 3/4] dts: dynamic config conf schema Dean Marx
@ 2024-07-08 19:30 ` Dean Marx
2024-07-10 16:45 ` Jeremy Spewock
2 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-08 19:30 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/tests/TestSuite_dynamic_config.py | 149 ++++++++++++++++++++++++++
1 file changed, 149 insertions(+)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..a6e5384c50
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from time import sleep
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def set_up_suite(self) -> None:
+ """Set up the test suite.
+
+ Setup:
+ Verify that at least two ports are open for session.
+ """
+ self.verify(len(self._port_links) > 1, "Not enough ports")
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet=packet, adjust_addresses=False)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ shell: interactive testpmd shell object.
+ """
+ shell = TestPmdShell(node=self.sut_node)
+ shell.start()
+ shell.set_promisc(port=port_id, on=False)
+ shell.set_forward_mode(SimpleForwardingModes.io)
+ return shell
+
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ testpmd = TestPmdShell(node=self.sut_node)
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:00")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:00")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
+ testpmd.close()
+ sleep(6)
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 4/4] dts: dynamic config test suite
2024-07-08 19:30 ` [PATCH v3 4/4] dts: dynamic config test suite Dean Marx
@ 2024-07-10 16:45 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-10 16:45 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 8, 2024 at 3:30 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> Suite for testing ability of Poll Mode Driver to turn promiscuous
> mode on/off, allmulticast mode on/off, and show expected behavior
> when sending packets with known, unknown, broadcast, and multicast
> destination MAC addresses.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
> dts/tests/TestSuite_dynamic_config.py | 149 ++++++++++++++++++++++++++
> 1 file changed, 149 insertions(+)
> create mode 100644 dts/tests/TestSuite_dynamic_config.py
>
> diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
> new file mode 100644
> index 0000000000..a6e5384c50
> --- /dev/null
> +++ b/dts/tests/TestSuite_dynamic_config.py
> @@ -0,0 +1,149 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2024 University of New Hampshire
> +
> +"""Dynamic configuration capabilities test suite.
> +
> +This suite checks that it is possible to change the configuration of a port
> +dynamically. The Poll Mode Driver should be able to enable and disable
> +promiscuous mode on each port, as well as check the Rx and Tx packets of
> +each port
It might be worth explaining here more of what specifically is being
checked by the PMD. It seems like there is different expected output
based on whether promisc mode is on or not as well as different
behaviors with different MAC addresses.
.
> +
> +If packets should be received and forwarded, or received and not forwarded,
> +depending on the configuration, the port info should match the expected behavior.
> +"""
<snip>
> + def test_default_mode(self) -> None:
> + """Tests default configuration.
> +
> + Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
> + and sends two packets; one matching source MAC address and one unknown.
> + Verifies that both are received.
> + """
> + testpmd = TestPmdShell(node=self.sut_node)
> + isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
> + self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
> + testpmd.start()
> + mac = testpmd.show_port_info(0).mac_address
> + # send a packet with Rx port mac address
> + self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
> + # send a packet with mismatched mac address
> + self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:00")
We should be careful using the MAC address that is all 0s as that is a
special address that is reserved for localhost. I think it would still
work in this case since it wouldn't match the address of the tester's
port anyway, but it might be safer to just make the last digit of this
a 1 regardless.
> + testpmd.close()
> + sleep(6)
> +
<snip>
> 2.44.0
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v4 1/3] dts: add multicast set function to shell
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
` (4 preceding siblings ...)
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
@ 2024-07-15 16:00 ` Dean Marx
2024-07-15 16:00 ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
` (2 more replies)
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
6 siblings, 3 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-15 16:00 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
added set multicast function for changing allmulticast mode within testpmd.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index ec22f72221..a0be0bd09d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -806,6 +806,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_promisc(self, port: int, on: bool, verify: bool = True):
+ """Turns promiscuous mode on/off for the specified port.
+
+ Args:
+ port: Port number to use, should be within 0-32.
+ on: If :data:`True`, turn promisc mode on, otherwise turn off.
+ verify: If :data:`True` an additional command will be sent to verify that promisc mode
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
+ is not correctly set.
+ """
+ promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
+ if verify:
+ stats = self.show_port_info(port_id=port)
+ if on ^ stats.is_promiscuous_mode_enabled:
+ self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set promisc mode on port {port}."
+ )
+
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
def close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.send_command("quit", "")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v4 2/3] dts: dynamic config conf schema
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
@ 2024-07-15 16:00 ` Dean Marx
2024-07-15 20:22 ` Jeremy Spewock
2024-07-15 16:00 ` [PATCH v4 3/3] dts: dynamic config test suite Dean Marx
2024-07-15 20:22 ` [PATCH v4 1/3] dts: add multicast set function to shell Jeremy Spewock
2 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-15 16:00 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
configuration schema to run dynamic configuration test suite.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..d7b4afed7d 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v4 2/3] dts: dynamic config conf schema
2024-07-15 16:00 ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
@ 2024-07-15 20:22 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-15 20:22 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 15, 2024 at 12:00 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> configuration schema to run dynamic configuration test suite.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v4 3/3] dts: dynamic config test suite
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
2024-07-15 16:00 ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
@ 2024-07-15 16:00 ` Dean Marx
2024-07-15 20:22 ` Jeremy Spewock
2024-07-15 20:22 ` [PATCH v4 1/3] dts: add multicast set function to shell Jeremy Spewock
2 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-15 16:00 UTC (permalink / raw)
To: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, jspewock, bruce.richardson, luca.vizzarro
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Depends-on: patch-1142113 ("add send_packets to test suites and rework
packet addressing")
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/tests/TestSuite_dynamic_config.py | 152 ++++++++++++++++++++++++++
1 file changed, 152 insertions(+)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..d6d26419f0
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,152 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from time import sleep
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def set_up_suite(self) -> None:
+ """Set up the test suite.
+
+ Setup:
+ Verify that at least two ports are open for session.
+ """
+ self.verify(len(self._port_links) > 1, "Not enough ports")
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ shell: interactive testpmd shell object.
+ """
+ shell = TestPmdShell(node=self.sut_node)
+ shell.start()
+ shell.set_promisc(port=port_id, on=False)
+ shell.set_forward_mode(SimpleForwardingModes.io)
+ return shell
+
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ testpmd = TestPmdShell(node=self.sut_node)
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+ testpmd.close()
+ sleep(6)
+
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ testpmd = self.disable_promisc_setup(port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
+ testpmd.close()
+ sleep(6)
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v4 3/3] dts: dynamic config test suite
2024-07-15 16:00 ` [PATCH v4 3/3] dts: dynamic config test suite Dean Marx
@ 2024-07-15 20:22 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-15 20:22 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 15, 2024 at 12:00 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> Suite for testing ability of Poll Mode Driver to turn promiscuous
> mode on/off, allmulticast mode on/off, and show expected behavior
> when sending packets with known, unknown, broadcast, and multicast
> destination MAC addresses.
>
> Depends-on: patch-1142113 ("add send_packets to test suites and rework
> packet addressing")
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v4 1/3] dts: add multicast set function to shell
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
2024-07-15 16:00 ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
2024-07-15 16:00 ` [PATCH v4 3/3] dts: dynamic config test suite Dean Marx
@ 2024-07-15 20:22 ` Jeremy Spewock
2 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-15 20:22 UTC (permalink / raw)
To: Dean Marx
Cc: Honnappa.Nagarahalli, juraj.linkes, probb, paul.szczepanek,
yoan.picchi, bruce.richardson, luca.vizzarro, dev
On Mon, Jul 15, 2024 at 12:00 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> added set multicast function for changing allmulticast mode within testpmd.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
I still think this patch would benefit from my above comments about
modifying the method signatures and using show_port_info_all(), but it
looks good to me otherwise.
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 0/3] dts: refactored dynamic config test suite
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
` (5 preceding siblings ...)
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
@ 2024-07-24 19:21 ` Dean Marx
2024-07-24 19:21 ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
` (3 more replies)
6 siblings, 4 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-24 19:21 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
Refactored dynamic configuration suite to be compatible with context
manager.
Dean Marx (3):
dts: add multicast set function to shell
dts: dynamic config conf schema
dts: dynamic config test suite
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/framework/remote_session/testpmd_shell.py | 46 ++++++
dts/tests/TestSuite_dynamic_config.py | 145 ++++++++++++++++++
3 files changed, 193 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 1/3] dts: add multicast set function to shell
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
@ 2024-07-24 19:21 ` Dean Marx
2024-08-07 15:50 ` Luca Vizzarro
2024-07-24 19:21 ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
` (2 subsequent siblings)
3 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-24 19:21 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
added set multicast function for changing allmulticast mode within testpmd.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index eda6eb320f..b7af2adb14 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -804,6 +804,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_promisc(self, port: int, on: bool, verify: bool = True):
+ """Turns promiscuous mode on/off for the specified port.
+
+ Args:
+ port: Port number to use, should be within 0-32.
+ on: If :data:`True`, turn promisc mode on, otherwise turn off.
+ verify: If :data:`True` an additional command will be sent to verify that promisc mode
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
+ is not correctly set.
+ """
+ promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
+ if verify:
+ stats = self.show_port_info(port_id=port)
+ if on ^ stats.is_promiscuous_mode_enabled:
+ self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set promisc mode on port {port}."
+ )
+
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
def _close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.stop()
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v5 1/3] dts: add multicast set function to shell
2024-07-24 19:21 ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
@ 2024-08-07 15:50 ` Luca Vizzarro
0 siblings, 0 replies; 36+ messages in thread
From: Luca Vizzarro @ 2024-08-07 15:50 UTC (permalink / raw)
To: Dean Marx, probb, npratte, jspewock, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev
Hi Dean,
Apologies again for having replied to the wrong email thread. I'll copy
my comments here. And thank you again for your contribution
On 24/07/2024 20:21, Dean Marx wrote:
> added set multicast function for changing allmulticast mode within testpmd.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
> dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
> index eda6eb320f..b7af2adb14 100644
> --- a/dts/framework/remote_session/testpmd_shell.py
> +++ b/dts/framework/remote_session/testpmd_shell.py
> @@ -804,6 +804,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
>
> return TestPmdPortStats.parse(output)
>
> + def set_promisc(self, port: int, on: bool, verify: bool = True):
> + """Turns promiscuous mode on/off for the specified port.
> +
> + Args:
> + port: Port number to use, should be within 0-32.
> + on: If :data:`True`, turn promisc mode on, otherwise turn off.
> + verify: If :data:`True` an additional command will be sent to verify that promisc mode
> + is properly set. Defaults to :data:`True`.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
> + is not correctly set.
> + """
> + promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
> + if verify:
> + stats = self.show_port_info(port_id=port)
> + if on ^ stats.is_promiscuous_mode_enabled:
> + self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
> + raise InteractiveCommandExecutionError(
> + f"Testpmd failed to set promisc mode on port {port}."
> + )
> +
> + def set_multicast_all(self, on: bool, verify: bool = True):
> + """Turns multicast mode on/off for the specified port.
> +
> + Args:
> + on: If :data:`True`, turns multicast mode on, otherwise turns off.
> + verify: If :data:`True` an additional command will be sent to verify
> + that multicast mode is properly set. Defaults to :data:`True`.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
> + mode is not properly set.
> + """
> + multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
> + if verify:
> + stats0 = self.show_port_info(port_id=0)
> + stats1 = self.show_port_info(port_id=1)
This assumes that we have port 0 and 1, but *technically* we shouldn't
be making assumptions about the environment in the framework. I'd rather
use show_port_info_all and sample from there what's available.
> + if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
> + self._logger.debug(
> + f"Failed to set multicast mode on all ports.: \n{multicast_output}"
> + )
> + raise InteractiveCommandExecutionError(
> + "Testpmd failed to set multicast mode on all ports."
> + )
> +
> def _close(self) -> None:
> """Overrides :meth:`~.interactive_shell.close`."""
> self.stop()
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 2/3] dts: dynamic config conf schema
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
2024-07-24 19:21 ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
@ 2024-07-24 19:21 ` Dean Marx
2024-07-26 19:35 ` Jeremy Spewock
2024-08-07 15:56 ` Luca Vizzarro
2024-07-24 19:21 ` [PATCH v5 3/3] dts: dynamic config test suite Dean Marx
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
3 siblings, 2 replies; 36+ messages in thread
From: Dean Marx @ 2024-07-24 19:21 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
configuration schema to run dynamic configuration test suite.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..d7b4afed7d 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v5 2/3] dts: dynamic config conf schema
2024-07-24 19:21 ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
@ 2024-07-26 19:35 ` Jeremy Spewock
2024-08-07 15:56 ` Luca Vizzarro
1 sibling, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-26 19:35 UTC (permalink / raw)
To: Dean Marx
Cc: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek, juraj.linkes, dev
On Wed, Jul 24, 2024 at 3:21 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> configuration schema to run dynamic configuration test suite.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v5 2/3] dts: dynamic config conf schema
2024-07-24 19:21 ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
2024-07-26 19:35 ` Jeremy Spewock
@ 2024-08-07 15:56 ` Luca Vizzarro
1 sibling, 0 replies; 36+ messages in thread
From: Luca Vizzarro @ 2024-08-07 15:56 UTC (permalink / raw)
To: Dean Marx, probb, npratte, jspewock, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev
Similar to my other reply.
Please follow contributing guidelines when writing your commit subject
and body[1]. For example, an imperative subject:
dts: add dynamic config test to conf schema
Moreover, is there a reason to split this from the test suite commit?
Thanks,
Luca
[1]
https://doc.dpdk.org/guides/contributing/patches.html#commit-messages-subject-line
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 3/3] dts: dynamic config test suite
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
2024-07-24 19:21 ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
2024-07-24 19:21 ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
@ 2024-07-24 19:21 ` Dean Marx
2024-07-26 19:35 ` Jeremy Spewock
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
3 siblings, 1 reply; 36+ messages in thread
From: Dean Marx @ 2024-07-24 19:21 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Depends-on: patch-1142113 ("add send_packets to test suites and rework
packet addressing")
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/tests/TestSuite_dynamic_config.py | 145 ++++++++++++++++++++++++++
1 file changed, 145 insertions(+)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..55e2a2ba12
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,145 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def set_up_suite(self) -> None:
+ """Set up the test suite.
+
+ Setup:
+ Verify that at least two ports are open for session.
+ """
+ self.verify(len(self._port_links) > 1, "Not enough ports")
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ testpmd: Testpmd session that is being configured.
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ TestPmdShell: interactive testpmd shell object.
+ """
+ testpmd.start()
+ testpmd.set_promisc(port=port_id, on=False)
+ testpmd.set_forward_mode(SimpleForwardingModes.io)
+ return testpmd
+
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v5 3/3] dts: dynamic config test suite
2024-07-24 19:21 ` [PATCH v5 3/3] dts: dynamic config test suite Dean Marx
@ 2024-07-26 19:35 ` Jeremy Spewock
0 siblings, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2024-07-26 19:35 UTC (permalink / raw)
To: Dean Marx
Cc: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek, juraj.linkes, dev
On Wed, Jul 24, 2024 at 3:21 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> Suite for testing ability of Poll Mode Driver to turn promiscuous
> mode on/off, allmulticast mode on/off, and show expected behavior
> when sending packets with known, unknown, broadcast, and multicast
> destination MAC addresses.
>
> Depends-on: patch-1142113 ("add send_packets to test suites and rework
> packet addressing")
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v6 0/2] dts: refactored dynamic config test suite
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
` (2 preceding siblings ...)
2024-07-24 19:21 ` [PATCH v5 3/3] dts: dynamic config test suite Dean Marx
@ 2024-08-07 19:18 ` Dean Marx
2024-08-07 19:18 ` [PATCH v6 1/2] dts: add multicast set function to shell Dean Marx
` (3 more replies)
3 siblings, 4 replies; 36+ messages in thread
From: Dean Marx @ 2024-08-07 19:18 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
*v6: combined conf schema patch with test suite patch
Dean Marx (2):
dts: add multicast set function to shell
dts: dynamic config test suite
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/framework/remote_session/testpmd_shell.py | 46 ++++++
dts/tests/TestSuite_dynamic_config.py | 145 ++++++++++++++++++
3 files changed, 193 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v6 1/2] dts: add multicast set function to shell
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
@ 2024-08-07 19:18 ` Dean Marx
2024-08-07 19:18 ` [PATCH v6 2/2] dts: dynamic config test suite Dean Marx
` (2 subsequent siblings)
3 siblings, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-08-07 19:18 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
added set multicast function for changing allmulticast mode within testpmd.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index eda6eb320f..b7af2adb14 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -804,6 +804,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_promisc(self, port: int, on: bool, verify: bool = True):
+ """Turns promiscuous mode on/off for the specified port.
+
+ Args:
+ port: Port number to use, should be within 0-32.
+ on: If :data:`True`, turn promisc mode on, otherwise turn off.
+ verify: If :data:`True` an additional command will be sent to verify that promisc mode
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
+ is not correctly set.
+ """
+ promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
+ if verify:
+ stats = self.show_port_info(port_id=port)
+ if on ^ stats.is_promiscuous_mode_enabled:
+ self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set promisc mode on port {port}."
+ )
+
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
def _close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.stop()
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v6 2/2] dts: dynamic config test suite
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
2024-08-07 19:18 ` [PATCH v6 1/2] dts: add multicast set function to shell Dean Marx
@ 2024-08-07 19:18 ` Dean Marx
2024-10-10 20:17 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
2024-10-10 20:21 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
3 siblings, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-08-07 19:18 UTC (permalink / raw)
To: probb, npratte, jspewock, luca.vizzarro, yoan.picchi,
Honnappa.Nagarahalli, paul.szczepanek, juraj.linkes
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Depends-on: patch-1142113 ("add send_packets to test suites and rework
packet addressing")
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/tests/TestSuite_dynamic_config.py | 145 +++++++++++++++++++++
2 files changed, 147 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..d7b4afed7d 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..55e2a2ba12
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,145 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def set_up_suite(self) -> None:
+ """Set up the test suite.
+
+ Setup:
+ Verify that at least two ports are open for session.
+ """
+ self.verify(len(self._port_links) > 1, "Not enough ports")
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ testpmd: Testpmd session that is being configured.
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ TestPmdShell: interactive testpmd shell object.
+ """
+ testpmd.start()
+ testpmd.set_promisc(port=port_id, on=False)
+ testpmd.set_forward_mode(SimpleForwardingModes.io)
+ return testpmd
+
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 0/2] dts: port over dynamic config suite
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
2024-08-07 19:18 ` [PATCH v6 1/2] dts: add multicast set function to shell Dean Marx
2024-08-07 19:18 ` [PATCH v6 2/2] dts: dynamic config test suite Dean Marx
@ 2024-10-10 20:17 ` Dean Marx
2024-10-10 20:17 ` [PATCH v7 1/2] dts: add multicast set funciton to shell Dean Marx
2024-10-10 20:17 ` [PATCH v7 2/2] dts: port over dynamic config test suite Dean Marx
2024-10-10 20:21 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
3 siblings, 2 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:17 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Dynamic Configuration suite for verifying the Poll Mode Driver's ability
to enable/disable promiscuous and allmulticast mode. Verifies the
expected behavior in the following four test cases:
1. Default mode - verifies that promiscuous mode is enabled by default,
and packets with any destination MAC address are forwarded.
2. Disable promisc - turns off promiscuous mode, verifies that packets
with destination MAC addresses matching that of the Rx port are
forwarded, while packets with unknown addresses are dropped.
3. Disable promisc broadcast - turns off promiscuous mode, verifies that
packets with matching or broadcast destination MAC addresses are
forwarded.
4. Disable promisc multicast - turns off promiscuous mode, verifies that
packets with multicast destination MAC addresses are dropped when
allmulticast mode is turned off, and forwarded when it is turned on.
--------------------
v6:
* Combined configuration schema with test suite patch
v7:
* Rebased off next-dts
Dean Marx (2):
dts: add multicast set funciton to shell
dts: port over dynamic config test suite
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/framework/remote_session/testpmd_shell.py | 24 +++
dts/tests/TestSuite_dynamic_config.py | 143 ++++++++++++++++++
3 files changed, 169 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 1/2] dts: add multicast set funciton to shell
2024-10-10 20:17 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
@ 2024-10-10 20:17 ` Dean Marx
2024-10-10 20:17 ` [PATCH v7 2/2] dts: port over dynamic config test suite Dean Marx
1 sibling, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:17 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Add set multicast function for changing allmulticast mode
within testpmd shell.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index dc1bef431d..ab0ffa930d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1718,6 +1718,30 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_cmd_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_cmd_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
@requires_stopped_ports
def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None:
"""Change the MTU of a port using testpmd.
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 2/2] dts: port over dynamic config test suite
2024-10-10 20:17 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
2024-10-10 20:17 ` [PATCH v7 1/2] dts: add multicast set funciton to shell Dean Marx
@ 2024-10-10 20:17 ` Dean Marx
1 sibling, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:17 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/tests/TestSuite_dynamic_config.py | 143 +++++++++++++++++++++
2 files changed, 145 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index df390e8ae2..5b70600f1f 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..e07a95ceb8
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite, func_test
+from framework.testbed_model.capability import TopologyType, requires
+
+
+@requires(topology_type=TopologyType.two_links)
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ testpmd: Testpmd session that is being configured.
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ TestPmdShell: interactive testpmd shell object.
+ """
+ testpmd.start()
+ testpmd.set_promisc(port=port_id, enable=False)
+ testpmd.set_forward_mode(SimpleForwardingModes.io)
+ return testpmd
+
+ @func_test
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+
+ @func_test
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+
+ @func_test
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+
+ @func_test
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 0/2] dts: port over dynamic config suite
2024-08-07 19:18 ` [PATCH v6 0/2] dts: refactored " Dean Marx
` (2 preceding siblings ...)
2024-10-10 20:17 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
@ 2024-10-10 20:21 ` Dean Marx
2024-10-10 20:21 ` [PATCH v7 1/2] dts: add multicast set function to shell Dean Marx
2024-10-10 20:21 ` [PATCH v7 2/2] dts: port over dynamic config test suite Dean Marx
3 siblings, 2 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:21 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Dynamic Configuration suite for verifying the Poll Mode Driver's ability
to enable/disable promiscuous and allmulticast mode. Verifies the
expected behavior in the following four test cases:
1. Default mode - verifies that promiscuous mode is enabled by default,
and packets with any destination MAC address are forwarded.
2. Disable promisc - turns off promiscuous mode, verifies that packets
with destination MAC addresses matching that of the Rx port are
forwarded, while packets with unknown addresses are dropped.
3. Disable promisc broadcast - turns off promiscuous mode, verifies that
packets with matching or broadcast destination MAC addresses are
forwarded.
4. Disable promisc multicast - turns off promiscuous mode, verifies that
packets with multicast destination MAC addresses are dropped when
allmulticast mode is turned off, and forwarded when it is turned on.
--------------------
v6:
* Combined configuration schema with test suite patch
v7:
* Rebased off next-dts
Dean Marx (2):
dts: add multicast set funciton to shell
dts: port over dynamic config test suite
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/framework/remote_session/testpmd_shell.py | 24 +++
dts/tests/TestSuite_dynamic_config.py | 143 ++++++++++++++++++
3 files changed, 169 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 1/2] dts: add multicast set function to shell
2024-10-10 20:21 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
@ 2024-10-10 20:21 ` Dean Marx
2024-10-10 20:21 ` [PATCH v7 2/2] dts: port over dynamic config test suite Dean Marx
1 sibling, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:21 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Add set multicast function for changing allmulticast mode
within testpmd shell.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index dc1bef431d..ab0ffa930d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1718,6 +1718,30 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
return TestPmdPortStats.parse(output)
+ def set_multicast_all(self, on: bool, verify: bool = True):
+ """Turns multicast mode on/off for the specified port.
+
+ Args:
+ on: If :data:`True`, turns multicast mode on, otherwise turns off.
+ verify: If :data:`True` an additional command will be sent to verify
+ that multicast mode is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
+ mode is not properly set.
+ """
+ multicast_cmd_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
+ if verify:
+ stats0 = self.show_port_info(port_id=0)
+ stats1 = self.show_port_info(port_id=1)
+ if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):
+ self._logger.debug(
+ f"Failed to set multicast mode on all ports.: \n{multicast_cmd_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to set multicast mode on all ports."
+ )
+
@requires_stopped_ports
def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None:
"""Change the MTU of a port using testpmd.
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v7 2/2] dts: port over dynamic config test suite
2024-10-10 20:21 ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
2024-10-10 20:21 ` [PATCH v7 1/2] dts: add multicast set function to shell Dean Marx
@ 2024-10-10 20:21 ` Dean Marx
1 sibling, 0 replies; 36+ messages in thread
From: Dean Marx @ 2024-10-10 20:21 UTC (permalink / raw)
To: probb, npratte, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli,
paul.szczepanek
Cc: dev, Dean Marx
Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/tests/TestSuite_dynamic_config.py | 143 +++++++++++++++++++++
2 files changed, 145 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_dynamic_config.py
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index df390e8ae2..5b70600f1f 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "dynamic_config"
]
},
"test_target": {
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..e07a95ceb8
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+from scapy.layers.inet import IP # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite, func_test
+from framework.testbed_model.capability import TopologyType, requires
+
+
+@requires(topology_type=TopologyType.two_links)
+class TestDynamicConfig(TestSuite):
+ """Dynamic config suite.
+
+ Use the show port commands to see the MAC address and promisc mode status
+ of the Rx port on the DUT. The suite will check the Rx and Tx packets
+ of each port after configuring promiscuous, multicast, and default mode
+ on the DUT to verify the expected behavior. It consists of four test cases:
+
+ 1. Default mode: verify packets are received and forwarded.
+ 2. Disable promiscuous mode: verify that packets are received
+ only for the packet with destination address matching the port address.
+ 3. Disable promiscuous mode broadcast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that broadcast packets are received and forwarded.
+ 4. Disable promiscuous mode multicast: verify that packets with destination
+ MAC address not matching the port are received and not forwarded, and verify
+ that multicast packets are received and forwarded.
+ """
+
+ def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+ """Generate, send and verify packets.
+
+ Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+ traffic generator if that behavior is expected.
+
+ Args:
+ should_receive: Indicate whether the packet should be received.
+ mac_address: Destination MAC address to generate in packet.
+ """
+ packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+ received = self.send_packet_and_capture(packet)
+ contains_packet = any(
+ packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+ )
+ self.verify(
+ should_receive == contains_packet,
+ f"Packet was {'dropped' if should_receive else 'received'}",
+ )
+
+ def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell:
+ """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+ Args:
+ testpmd: Testpmd session that is being configured.
+ port_id: Port number to disable promisc mode on.
+
+ Returns:
+ TestPmdShell: interactive testpmd shell object.
+ """
+ testpmd.start()
+ testpmd.set_promisc(port=port_id, enable=False)
+ testpmd.set_forward_mode(SimpleForwardingModes.io)
+ return testpmd
+
+ @func_test
+ def test_default_mode(self) -> None:
+ """Tests default configuration.
+
+ Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that both are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+ self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+ testpmd.start()
+ mac = testpmd.show_port_info(0).mac_address
+ # send a packet with Rx port mac address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ # send a packet with mismatched mac address
+ self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+
+ @func_test
+ def test_disable_promisc(self) -> None:
+ """Tests disabled promiscuous mode configuration.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one unknown.
+ Verifies that only the matching address packet is received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+
+ @func_test
+ def test_disable_promisc_broadcast(self) -> None:
+ """Tests broadcast reception with disabled promisc mode config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one broadcast.
+ Verifies that both packets are received.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ mac = testpmd.show_port_info(0).mac_address
+ self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+ self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+
+ @func_test
+ def test_disable_promisc_multicast(self) -> None:
+ """Tests allmulticast mode with disabled promisc config.
+
+ Creates an interactive testpmd shell, disables promiscuous mode,
+ and sends two packets; one matching source MAC address and one multicast.
+ Verifies that the multicast packet is only received once allmulticast mode is enabled.
+ """
+ with TestPmdShell(node=self.sut_node) as testpmd:
+ testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+ testpmd.set_multicast_all(on=False)
+ # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+ self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+ testpmd.set_multicast_all(on=True)
+ self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
--
2.44.0
^ permalink raw reply [flat|nested] 36+ messages in thread