diff mbox series

[net-next,v2,5/5] net/mlx5e: Return -EOPNOTSUPP when attempting to offload an unsupported action

Message ID 1551091207-10366-6-git-send-email-xiangxia.m.yue@gmail.com
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series net/mlx5e: Make little improvement for mlx5e | expand

Commit Message

Tonghao Zhang Feb. 25, 2019, 10:40 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

The encapsulation is not supported for mlx5 VFs. When we try to
offload that action, the -EINVAL is returned, but not -EOPNOTSUPP.
This patch changes the returned value and ignore to confuse user.

For example: (p2p1_0 is VF net device)
tc filter add dev p2p1_0 protocol ip  parent ffff: prio 1 flower skip_sw \
	src_mac e4:11:22:33:44:01	\
	action tunnel_key set		\
	src_ip 1.1.1.100		\
	dst_ip 1.1.1.200		\
	dst_port 4789 id 100		\
	action mirred egress redirect dev vxlan0

"RTNETLINK answers: Invalid argument"

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Roi Dayan Feb. 26, 2019, 1:49 p.m. UTC | #1
On 25/02/2019 12:40, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> The encapsulation is not supported for mlx5 VFs. When we try to
> offload that action, the -EINVAL is returned, but not -EOPNOTSUPP.
> This patch changes the returned value and ignore to confuse user.
> 
> For example: (p2p1_0 is VF net device)
> tc filter add dev p2p1_0 protocol ip  parent ffff: prio 1 flower skip_sw \
> 	src_mac e4:11:22:33:44:01	\
> 	action tunnel_key set		\
> 	src_ip 1.1.1.100		\
> 	dst_ip 1.1.1.200		\
> 	dst_port 4789 id 100		\
> 	action mirred egress redirect dev vxlan0
> 
> "RTNETLINK answers: Invalid argument"
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index d9fcb14..f5029ea 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2302,7 +2302,8 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
>  			}
>  			break;
>  		default:
> -			return -EINVAL;
> +			NL_SET_ERR_MSG_MOD(extack, "The offload action is not supported");
> +			return -EOPNOTSUPP;
>  		}
>  	}
>  
> @@ -2624,7 +2625,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
>  			break;
>  			}
>  		default:
> -			return -EINVAL;
> +			NL_SET_ERR_MSG_MOD(extack, "The offload action is not supported");
> +			return -EOPNOTSUPP;
>  		}
>  	}
>  
> 

Reviewed-by: Roi Dayan <roid@mellanox.com>
Or Gerlitz Feb. 26, 2019, 10:42 p.m. UTC | #2
On Mon, Feb 25, 2019 at 1:07 PM <xiangxia.m.yue@gmail.com> wrote:

> The encapsulation is not supported for mlx5 VFs. When we try to
> offload that action, the -EINVAL is returned, but not -EOPNOTSUPP.
> This patch changes the returned value and ignore to confuse user.

FWIW, note that this changes the behavior towards user-space, I don't see
concrete harm done here but we should realize that

> For example: (p2p1_0 is VF net device)
> tc filter add dev p2p1_0 protocol ip  parent ffff: prio 1 flower skip_sw \
>         src_mac e4:11:22:33:44:01       \
>         action tunnel_key set           \
>         src_ip 1.1.1.100                \
>         dst_ip 1.1.1.200                \
>         dst_port 4789 id 100            \
>         action mirred egress redirect dev vxlan0
>
> "RTNETLINK answers: Invalid argument"
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index d9fcb14..f5029ea 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2302,7 +2302,8 @@  static int parse_tc_nic_actions(struct mlx5e_priv *priv,
 			}
 			break;
 		default:
-			return -EINVAL;
+			NL_SET_ERR_MSG_MOD(extack, "The offload action is not supported");
+			return -EOPNOTSUPP;
 		}
 	}
 
@@ -2624,7 +2625,8 @@  static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
 			break;
 			}
 		default:
-			return -EINVAL;
+			NL_SET_ERR_MSG_MOD(extack, "The offload action is not supported");
+			return -EOPNOTSUPP;
 		}
 	}