From nobody Thu Apr 20 19:42:51 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q2Sk43cKbz46Vr2; Thu, 20 Apr 2023 19:42:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q2Sk41Zb3z3R8c; Thu, 20 Apr 2023 19:42:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682019772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=55KyJftk6Mhe7rfoZBjPNF1TNkM8rjbvrYRvCqHOYW0=; b=mnjIVzW4jgr40SB7OsKnXY1URPKPA0flEFFLSlLKWgkkwqDTX4e3woTXchfqmznZQiaKfh lNMn7sFV6glxnICeGOcj6giaHtaCY77mVWhgf4nod/0KifrUQRZObpuBMS6JI4rG0+LEic XjJRWgxwu+zjRrui/ApxyGkjFN1nqwLWm/5+uqR5JpDfOAR5bwePymwK4wreFgWtHgif48 /5niWI3Y7Aene0cDBOugnXYHnxQu+nSq+9iTVWX7L4NVJNWhujnKB+vFTgiYacLgCAxIqj xTN+FalbYm38egiEnXAZxqCvyeTE5LupsYd/BTD1DzAlYuTlI0gseW3ICqM9Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682019772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=55KyJftk6Mhe7rfoZBjPNF1TNkM8rjbvrYRvCqHOYW0=; b=xQBaJIoQGYWWrZCbYaIFRJscH3AF7ZYOSTEcBNE6EZPc+Jao+o88VziatLfdpMIsTyXozQ kKENDOK+0PF+hRpB9fRzw2Gxp2vX7NATXiG72j7znteuFjVZNdYZmSlVlvR0MXpHiP7kI3 qpDLzMmO/oEvSPGbPpPK7AxthWaRlWGQdmeshspP73Jzh3rw4+NwITak4eLwBLMuRI6RWP Xl+Lc8OoBeaUB1YCMKmAmEz6CNamZGg4lzMSfU/kOqWWgqmHHIEmQtRXqPVdh0SbxxAPOf WyAllkolfh6hIaVsqjdgEKydMi706G37I+/lZiiYkJxE75bW+pbD7gQWoobkag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682019772; a=rsa-sha256; cv=none; b=oKOHLJUsqjZBRf2pswLBCPWum3hhWU/DeTzdl+iTe+JMJ/8RFyGvUTK4Cn2K9kJ78E5zRB xN6IRpiegdsFkAUi04X28jaRPRdKEO0QuBvSRXDoJA2P6Uz6gXzItUvs80Onyw48ayLnfS Upaa/TwGkH5vLShzyXFsJbWfY21c73azu2qmpAnaq0Pxzy8mPRd1RF0OXpGW/QpUNhQ1xw h9cDObUk4Ap9F1K/asLDioFx3fsFW4pB+dZReH9Z2/G7pxbGykLn4xabVgqDwL5QmILsJz VeNp3iD8EWS2kqCgYZt7YRxCcOcK+jmXs0o/Hm2GTv66b92uBsY3McVKZFwvRw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q2Sk40WkSzrFS; Thu, 20 Apr 2023 19:42:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33KJgpQ9092571; Thu, 20 Apr 2023 19:42:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33KJgpgk092570; Thu, 20 Apr 2023 19:42:51 GMT (envelope-from git) Date: Thu, 20 Apr 2023 19:42:51 GMT Message-Id: <202304201942.33KJgpgk092570@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 8e813d07c680 - main - netstat: fix printing of TCP pcbs with -A List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e813d07c6804f80e1380b54f6e5fa6d34a3be52 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=8e813d07c6804f80e1380b54f6e5fa6d34a3be52 commit 8e813d07c6804f80e1380b54f6e5fa6d34a3be52 Author: Gleb Smirnoff AuthorDate: 2023-04-20 19:41:03 +0000 Commit: Gleb Smirnoff CommitDate: 2023-04-20 19:42:42 +0000 netstat: fix printing of TCP pcbs with -A This change touches both kernel and netstat(1), but either of the changes will fix printing pcb addresses with -A. The thing is that historically netstat(1) treated TCP differently, and printed tcpcb address instead of inpcb address. This is not documented anywhere! With e68b3792440 these two addresses became the same. It is highly likely they will be the same for a long time, but it might be they will start to differ again in a far future. My proposal is to stop treating TCP differently with netstat(1) and right now is a good opportunity to do that, since there will be no behavior change at all. The kernel change to tcp_inptoxtp() will go into stable/14 to make it compatible with netstat(1) binary from stable/13. We can drop it later, probably together with in_ppcb pointer from inpcb. The in_ppcb in xinpcb will stay for size compatibility. Reviewed by: tuexen, rrs Differential Revision: https://reviews.freebsd.org/D39736 --- sys/netinet/tcp_subr.c | 7 +++++++ usr.bin/netstat/inet.c | 13 +++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index db0c71fdbfff..d7ca44e8a581 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -3968,6 +3968,13 @@ tcp_inptoxtp(const struct inpcb *inp, struct xtcpcb *xt) xt->xt_len = sizeof(struct xtcpcb); in_pcbtoxinpcb(inp, &xt->xt_inp); + /* + * TCP doesn't use inp_ppcb pointer, we embed inpcb into tcpcb. + * Fixup the pointer that in_pcbtoxinpcb() has set. When printing + * TCP netstat(1) used to use this pointer, so this fixup needs to + * stay for stable/14. + */ + xt->xt_inp.inp_ppcb = (uintptr_t)tp; } void diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index a16f09d391fb..fd1a6ff20e42 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -383,16 +383,9 @@ protopr(u_long off, const char *name, int af1, int proto) if (Lflag && so->so_qlimit == 0) continue; xo_open_instance("socket"); - if (Aflag) { - if (istcp) - xo_emit("{q:address/%*lx} ", - 2 * (int)sizeof(void *), - (u_long)inp->inp_ppcb); - else - xo_emit("{q:address/%*lx} ", - 2 * (int)sizeof(void *), - (u_long)so->so_pcb); - } + if (Aflag) + xo_emit("{q:address/%*lx} ", 2 * (int)sizeof(void *), + (u_long)so->so_pcb); #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?