Skip to contentSkip to conversation

net/mlx5: fix eCPRI previous layer checking

PATCH Superseded Bing Zhao 4 participants 7 messages Nov 3, 2020 – Nov 13, 2020 Network drivers

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH 1/1 net/mlx5: fix eCPRI previous layer checking

Based on the specification, eCPRI can only follow ETH (VLAN) layer or UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI header")
---
 drivers/net/mlx5/mlx5_flow.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
drivers/net/mlx5/mlx5_flow.c +18 -11
index a6e60af..11dba3b 100644
@@ -2896,17 +2896,23 @@ struct mlx5_flow_tunnel_info {
 					MLX5_FLOW_LAYER_OUTER_VLAN);
 	struct rte_flow_item_ecpri mask_lo;
 
+	if (!(last_item & outer_l2_vlan) &&
+	    last_item != MLX5_FLOW_LAYER_OUTER_L4_UDP)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI can only follow L2/VLAN layer"
+					  " or UDP layer.");
 	if ((last_item & outer_l2_vlan) && ether_type &&
 	    ether_type != RTE_ETHER_TYPE_ECPRI)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI cannot follow L2/VLAN layer "
-					  "which ether type is not 0xAEFE.");
+					  "eCPRI cannot follow L2/VLAN layer"
+					  " which ether type is not 0xAEFE.");
 	if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI with tunnel is not supported "
-					  "right now.");
+					  "eCPRI with tunnel is not supported"
+					  " right now.");
 	if (item_flags & MLX5_FLOW_LAYER_OUTER_L3)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
@@ -2914,13 +2920,14 @@ struct mlx5_flow_tunnel_info {
 	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI cannot follow a TCP layer.");
+					  "eCPRI cannot coexist with a"
+					  " TCP layer.");
 	/* In specification, eCPRI could be over UDP layer. */
 	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_UDP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI over UDP layer is not yet "
-					  "supported right now.");
+					  "eCPRI over UDP layer is not yet"
+					  " supported right now.");
 	/* Mask for type field in common header could be zero. */
 	if (!mask)
 		mask = &rte_flow_item_ecpri_mask;
@@ -2929,13 +2936,13 @@ struct mlx5_flow_tunnel_info {
 	if (mask_lo.hdr.common.type != 0 && mask_lo.hdr.common.type != 0xff)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
-					  "partial mask is not supported "
-					  "for protocol");
+					  "partial mask is not supported"
+					  " for protocol");
 	else if (mask_lo.hdr.common.type == 0 && mask->hdr.dummy[0] != 0)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
-					  "message header mask must be after "
-					  "a type mask");
+					  "message header mask must be after"
+					  " a type mask");
 	return mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
 					 acc_mask ? (const uint8_t *)acc_mask
 						  : (const uint8_t *)&nic_mask,
Signature · 1 line
1.8.3.1
#1 lore raw

Hi,

Quoted 15 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Tuesday, November 3, 2020 7:43 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH] net/mlx5: fix eCPRI previous layer checking

Based on the specification, eCPRI can only follow ETH (VLAN) layer or UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI header")
Quoted 7 lines
---
 drivers/net/mlx5/mlx5_flow.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh

#2 lore raw
In reply to Bing Zhao
Quoted 33 lines · Bing Zhao

Based on the specification, eCPRI can only follow ETH (VLAN) layer or UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI header")
---
  drivers/net/mlx5/mlx5_flow.c | 29 ++++++++++++++++++-----------
  1 file changed, 18 insertions(+), 11 deletions(-)
drivers/net/mlx5/mlx5_flow.c +6 -1
index a6e60af..11dba3b 100644
@@ -2896,17 +2896,23 @@ struct mlx5_flow_tunnel_info {
  					MLX5_FLOW_LAYER_OUTER_VLAN);
  	struct rte_flow_item_ecpri mask_lo;
 
+	if (!(last_item & outer_l2_vlan) &&
+	    last_item != MLX5_FLOW_LAYER_OUTER_L4_UDP)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI can only follow L2/VLAN layer"
+					  " or UDP layer.");
  	if ((last_item & outer_l2_vlan) && ether_type &&
  	    ether_type != RTE_ETHER_TYPE_ECPRI)
  		return rte_flow_error_set(error, EINVAL,
  					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI cannot follow L2/VLAN layer "

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2915

Quoted 10 lines
drivers/net/mlx5/mlx5_flow.c +4 -3
-					  "which ether type is not 0xAEFE.");
+					  "eCPRI cannot follow L2/VLAN layer"
+					  " which ether type is not 0xAEFE.");
  	if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
  		return rte_flow_error_set(error, EINVAL,
  					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI with tunnel is not supported "
-					  "right now.");
+					  "eCPRI with tunnel is not supported"
+					  " right now.");

Why these changes done, it only moves space from end of first line to beginning of the second line?

Overall I think no need to break the log strings, keeping them intact helps users search the error message in the code.
I assume the break is because of the 80 chars limit but for log strings we don't have that limit, unless it is too long (lets say 120 chars as thumb of rule, there is no official convention) I think better to not break.

What do you think remove the whitespace changes out of this commit and make another patch to merge the log strings?

author
#3 lore raw

Hi Ferruh,

Quoted 64 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, November 6, 2020 7:35 PM
To: Bing Zhao <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] net/mlx5: fix eCPRI previous layer checking

External email: Use caution opening links or attachments

Quoted 1 line · Bing Zhao

Based on the specification, eCPRI can only follow ETH (VLAN) layer

or

Quoted 4 lines

UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI

header")

Quoted 14 lines
---
  drivers/net/mlx5/mlx5_flow.c | 29 ++++++++++++++++++-----------
  1 file changed, 18 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index a6e60af..11dba3b 100644

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2902

Quoted 7 lines
drivers/net/mlx5/mlx5_flow.c +4 -0
@@ -2896,17 +2896,23 @@ struct mlx5_flow_tunnel_info {
                                      MLX5_FLOW_LAYER_OUTER_VLAN);
      struct rte_flow_item_ecpri mask_lo;
 
+     if (!(last_item & outer_l2_vlan) &&
+         last_item != MLX5_FLOW_LAYER_OUTER_L4_UDP)
+             return rte_flow_error_set(error, EINVAL,
+                                       RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2903

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       "eCPRI can only follow

L2/VLAN layer"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info {

Quoted 5 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       " or UDP layer.");
      if ((last_item & outer_l2_vlan) && ether_type &&
          ether_type != RTE_ETHER_TYPE_ECPRI)
              return rte_flow_error_set(error, EINVAL,
                                        RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2903

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "eCPRI cannot follow

L2/VLAN layer "

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2904

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "which ether type is not

0xAEFE.");

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2909

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       "eCPRI cannot follow

L2/VLAN layer"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2914

Quoted 5 lines
drivers/net/mlx5/mlx5_flow.c +2 -0
+                                       " which ether type is not
+ 0xAEFE.");
      if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
              return rte_flow_error_set(error, EINVAL,
                                        RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2908

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "eCPRI with tunnel is not
Quoted 8 lines

supported "

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2915

Quoted 2 lines
drivers/net/mlx5/mlx5_flow.c +1 -1
-                                       "right now.");
+                                       "eCPRI with tunnel is not

supported"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2915

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       " right now.");

Why these changes done, it only moves space from end of first line to beginning of the second line?

Yes, because when I am doing the fix. I found this log part is different from others in the same file and just want to be consistent.

Quoted 7 lines

Overall I think no need to break the log strings, keeping them intact helps users search the error message in the code. I assume the break is because of the 80 chars limit but for log strings we don't have that limit, unless it is too long (lets say 120 chars as thumb of rule, there is no official convention) I think better to not break.

Good point, in the past when I was searching some logs and I failed due to the long log line break.

Quoted 3 lines

What do you think remove the whitespace changes out of this commit and make another patch to merge the log strings?

Yes I can and will send v2 of this.
Or should I keep the log in a single line @Slava Ovsiienko, what do you think? Any comments? I remember in the past, my "checkpatch.pl" will report warning against this. Could we ignore this?

BR. Bing

#4 lore raw
Quoted 88 lines · Bing Zhao

Hi Ferruh,

Quoted 64 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, November 6, 2020 7:35 PM
To: Bing Zhao <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Raslan Darawsheh <[email protected]>; [email protected]
Subject: Re: [dpdk-stable] [PATCH] net/mlx5: fix eCPRI previous layer checking

External email: Use caution opening links or attachments

Quoted 1 line · Bing Zhao

Based on the specification, eCPRI can only follow ETH (VLAN) layer

or

Quoted 4 lines

UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI

header")

Quoted 14 lines
---
   drivers/net/mlx5/mlx5_flow.c | 29 ++++++++++++++++++-----------
   1 file changed, 18 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_flow.c index a6e60af..11dba3b 100644

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2902

Quoted 7 lines
drivers/net/mlx5/mlx5_flow.c +4 -0
@@ -2896,17 +2896,23 @@ struct mlx5_flow_tunnel_info {
                                       MLX5_FLOW_LAYER_OUTER_VLAN);
       struct rte_flow_item_ecpri mask_lo;
 
+     if (!(last_item & outer_l2_vlan) &&
+         last_item != MLX5_FLOW_LAYER_OUTER_L4_UDP)
+             return rte_flow_error_set(error, EINVAL,
+                                       RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2903

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       "eCPRI can only follow

L2/VLAN layer"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info {

Quoted 5 lines
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       " or UDP layer.");
       if ((last_item & outer_l2_vlan) && ether_type &&
           ether_type != RTE_ETHER_TYPE_ECPRI)
               return rte_flow_error_set(error, EINVAL,
                                         RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2903

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "eCPRI cannot follow

L2/VLAN layer "

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2904

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "which ether type is not

0xAEFE.");

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2909

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       "eCPRI cannot follow

L2/VLAN layer"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2914

Quoted 5 lines
drivers/net/mlx5/mlx5_flow.c +2 -0
+                                       " which ether type is not
+ 0xAEFE.");
       if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
               return rte_flow_error_set(error, EINVAL,
                                         RTE_FLOW_ERROR_TYPE_ITEM,

item,

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2908

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +0 -1
-                                       "eCPRI with tunnel is not
Quoted 8 lines

supported "

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2915

Quoted 2 lines
drivers/net/mlx5/mlx5_flow.c +1 -1
-                                       "right now.");
+                                       "eCPRI with tunnel is not

supported"

drivers/net/mlx5/mlx5_flow.c struct mlx5_flow_tunnel_info { · line 2915

Quoted 1 line
drivers/net/mlx5/mlx5_flow.c +1 -0
+                                       " right now.");

Why these changes done, it only moves space from end of first line to beginning of the second line?

Yes, because when I am doing the fix. I found this log part is different from others in the same file and just want to be consistent.

Quoted 7 lines

Overall I think no need to break the log strings, keeping them intact helps users search the error message in the code. I assume the break is because of the 80 chars limit but for log strings we don't have that limit, unless it is too long (lets say 120 chars as thumb of rule, there is no official convention) I think better to not break.

Good point, in the past when I was searching some logs and I failed due to the long log line break.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

What do you think remove the whitespace changes out of this commit and make another patch to merge the log strings?

Yes I can and will send v2 of this.
Or should I keep the log in a single line @Slava Ovsiienko, what do you think? Any comments? I remember in the past, my "checkpatch.pl" will report warning against this. Could we ignore this?

As far as I know checkpatch is not complaining for the long lines of the string, even it does I am OK to ignore it.

author
#5 lore raw

PATCH v2 1/1 net/mlx5: fix eCPRI previous layer checking

In reply to Bing Zhao

Based on the specification, eCPRI can only follow ETH (VLAN) layer or UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI header")

---
v2: remove the line break for error log message.

---
 drivers/net/mlx5/mlx5_flow.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/mlx5/mlx5_flow.c +11 -11
index a6e60af..859b7f6 100644
@@ -2896,17 +2896,20 @@ struct mlx5_flow_tunnel_info {
 					MLX5_FLOW_LAYER_OUTER_VLAN);
 	struct rte_flow_item_ecpri mask_lo;
 
+	if (!(last_item & outer_l2_vlan) &&
+	    last_item != MLX5_FLOW_LAYER_OUTER_L4_UDP)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "eCPRI can only follow L2/VLAN layer or UDP layer");
 	if ((last_item & outer_l2_vlan) && ether_type &&
 	    ether_type != RTE_ETHER_TYPE_ECPRI)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI cannot follow L2/VLAN layer "
-					  "which ether type is not 0xAEFE.");
+					  "eCPRI cannot follow L2/VLAN layer which ether type is not 0xAEFE");
 	if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI with tunnel is not supported "
-					  "right now.");
+					  "eCPRI with tunnel is not supported right now");
 	if (item_flags & MLX5_FLOW_LAYER_OUTER_L3)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
@@ -2914,13 +2917,12 @@ struct mlx5_flow_tunnel_info {
 	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI cannot follow a TCP layer.");
+					  "eCPRI cannot coexist with a TCP layer");
 	/* In specification, eCPRI could be over UDP layer. */
 	else if (item_flags & MLX5_FLOW_LAYER_OUTER_L4_UDP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "eCPRI over UDP layer is not yet "
-					  "supported right now.");
+					  "eCPRI over UDP layer is not yet supported right now");
 	/* Mask for type field in common header could be zero. */
 	if (!mask)
 		mask = &rte_flow_item_ecpri_mask;
@@ -2929,13 +2931,11 @@ struct mlx5_flow_tunnel_info {
 	if (mask_lo.hdr.common.type != 0 && mask_lo.hdr.common.type != 0xff)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
-					  "partial mask is not supported "
-					  "for protocol");
+					  "partial mask is not supported for protocol");
 	else if (mask_lo.hdr.common.type == 0 && mask->hdr.dummy[0] != 0)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
-					  "message header mask must be after "
-					  "a type mask");
+					  "message header mask must be after a type mask");
 	return mlx5_flow_item_acceptable(item, (const uint8_t *)mask,
 					 acc_mask ? (const uint8_t *)acc_mask
 						  : (const uint8_t *)&nic_mask,
Signature · 1 line
1.8.3.1
#6 lore raw

11/11/2020 10:28, Bing Zhao:

Quoted 4 lines

Based on the specification, eCPRI can only follow ETH (VLAN) layer or UDP layer. When creating a flow with eCPRI item, this should be checked and invalid layout of the layers should be rejected.

Quoted 8 lines
Fixes c7eca23657b7 ("net/mlx5: add flow validation of eCPRI header")

---
v2: remove the line break for error log message.

Applied in next-net-mlx instead of the first version, thanks.