From patchwork Mon Jul 15 16:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142407 X-Patchwork-Delegate: thomas@monjalon.net 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 067D3455FC; Mon, 15 Jul 2024 18:00:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBA7D4067A; Mon, 15 Jul 2024 18:00:35 +0200 (CEST) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by mails.dpdk.org (Postfix) with ESMTP id AA9B84065F for ; Mon, 15 Jul 2024 18:00:34 +0200 (CEST) Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-79f323f0898so286793985a.0 for ; Mon, 15 Jul 2024 09:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721059234; x=1721664034; 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=J0MY/4PRf8RS3DEkIQtsJfqVtKxjkPaPNqBU5yfDBfg=; b=FeZyJtH5mseWbv3yM02/vuyS2exX515/hWmqVnN4s6TGtwI095CXxdQ/jDYDoO6deP fro4JPlZBFO15vllOjafMBnVbzLg/heJPoil1u4Gxa7bFnZM9Dx5YvaivoGkAWvD0kC7 5Xmr4fIQ+fNJvxTHVSYpVe0WDYAg/+6HXUUTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721059234; x=1721664034; 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=J0MY/4PRf8RS3DEkIQtsJfqVtKxjkPaPNqBU5yfDBfg=; b=srR+G5OhwtSMyziEIAIy4D+TbQ1kAIpALI4W8vgTWZ51OqtLJzSLouMOleOYC0HoVZ kIwvmU+o5obCY56BPghNAkSGiQvO1grOscowySQeY1d1JpOmcNymTtMYVpcDM67qWhwg dEbkuGrHbcXJEGFvq+gHQ2a8LD3KX+Hmyyf+463VUAhGtMZgTJByWtsNuKgsdnqvYc+s Z2tkP+AxpKX7nRlZH0+5AVUoY1dZn/D4r06c8MKF2eh4lkJUfao0EEbAyyNIodEqy91+ v7ybFKUJfdngGo67+7jl7j4oSMONmwmeO2bZGZWAmqpjXr+qE9lAvgWLAo/FamBMFg5y swOA== X-Gm-Message-State: AOJu0YzC0ker2+1D5PNUnrnIn71naVk8o0eJAwzc+Zxn0lPJ8Zqm4ct/ ZWv/i5HVMDlIt1Fd6FEEjPUjT2+1PPVS3fNaxB4GAtwLmZNsOvls9A9aUUd2q4c= X-Google-Smtp-Source: AGHT+IGqiF/ji/vAG3gyR3bpt5Ir8kljJp7QAAd/MvfaRSjTnFrElBl2JCN8UAvSZCwdur7uKKPDMw== X-Received: by 2002:a05:620a:44cb:b0:79e:f78e:c554 with SMTP id af79cd13be357-7a179f18f3bmr22125185a.3.1721059233802; Mon, 15 Jul 2024 09:00:33 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bdd7fesm211292085a.65.2024.07.15.09.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 09:00:33 -0700 (PDT) From: Dean Marx To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v4 1/3] dts: add multicast set function to shell Date: Mon, 15 Jul 2024 12:00:19 -0400 Message-ID: <20240715160021.23352-1-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240708191938.32132-1-dmarx@iol.unh.edu> References: <20240708191938.32132-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 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", "") From patchwork Mon Jul 15 16:00:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142408 X-Patchwork-Delegate: thomas@monjalon.net 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 837C7455FC; Mon, 15 Jul 2024 18:00:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11A0C40E3F; Mon, 15 Jul 2024 18:00:40 +0200 (CEST) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by mails.dpdk.org (Postfix) with ESMTP id 15F5440E37 for ; Mon, 15 Jul 2024 18:00:36 +0200 (CEST) Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-79f083f5cb6so267977685a.3 for ; Mon, 15 Jul 2024 09:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721059235; x=1721664035; 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=AIQXJPVzCOy7PzUKPo0QIhI36d8ZJm+FeOIUoFnj7pogtl1xB4hJBxsevUHH52iowp Fy7D343fswWbJF/Z55w7fb/HNqy8I+NDDySHAhjLZhrAO8L4hZ3V05W9rAbiQ2CKL7WC hzM60Q/ukpDqzctgB5ZLC4sCbnwGUxUpMhO2c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721059235; x=1721664035; 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=M3+rdLrgD5wVtqapqwZbmaUp9RZF0zHR4LdDqV1p9Y6UHZGJS8sWduDygyt75+e2dV yplFVPbvOU9CdNCCBMpMf1QBfdpx2ruS7xNon7n4EaaM0GHU/sSDBzHOkaSD5BWouIRX ojiWo5yeqXwGyAAv5/Z6OAgw6fPxfqhw5Wjb2JRONvLrbsyh2Z/imWZ7EoWYUd0Eh4l2 xvOsmMVELIJXla72SRN8mUvM3ihn6gCPFT1enMfHHReMNHQaYe5Oe+7tXTT4zrFXkyHe O2sVdN3cGPSXz9TUbSbynQWMozEVImJFNO2uBBCdn5X1Qk0IIip+F3aU98X+Pe2R0pRw zojA== X-Gm-Message-State: AOJu0YzH9gtvFNbD3NLkXYdr/zsR8aahFkEVvkGhrBccw60sLp5ld9px 7q7hHHuzyUMYaw9R+cY1YHYECcb929jEQU0xQCcOkENdzYyw+5Tpj2zItScCmoc= X-Google-Smtp-Source: AGHT+IF9CUg9maB4o55+86Fd/gE7v/9/0TFc1vDk45K48Z/+MYrUYJQaFHGyliiwRkICeykWAbSsBQ== X-Received: by 2002:a05:620a:bc8:b0:79e:fbab:4762 with SMTP id af79cd13be357-7a179f987d4mr16979185a.50.1721059235379; Mon, 15 Jul 2024 09:00:35 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bdd7fesm211292085a.65.2024.07.15.09.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 09:00:35 -0700 (PDT) From: Dean Marx To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v4 2/3] dts: dynamic config conf schema Date: Mon, 15 Jul 2024 12:00:20 -0400 Message-ID: <20240715160021.23352-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240715160021.23352-1-dmarx@iol.unh.edu> References: <20240708191938.32132-1-dmarx@iol.unh.edu> <20240715160021.23352-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 Mon Jul 15 16:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Marx X-Patchwork-Id: 142409 X-Patchwork-Delegate: thomas@monjalon.net 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 78ABF455FC; Mon, 15 Jul 2024 18:00:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4379B40E44; Mon, 15 Jul 2024 18:00:41 +0200 (CEST) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by mails.dpdk.org (Postfix) with ESMTP id 996A640E38 for ; Mon, 15 Jul 2024 18:00:37 +0200 (CEST) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-79f1828ed64so310348885a.1 for ; Mon, 15 Jul 2024 09:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721059237; x=1721664037; 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=6y47Or2X/W/N604OUihGfw6wcLerV6yk4lWLGTMev8g=; b=Zwarf+vTnfGPqPm2NkXgAHbGMiz2zmC4yu8iLsdteJJ5b/58Mgg0bGEvCATRVpAowK uFvDYVUtP+8e2SgEYR8DLWq3y9yZzByBs3hpoMJGs4YBpxg2+WiXxzI/BfELokFlPOqk i720zqbXyd5IeV0NGRDKGlqYaZk09E0IzBGvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721059237; x=1721664037; 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=6y47Or2X/W/N604OUihGfw6wcLerV6yk4lWLGTMev8g=; b=iZrhxBjgYVKoRQOIdSifpwQvRam7+jls/HJ/FptVPr/aSQc2LZJY/D9Bm6i1TKRLBz O6qn+dORxfuutCS8xYXypSqobMLxMQ+SPP05He3Y3HOK2i41Tkj7vH9aI61MSshxDt/L J3DqRFnOURwneglNzJXrA3+ev33fQrxE0T3lsCHK8Cif/VQxTVKJgx+4A63pKpvHborB qAKGdsGbqqYdlEQ9DVzCoaENf2b/F5V2Rs33LgttyGxOLQtfwSIbGpnO6aAXRZhnLGms hyofblzUMdfTCYy5Vy28IWDJ9I5YTtMxU3E/3NBfA/FlEeUCfwzDvPNHtAcsgEfWFvdJ ydEg== X-Gm-Message-State: AOJu0Yyx2dk9a3gm8pihvRjscBPCelQR+XnujDj//cb0QCOrOIzICfGB UKSdEBoZmo15rLMYgss5P/qF4NvRoB5MBa91qqAnw03AwXdif+dh9BhlCYJl7tI= X-Google-Smtp-Source: AGHT+IEqKPMIDAeXz+eQCpFXjA4Q4AhOEbrGTwI1t+wRsxmXSbqas//IWEMDYDSSWUJ20Mnj4ynX2g== X-Received: by 2002:a05:620a:2585:b0:79d:5b21:804a with SMTP id af79cd13be357-7a179f19a3bmr22008785a.14.1721059236889; Mon, 15 Jul 2024 09:00:36 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bdd7fesm211292085a.65.2024.07.15.09.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 09:00:36 -0700 (PDT) From: Dean Marx To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v4 3/3] dts: dynamic config test suite Date: Mon, 15 Jul 2024 12:00:21 -0400 Message-ID: <20240715160021.23352-3-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240715160021.23352-1-dmarx@iol.unh.edu> References: <20240708191938.32132-1-dmarx@iol.unh.edu> <20240715160021.23352-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 | 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)