From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC561A0C4D; Wed, 13 Oct 2021 09:23:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A3AF410EB; Wed, 13 Oct 2021 09:23:14 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id EE22540150 for ; Wed, 13 Oct 2021 09:23:13 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id y3so5031254wrl.1 for ; Wed, 13 Oct 2021 00:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aMW4UewWsUiAUUR+t5MA34KHlXemvjrIkmISoYTRumw=; b=bwe17SPJ9Yen75tYUpY/P6oEmVKVt6Xa2Z9c4YNO49i7todBnlu2uiVgXfgaGKCvvF hPegLFFUtzc6Sg+yFh5eXlnaTq3JidAfkc9dvTgcj216ZLdyQcQwhcHjMWA/Rx0OFsQd WdwuJ29qXjIQ/dyLPwGhhhdP5xCkDqJZmqFLkQYFBoUdmdkM3jMqEO5p1lAEu6IOEYHr gK6hdflgxD4Hk9ltZiin6XeeCwIW17MNU78IoyWKXWAVSGwSnKwevaMs02vx7wUuRhiL DX0ccfpkjaCIyPxdUP7SmBBpkKuyRQQ7y7V7fz9U5vOB5P3iqcA9Ml4PIugMlkqoicBP kxMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aMW4UewWsUiAUUR+t5MA34KHlXemvjrIkmISoYTRumw=; b=Vbhet1WJxFkoKC2faffqtR6XkOnL39mohR0EvY4xHvvZ2yDKaKy9Gd8Z0+B70sVmJh Y7pxTP2a4ZlbRCCL1DTc5j2S+lR9m+DBn2+RBNUCgCPl9x3junVymhTrqveHC8TDHotk 82ifWqNgcA/Qw391KyBZkRjnKdNBZ9L9IrGz5ELJiAhydZw78/jfzdZHt5v1ATVnPSf3 FaPTbvo/IAAStgBhr88AtsOgHFucW8OdJiyJJRU8QACGrk0lV69lGMIlK9fHEoTqPKOn FQR2V5Jj3HScrFgYJ01NJGZZdmxCpQJqYk0jw7zFYTTAk4QlzrUfuCn/8wiVxXsWh8QJ vl8w== X-Gm-Message-State: AOAM530BIcGOleIrKpXjOKp9A5cAG+xsd2r784Y4vgaCla28xTRMIFE5 2oUDk7Jagxgni+bPKMD2ph1YVQ== X-Google-Smtp-Source: ABdhPJw+OO7RfxZP4vnEnppa1mpXwwpJnWXWJQ74rLF6TGa8cWshvKQA5jM7hH1wqMRkve345SpdQg== X-Received: by 2002:a5d:6484:: with SMTP id o4mr27418704wri.337.1634109793733; Wed, 13 Oct 2021 00:23:13 -0700 (PDT) Received: from localhost.localdomain ([101.50.108.46]) by smtp.gmail.com with ESMTPSA id l2sm4895691wmi.1.2021.10.13.00.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 00:23:13 -0700 (PDT) From: Sarosh Arif To: bruce.richardson@intel.com Cc: dev@dpdk.org, Sarosh Arif Date: Wed, 13 Oct 2021 12:23:03 +0500 Message-Id: <20211013072303.157394-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] examples/l2fwd: add promiscuous mode selection through command line option 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 Sender: "dev" The default behaviour of l2fwd is to exit if we are unable to turn promiscuous mode on. On some aws instances turning promiscuous mode on is not permitted. In such cases there should be a way to run the application without promiscuous mode. This patch allows user to turn promiscuous mode on via command line parameter. l3fwd has a similar option available. Signed-off-by: Sarosh Arif --- .../sample_app_ug/l2_forward_real_virtual.rst | 4 ++++ examples/l2fwd/main.c | 23 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst index 7b1529b2fa..ac1eab0b31 100644 --- a/doc/guides/sample_app_ug/l2_forward_real_virtual.rst +++ b/doc/guides/sample_app_ug/l2_forward_real_virtual.rst @@ -92,6 +92,7 @@ The application requires a number of command line options: .. code-block:: console .//examples/dpdk-l2fwd [EAL options] -- -p PORTMASK + [-P] [-q NQ] --[no-]mac-updating [--portmap="(port, port)[,(port, port)]"] @@ -100,6 +101,9 @@ where, * p PORTMASK: A hexadecimal bitmask of the ports to configure +* P: Optional, sets all ports to promiscuous mode so that packets are accepted regardless of the packet's Ethernet MAC destination address. + Without this option, only packets with the Ethernet MAC destination address set to the Ethernet address of the port are accepted. + * q NQ: A number of queues (=ports) per lcore (default is 1) * --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index f3deeba0a6..ce56cef863 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -44,6 +44,9 @@ static volatile bool force_quit; /* MAC updating enabled by default */ static int mac_updating = 1; +/* Ports set in promiscuous mode off by default. */ +static int promiscuous_on; + #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 #define MAX_PKT_BURST 32 @@ -307,8 +310,9 @@ l2fwd_launch_one_lcore(__rte_unused void *dummy) static void l2fwd_usage(const char *prgname) { - printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" + printf("%s [EAL options] -- -p PORTMASK [-P] [-q NQ]\n" " -p PORTMASK: hexadecimal bitmask of ports to configure\n" + " -P : Enable promiscuous mode\n" " -q NQ: number of queue (=ports) per lcore (default is 1)\n" " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n" " --no-mac-updating: Disable MAC addresses updating (enabled by default)\n" @@ -425,6 +429,7 @@ l2fwd_parse_timer_period(const char *q_arg) static const char short_options[] = "p:" /* portmask */ + "P" /* promiscuous */ "q:" /* number of queues */ "T:" /* timer period */ ; @@ -473,6 +478,9 @@ l2fwd_parse_args(int argc, char **argv) return -1; } break; + case 'P': + promiscuous_on = 1; + break; /* nqueue */ case 'q': @@ -872,12 +880,13 @@ main(int argc, char **argv) ret, portid); printf("done: \n"); - - ret = rte_eth_promiscuous_enable(portid); - if (ret != 0) - rte_exit(EXIT_FAILURE, - "rte_eth_promiscuous_enable:err=%s, port=%u\n", - rte_strerror(-ret), portid); + if (promiscuous_on) { + ret = rte_eth_promiscuous_enable(portid); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "rte_eth_promiscuous_enable:err=%s, port=%u\n", + rte_strerror(-ret), portid); + } printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n", portid, -- 2.25.1