DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pascal Mazon <pascal.mazon@6wind.com>
To: keith.wiles@intel.com
Cc: dev@dpdk.org, Pascal Mazon <pascal.mazon@6wind.com>
Subject: [dpdk-dev] [PATCH 1/2] net/tap: UDP/TCP port mask not supported in flow
Date: Thu, 30 Mar 2017 10:52:47 +0200	[thread overview]
Message-ID: <11b7aa6796bd3e4147fbd4ec14b0125b6419aa80.1490863952.git.pascal.mazon@6wind.com> (raw)

Only full mask (0xffff) is accepted, there is no way to specify a mask
for layer 4 ports to the kernel using TC rules.

Fixes: 1c71189ab9b7 ("net/tap: add basic flow API patterns and actions")

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/tap_flow.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 514e3fae5c38..cf1c8a26c8ff 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -614,18 +614,20 @@ tap_flow_create_udp(const struct rte_flow_item *item, void *data)
 	/* check that previous ip_proto is compatible with udp */
 	if (info->ip_proto && info->ip_proto != IPPROTO_UDP)
 		return -1;
+	/* TC does not support UDP port masking. Only accept if exact match. */
+	if ((mask->hdr.src_port && mask->hdr.src_port != 0xffff) ||
+	    (mask->hdr.dst_port && mask->hdr.dst_port != 0xffff))
+		return -1;
 	if (!flow)
 		return 0;
 	msg = &flow->msg;
 	nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_UDP);
 	if (!spec)
 		return 0;
-	if (spec->hdr.dst_port &&
-	    (spec->hdr.dst_port & mask->hdr.dst_port) == spec->hdr.dst_port)
+	if (spec->hdr.dst_port & mask->hdr.dst_port)
 		nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_DST,
 			     spec->hdr.dst_port);
-	if (spec->hdr.src_port &&
-	    (spec->hdr.src_port & mask->hdr.src_port) == spec->hdr.src_port)
+	if (spec->hdr.src_port & mask->hdr.src_port)
 		nlattr_add16(&msg->nh, TCA_FLOWER_KEY_UDP_SRC,
 			     spec->hdr.src_port);
 	return 0;
@@ -658,18 +660,20 @@ tap_flow_create_tcp(const struct rte_flow_item *item, void *data)
 	/* check that previous ip_proto is compatible with tcp */
 	if (info->ip_proto && info->ip_proto != IPPROTO_TCP)
 		return -1;
+	/* TC does not support TCP port masking. Only accept if exact match. */
+	if ((mask->hdr.src_port && mask->hdr.src_port != 0xffff) ||
+	    (mask->hdr.dst_port && mask->hdr.dst_port != 0xffff))
+		return -1;
 	if (!flow)
 		return 0;
 	msg = &flow->msg;
 	nlattr_add8(&msg->nh, TCA_FLOWER_KEY_IP_PROTO, IPPROTO_TCP);
 	if (!spec)
 		return 0;
-	if (spec->hdr.dst_port &&
-	    (spec->hdr.dst_port & mask->hdr.dst_port) == spec->hdr.dst_port)
+	if (spec->hdr.dst_port & mask->hdr.dst_port)
 		nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_DST,
 			     spec->hdr.dst_port);
-	if (spec->hdr.src_port &&
-	    (spec->hdr.src_port & mask->hdr.src_port) == spec->hdr.src_port)
+	if (spec->hdr.src_port & mask->hdr.src_port)
 		nlattr_add16(&msg->nh, TCA_FLOWER_KEY_TCP_SRC,
 			     spec->hdr.src_port);
 	return 0;
-- 
2.12.0.306.g4a9b9b3

             reply	other threads:[~2017-03-30  8:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  8:52 Pascal Mazon [this message]
2017-03-30  8:52 ` [dpdk-dev] [PATCH 2/2] net/tap: remove minimum packet size in Rx Pascal Mazon
2017-03-30 13:06   ` Wiles, Keith
2017-03-30 13:08 ` [dpdk-dev] [PATCH 1/2] net/tap: UDP/TCP port mask not supported in flow Wiles, Keith
2017-04-03 11:25   ` Ferruh Yigit

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=11b7aa6796bd3e4147fbd4ec14b0125b6419aa80.1490863952.git.pascal.mazon@6wind.com \
    --to=pascal.mazon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    /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).