From nobody Mon Feb 3 18:09:26 2025 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 4Ymvdz1vfcz5mHft; Mon, 03 Feb 2025 18:09:27 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ymvdy6sfdz3SW2; Mon, 03 Feb 2025 18:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738606167; 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=XDFIPUZtMPLTBiti/4h/a+G5zCftZz3ZbXNLaUb7brI=; b=uwyd3TGwusEixVhvr/Mip4eRIC8RP+7ZB3/biwfAnBjvytE83va4LAAKADAujsZ7jE107L q+oiWTRNXY+ZVX9EV3mfBGiv2sQHqWtE7RrsHwCQeTyXX/7prvhV1bew0QPAfpVPX53eBT 8voD0DwlYW8TYU43j4frK1kVGuJir65sDpzTzlpgp7u0a2ti1s722RIiZnhh7ioUoxZCnL r2Vhhz/SNLVhPIxSiPAEuSLG6zIQCSmsU3bc30NOU1gRnYrBsidMjRkP7xV6bsFnG3Peha cczhwRkxOBFi5lEj80UYqXa/4YFic9EAYSkPwDitkFEjGvNQMGarAPZSbaCDkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738606167; 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=XDFIPUZtMPLTBiti/4h/a+G5zCftZz3ZbXNLaUb7brI=; b=fDAgxplKH9XKfTsl4Ezwe8bN5G9i70RG+7GTSiLNMGdMGb9DCc+oTG4FmU/VvNzb+5/zH/ nfqLX5z0bxhOMJXBDEGic9mGnmMnJ8HBlNwes/TbH3Cp3ohrwtU+tein3Ua+WQgCO33g8q 7x9dtfxjk7SKvzRIZ0aXoSeHGoxoMGRo5a4KTJYKg51/nch9SxOZt8223mLDMXXPBH4Za9 4inZI2KZnTd1OYrhfYACWeQTLwbJju1BmtDUnyGPgCAxmAYgB3zgLs3gato2LXq8QHuMvy UxhFf+z9VkOll+CDyNl9fH6leGjWrCaeO3R4ypMpC/DP7VdsmnqolqtKP2JsPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738606167; a=rsa-sha256; cv=none; b=ZMKyE7zSvjD7cW2T8u2OiDsJt3r8QY1NZtzVYoaEL8XBqh7Lh7hMJ+h44SluzyBralySFs v55RNdQ2b92eJ/5/+Z/ieYjdpl0l+ppMobN/A+3wSUwXRzG5/wUH6nBqJTF5CpdB915WVG 6DJrYrRfLuMKyWkigXxDcARjITGiOLOXeCqSvaMiGNUWgBNCBu9e7nMl6Ro0c+7kO8Fhfr 59par2mCw49lZ4awsTFsuXKj2YxahhdZdESm7BHj/PkKHp72iSi6syGpy0tfIsb96g90ri T/JFiuDVDV8K66pSyAQPk8SsfpSqScAk0nD1/FBU78W/krlK5Vn1ZmePedsmUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4Ymvdy4JCmzms3; Mon, 03 Feb 2025 18:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 513I9Q24085865; Mon, 3 Feb 2025 18:09:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 513I9Qjp085862; Mon, 3 Feb 2025 18:09:26 GMT (envelope-from git) Date: Mon, 3 Feb 2025 18:09:26 GMT Message-Id: <202502031809.513I9Qjp085862@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: fe5a6266dde0 - main - protosw: this is a kernel only header, put back #ifdef _KERNEL 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: fe5a6266dde08cece15025c75a80a45d977c57c2 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=fe5a6266dde08cece15025c75a80a45d977c57c2 commit fe5a6266dde08cece15025c75a80a45d977c57c2 Author: Gleb Smirnoff AuthorDate: 2025-02-03 07:08:05 +0000 Commit: Gleb Smirnoff CommitDate: 2025-02-03 17:48:53 +0000 protosw: this is a kernel only header, put back #ifdef _KERNEL The uncommented #ifdef _KERNEL originates from 1997 by wollman@ (see 57bf258e3dc9e) with no clear original reason. Since these old times two abusers of the header leak were created - libprocstat(3) and netstat(1). These two already have a lot of _WANT_FOO hacks, so satisfy them with _WANT_PROTOSW. While here, cleanup and sort forward declaraions. --- lib/libprocstat/libprocstat.c | 1 + sys/sys/protosw.h | 26 ++++++++++---------------- usr.bin/netstat/inet.c | 1 + 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index b808085f5eed..90e4879ca05b 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -50,6 +50,7 @@ #define _WANT_SOCKET #include #include +#define _WANT_PROTOSW #include #include #define _WANT_UNPCB diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 941d377b1549..2f74148efa1d 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -31,19 +31,7 @@ #ifndef _SYS_PROTOSW_H_ #define _SYS_PROTOSW_H_ - -#include - -/* Forward declare these structures referenced from prototypes below. */ -struct kaiocb; -struct mbuf; -struct thread; -struct sockaddr; -struct socket; -struct sockopt; -enum shutdown_how; - -/*#ifdef _KERNEL*/ +#if defined(_KERNEL) || defined(_WANT_PROTOSW) /* * Protocol switch table. * @@ -53,10 +41,17 @@ enum shutdown_how; * In retrospect, it would be a lot nicer to use an interface * similar to the vnode VOP interface. */ +struct socket; +struct sockopt; +struct thread; +struct sockaddr; struct ifnet; +struct mbuf; struct stat; struct ucred; struct uio; +struct kaiocb; +enum shutdown_how; /* USE THESE FOR YOUR PROTOTYPES ! */ typedef int pr_ctloutput_t(struct socket *, struct sockopt *); @@ -144,7 +139,8 @@ struct protosw { pr_setsbopt_t *pr_setsbopt; /* Socket buffer ioctls */ pr_chmod_t *pr_chmod; /* fchmod(2) */ }; -/*#endif*/ +#endif /* defined(_KERNEL) || defined(_WANT_PROTOSW) */ +#ifdef _KERNEL /* * Values for pr_flags. @@ -167,7 +163,6 @@ struct protosw { #define PR_CAPATTACH 0x80 /* socket can attach in cap mode */ #define PR_SOCKBUF 0x100 /* private implementation of buffers */ -#ifdef _KERNEL struct domain *pffinddomain(int family); struct protosw *pffindproto(int family, int type, int proto); int protosw_register(struct domain *, struct protosw *); @@ -177,5 +172,4 @@ int protosw_unregister(struct protosw *); extern struct domain inetdomain; extern struct domain inet6domain; #endif - #endif diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 5a5610ccb6c0..6065a2a7644c 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -30,6 +30,7 @@ #include #include #include +#define _WANT_PROTOSW #include #include #define _WANT_SOCKET