From: Stephen Hemminger <step...@networkplumber.org> In case of errors in setting up XDP, report error through extack string rather than console log.
Signed-off-by: Stephen Hemminger <step...@networkplumber.org> --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index e5f74eb986b3..f8e3661c6846 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4177,18 +4177,20 @@ static void mlx5e_tx_timeout(struct net_device *dev) queue_work(priv->wq, &priv->tx_timeout_work); } -static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog) +static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog, + struct netlink_ext_ack *extack) { - struct net_device *netdev = priv->netdev; struct mlx5e_channels new_channels = {}; if (priv->channels.params.lro_en) { - netdev_warn(netdev, "can't set XDP while LRO is on, disable LRO first\n"); + NL_SET_ERR_MSG(extack, + "can't set XDP while LRO is on, disable LRO first"); return -EINVAL; } if (MLX5_IPSEC_DEV(priv->mdev)) { - netdev_warn(netdev, "can't set XDP with IPSec offload\n"); + NL_SET_ERR_MSG(extack, + "can't set XDP with IPSec offload"); return -EINVAL; } @@ -4196,15 +4198,16 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog) new_channels.params.xdp_prog = prog; if (!mlx5e_rx_is_linear_skb(priv->mdev, &new_channels.params)) { - netdev_warn(netdev, "XDP is not allowed with MTU(%d) > %d\n", - new_channels.params.sw_mtu, MLX5E_XDP_MAX_MTU); + NL_SET_ERR_MSG(extack, + "XDP is not allowed with large MTU"); return -EINVAL; } return 0; } -static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) +static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog, + struct netlink_ext_ack *extack) { struct mlx5e_priv *priv = netdev_priv(netdev); struct bpf_prog *old_prog; @@ -4215,7 +4218,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog) mutex_lock(&priv->state_lock); if (prog) { - err = mlx5e_xdp_allowed(priv, prog); + err = mlx5e_xdp_allowed(priv, prog, extack); if (err) goto unlock; } @@ -4297,11 +4300,12 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp) { switch (xdp->command) { case XDP_SETUP_PROG: - return mlx5e_xdp_set(dev, xdp->prog); + return mlx5e_xdp_set(dev, xdp->prog, xdp->extack); case XDP_QUERY_PROG: xdp->prog_id = mlx5e_xdp_query(dev); return 0; default: + NL_SET_ERR_MSG(xdp->extack, "Unsupported XDP command"); return -EINVAL; } } -- 2.17.1