[dpdk-dev] net/mlx4: fix restriction on TCP/UDP flow rules

Message ID 1508503129-6298-1-git-send-email-adrien.mazarguil@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

Adrien Mazarguil Oct. 20, 2017, 12:39 p.m. UTC
  The code as currently written requires TCP/UDP source and destination ports
to be always specified.

No such restriction is enforced by hardware; all TCP and UDP traffic can be
matched by providing an empty mask for these fields.

Fixes: 680d5280c20b ("net/mlx4: refactor flow item validation code")

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx4/mlx4_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Nélio Laranjeiro Oct. 20, 2017, 12:45 p.m. UTC | #1
On Fri, Oct 20, 2017 at 02:39:58PM +0200, Adrien Mazarguil wrote:
> The code as currently written requires TCP/UDP source and destination ports
> to be always specified.
> 
> No such restriction is enforced by hardware; all TCP and UDP traffic can be
> matched by providing an empty mask for these fields.
> 
> Fixes: 680d5280c20b ("net/mlx4: refactor flow item validation code")
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
  
Ferruh Yigit Oct. 23, 2017, 8:32 p.m. UTC | #2
On 10/20/2017 5:45 AM, Nélio Laranjeiro wrote:
> On Fri, Oct 20, 2017 at 02:39:58PM +0200, Adrien Mazarguil wrote:
>> The code as currently written requires TCP/UDP source and destination ports
>> to be always specified.
>>
>> No such restriction is enforced by hardware; all TCP and UDP traffic can be
>> matched by providing an empty mask for these fields.
>>
>> Fixes: 680d5280c20b ("net/mlx4: refactor flow item validation code")
>>
>> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> 
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 5af6efb..a0f431b 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -404,7 +404,7 @@  mlx4_flow_merge_udp(struct rte_flow *flow,
 	struct ibv_flow_spec_tcp_udp *udp;
 	const char *msg;
 
-	if (!mask ||
+	if (mask &&
 	    ((uint16_t)(mask->hdr.src_port + 1) > UINT16_C(1) ||
 	     (uint16_t)(mask->hdr.dst_port + 1) > UINT16_C(1))) {
 		msg = "mlx4 does not support matching partial UDP fields";
@@ -464,7 +464,7 @@  mlx4_flow_merge_tcp(struct rte_flow *flow,
 	struct ibv_flow_spec_tcp_udp *tcp;
 	const char *msg;
 
-	if (!mask ||
+	if (mask &&
 	    ((uint16_t)(mask->hdr.src_port + 1) > UINT16_C(1) ||
 	     (uint16_t)(mask->hdr.dst_port + 1) > UINT16_C(1))) {
 		msg = "mlx4 does not support matching partial TCP fields";