From d0dd0cf06135ec043c587bf14b66ec55adde876a Mon Sep 17 00:00:00 2001 From: Faicker Mo Date: Tue, 18 Sep 2018 13:48:52 +0800 Subject: [PATCH] net/ixgbe: fix flow create in ntuple check In ixgbe_flow_create function, ntuple filter is parsed first. If the flow is considered to be ntuple filter, it will not go on to judge ethertype filter, syn filter and fdir filter. In the function ntuple_filter_to_5tuple, 5 tuple info is checked, but it's too late to jump over the ntuple filter if it's a fdir filter. Fixes: 46ea969177f3 ("net/ixgbe: add ntuple support to flow parser") Cc: stable@dpdk.org Signed-off-by: Faicker Mo Acked-by: Wei Zhao --- drivers/net/ixgbe/ixgbe_flow.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 1adf1b803c..f0fafebc8c 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -363,6 +363,17 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, item, "Not supported by ntuple filter"); return -rte_errno; } + if ((ipv4_mask->hdr.src_addr != 0 && + ipv4_mask->hdr.src_addr != UINT32_MAX) || + (ipv4_mask->hdr.dst_addr != 0 && + ipv4_mask->hdr.dst_addr != UINT32_MAX) || + (ipv4_mask->hdr.next_proto_id != UINT8_MAX && + ipv4_mask->hdr.next_proto_id != 0)) { + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, + item, "Not supported by ntuple filter"); + return -rte_errno; + } filter->dst_ip_mask = ipv4_mask->hdr.dst_addr; filter->src_ip_mask = ipv4_mask->hdr.src_addr; @@ -432,6 +443,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, item, "Not supported by ntuple filter"); return -rte_errno; } + if ((tcp_mask->hdr.src_port != 0 && + tcp_mask->hdr.src_port != UINT16_MAX) || + (tcp_mask->hdr.dst_port != 0 && + tcp_mask->hdr.dst_port != UINT16_MAX)) { + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, + item, "Not supported by ntuple filter"); + return -rte_errno; + } filter->dst_port_mask = tcp_mask->hdr.dst_port; filter->src_port_mask = tcp_mask->hdr.src_port; @@ -467,6 +487,15 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr, item, "Not supported by ntuple filter"); return -rte_errno; } + if ((udp_mask->hdr.src_port != 0 && + udp_mask->hdr.src_port != UINT16_MAX) || + (udp_mask->hdr.dst_port != 0 && + udp_mask->hdr.dst_port != UINT16_MAX)) { + rte_flow_error_set(error, + EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, + item, "Not supported by ntuple filter"); + return -rte_errno; + } filter->dst_port_mask = udp_mask->hdr.dst_port; filter->src_port_mask = udp_mask->hdr.src_port; -- 2.20.1