DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vipin Varghese <vipin.varghese@intel.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, pablo.de.lara.guarch@intel.com,
	bruce.richardson@intel.com,
	Vipin Varghese <vipin.varghese@intel.com>
Subject: [dpdk-dev] [PATCH] examples/l2fwd: check if user portmask is valid
Date: Fri,  2 Feb 2018 00:21:21 +0530	[thread overview]
Message-ID: <1517511081-16289-1-git-send-email-vipin.varghese@intel.com> (raw)

User can pass portmask with any value, even invalid mask. The code
checks against actual portmask.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
 examples/l2fwd/main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 6c07ed4..1c02c1b 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -549,6 +549,11 @@ enum {
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
+	/* icheck port mask to possible port mask */
+	if (l2fwd_enabled_port_mask & ~((1 << nb_ports) - 1))
+		rte_exit(EXIT_FAILURE, "Invalid portmask; possible (0x%x)\n",
+			(1 << nb_ports) - 1);
+
 	/* reset l2fwd_dst_ports */
 	for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
 		l2fwd_dst_ports[portid] = 0;
-- 
1.9.1

             reply	other threads:[~2018-02-01 18:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 18:51 Vipin Varghese [this message]
2018-02-01 18:58 ` [dpdk-dev] [PATCH v2] " Vipin Varghese
2018-02-06 16:55   ` De Lara Guarch, Pablo
2018-02-06 17:53     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517511081-16289-1-git-send-email-vipin.varghese@intel.com \
    --to=vipin.varghese@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).