[dpdk-dev] net/ixgbe: fix ntuple filter support for sctp

Message ID 1493262879-47696-1-git-send-email-wei.zhao1@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Zhao1, Wei April 27, 2017, 3:14 a.m. UTC
  Add the support of RTE_FLOW_ITEM_TYPE_SCTP type packet for
ixgbe ntuple filter.

Fixes: 672be56d76a ("net/ixgbe: parse n-tuple filter")

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 drivers/net/ixgbe/ixgbe_flow.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit April 27, 2017, 4:53 a.m. UTC | #1
On 4/27/2017 4:14 AM, Wei Zhao wrote:
> Add the support of RTE_FLOW_ITEM_TYPE_SCTP type packet for
> ixgbe ntuple filter.

The function comment also should be updated for this pattern type.

And is this a fix or adding new type support? If this is not fixing
something existing, lets postpone this to next release.

> 
> Fixes: 672be56d76a ("net/ixgbe: parse n-tuple filter")
> 
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_flow.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
> index e2ba9c2..2c18bcd 100644
> --- a/drivers/net/ixgbe/ixgbe_flow.c
> +++ b/drivers/net/ixgbe/ixgbe_flow.c
> @@ -142,6 +142,8 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
>  	const struct rte_flow_item_tcp *tcp_mask;
>  	const struct rte_flow_item_udp *udp_spec;
>  	const struct rte_flow_item_udp *udp_mask;
> +	const struct rte_flow_item_sctp *sctp_spec;
> +	const struct rte_flow_item_sctp *sctp_mask;
>  	uint32_t index;
>  
>  	if (!pattern) {
> @@ -319,7 +321,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
>  		filter->dst_port  = tcp_spec->hdr.dst_port;
>  		filter->src_port  = tcp_spec->hdr.src_port;
>  		filter->tcp_flags = tcp_spec->hdr.tcp_flags;
> -	} else {
> +	} else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
>  		udp_mask = (const struct rte_flow_item_udp *)item->mask;
>  
>  		/**
> @@ -342,6 +344,29 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
>  		udp_spec = (const struct rte_flow_item_udp *)item->spec;
>  		filter->dst_port = udp_spec->hdr.dst_port;
>  		filter->src_port = udp_spec->hdr.src_port;
> +	} else {

There is a check for this item if it is TCP or UDP, else it returns an
error (in line 255), so it should not be hitting this else at all, am I
missing something?

> +		sctp_mask = (const struct rte_flow_item_sctp *)item->mask;
> +
> +		/**
> +		 * Only support src & dst ports,
> +		 * others should be masked.
> +		 */
> +		if (sctp_mask->hdr.tag ||
> +		    sctp_mask->hdr.cksum) {
> +			memset(filter, 0,
> +				sizeof(struct rte_eth_ntuple_filter));
> +			rte_flow_error_set(error, EINVAL,
> +				RTE_FLOW_ERROR_TYPE_ITEM,
> +				item, "Not supported by ntuple filter");
> +			return -rte_errno;
> +		}
> +
> +		filter->dst_port_mask = sctp_mask->hdr.dst_port;
> +		filter->src_port_mask = sctp_mask->hdr.src_port;
> +
> +		sctp_spec = (const struct rte_flow_item_sctp *)item->spec;
> +		filter->dst_port = sctp_spec->hdr.dst_port;
> +		filter->src_port = sctp_spec->hdr.src_port;
>  	}
>  
>  	/* check if the next not void item is END */
>
  
Zhao1, Wei April 27, 2017, 5:39 a.m. UTC | #2
Hi,  Ferruh

> -----Original Message-----

> From: Yigit, Ferruh

> Sent: Thursday, April 27, 2017 12:53 PM

> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org

> Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: fix ntuple filter support for sctp

> 

> On 4/27/2017 4:14 AM, Wei Zhao wrote:

> > Add the support of RTE_FLOW_ITEM_TYPE_SCTP type packet for ixgbe

> > ntuple filter.

> 

> The function comment also should be updated for this pattern type.

> 

> And is this a fix or adding new type support? If this is not fixing something

> existing, lets postpone this to next release.

> 


No, it is a fix patch for our missing support for sctp packet type filter.
There are also other 2 had better been merge to this release also, they are high risk bug need to be fix.  
http://dpdk.org/dev/patchwork/patch/23761/
http://dpdk.org/dev/patchwork/patch/23760/

> >

> > Fixes: 672be56d76a ("net/ixgbe: parse n-tuple filter")

> >

> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>

> > ---

> >  drivers/net/ixgbe/ixgbe_flow.c | 27 ++++++++++++++++++++++++++-

> >  1 file changed, 26 insertions(+), 1 deletion(-)

> >

> > diff --git a/drivers/net/ixgbe/ixgbe_flow.c

> > b/drivers/net/ixgbe/ixgbe_flow.c index e2ba9c2..2c18bcd 100644

> > --- a/drivers/net/ixgbe/ixgbe_flow.c

> > +++ b/drivers/net/ixgbe/ixgbe_flow.c

> > @@ -142,6 +142,8 @@ cons_parse_ntuple_filter(const struct rte_flow_attr

> *attr,

> >  	const struct rte_flow_item_tcp *tcp_mask;

> >  	const struct rte_flow_item_udp *udp_spec;

> >  	const struct rte_flow_item_udp *udp_mask;

> > +	const struct rte_flow_item_sctp *sctp_spec;

> > +	const struct rte_flow_item_sctp *sctp_mask;

> >  	uint32_t index;

> >

> >  	if (!pattern) {

> > @@ -319,7 +321,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr

> *attr,

> >  		filter->dst_port  = tcp_spec->hdr.dst_port;

> >  		filter->src_port  = tcp_spec->hdr.src_port;

> >  		filter->tcp_flags = tcp_spec->hdr.tcp_flags;

> > -	} else {

> > +	} else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {

> >  		udp_mask = (const struct rte_flow_item_udp *)item->mask;

> >

> >  		/**

> > @@ -342,6 +344,29 @@ cons_parse_ntuple_filter(const struct

> rte_flow_attr *attr,

> >  		udp_spec = (const struct rte_flow_item_udp *)item->spec;

> >  		filter->dst_port = udp_spec->hdr.dst_port;

> >  		filter->src_port = udp_spec->hdr.src_port;

> > +	} else {

> 

> There is a check for this item if it is TCP or UDP, else it returns an error (in line

> 255), so it should not be hitting this else at all, am I missing something?


Yes,  you are right, I miss SOME in line 255, a v2 later to be commit.

> 

> > +		sctp_mask = (const struct rte_flow_item_sctp *)item->mask;

> > +

> > +		/**

> > +		 * Only support src & dst ports,

> > +		 * others should be masked.

> > +		 */

> > +		if (sctp_mask->hdr.tag ||

> > +		    sctp_mask->hdr.cksum) {

> > +			memset(filter, 0,

> > +				sizeof(struct rte_eth_ntuple_filter));

> > +			rte_flow_error_set(error, EINVAL,

> > +				RTE_FLOW_ERROR_TYPE_ITEM,

> > +				item, "Not supported by ntuple filter");

> > +			return -rte_errno;

> > +		}

> > +

> > +		filter->dst_port_mask = sctp_mask->hdr.dst_port;

> > +		filter->src_port_mask = sctp_mask->hdr.src_port;

> > +

> > +		sctp_spec = (const struct rte_flow_item_sctp *)item->spec;

> > +		filter->dst_port = sctp_spec->hdr.dst_port;

> > +		filter->src_port = sctp_spec->hdr.src_port;

> >  	}

> >

> >  	/* check if the next not void item is END */

> >
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
index e2ba9c2..2c18bcd 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -142,6 +142,8 @@  cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
 	const struct rte_flow_item_tcp *tcp_mask;
 	const struct rte_flow_item_udp *udp_spec;
 	const struct rte_flow_item_udp *udp_mask;
+	const struct rte_flow_item_sctp *sctp_spec;
+	const struct rte_flow_item_sctp *sctp_mask;
 	uint32_t index;
 
 	if (!pattern) {
@@ -319,7 +321,7 @@  cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
 		filter->dst_port  = tcp_spec->hdr.dst_port;
 		filter->src_port  = tcp_spec->hdr.src_port;
 		filter->tcp_flags = tcp_spec->hdr.tcp_flags;
-	} else {
+	} else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) {
 		udp_mask = (const struct rte_flow_item_udp *)item->mask;
 
 		/**
@@ -342,6 +344,29 @@  cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
 		udp_spec = (const struct rte_flow_item_udp *)item->spec;
 		filter->dst_port = udp_spec->hdr.dst_port;
 		filter->src_port = udp_spec->hdr.src_port;
+	} else {
+		sctp_mask = (const struct rte_flow_item_sctp *)item->mask;
+
+		/**
+		 * Only support src & dst ports,
+		 * others should be masked.
+		 */
+		if (sctp_mask->hdr.tag ||
+		    sctp_mask->hdr.cksum) {
+			memset(filter, 0,
+				sizeof(struct rte_eth_ntuple_filter));
+			rte_flow_error_set(error, EINVAL,
+				RTE_FLOW_ERROR_TYPE_ITEM,
+				item, "Not supported by ntuple filter");
+			return -rte_errno;
+		}
+
+		filter->dst_port_mask = sctp_mask->hdr.dst_port;
+		filter->src_port_mask = sctp_mask->hdr.src_port;
+
+		sctp_spec = (const struct rte_flow_item_sctp *)item->spec;
+		filter->dst_port = sctp_spec->hdr.dst_port;
+		filter->src_port = sctp_spec->hdr.src_port;
 	}
 
 	/* check if the next not void item is END */