DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] app/testpmd: fix MAC endian issue in flow command
Date: Thu,  4 May 2017 19:08:23 +0200	[thread overview]
Message-ID: <2f565661121fe816a097d41dd375cb7c44932cf4.1493917362.git.adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <76e59d59935ffccf9996c536866fcef64d6319b0.1493917362.git.adrien.mazarguil@6wind.com>

MAC addresses are implicitly handled in network order since they are
actually byte strings, however this is not properly enforced with MAC masks
provided as prefix lengths, which end up inverted on little endian
systems.

Fixes: 6df81b325fa4 ("app/testpmd: add items eth/vlan to flow command")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e952c91..0fd69f9 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -1057,13 +1057,13 @@ static const struct token token_list[] = {
 		.name = "dst",
 		.help = "destination MAC",
 		.next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
-		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_eth, dst)),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
 	},
 	[ITEM_ETH_SRC] = {
 		.name = "src",
 		.help = "source MAC",
 		.next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
-		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_eth, src)),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
 	},
 	[ITEM_ETH_TYPE] = {
 		.name = "type",
@@ -2238,6 +2238,9 @@ parse_mac_addr(struct context *ctx, const struct token *token,
 	/* Bit-mask fill is not supported. */
 	if (arg->mask || size != sizeof(tmp))
 		goto error;
+	/* Only network endian is supported. */
+	if (!arg->hton)
+		goto error;
 	ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
 	if (ret < 0 || (unsigned int)ret != len)
 		goto error;
-- 
2.1.4

  reply	other threads:[~2017-05-04 17:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 17:08 [dpdk-dev] [PATCH 1/2] app/testpmd: fix stack overwriting by " Adrien Mazarguil
2017-05-04 17:08 ` Adrien Mazarguil [this message]
2017-05-06  8:14   ` [dpdk-dev] [PATCH 2/2] app/testpmd: fix MAC endian issue in " 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=2f565661121fe816a097d41dd375cb7c44932cf4.1493917362.git.adrien.mazarguil@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=dev@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).