* net: thunderx: nicvf_xdp_setup error code path
@ 2018-11-20 17:56 Lorenzo Bianconi
2018-11-21 4:43 ` Goutham, Sunil
2018-11-22 0:18 ` net: " David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2018-11-20 17:56 UTC (permalink / raw)
To: netdev; +Cc: sgoutham
Hi all,
looking at thunderx XDP support I noticed that nic->xdp_prog pointer in
nicvf_xdp_setup is not actually set to NULL if bpf_prog_add fails but it
is initialized with bpf_prog_add error code. xdp_prog pointer value is used in
the driver to verify if XDP is currently enabled.
Moreover nicvf_xdp_setup does not report to the userspace any error code in
case of failure.
I wrote the following patch to fix the reported issues. Please note I just
compiled it, not actually tested since I have no thunderx nic at the moment.
@Sunil: could you please give it a whirl? If it is ok I will post a formal
patch, thanks
Regards,
Lorenzo
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: thunderx: nicvf_xdp_setup error code path
2018-11-20 17:56 net: thunderx: nicvf_xdp_setup error code path Lorenzo Bianconi
@ 2018-11-21 4:43 ` Goutham, Sunil
2018-11-22 0:18 ` net: " David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Goutham, Sunil @ 2018-11-21 4:43 UTC (permalink / raw)
To: Lorenzo Bianconi, netdev
> -----Original Message-----
> From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> Sent: 20 November 2018 23:27
> To: netdev@vger.kernel.org
> Cc: Goutham, Sunil <Sunil.Goutham@cavium.com>
> Subject: net: thunderx: nicvf_xdp_setup error code path
>
> External Email
>
> Hi all,
>
> looking at thunderx XDP support I noticed that nic->xdp_prog pointer in
> nicvf_xdp_setup is not actually set to NULL if bpf_prog_add fails but it
> is initialized with bpf_prog_add error code. xdp_prog pointer value is used in
> the driver to verify if XDP is currently enabled.
> Moreover nicvf_xdp_setup does not report to the userspace any error code in
> case of failure.
> I wrote the following patch to fix the reported issues. Please note I just
> compiled it, not actually tested since I have no thunderx nic at the moment.
>
> @Sunil: could you please give it a whirl? If it is ok I will post a formal
> patch, thanks
>
> Regards,
> Lorenzo
>
Thanks for fixing, changes look good to me,
Sunil.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: net: thunderx: nicvf_xdp_setup error code path
2018-11-20 17:56 net: thunderx: nicvf_xdp_setup error code path Lorenzo Bianconi
2018-11-21 4:43 ` Goutham, Sunil
@ 2018-11-22 0:18 ` David Miller
2018-11-22 9:11 ` Lorenzo Bianconi
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2018-11-22 0:18 UTC (permalink / raw)
To: lorenzo.bianconi; +Cc: netdev, sgoutham
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Tue, 20 Nov 2018 18:56:36 +0100
> Hi all,
>
> looking at thunderx XDP support I noticed that nic->xdp_prog pointer in
> nicvf_xdp_setup is not actually set to NULL if bpf_prog_add fails but it
> is initialized with bpf_prog_add error code. xdp_prog pointer value is used in
> the driver to verify if XDP is currently enabled.
> Moreover nicvf_xdp_setup does not report to the userspace any error code in
> case of failure.
> I wrote the following patch to fix the reported issues. Please note I just
> compiled it, not actually tested since I have no thunderx nic at the moment.
>
> @Sunil: could you please give it a whirl? If it is ok I will post a formal
> patch, thanks
Sunil did review this, so please resubmit formally.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: net: thunderx: nicvf_xdp_setup error code path
2018-11-22 0:18 ` net: " David Miller
@ 2018-11-22 9:11 ` Lorenzo Bianconi
0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2018-11-22 9:11 UTC (permalink / raw)
To: David Miller; +Cc: netdev, sgoutham
>
> Sunil did review this, so please resubmit formally.
Hi David,
I have already posted a formal patch:
https://patchwork.ozlabs.org/patch/1001213/
Reviewing the mail I have not explicitly added you in cc, sorry
Regards,
Lorenzo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-22 19:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-20 17:56 net: thunderx: nicvf_xdp_setup error code path Lorenzo Bianconi
2018-11-21 4:43 ` Goutham, Sunil
2018-11-22 0:18 ` net: " David Miller
2018-11-22 9:11 ` Lorenzo Bianconi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.