From nobody Mon Nov 25 16:31:31 2024 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC04715C147; Sat, 26 Oct 2024 03:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729915069; cv=none; b=UHzypJJ6c6u7S/P6nTR9nHLr9PSNzxa5kdxmBEvMIazf2s8KKKdoMDxSN900uzAdeGh7yIMDiq8KBjW0lQzNlNoUXUkyS86JFo4/6BqNSvN5t6ixERs9e9FS/RbPvZlU62vNF1TmjMl8FVOvlcVOkDgaiWw9NNLF4UKVM/R7E7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729915069; c=relaxed/simple; bh=49WP904npWM081cav2pwr56e9k8eNS2Tx63DsRnsEBU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ez6VS+HdtTY1t7UYO0Ci5hfsokWccQowRm58Pd8JHhUVMD99nKkSYAk5/KUZmGN2SdjdUvVkEthrKpTfRQ1n2Sg006acxfcNFs8oiSybgT6Ky5zEd37CR8aeaVwZ6qR9E86rnIsWLnBe6JVGOjVXfHQdE9Q/SqytkBsPZeWtYp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Xb5SL0lDcz20qWv; Sat, 26 Oct 2024 11:56:50 +0800 (CST) Received: from dggpemf500002.china.huawei.com (unknown [7.185.36.57]) by mail.maildlp.com (Postfix) with ESMTPS id C7C1414011D; Sat, 26 Oct 2024 11:57:44 +0800 (CST) Received: from huawei.com (10.175.101.6) by dggpemf500002.china.huawei.com (7.185.36.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 26 Oct 2024 11:57:43 +0800 From: Yue Haibing To: , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 net-next 3/4] ixgbe: Fix passing 0 to ERR_PTR in ixgbe_run_xdp() Date: Sat, 26 Oct 2024 12:12:48 +0800 Message-ID: <20241026041249.1267664-4-yuehaibing@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241026041249.1267664-1-yuehaibing@huawei.com> References: <20241026041249.1267664-1-yuehaibing@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf500002.china.huawei.com (7.185.36.57) Content-Type: text/plain; charset="utf-8" ixgbe_run_xdp() converts customed xdp action to a negative error code with the sk_buff pointer type which be checked with IS_ERR in ixgbe_clean_rx_irq(). Remove this error pointer handing instead use plain int return value. Fixes: 924708081629 ("ixgbe: add XDP support for pass and drop actions") Reviewed-by: Jacob Keller Reviewed-by: Maciej Fijalkowski Signed-off-by: Yue Haibing Reviewed-by: Simon Horman Tested-by: Chandan Kumar Rout (A Contingent Worke= r at Intel) --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/et= hernet/intel/ixgbe/ixgbe_main.c index 8b8404d8c946..78bf97ab0524 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1908,10 +1908,6 @@ bool ixgbe_cleanup_headers(struct ixgbe_ring *rx_rin= g, { struct net_device *netdev =3D rx_ring->netdev; =20 - /* XDP packets use error pointer so abort at this point */ - if (IS_ERR(skb)) - return true; - /* Verify netdev is present, and that packet does not have any * errors that would be unacceptable to the netdev. */ @@ -2219,9 +2215,9 @@ static struct sk_buff *ixgbe_build_skb(struct ixgbe_r= ing *rx_ring, return skb; } =20 -static struct sk_buff *ixgbe_run_xdp(struct ixgbe_adapter *adapter, - struct ixgbe_ring *rx_ring, - struct xdp_buff *xdp) +static int ixgbe_run_xdp(struct ixgbe_adapter *adapter, + struct ixgbe_ring *rx_ring, + struct xdp_buff *xdp) { int err, result =3D IXGBE_XDP_PASS; struct bpf_prog *xdp_prog; @@ -2271,7 +2267,7 @@ static struct sk_buff *ixgbe_run_xdp(struct ixgbe_ada= pter *adapter, break; } xdp_out: - return ERR_PTR(-result); + return result; } =20 static unsigned int ixgbe_rx_frame_truesize(struct ixgbe_ring *rx_ring, @@ -2329,6 +2325,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *= q_vector, unsigned int offset =3D rx_ring->rx_offset; unsigned int xdp_xmit =3D 0; struct xdp_buff xdp; + int xdp_res =3D 0; =20 /* Frame size depend on rx_ring setup when PAGE_SIZE=3D4K */ #if (PAGE_SIZE < 8192) @@ -2374,12 +2371,10 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector= *q_vector, /* At larger PAGE_SIZE, frame_sz depend on len size */ xdp.frame_sz =3D ixgbe_rx_frame_truesize(rx_ring, size); #endif - skb =3D ixgbe_run_xdp(adapter, rx_ring, &xdp); + xdp_res =3D ixgbe_run_xdp(adapter, rx_ring, &xdp); } =20 - if (IS_ERR(skb)) { - unsigned int xdp_res =3D -PTR_ERR(skb); - + if (xdp_res) { if (xdp_res & (IXGBE_XDP_TX | IXGBE_XDP_REDIR)) { xdp_xmit |=3D xdp_res; ixgbe_rx_buffer_flip(rx_ring, rx_buffer, size); @@ -2399,7 +2394,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *= q_vector, } =20 /* exit if we failed to retrieve a buffer */ - if (!skb) { + if (!xdp_res && !skb) { rx_ring->rx_stats.alloc_rx_buff_failed++; rx_buffer->pagecnt_bias++; break; @@ -2413,7 +2408,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *= q_vector, continue; =20 /* verify the packet layout is correct */ - if (ixgbe_cleanup_headers(rx_ring, rx_desc, skb)) + if (xdp_res || ixgbe_cleanup_headers(rx_ring, rx_desc, skb)) continue; =20 /* probably a little skewed due to removing CRC */ --=20 2.34.1