diff --git a/sbin/sysctl/sysctl.8 b/sbin/sysctl/sysctl.8 --- a/sbin/sysctl/sysctl.8 +++ b/sbin/sysctl/sysctl.8 @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 18, 2023 +.Dd October 14, 2024 .Dt SYSCTL 8 .Os .Sh NAME @@ -111,6 +111,8 @@ .Nm for collecting data from a variety of machines (not all of which are necessarily running exactly the same software) easier. +.It Fl J +Display only VNET sysctl variables (CTLFLAG_VNET). .It Fl l Show the length of variables along with their values. This option cannot be combined with the diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -63,7 +63,7 @@ static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag; static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag; -static bool Fflag, lflag; +static bool Fflag, Jflag, lflag; static int oidfmt(int *, int, char *, u_int *); static int parsefile(const char *); @@ -136,7 +136,7 @@ setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabB:def:FhilNnoqtTwWxX")) != -1) { + while ((ch = getopt(argc, argv, "AabB:def:FhiJlNnoqtTwWxX")) != -1) { switch (ch) { case 'A': /* compatibility */ @@ -169,6 +169,9 @@ case 'i': iflag = 1; break; + case 'J': + Jflag = true; + break; case 'l': lflag = true; break; @@ -1052,6 +1055,10 @@ if (Tflag && (kind & CTLFLAG_TUN) == 0) return (1); + /* if Jflag then only list sysctls that are vnet variables. */ + if (Jflag && (kind & CTLFLAG_VNET) == 0) + return (1); + if (Nflag) { printf("%s", name); return (0);