[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190228183809.25417-4-sthemmin@microsoft.com>
Date: Thu, 28 Feb 2019 10:38:06 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [RFC 3/6] i40e: use extack for bpf errors
From: Stephen Hemminger <stephen@...workplumber.org>
If ndo_bpf fails fill in error string with reason.
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
drivers/net/ethernet/intel/i40e/i40e_main.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index da62218eb70a..3de1f2590ca0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -11831,7 +11831,8 @@ static netdev_features_t i40e_features_check(struct sk_buff *skb,
* @prog: XDP program
**/
static int i40e_xdp_setup(struct i40e_vsi *vsi,
- struct bpf_prog *prog)
+ struct bpf_prog *prog,
+ struct netlink_ext_ack *extack)
{
int frame_size = vsi->netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
struct i40e_pf *pf = vsi->back;
@@ -11840,8 +11841,10 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi,
int i;
/* Don't allow frames that span over multiple buffers */
- if (frame_size > vsi->rx_buf_len)
+ if (frame_size > vsi->rx_buf_len) {
+ NL_SET_ERR_MSG(extack, "XDP does not support multiple buffers");
return -EINVAL;
+ }
if (!i40e_enabled_xdp_vsi(vsi) && !prog)
return 0;
@@ -12140,12 +12143,14 @@ static int i40e_xdp(struct net_device *dev,
struct i40e_netdev_priv *np = netdev_priv(dev);
struct i40e_vsi *vsi = np->vsi;
- if (vsi->type != I40E_VSI_MAIN)
+ if (vsi->type != I40E_VSI_MAIN) {
+ NL_SET_ERR_MSG(xdp->extack, "XDP not allowed on VF");
return -EINVAL;
+ }
switch (xdp->command) {
case XDP_SETUP_PROG:
- return i40e_xdp_setup(vsi, xdp->prog);
+ return i40e_xdp_setup(vsi, xdp->prog, xdp->extack);
case XDP_QUERY_PROG:
xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0;
return 0;
@@ -12153,6 +12158,7 @@ static int i40e_xdp(struct net_device *dev,
return i40e_xsk_umem_setup(vsi, xdp->xsk.umem,
xdp->xsk.queue_id);
default:
+ NL_SET_ERR_MSG(xdp->extack, "Unknown XDP command");
return -EINVAL;
}
}
--
2.17.1
Powered by blists - more mailing lists