Article View: linux.kernel.netdev
Article #9466Re: [PATCH net] tcp: initialize send sequence numbers before deferring TFO
From: Jiayuan Chen
Date: Mon, 02 Nov 2026 06:11
Date: Mon, 02 Nov 2026 06:11
33 lines
9352 bytes
9352 bytes
On 11/2/26 11:59 AM, Qingfang Deng wrote:
> TCP_FASTOPEN_CONNECT can return from connect() before tcp_connect_init()
> when a cached cookie or cookieless Fast Open allows deferring the SYN.
> At this point write_seq contains the initial sequence number, while
> snd_una and snd_nxt have not been initialized to that sequence number.
>
> Consequently, inet_diag and /proc/net/tcp{,6} report the initial
> sequence number as the send queue length despite no SYN or payload being
> queued.
>
> Initialize snd_una and snd_nxt to write_seq before marking the
> connection as deferred. Both sequence-based queue lengths then remain
> zero until the first write starts the connection and runs
> tcp_connect_init().
This patch looks good to me. But idiag_wqueue can still go negative
on the normal connect path, since the socket is already hashed and
diag does not take the socket lock. We always set write_seq first,
then init snd_una later:
tcp_v4_connect
WRITE_ONCE(tp->write_seq, st.seq)
tcp_connect
tcp_connect_init
WRITE_ONCE(tp->snd_una, tp->write_seq)
Can you try this instead?
r->idiag_wqueue = READ_ONCE(sk->sk_wmem_queued) ?
READ_ONCE(tp->write_seq) - READ_ONCE(tp->snd_una) : 0;
Technical Details
Message-ID:
<bfbc4b3c-fe19-4070-97b4-4ff8ded06011@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-354461-linux-kernel-netdev=dewy.ruReferences:
<20261102035943.9700-1-qingfang.deng@linux.dev>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-354461-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] tcp: initialize send sequence numbers before deferring TFO Date: Mon, 2 Nov 2026 14:11:43 +0800 Organization: Usenet Network Message-ID: <bfbc4b3c-fe19-4070-97b4-4ff8ded06011@linux.dev> References: <20261102035943.9700-1-qingfang.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2859172"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OHdBunVNUbtoiQMe88mrY+WE6cw= sha256:fEbmLCgf76SNvhrC4YN3WohsHKomRc+J0COvmJVQyDg= sha1:Ao1T4xjXqMnQnB06HsRL7KWJyyM= sha256:kt6YGYqQMEO3wlszZXne5skIpmQeKkEPRK9h51NlRwY= 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 C1058125CC6; Mon, 2 Nov 2026 09:12:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.05 X-Spam-Status: No, score=-2.05 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, URIBL_BLOCKED=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 HLaP0UwHvN6o; Mon, 2 Nov 2026 09:12:08 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354461-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 2F779125CC5; Mon, 2 Nov 2026 09:11:59 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C37B12B4BB; Mon, 2 Nov 2026 06:11:56 +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=1793599916; b=mmvYUOcoVY4Q547zyx432TjeD5+SDGqepfUvrMswvof4M5MjzRMVWTk28xK8dEVMT/bN U29cgOUIxGT7cGorSWHMkNdKvcl23LB5ThZ+2zu11b7Vk2zPqF28AtYyr2K8VMWubSyLc Q69XlIhJiBqjtHNadSzJEdsKBWucZcqt0iltw4AWHF+s1KZ9RejDTqVBrOgtsFXFr5yEX kbcmWXGMgn00T5ahUCdkrSDS/qoDmmvq4Lch5QS+Cd1J8FHs3D638k3zJwTtq/gBl5Cpt Anl/eqh7at7ce19fzITkc0tCQA4KZp2uY4hnUl37eUdwt4RTKkdA22qIi+1HRSgmx6w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793599916; 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:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=9/+XZluyuQYuL1PPzJIXmb0wYbMN8JEjNGZtTVHdimI=; b=oEJq8aLAy/lkbaRaPv3BazP1ZZ/cIj/dNNoTcYaQTa6GyC6SyIJPX0H51XuKcqfmM8OG kGIGs4gg/MDcVky9vRQZsNfCaYdJXoyHaBTFhPmo/rjJAkBkHzkax2YbHS7PXrVRkjxW3 jWQXpmew6C/1KP171Z8Fg4IFDnf0lGLYaTMmagHgSxNiwb1W7kar/HbN7nvqMAAD0eVwS wxJIUmBuoykyoHN3AF+liV6mIYCQkRwktO3XlMA8Sd7RUTuaJSUCz/XQ3jc+7X0qERb9J bnOaHLlMP8VBprPKwKpHms/b7jE6dMx8/yhDt2PNvwiErIs49Ao1FWUPsuTSV5E9IoA== 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=NAtJJXle; 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 87A10606A330; Mon, 2 Nov 2026 06:11:56 +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=NAtJJXle X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.172 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793599910; b=eQBUL3uZ3SRgfBDqOMwFwQM9QXsUv2ICw7PZHu3NmYLgDnzR/gAgxVMl9NIdkHLlNXW8 wYe0j+ahZZG+4Lys4aWbxb7Jf232MMPztQVmb8Od9CFRugv0ZIAcbD5OHMOni6H6NFBIn vqykhOSGy39rPHAKP3lzUyiPEXbVgl6alnOOLFu3FuqLI+GmR9H13+Cw1PEenzUGHVHck 95RYXVhscI3ldtNlpfgUV9PPlL5i+27KyqvMZFdu0jQKF3XlDwOjykhpM/jANqT3q28/v GNf8DliEtPUKCX/RokcsM3Yy2b0YpCaYMDL4iGXAQ48fCZgmEI7U+UHmsCCcxjxZMNg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793599910; 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:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=9/+XZluyuQYuL1PPzJIXmb0wYbMN8JEjNGZtTVHdimI=; b=3lUFV0y5peyXeE+Ejm82pNmx2hJZWvmrCr37PgE5rrLIxnjx00AQDhDF3dqCQL68r9ca InTGcn+RPr5KwkbvhZc9D+n8T5FYyWa16tB4twyqnGRJuFR77Uns3+LQJnJqlwtaRWaRd vnKRUrAuq62/dhuuo1kTEZgn0iLpK3+GjwbXCkDP2XmsOD3ebbHSyedLkJU4xu0gmJegJ ioOy86QSZ7LeT15ghimC/fNogHF0vdAJFMcTpBkZoscabgXWvmoLJmsK1iSUS32c2bUA4 5p0XjrX406nH8rJD3gookMu5Jypf1p1cjqB0G7e/Je93DnRUsdcZC4u4kBf8B/QclGw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NAtJJXle; arc=none smtp.remote-ip=91.218.175.172 X-Received: from mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 DC96F606A324 for <netdev@vger.kernel.org>; Mon, 2 Nov 2026 06:11:49 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC96F606A324 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=9/+XZluyuQYuL1PPzJIXmb0wYbMN8JEjNGZtTVHdimI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793599907; v=1; x=1794204707; b=NAtJJXlenW+h0I4eC/Y29Ra0n7wrbkvXBzOBWOM7stgSa/poa+4xZCwdeofPTfBuJj+R6nxF 9iX9AChKcJMQlgdhW3WsxTQ8COMW0XIv23CIR78ixFuucpfp3bC+JAYoHtz2fZMaI5mfCZnzX6N EmJNMqXVeozJu9RapD8eY8xo= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 0e361a7862659f90; Mon, 02 Nov 2026 06:11:47 +0000 X-Mizu-Trace-ID: 0e361a7862659f90 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-In-Reply-To: <20261102035943.9700-1-qingfang.deng@linux.dev>