Article View: linux.kernel.netdev
Article #7332Re: [PATCH bpf 1/2] bpf, sockmap: Stop reporting EPIPE on zero-length skb redirect
From: Jiayuan Chen
Date: Mon, 26 Oct 2026 06:32
Date: Mon, 26 Oct 2026 06:32
55 lines
11660 bytes
11660 bytes
On 10/26/26 11:17 AM, Eli Skeggs wrote: > On Mon, Oct 26, 2026 at 09:59:00AM +0800, Jiayuan Chen wrote: >> On 10/26/26 7:41 AM, Eli Skeggs via B4 Relay wrote: >>> From: Eli Skeggs <kernel@eliskeggs.com> >>> >>> Treat a return of 0 as success when there is no data to send, while >>> continuing to fail on a 0 return with residual bytes. The loop exits >>> without incident on an empty skb, and the skb gets cleaned up as usual. >>> On an ingress redirect, the empty message is still queued as before, but >>> the target socket no longer reports EPIPE. >> The target can't receive anything after that though. The empty msg sits >> at the head of psock->ingress_msg and nothing ever dequeues it: >> >> [...] >> >> So the user gets EOF on a socket whose peer never closed, and everything >> redirected to it after the FIN is lost. Without a verdict prog on the >> target it is worse, tcp_bpf_recvmsg() returns -EFAULT forever. >> >> Since this patch is already about the zero-length skb, can you handle >> the ingress side too? E.g. in sk_psock_skb_ingress(), don't queue an >> empty msg when len is 0 and the skb was redirected (skb->sk != sk). The >> self PASS case must keep its empty msg since is_next_msg_fin() depends >> on it. > Yep, thanks for pointing that out. > > Alexei suggested skipping empty skbs in sk_psock_backlog(): > https://lore.kernel.org/all/DMEE6SW3UE97.2DF11HBEBKYYI@gmail.com/ > > To your point, I think the critical difference between these approaches > happens when the sk's backlog queue is not empty and the socket's own > FIN (the self PASS FIN) gets queued. In that case, we rely on the empty > msg to correctly update copied_seq, and skipping it means the copied > sequence number ends up 1 behind rcv_nxt. > > This path is already broken: when a socket's FIN gets queued behind > other skbs, the backlog reports the erroneous EPIPE just as in the > redirect case. > > I do like the simplicity of skipping the empty skbs entirely. I don't > immediately see what the consequence is for copied_seq being behind in > this terminal state, but the approach that updates copied_seq does seem > strictly more correct. > > Is that the right interpretation? Let me know what direction I should > take for v2. Yes, go with Alexei's suggestion. Skipping zero-length skbs in sk_psock_backlog() also covers the ingress redirect case I raised, since the empty msg is never queued. copied_seq being 1 behind rcv_nxt is fine now, plain TCP sits in that state until the user reads EOF, and nothing on the psock side depends on it.
Technical Details
Message-ID:
<50b12d32-891c-46d4-bd5f-8924cb8db60f@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351701-linux-kernel-netdev=dewy.ruReferences:
<20261025-sockmap-bare-fin-v1-0-bb8feae7c4a7@eliskeggs.com> <20261025-sockmap-bare-fin-v1-1-bb8feae7c4a7@eliskeggs.com> <23181ba7-e4ef-4475-92ee-366e0ca2dcf0@linux.dev> <010101a176362646-06b53e65-6c20-4ac2-9e05-b74eb5376abf-000000@us-west-2.amazonses.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351701-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf 1/2] bpf, sockmap: Stop reporting EPIPE on zero-length skb redirect Date: Mon, 26 Oct 2026 14:32:23 +0800 Organization: Usenet Network Message-ID: <50b12d32-891c-46d4-bd5f-8924cb8db60f@linux.dev> References: <20261025-sockmap-bare-fin-v1-0-bb8feae7c4a7@eliskeggs.com> <20261025-sockmap-bare-fin-v1-1-bb8feae7c4a7@eliskeggs.com> <23181ba7-e4ef-4475-92ee-366e0ca2dcf0@linux.dev> <010101a176362646-06b53e65-6c20-4ac2-9e05-b74eb5376abf-000000@us-west-2.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1241048"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:3RZ6Pj3jy/fR1VtWTLH4uZuCiuU= sha256:FttXLrL+E8JEw1pC67q1q42quu0qKGrZvQj1K4/NYuk= sha1:8aPSxh0LVc02iZusPjjhKcVEIQ0= sha256:mIZkTA39A1OwwiBon4N4pVsdKrZl6pRSUa48tvwfc5o= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 946F1125B8B; Mon, 26 Oct 2026 09:35:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.051 X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HK_RANDOM_FROM=0.999, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lu6J-2jSrzaN; Mon, 26 Oct 2026 09:35:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351701-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E8A98125B8A; Mon, 26 Oct 2026 09:35:22 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 6FC432E3EA; Mon, 26 Oct 2026 06:32:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792996371; b=xl41DFq51uabmX6UL3oxiwNBTmDUqrjsuj8Yw3j+5cU34M5/swGsn0+1nYf++Ry1uvAW mzaS/hDUunqiQ/LRR+dxocS4aF9NM4qGIcVKophos8SLpptqxefd3N5/CRFqGCMpV7fCV Dijjp0iQOLfUgCYXZ9Do8nvvEvkwoBdi3WGsMU6preOAuw8jIne5W4kjegIiw9Kzc75WK RSwbq1psdUwk7RANtEQ7ThaSNfNukI37ar4JvrzFqYriqlAc1bAcmNt+OX0cfUSCTOHCQ QYLsH8vK+TFRPnzb5yB5GrOexTqPAaBXWfB13iwqIeNPx1QazXAxEgJkbp2NIkP6kjA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996371; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=CC59iY1aw6OyV8aTURcQLbLL17pBSNRBVzyiXs5pORM=; b=CQnxzPxIz2JqJsl2dUR3hnCBZYd0GEBKbKM1Wm8e8kkXsfa11av6KPJDh5S122jAZVcF K1PA4H/LNWNRkK5p5PAzc4y8188vMmJxJEdwIFEP7MYXiDQd3Cijmn/sFLVUZrZuhY8AR 2QnEw/TpcLzkZsDM3aIZwcMyzvUM9vXvjCg/HFDUIGTG+C+2xWWyjSWN9ZGocv59UeT9e l9GdcmA3hyN78k66u/4cBIgxa7hIilSYd03xbjzJc8FnGoRb+0a9WptyQi51Oz8QzGjic UwDhSa/gH1QCZtzCNL2IhuexyhNqvE1JJVSQqDhyKfxWegmqM3xdI+N6XSWDyBmY/CQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=i+8Ult+S; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34D56606A326; Mon, 26 Oct 2026 06:32:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=i+8Ult+S X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.73 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996364; b=VDAg7zUfGZashcyDcpGcIGnvTL5Zerl0SxLVII9r1rjpum9Th5gHUR5KYS6LYCEUD+42 VkpALBsyoRRUg3w+nfZ9Bs82zarYZqs/3Drjj101eUZKdkkT3KG89H+I064iqxK7UXz0U nyl1t4wfZA4erBhkD73TEU4Z7BnLNRS6qxMRuj4XOURvzaw9V//QrNPer7s4JtGZvHHtK I3gWUbsuSy3sDSABO+ley9Bfdc/r1TpkWFlI+n5gdhoOJXxqECkqT3buhTh8daDgXnSWQ NrMr4ijsEXo+gv69nRS6sHxZkvomvFu1RBSnkABc7gQidgsGxFYOEvv30SF1gc1nqQQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996364; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=CC59iY1aw6OyV8aTURcQLbLL17pBSNRBVzyiXs5pORM=; b=vxRVT40bpk36g1/EQQ3c2yYiC05UsWJN5hbfFMt9HI7wpTlUsMAILmpFYf5mb4Vis7WF WjcR2now/1YBP9YxLZ/bwiJ12ABpvWy8TQNz2rhpNeDAgSUHVQXV3u3vBMbLo0pImcrHS 0h1Q5GskQl2XK2643cBV/IXM+co+qhdGDIOxY3eIal160TeLNdPvzPPl0LJ9f9vxoWjSx sXrQofTD0etfyrw9S8slzNi2Cobc9T5l8i0NO9t3avZzcWXnnto/tf7zD1sL9lt/0/dq6 ieDPnZzss487strlr4jZ0iw1fkxC2gAg+Q18ZV/WUs06+wreAXFAw/Q1hZ7O3Hul2nw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=none smtp.remote-ip=91.218.175.73 X-Received: from mta0.migadu.com (out-73.mta0.migadu.com [91.218.175.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8676606A31B for <netdev@vger.kernel.org>; Mon, 26 Oct 2026 06:32:40 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8676606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=CC59iY1aw6OyV8aTURcQLbLL17pBSNRBVzyiXs5pORM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792996358; v=1; x=1793601158; b=i+8Ult+S6zvD9Bg7VMNe5iRbHrfBhZVRsULgmUnxm37S/8jDYdapDB+FvUaGp2zrcK/aaEFE D8uzEsO15Z75t2TuY3WKWU/zKZGkAG0ewvT/UeMW/bCmF9V8zzU8BjTtMkycyGJ2BJD8jbI40oI AMmWhlsG/2P/E2gnd59fe7fw= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id b6a4888feb48e90f; Mon, 26 Oct 2026 06:32:38 +0000 X-Mizu-Trace-ID: b6a4888feb48e90f X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: John Fastabend <john.fastabend@gmail.com>, Jakub Sitnicki <jakub@cloudflare.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, Shuah Khan <shuah@kernel.org>, Geliang Tang <geliang@kernel.org>, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org X-In-Reply-To: <010101a176362646-06b53e65-6c20-4ac2-9e05-b74eb5376abf-000000@us-west-2.amazonses.com>