From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 788004315A; Mon, 23 Jun 2025 21:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714887; cv=none; b=ZuxxrQvsfAYMYTO30c4xB38a1K22Ae+ptH7Mk6KWD+trHXKvQPbwsNZRSJIhNuXHgX1M4VMkj27cxrLlhpnSrLY4LIhYd9Y+IWI1bZ/UEJOs0DS1Bt8AapL4DXAnQXTdOdCO1GQcD2qHjp6WwdSn6mPcxryGisfnum3hMP+7VUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714887; c=relaxed/simple; bh=FxFiiJSGBjPcdxeQ9jZ1hZx/Y1b2vGj9AYmFHach9kg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DOP1cbzmR0QP1IiDjbdi0y3oqw/m+6ZWJWCxe3/8wv7R4IHQRnGO9Lv9nJtUNIAvvS4B0FyEM5j6BDuegFcEo8BSzOww+xAGq4JNbHZvh2P+i+q7yV1qhA5ryCPSKs3oo1BWrIuJElufNGyfPVQiWrnSPk+Rwk8n+Rx0q5WMJZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qXMWGinC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qXMWGinC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10A7BC4CEEA; Mon, 23 Jun 2025 21:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714887; bh=FxFiiJSGBjPcdxeQ9jZ1hZx/Y1b2vGj9AYmFHach9kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qXMWGinCgIZlOsPiART8u0OrhfhaCG5D4rRqtccd8Q3QnmX4iVEXc7+S+Nc51LPCF iCUn1CRQLafFAkyxjBFh/vRfSqH46lSHJzYforNrSedLbHRKfEDVYT1dRFnx+rciwW l+fEmXo7/cJ+GYuYSOtadxnVxNIQ3zNCEpKmoekk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiayuan Chen , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.6 187/290] bpf, sockmap: Fix data lost during EAGAIN retries Date: Mon, 23 Jun 2025 15:07:28 +0200 Message-ID: <20250623130632.493431199@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiayuan Chen [ Upstream commit 7683167196bd727ad5f3c3fc6a9ca70f54520a81 ] We call skb_bpf_redirect_clear() to clean _sk_redir before handling skb in backlog, but when sk_psock_handle_skb() return EAGAIN due to sk_rcvbuf limit, the redirect info in _sk_redir is not recovered. Fix skb redir loss during EAGAIN retries by restoring _sk_redir information using skb_bpf_set_redir(). Before this patch: ''' ./bench sockmap -c 2 -p 1 -a --rx-verdict-ingress Setting up benchmark 'sockmap'... create socket fd c1:13 p1:14 c2:15 p2:16 Benchmark 'sockmap' started. Send Speed 1343.172 MB/s, BPF Speed 1343.238 MB/s, Rcv Speed 65.271 MB/s Send Speed 1352.022 MB/s, BPF Speed 1352.088 MB/s, Rcv Speed 0 MB/s Send Speed 1354.105 MB/s, BPF Speed 1354.105 MB/s, Rcv Speed 0 MB/s Send Speed 1355.018 MB/s, BPF Speed 1354.887 MB/s, Rcv Speed 0 MB/s ''' Due to the high send rate, the RX processing path may frequently hit the sk_rcvbuf limit. Once triggered, incorrect _sk_redir will cause the flow to mistakenly enter the "!ingress" path, leading to send failures. (The Rcv speed depends on tcp_rmem). After this patch: ''' ./bench sockmap -c 2 -p 1 -a --rx-verdict-ingress Setting up benchmark 'sockmap'... create socket fd c1:13 p1:14 c2:15 p2:16 Benchmark 'sockmap' started. Send Speed 1347.236 MB/s, BPF Speed 1347.367 MB/s, Rcv Speed 65.402 MB/s Send Speed 1353.320 MB/s, BPF Speed 1353.320 MB/s, Rcv Speed 65.536 MB/s Send Speed 1353.186 MB/s, BPF Speed 1353.121 MB/s, Rcv Speed 65.536 MB/s ''' Signed-off-by: Jiayuan Chen Link: https://lore.kernel.org/r/20250407142234.47591-2-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- net/core/skmsg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/skmsg.c b/net/core/skmsg.c index 2076db464e936..c3169e1e63524 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -689,7 +689,8 @@ static void sk_psock_backlog(struct work_struct *work) if (ret <= 0) { if (ret == -EAGAIN) { sk_psock_skb_state(psock, state, len, off); - + /* Restore redir info we cleared before */ + skb_bpf_set_redir(skb, psock->sk, ingress); /* Delay slightly to prioritize any * other work that might be here. */ -- 2.39.5