Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8133483imu; Tue, 4 Dec 2018 03:35:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/USj5F5oTqpp7PfokyVCanLNH/yS9RRH763a1nmp4AB1r84zjFEtNvzq9ib54G863GQg0hm X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr19643626plo.67.1543923309125; Tue, 04 Dec 2018 03:35:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543923309; cv=none; d=google.com; s=arc-20160816; b=TpEb1rnGBD2ikGS+PvkqMsURYXi+L3i0szVBjnKe8QCMPGOhxX/21dTsLGUvRGlTAG AqQpa7OsA57KCLESm/Jw/Y86BGmeS1TipW52LFLHpFxLcjUXxUR1a+AQ9bqAAhx4VF1c bL3qodKLWfXRY7PhYqcA8WZj31KEvMj/rFMBGPOOjJEE0H06m/F1fHFOFJciY5LYDMA0 lFJ3duXU5fx8cNuKJtHsKghTtcoCLKexBA7fH4l8Hh+VeMwaOqcUSnwIg7dmDQyyA7f9 wnQFRsPuxq0UHpY1aBIqga4qcqX+3sKml7O1wxmNo5+x7m0becLhzTEFQUBic0dVXFyC 1+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JSaUX44TJeRPRQFNzfnO91xj6pL1R4/d+v0OJcWqAVk=; b=kPp1L9AHtrYEVHq4XoR1da9EEOITX53kW929LXVyGFo3FBhDwAplW64xKYmuCCRxOb APlg1KQyLv2GfcPvT/7uwbyho5dC6y6w/OQKvo7i6X0JWuPrkOuZH/75aJmZ7azOcuzb BHAmfZyfCBE4dZdqMW7EqpbSFjPnwuH+aUiaMtOr3IMBkhu7vHUeRpHKzHt3HhFWqfKw tWh42XAEbm5Nv/TC2v7Dl+mH0axxMcy20mDaWE4AHxyUc4ui+LsUG37pKdwH/Ny88H/n SIae68ZEb4xvZc0ufBFkYUwgr0Lm9dx31d8aWV2wJn8Q6a6gEDUfOvZcl0ieP3zOX22J ZBvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRulE8Ut; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si17957640pfh.147.2018.12.04.03.34.54; Tue, 04 Dec 2018 03:35:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRulE8Ut; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726312AbeLDKzm (ORCPT + 99 others); Tue, 4 Dec 2018 05:55:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:38564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbeLDKzk (ORCPT ); Tue, 4 Dec 2018 05:55:40 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64B6D2146D; Tue, 4 Dec 2018 10:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543920939; bh=b6jf/IryfvBW2/WmAKhTfQWbj4iesrO6dsWqM4n9/wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRulE8Utu/+Y1hZz1Dmr7Utkasm8XeZ6Qnq7eA7ukQtBZfGj49NGmU+zC6bb4uFlK 2cuq+l+ikEQacpkEoiut5UvpaDmQA7QzWXyvzg2RFOBPC9HcudV0wba63SvQWMNfOv jA9++yl7ogR2M7MxDxq8HsSYDnSqvNqYsfcCcw2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , "David S. Miller" Subject: [PATCH 4.19 019/139] net: thunderx: set xdp_prog to NULL if bpf_prog_add fails Date: Tue, 4 Dec 2018 11:48:20 +0100 Message-Id: <20181204103650.768788031@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lorenzo Bianconi [ 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- 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)