From 6b890c2cd66d063f2a02ea33488a3a4a264a3ef7 Mon Sep 17 00:00:00 2001 From: Pascal Mazon Date: Thu, 30 Mar 2017 10:52:47 +0200 Subject: [PATCH] net/tap: remove unsupported UDP/TCP port mask in flow 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: de96fe68ae95 ("net/tap: add basic flow API patterns and actions") Signed-off-by: Pascal Mazon Acked-by: Keith Wiles --- 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 7f1693d404..0973b63d69 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -612,18 +612,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; @@ -656,18 +658,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.20.1