* [PATCH net] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails
[not found] <cover.1542809524.git.lorenzo.bianconi@redhat.com>
@ 2018-11-21 15:32 ` Lorenzo Bianconi
2018-11-22 19:41 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2018-11-21 15:32 UTC (permalink / raw)
To: netdev; +Cc: Sunil.Goutham
Set xdp_prog pointer to NULL if bpf_prog_add fails since that routine
reports the error code instead of NULL in case of failure and xdp_prog
pointer value is used in the driver to verify if XDP is currently
enabled.
Moreover report the error code to userspace if nicvf_xdp_setup fails
Fixes: 05c773f52b96 ("net: thunderx: Add basic XDP support")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 768f584f8392..88f8a8fa93cd 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1784,6 +1784,7 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog)
bool if_up = netif_running(nic->netdev);
struct bpf_prog *old_prog;
bool bpf_attached = false;
+ int ret = 0;
/* For now just support only the usual MTU sized frames */
if (prog && (dev->mtu > 1500)) {
@@ -1817,8 +1818,12 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog)
if (nic->xdp_prog) {
/* Attach BPF program */
nic->xdp_prog = bpf_prog_add(nic->xdp_prog, nic->rx_queues - 1);
- if (!IS_ERR(nic->xdp_prog))
+ if (!IS_ERR(nic->xdp_prog)) {
bpf_attached = true;
+ } else {
+ ret = PTR_ERR(nic->xdp_prog);
+ nic->xdp_prog = NULL;
+ }
}
/* Calculate Tx queues needed for XDP and network stack */
@@ -1830,7 +1835,7 @@ static int nicvf_xdp_setup(struct nicvf *nic, struct bpf_prog *prog)
netif_trans_update(nic->netdev);
}
- return 0;
+ return ret;
}
static int nicvf_xdp(struct net_device *netdev, struct netdev_bpf *xdp)
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails
2018-11-21 15:32 ` [PATCH net] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails Lorenzo Bianconi
@ 2018-11-22 19:41 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-11-22 19:41 UTC (permalink / raw)
To: lorenzo.bianconi; +Cc: netdev, Sunil.Goutham
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Wed, 21 Nov 2018 16:32:10 +0100
> Set xdp_prog pointer to NULL if bpf_prog_add fails since that routine
> reports the error code instead of NULL in case of failure and xdp_prog
> pointer value is used in the driver to verify if XDP is currently
> enabled.
> Moreover report the error code to userspace if nicvf_xdp_setup fails
>
> Fixes: 05c773f52b96 ("net: thunderx: Add basic XDP support")
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-23 6:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1542809524.git.lorenzo.bianconi@redhat.com>
2018-11-21 15:32 ` [PATCH net] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails Lorenzo Bianconi
2018-11-22 19:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).