From owner-svn-src-stable@FreeBSD.ORG Wed Jun 27 23:16:54 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6A461065674 for ; Wed, 27 Jun 2012 23:16:54 +0000 (UTC) (envelope-from jhellenthal@dataix.net) Received: from mail-yw0-f49.google.com (mail-yw0-f49.google.com [209.85.213.49]) by mx1.freebsd.org (Postfix) with ESMTP id 5742B8FC17 for ; Wed, 27 Jun 2012 23:16:54 +0000 (UTC) Received: by yhjj52 with SMTP id j52so1860300yhj.36 for ; Wed, 27 Jun 2012 16:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dataix.net; s=rsa; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; bh=Sp2zpQUGedtS5DW+7PUiPqZsh0hzsQs6PxpZt1rIawg=; b=GFkB59RLrgeBAQpfs3dnQnEKOApXiZ+crrxf4h8WFC0ibcoIBMQ09SZKjZC6HBzQmd /j9FrsY/u4a1thpw09d4yAH95mEyNuPN6rOhPpJjB6+EzBkG6E3779lLTG8VLfwBJQfz h2TqxuFe3+J7uR/HnuN37OQywfq7vLiqQx1EQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:x-gm-message-state; bh=Sp2zpQUGedtS5DW+7PUiPqZsh0hzsQs6PxpZt1rIawg=; b=F68O2e/k8myn1pc26UO0+sz/3J/Y0G5lIJ993KjZ/0pP5BT/zHHJVtInHVG8nAEuVK MP5hXRnqRnJlMuq2ODmRaB/upc22EOBCWNuKgWDfaESeCs38+c/d0PNCu6VwHxclbiQf vYOBiQPgDCwO5YTzpy2YnbQv9byZcQQpWA8BnqCM3rh/HWzuoOHp/tdlZ7uSn4+G8Rjm GIRJrmBS7fnSsqcjh3Cr/B/TOfm4gZsf3fAtpClLGa8YSUF+kClBRQGN+VsV5Cbh9lw6 rTQxriTv9twfV9ryMgejbEo6FNb0glygspIb+VetZD1RJoyZLj0WwhfXbnuq2YydIy/6 rrJw== Received: by 10.236.177.104 with SMTP id c68mr23155843yhm.76.1340839013639; Wed, 27 Jun 2012 16:16:53 -0700 (PDT) Received: from DataIX.net (75-128-120-86.dhcp.aldl.mi.charter.com. [75.128.120.86]) by mx.google.com with ESMTPS id k67sm30865716yhj.18.2012.06.27.16.16.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Jun 2012 16:16:53 -0700 (PDT) Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.5/8.14.5) with ESMTP id q5RNGoc5012238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Jun 2012 19:16:50 -0400 (EDT) (envelope-from jhellenthal@DataIX.net) Received: (from jh@localhost) by DataIX.net (8.14.5/8.14.5/Submit) id q5RNGoGI012237; Wed, 27 Jun 2012 19:16:50 -0400 (EDT) (envelope-from jhellenthal@DataIX.net) Date: Wed, 27 Jun 2012 19:16:50 -0400 From: Jason Hellenthal To: Andrew Thompson Message-ID: <20120627231650.GA7853@DataIX.net> References: <201206272213.q5RMDfxt035907@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201206272213.q5RMDfxt035907@svn.freebsd.org> X-Gm-Message-State: ALoCoQnlwvC/ynpSGPodq32zneL7LGhGeifCbBEAEiWuEy+41maU3KeiTRAZmjhMHOHfsmmLJM7f Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r237672 - stable/8/usr.bin/sockstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2012 23:16:54 -0000 The usage information never got updated from this change... $ sockstat --help sockstat: illegal option -- - Usage: sockstat [-46cLlu] [-p ports] [-P protocols] On Wed, Jun 27, 2012 at 10:13:41PM +0000, Andrew Thompson wrote: > Author: thompsa > Date: Wed Jun 27 22:13:40 2012 > New Revision: 237672 > URL: http://svn.freebsd.org/changeset/base/237672 > > Log: > MFC r235870 > > Allow the socket list to be limited to a specific jail id. > > Modified: > stable/8/usr.bin/sockstat/sockstat.1 > stable/8/usr.bin/sockstat/sockstat.c > Directory Properties: > stable/8/usr.bin/sockstat/ (props changed) > > Modified: stable/8/usr.bin/sockstat/sockstat.1 > ============================================================================== > --- stable/8/usr.bin/sockstat/sockstat.1 Wed Jun 27 22:11:31 2012 (r237671) > +++ stable/8/usr.bin/sockstat/sockstat.1 Wed Jun 27 22:13:40 2012 (r237672) > @@ -27,7 +27,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd January 24, 2012 > +.Dd May 16, 2012 > .Dt SOCKSTAT 1 > .Os > .Sh NAME > @@ -36,6 +36,7 @@ > .Sh SYNOPSIS > .Nm > .Op Fl 46cLlu > +.Op Fl j Ar jid > .Op Fl p Ar ports > .Op Fl P Ar protocols > .Sh DESCRIPTION > @@ -57,6 +58,8 @@ Show > (IPv6) sockets. > .It Fl c > Show connected sockets. > +.It Fl j Ar jid > +Show only sockets belonging to the specified jail ID. > .It Fl L > Only show Internet sockets if the local or foreign addresses are not > in the loopback network prefix > > Modified: stable/8/usr.bin/sockstat/sockstat.c > ============================================================================== > --- stable/8/usr.bin/sockstat/sockstat.c Wed Jun 27 22:11:31 2012 (r237671) > +++ stable/8/usr.bin/sockstat/sockstat.c Wed Jun 27 22:13:40 2012 (r237672) > @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); > static int opt_4; /* Show IPv4 sockets */ > static int opt_6; /* Show IPv6 sockets */ > static int opt_c; /* Show connected sockets */ > +static int opt_j; /* Show specified jail */ > static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */ > static int opt_l; /* Show listening sockets */ > static int opt_u; /* Show Unix domain sockets */ > @@ -549,6 +550,27 @@ getprocname(pid_t pid) > } > > static int > +getprocjid(pid_t pid) > +{ > + static struct kinfo_proc proc; > + size_t len; > + int mib[4]; > + > + mib[0] = CTL_KERN; > + mib[1] = KERN_PROC; > + mib[2] = KERN_PROC_PID; > + mib[3] = (int)pid; > + len = sizeof proc; > + if (sysctl(mib, 4, &proc, &len, NULL, 0) == -1) { > + /* Do not warn if the process exits before we get its jid. */ > + if (errno != ESRCH) > + warn("sysctl()"); > + return (-1); > + } > + return (proc.ki_jid); > +} > + > +static int > check_ports(struct sock *s) > { > int port; > @@ -643,6 +665,8 @@ display(void) > for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) { > if (xf->xf_data == NULL) > continue; > + if (opt_j >= 0 && opt_j != getprocjid(xf->xf_pid)) > + continue; > hash = (int)((uintptr_t)xf->xf_data % HASHSIZE); > for (s = sockhash[hash]; s != NULL; s = s->next) > if ((void *)s->socket == xf->xf_data) > @@ -668,6 +692,8 @@ display(void) > pos += xprintf("%d ", xf->xf_fd); > displaysock(s, pos); > } > + if (opt_j >= 0) > + return; > for (hash = 0; hash < HASHSIZE; hash++) { > for (s = sockhash[hash]; s != NULL; s = s->next) { > if (s->shown) > @@ -716,7 +742,8 @@ main(int argc, char *argv[]) > int protos_defined = -1; > int o, i; > > - while ((o = getopt(argc, argv, "46cLlp:P:uv")) != -1) > + opt_j = -1; > + while ((o = getopt(argc, argv, "46cj:Llp:P:uv")) != -1) > switch (o) { > case '4': > opt_4 = 1; > @@ -727,6 +754,9 @@ main(int argc, char *argv[]) > case 'c': > opt_c = 1; > break; > + case 'j': > + opt_j = atoi(optarg); > + break; > case 'L': > opt_L = 1; > break; > _______________________________________________ > svn-src-stable-8@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-8 > To unsubscribe, send any mail to "svn-src-stable-8-unsubscribe@freebsd.org" -- - (2^(N-1))