From patchwork Fri Dec 8 11:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fijalkowski, Maciej" X-Patchwork-Id: 13485315 X-Patchwork-Delegate: bpf@iogearbox.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IK2itEkx" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1BF510F9; Fri, 8 Dec 2023 03:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702035010; x=1733571010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UiwvDZZEBGN+l/sEs2EZd8sLOX+zt/DQye+jA7flp2s=; b=IK2itEkx1tDpUrPxk4Ry6jFT7B61RqUK/BKd9FKZIozLD7niNwJMTdwG yVPjvFo6fxu+KpqvNcpGfpdF0Y/TBAlA03YxGKO/0yJk0U46RuHLselPr 4cRlVAj985bZCSxkebRGeEd77IvMxfIkVo1AZ5lw9ei4YL2X4rGRABysH asxitR6LsF1IWT58mkSRWKtIVsyNkB/hcvYuWQhBUeHoxt7ikyvKN4E58 GthfsNAzo1OGAjt+/5mxdsAM+YwXxjopRAxWEJq1owPtaB+huTPYIzUWC mxlrwwHVCnEe1yEskQqiSABFXri4xu/N+wPGinYghNp2OBf4JBT0XHNN/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="458705890" X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="458705890" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2023 03:30:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="862828134" X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="862828134" Received: from boxer.igk.intel.com ([10.102.20.173]) by FMSMGA003.fm.intel.com with ESMTP; 08 Dec 2023 03:30:08 -0800 From: Maciej Fijalkowski To: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com, bjorn@kernel.org, maciej.fijalkowski@intel.com, echaudro@redhat.com, lorenzo@kernel.org Subject: [PATCH bpf 1/3] xsk: recycle buffer in case Rx queue was full Date: Fri, 8 Dec 2023 12:29:43 +0100 Message-Id: <20231208112945.313687-2-maciej.fijalkowski@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231208112945.313687-1-maciej.fijalkowski@intel.com> References: <20231208112945.313687-1-maciej.fijalkowski@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add missing xsk_buff_free() call when __xsk_rcv_zc() failed to produce descriptor to XSK Rx queue. Fixes: 24ea50127ecf ("xsk: support mbuf on ZC RX") Signed-off-by: Maciej Fijalkowski --- net/xdp/xsk.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 281d49b4fca4..bd4abb200fa9 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -167,8 +167,10 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len) contd = XDP_PKT_CONTD; err = __xsk_rcv_zc(xs, xskb, len, contd); - if (err || likely(!frags)) - goto out; + if (err) + goto err; + if (likely(!frags)) + return 0; xskb_list = &xskb->pool->xskb_list; list_for_each_entry_safe(pos, tmp, xskb_list, xskb_list_node) { @@ -177,11 +179,13 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len) len = pos->xdp.data_end - pos->xdp.data; err = __xsk_rcv_zc(xs, pos, len, contd); if (err) - return err; + goto err; list_del(&pos->xskb_list_node); } -out: + return 0; +err: + xsk_buff_free(xdp); return err; }