Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Nov 2006 18:40:05 +0100
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        src-committers@freebsd.org, cvs-src@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src/usr.bin/sockstat sockstat.1 sockstat.c
Message-ID:  <20061112174004.GB4237@kobe.laptop>
In-Reply-To: <200611112211.kABMBsHp073602@repoman.freebsd.org>
References:  <200611112211.kABMBsHp073602@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-11-11 22:11, Giorgos Keramidas <keramida@freebsd.org> wrote:
> keramida    2006-11-11 22:11:54 UTC
> 
>   FreeBSD src repository (doc committer)
> 
>   Modified files:
>     usr.bin/sockstat     sockstat.1 sockstat.c 
>   Log:
>   Add support for filtering sockets by protocol type.  The default
>   behavior of sockstat(1) will still be to show "udp", "tcp" and
>   "divert" protocols, but we can now provide a (comma-separated)
>   list of protocols, as in:
>   
>       % sockstat -P tcp
>   
>   to list only TCP sockets, or we can filter more than one protocol
>   by separating the protocol names with a comma:
>   
>       % sockstat -P tcp,udp
>   
>   Protocol names are parsed with getprotobyname(3), so any protocol
>   whose name is listed in `/etc/protocols' should work fine.
>   
>   Submitted by:   Josh Carroll <josh.carroll@psualum.com>
>   Approved by:    des
>   
>   Revision  Changes    Path
>   1.21      +12 -2     src/usr.bin/sockstat/sockstat.1
>   1.14      +115 -12   src/usr.bin/sockstat/sockstat.c

This commit breaks sockstat when only *one* of -4 or -6 is used.
My apologies for not testing the changes more thoroughly, everyone :(

I've already emailed a followup patch to des@ for review, which you can
also find attached below.  When I get his approval, I'll commit it to
CVS too:

%%%
diff -r b717d3e25bc0 -r a894939b8792 usr.bin/sockstat/sockstat.c
--- a/usr.bin/sockstat/sockstat.c	Sun Nov 12 16:33:09 2006 +0100
+++ b/usr.bin/sockstat/sockstat.c	Sun Nov 12 18:34:29 2006 +0100
@@ -714,12 +714,17 @@ main(int argc, char *argv[])
 		usage();
 
 	/*
-	 * If protos_defined remains -1, no -P was provided, so we have to
-	 * set up the default protocol list in protos[] first.
+	 * If no -4, -6, -u or -P option was specified, use the default list
+	 * of protocols *and* UNIX domain sockets.  Otherwise, if only one
+	 * of -4 and -6 was specified and we don't have a protocol list yet
+	 * (i.e. because no -P option was present), still use the default
+	 * protocol list (to list sockets of the respective address family).
 	 */
 	if (!opt_4 && !opt_6 && !opt_u && protos_defined == -1) {
 		opt_u = 1;
 		protos_defined = set_default_protos();
+	} else if ((opt_4 || opt_6) && protos_defined == -1) {
+		protos_defined = set_default_protos();
 	}
 
 	if (!opt_4 && !opt_6)
%%%



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061112174004.GB4237>