Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2009 15:06:15 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197777 - head/usr.bin/netstat
Message-ID:  <200910051506.n95F6FWb015948@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rwatson
Date: Mon Oct  5 15:06:14 2009
New Revision: 197777
URL: http://svn.freebsd.org/changeset/base/197777

Log:
  netstat(1) support for UNIX SOCK_SEQPACKET sockets -- changes were required
  only for the kvm case, as we supported SOCK_SEQPACKET via sysctl already.
  
  Sponsored by:	Google
  MFC after:	3 months

Modified:
  head/usr.bin/netstat/main.c
  head/usr.bin/netstat/netstat.h
  head/usr.bin/netstat/unix.c

Modified: head/usr.bin/netstat/main.c
==============================================================================
--- head/usr.bin/netstat/main.c	Mon Oct  5 15:05:43 2009	(r197776)
+++ head/usr.bin/netstat/main.c	Mon Oct  5 15:06:14 2009	(r197777)
@@ -186,6 +186,8 @@ static struct nlist nl[] = {
 	{ .n_name = "_mfctablesize" },
 #define N_ARPSTAT       55
 	{ .n_name = "_arpstat" },
+#define	N_UNP_SPHEAD	56
+	{ .n_name = "unp_sphead" },
 	{ .n_name = NULL },
 };
 
@@ -601,7 +603,8 @@ main(int argc, char *argv[])
 #endif /* NETGRAPH */
 	if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
 		unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value,
-		    nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value);
+		    nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value,
+		    nl[N_UNP_SPHEAD].n_value);
 	exit(0);
 }
 

Modified: head/usr.bin/netstat/netstat.h
==============================================================================
--- head/usr.bin/netstat/netstat.h	Mon Oct  5 15:05:43 2009	(r197776)
+++ head/usr.bin/netstat/netstat.h	Mon Oct  5 15:06:14 2009	(r197777)
@@ -150,7 +150,7 @@ void	ddp_stats(u_long, const char *, int
 void	netgraphprotopr(u_long, const char *, int, int);
 #endif
 
-void	unixpr(u_long, u_long, u_long, u_long);
+void	unixpr(u_long, u_long, u_long, u_long, u_long);
 
 void	esis_stats(u_long, const char *, int, int);
 void	clnp_stats(u_long, const char *, int, int);

Modified: head/usr.bin/netstat/unix.c
==============================================================================
--- head/usr.bin/netstat/unix.c	Mon Oct  5 15:05:43 2009	(r197776)
+++ head/usr.bin/netstat/unix.c	Mon Oct  5 15:06:14 2009	(r197777)
@@ -193,21 +193,37 @@ fail:
 }
 
 void
-unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off)
+unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
+    u_long sphead_off)
 {
 	char 	*buf;
 	int	ret, type;
 	struct	xsocket *so;
 	struct	xunpgen *xug, *oxug;
 	struct	xunpcb *xunp;
+	u_long	head_off;
 
 	for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
 		if (live)
 			ret = pcblist_sysctl(type, &buf);
-		else
-			ret = pcblist_kvm(count_off, gencnt_off,
-			    type == SOCK_STREAM ? shead_off :
-			    (type == SOCK_DGRAM ? dhead_off : 0), &buf);
+		else {
+			head_off = 0;
+			switch (type) {
+			case SOCK_STREAM:
+				head_off = shead_off;
+				break;
+
+			case SOCK_DGRAM:
+				head_off = dhead_off;
+				break;
+
+			case SOCK_SEQPACKET:
+				head_off = sphead_off;
+				break;
+			}
+			ret = pcblist_kvm(count_off, gencnt_off, head_off,
+			    &buf);
+		}
 		if (ret == -1)
 			continue;
 		if (ret < 0)



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