[dpdk-dev,1/2] net/tap: UDP/TCP port mask not supported in flow

Message ID 11b7aa6796bd3e4147fbd4ec14b0125b6419aa80.1490863952.git.pascal.mazon@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pascal Mazon March 30, 2017, 8:52 a.m. UTC
  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(-)
  

Comments

Wiles, Keith March 30, 2017, 1:08 p.m. UTC | #1
> On Mar 30, 2017, at 3:52 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
> 
> 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>

Acked-by: Keith Wiles <keith.wiles@intel.com>

Regards,
Keith
  
Ferruh Yigit April 3, 2017, 11:25 a.m. UTC | #2
On 3/30/2017 2:08 PM, Wiles, Keith wrote:
> 
>> On Mar 30, 2017, at 3:52 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>>
>> 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>
> 
> Acked-by: Keith Wiles <keith.wiles@intel.com>

Series applied to dpdk-next-net/master, thanks.

(This patch fixes commits in next-net, when integrated to main tree
"Fixes:" will be with wrong commit id, please confirm the commit log of
integrated commit.)
  

Patch

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;