From patchwork Wed Jul 24 19:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142710 X-Patchwork-Delegate: juraj.linkes@pantheon.tech Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D5EBF456A2; Wed, 24 Jul 2024 21:21:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CC024337A; Wed, 24 Jul 2024 21:21:42 +0200 (CEST) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by mails.dpdk.org (Postfix) with ESMTP id 6AB0E43370 for ; Wed, 24 Jul 2024 21:21:40 +0200 (CEST) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-44930ea05b8so894061cf.1 for ; Wed, 24 Jul 2024 12:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721848900; x=1722453700; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S+uEdwGGBPA+um5aZwyI/r1/i0fA2HJ0Psbc0e62X+0=; b=M1NZcVqJKNeEGUkL0h5TT3jA4+fFG8XrsEiUJZpeqDIE9r9saxVew5t3BNCLKQ3Cia lu1LCss0A5uAZvZtEgiqGZf3ji39lO4WnzcM8gpp05KOPXCJFyio69OzchNFV063shnd xNE495a7jaTermq543EM75KcFgm3Wp3wO8mKo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721848900; x=1722453700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+uEdwGGBPA+um5aZwyI/r1/i0fA2HJ0Psbc0e62X+0=; b=mwxLVi/tXT/erRY8vW4bab6gcOLfEu3p2kXP5VCQjZoaqGKVGPybwaxQt9rjppgR6t yC45yKVyAenXr9UP9NOCGf+NHJrRgbYR99cbjYvqfky4We2S/EpRq3Mf6TdVJDeu7uuo jyL94PrHKgXrNnJ9MnrP5kwF3bsyMPiMNx6F8XhZZelyO+oJEc1IiBG2yG0x8swCim8e wcPsQQtYW61IKswwVHh6JP0J02RHn1GwPOrkANXQhdoDQ4zx8farVjzSLaq010nVt68Q 7ef9wpplWCbG6hVAjDoDsWNzdjSd6lLPWz7VSfoRDsQ2nPaHHn/jOZATUHQNWDOkNlHu IvoQ== X-Gm-Message-State: AOJu0Ywp94OUQTaSW8ugkokKjV1M3YmC3pfeB9uKIp3dGqTVbj5vj+Yh KjEBfKHIg3IHwr6FD7dGMl8FWNtymq1P4I1ldLr1PI/RYAKJ3SeH8VdvPgHIrr5TDjknNipNGjX F X-Google-Smtp-Source: AGHT+IHU+CeGhTen8vwz9f7PtHU8Ipr0y3W8q+CQaGOQ7lj7gh5p/KMFV8ZQ/cL/sYRtqUhdsvJ8pA== X-Received: by 2002:ac8:7fc5:0:b0:446:5d83:7335 with SMTP id d75a77b69052e-44fe30e8189mr7738081cf.0.1721848899633; Wed, 24 Jul 2024 12:21:39 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe542f8b6sm1150331cf.67.2024.07.24.12.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 12:21:38 -0700 (PDT) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v5 1/3] dts: add multicast set function to shell Date: Wed, 24 Jul 2024 15:21:27 -0400 Message-ID: <20240724192129.29721-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240724192129.29721-1-dmarx@iol.unh.edu> References: <20240708191938.32132-1-dmarx@iol.unh.edu> <20240724192129.29721-1-dmarx@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org added set multicast function for changing allmulticast mode within testpmd. Signed-off-by: Dean Marx --- 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() From patchwork Wed Jul 24 19:21:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142711 X-Patchwork-Delegate: juraj.linkes@pantheon.tech Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 614F5456A2; Wed, 24 Jul 2024 21:21:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7CB0C43398; Wed, 24 Jul 2024 21:21:45 +0200 (CEST) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by mails.dpdk.org (Postfix) with ESMTP id BAB6143376 for ; Wed, 24 Jul 2024 21:21:41 +0200 (CEST) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-447ea09c8ddso934791cf.0 for ; Wed, 24 Jul 2024 12:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721848901; x=1722453701; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bq3lx7l6PcZDswU4+r6pDALdNMSX0X7a9iu9zuf91wc=; b=W7m0vpiizzskHnWyjre0jxYlPA3nfwEKn/sHNlqlminaG6ERuwREt2aNkUpoRtoXTi AY+BZW0keM75e7RaSmaANzKVAZVT5V1fQtCAdPTdTTzHGDs1J4WoO4WwD33LHxXzPwQN nZn6KFouDrblcC8eyamUzXNL+5n2BkztyChEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721848901; x=1722453701; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bq3lx7l6PcZDswU4+r6pDALdNMSX0X7a9iu9zuf91wc=; b=dh7Xy7fRqisxKI47nI7C2sywJjUgZ6RlzFXIml4J9xAyJeFu+jjF6dwR8AWa4JsZBs LwpRf5YYIu8JxfrElvIKQiz3HaVffpFfBRum+mo0u24iAsFiyIO81/dlAm/RxGeIfYXZ kH+6L9NU8zCcTiKss/h4YVjrvMH6GNBFgILMTDH2Wpw9m3zTTm6i35KLA6EuNpoCkUxp feCfDHio9klP4dH11H1qxjKj4iLYdxAwwWJxWXFwLrvGxZbE/cMUsQ+T0uM8lW6DDMmD 6agjaA2k7whMHXld2tzdcDpDV1gdhEiEp08zlx3XlhfRouyrhatp/fUwMoBuzY5DbERP xNlA== X-Gm-Message-State: AOJu0Yx0Ial/S0CMp373iYVzwBUAHpO5XyfROg8GGpZvzyLx1h8TN/v+ n43QSX8jtp64ADZ3rgUxxJej+QULI9GPTIvMyC5k7LDwxKXzSvEsMZ59dnzUE4M= X-Google-Smtp-Source: AGHT+IEaSDGWpmIzCLQOn/owUIVWUYzvNoOMoQZem4iPmCmEXReeRpGefZE9Zr374pto/Rb791DjLw== X-Received: by 2002:ac8:5909:0:b0:447:f6bb:6f80 with SMTP id d75a77b69052e-44fe30e3616mr7161791cf.0.1721848901082; Wed, 24 Jul 2024 12:21:41 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe542f8b6sm1150331cf.67.2024.07.24.12.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 12:21:40 -0700 (PDT) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v5 2/3] dts: dynamic config conf schema Date: Wed, 24 Jul 2024 15:21:28 -0400 Message-ID: <20240724192129.29721-3-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240724192129.29721-1-dmarx@iol.unh.edu> References: <20240708191938.32132-1-dmarx@iol.unh.edu> <20240724192129.29721-1-dmarx@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org configuration schema to run dynamic configuration test suite. Signed-off-by: Dean Marx Reviewed-by: Jeremy Spewock --- 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": { From patchwork Wed Jul 24 19:21:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142712 X-Patchwork-Delegate: juraj.linkes@pantheon.tech Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23C55456A2; Wed, 24 Jul 2024 21:21:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99476433C9; Wed, 24 Jul 2024 21:21:46 +0200 (CEST) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by mails.dpdk.org (Postfix) with ESMTP id B7B9D43398 for ; Wed, 24 Jul 2024 21:21:43 +0200 (CEST) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-447e2d719afso1956481cf.0 for ; Wed, 24 Jul 2024 12:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721848903; x=1722453703; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uGHSbV2JoX22SNc0h4vTlVu8z8pBJ++NaXZG+xxG/8s=; b=evugs8v5C3PsrVQqVjJZfA24yM2FM3yPMK63j1D3pgGkY+yNCkcd0SlGpLA4K2Eo/W H+iewk2dOlGu3jBJPUxys3dAnF2hzYYIk9/2PccBm49JWH7XXlOBy8Im2O2gatvV/Wnr lZqOyxEAaBuvmejnMKLThg4TZFZOpsaUO8+rE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721848903; x=1722453703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uGHSbV2JoX22SNc0h4vTlVu8z8pBJ++NaXZG+xxG/8s=; b=hGaiw+zvTlU04WbBQv5GRRw8AV00YMHktE1jFFq5tzaylLZDCqV4433l6qK0gCRDw5 f26I/hMx1UvBs5J+WqWmwATcuIPUo/HN9fseZfFXVuBxC/tO3tlkBe/e9WL+WI5I1skO eFbmqWVel6beqvAoshjms8AwAHxkncaBQiEfW6emJaqP42+toKVRRHxIw3hI8YHzrevh HHzBCKYLmyvTanXj5XZmqTRcjbR4PkDpAcxa6o/kdTCcsNi3OAzBvkGk4HEbGgNX08Bf Y7ErC887qc/QfzQyGOh22Qz6wdjGQ8R4wELQC/Uqb4oH6nd3qVf57M8/S+Ae0KnaMrgk Xurw== X-Gm-Message-State: AOJu0Ywlwt+D/RkYAFJn04PHzbgY2qetnhh/ef72PD1XQghKe2xhF8P1 JV5mUJb/vL3oXaBLJ1uUmSKjQi4y3XEGWHA+QtwI5tbCkQA/SVUQ7/UX9bWzvpc= X-Google-Smtp-Source: AGHT+IHdfD2Aa0eg9tUlMkOd0ZIGBRPMLoH2L/RhzzSZSJnRYQ+q3COtT/3qBzns4T+8NVFXgUFhYQ== X-Received: by 2002:a05:622a:1a13:b0:447:fa40:9f24 with SMTP id d75a77b69052e-44fe31e3c0bmr13177061cf.14.1721848902981; Wed, 24 Jul 2024 12:21:42 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe542f8b6sm1150331cf.67.2024.07.24.12.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 12:21:42 -0700 (PDT) From: Dean Marx To: probb@iol.unh.edu, npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v5 3/3] dts: dynamic config test suite Date: Wed, 24 Jul 2024 15:21:29 -0400 Message-ID: <20240724192129.29721-4-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240724192129.29721-1-dmarx@iol.unh.edu> References: <20240708191938.32132-1-dmarx@iol.unh.edu> <20240724192129.29721-1-dmarx@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Reviewed-by: Jeremy Spewock --- 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")