From patchwork Fri Jan 19 23:30:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Fijalkowski X-Patchwork-Id: 13524238 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 306BD58AD3; Fri, 19 Jan 2024 23:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705707056; cv=none; b=SU3gxdSsDaDUuGIf45QHEC8wmFUw0gDEPD8llFI+iKiHviDJHiWBxFFOtuLm7Wl5E0INUfXyzBPwftRxEN5QrguLE+sUHO0PO1oXmUC1ZKZ3o1VL0o8+njHYdvKiAn2xv9VgTVGdaZztw2NqeOenBvNqCO5y9MCSiaq5aWRXCrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705707056; c=relaxed/simple; bh=eJyulSxFkLgss8vVHYcG6J+Lt6BM/8SR04Fb1v9dFa8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ldi1GSfqHQLab49gcqjCRs0kPIhN+ESYVk98TUPj/XY3Xhok4YuC0QpDt9HLtrmDfBo9TmxJmmmu+Rn2f1HZbUe+55UF6wBLKdBIJOcx3BmGT6j7HqQh0jGmLL1FzX3OK5+vRQ3iLENB0HnHLuwqfPcihFQngBk/Gi0ESb7r1HM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZETzoc4I; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZETzoc4I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705707055; x=1737243055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eJyulSxFkLgss8vVHYcG6J+Lt6BM/8SR04Fb1v9dFa8=; b=ZETzoc4Ip0koSzyFMC810XOVK3M5XdD6zUFpaJKfScJqczc5olo/JMbH RXztSjV5ajV7Jn//N0F4F4AXtqZkVXo4k/dx0azVKP9g0kZCCT6Z2RK5p UeZpC6y4yxkAHwgohPSMID3swFGuhOFZ5ZyzZLPph8tAeUiEUwRlNsqd0 w4F2DJ/S0OSk5ahsLWRbh7Uu/hDa0Pt/HDTrn+CgyaGu19rzGQgYXZwdg xBUJ71b+DnerfJRiYSDgK9sIaENU3aUtpQqpIrydWUbfOC6k097pYAQwd 2+SpIxYr1k5nejzYcdXWQI4Y0Kh8obLcZZbI5RikZxoU2kBUPrTtMNnIW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="771523" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="771523" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2024 15:30:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10957"; a="904277413" X-IronPort-AV: E=Sophos;i="6.05,206,1701158400"; d="scan'208";a="904277413" Received: from boxer.igk.intel.com ([10.102.20.173]) by fmsmga002.fm.intel.com with ESMTP; 19 Jan 2024 15:30:51 -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, martin.lau@linux.dev, tirthendu.sarkar@intel.com, john.fastabend@gmail.com Subject: [PATCH v4 bpf 01/11] xsk: recycle buffer in case Rx queue was full Date: Sat, 20 Jan 2024 00:30:27 +0100 Message-Id: <20240119233037.537084-2-maciej.fijalkowski@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240119233037.537084-1-maciej.fijalkowski@intel.com> References: <20240119233037.537084-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") Acked-by: Magnus Karlsson 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 9f13aa3353e3..1eadfac03cc4 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; }