lkml.org 
[lkml]   [2018]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 019/139] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails
    Date
    4.19-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

    [ Upstream commit 6d0f60b0f8588fd4380ea5df9601e12fddd55ce2 ]

    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>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/net/ethernet/cavium/thunder/nicvf_main.c | 9 +++++++--
    1 file changed, 7 insertions(+), 2 deletions(-)

    --- 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
    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
    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
    netif_trans_update(nic->netdev);
    }

    - return 0;
    + return ret;
    }

    static int nicvf_xdp(struct net_device *netdev, struct netdev_bpf *xdp)

    \
     
     \ /
      Last update: 2018-12-04 12:34    [W:4.096 / U:0.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site