From citrin@mx3.rambler.ru  Fri Nov 14 15:47:31 2008
Return-Path: <citrin@mx3.rambler.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9FD9A1065690
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 14 Nov 2008 15:47:31 +0000 (UTC)
	(envelope-from citrin@mx3.rambler.ru)
Received: from mx-carp-ext.rambler.ru (mx-carp-ext.rambler.ru [81.19.66.237])
	by mx1.freebsd.org (Postfix) with ESMTP id 584AC8FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 14 Nov 2008 15:47:31 +0000 (UTC)
	(envelope-from citrin@mx3.rambler.ru)
Received: by mx3.rambler.ru (Postfix, from userid 1072)
	id DF7C65C3C; Fri, 14 Nov 2008 18:32:13 +0300 (MSK)
Message-Id: <20081114153213.DF7C65C3C@mx3.rambler.ru>
Date: Fri, 14 Nov 2008 18:32:13 +0300 (MSK)
From: Anton Yuzhaninov <citrin@mx3.rambler.ru>
Reply-To: Anton Yuzhaninov <citrin@mx3.rambler.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] show unix sockets in netstat -Lan
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         128871
>Category:       bin
>Synopsis:       [patch] netstat(1): show unix sockets in netstat -Lan
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 14 15:50:04 UTC 2008
>Closed-Date:    Wed Feb 11 10:29:23 UTC 2009
>Last-Modified:  Wed Feb 11 10:29:23 UTC 2009
>Originator:     Anton Yuzhaninov
>Release:        FreeBSD 7.1-PRERELEASE amd64
>Organization:
Rambler
>Environment:
System: FreeBSD mx3.rambler.ru 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Wed Sep 24 22:20:35 MSD 2008 citrin@mx3.rambler.ru:/usr/obj/usr/src/sys/MAIL amd64
>Description:
netstat -Lan currently don't show unix sockets, but for monitoring it is useful to know
number of not accepted connections.
>How-To-Repeat:
>Fix:

--- patch-netstat begins here ---
--- main.c.orig	2008-11-14 17:50:15.000000000 +0300
+++ main.c	2008-11-14 17:47:46.000000000 +0300
@@ -583,7 +583,7 @@
 	if (af == AF_NETGRAPH || af == AF_UNSPEC)
 		for (tp = netgraphprotox; tp->pr_name; tp++)
 			printproto(tp, tp->pr_name);
-	if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag)
+	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);
 	exit(0);
--- unix.c.orig	2008-11-14 15:18:41.000000000 +0300
+++ unix.c	2008-11-14 18:25:39.000000000 +0300
@@ -254,7 +254,7 @@
 	else
 		sa = (struct sockaddr_un *)0;
 
-	if (first) {
+	if (first && !Lflag) {
 		printf("Active UNIX domain sockets\n");
 		printf(
 "%-8.8s %-6.6s %-6.6s %-6.6s %8.8s %8.8s %8.8s %8.8s Addr\n",
@@ -262,11 +262,24 @@
 		    "Inode", "Conn", "Refs", "Nextref");
 		first = 0;
 	}
-	printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
-	       (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
-	       so->so_snd.sb_cc,
-	       (long)unp->unp_vnode, (long)unp->unp_conn,
-	       (long)LIST_FIRST(&unp->unp_refs), (long)LIST_NEXT(unp, unp_reflink));
+
+	if (Lflag && so->so_qlimit == 0)
+		return;
+
+	if (Lflag) {
+		char buf1[15];
+
+		snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
+		    so->so_incqlen, so->so_qlimit);
+		printf("unix  %-14.14s", buf1);
+	} else {
+		printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
+		    (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
+		    so->so_snd.sb_cc,
+		    (long)unp->unp_vnode, (long)unp->unp_conn,
+		    (long)LIST_FIRST(&unp->unp_refs), (long)LIST_NEXT(unp, unp_reflink));
+	}
+
 	if (sa)
 		printf(" %.*s",
 		    (int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
--- patch-netstat ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Wed Dec 31 08:58:40 UTC 2008 
State-Changed-Why:  
Committed to HEAD.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128871 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/128871: commit references a PR
Date: Wed, 31 Dec 2008 08:56:59 +0000 (UTC)

 Author: maxim
 Date: Wed Dec 31 08:56:49 2008
 New Revision: 186644
 URL: http://svn.freebsd.org/changeset/base/186644
 
 Log:
   o With -L flag show unix sockets listen queues stats.  It is useful
   to know number of not accepted connections for monitoring purposes.
   
   PR:		bin/128871
   Submitted by:	Anton Yuzhaninov
   MFC after:	1 month
 
 Modified:
   head/usr.bin/netstat/main.c
   head/usr.bin/netstat/unix.c
 
 Modified: head/usr.bin/netstat/main.c
 ==============================================================================
 --- head/usr.bin/netstat/main.c	Wed Dec 31 08:07:10 2008	(r186643)
 +++ head/usr.bin/netstat/main.c	Wed Dec 31 08:56:49 2008	(r186644)
 @@ -593,7 +593,7 @@ main(int argc, char *argv[])
  		for (tp = netgraphprotox; tp->pr_name; tp++)
  			printproto(tp, tp->pr_name);
  #endif /* NETGRAPH */
 -	if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag)
 +	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);
  	exit(0);
 
 Modified: head/usr.bin/netstat/unix.c
 ==============================================================================
 --- head/usr.bin/netstat/unix.c	Wed Dec 31 08:07:10 2008	(r186643)
 +++ head/usr.bin/netstat/unix.c	Wed Dec 31 08:56:49 2008	(r186644)
 @@ -247,6 +247,7 @@ unixdomainpr(struct xunpcb *xunp, struct
  	struct unpcb *unp;
  	struct sockaddr_un *sa;
  	static int first = 1;
 +	char buf1[15];
  
  	unp = &xunp->xu_unp;
  	if (unp->unp_addr)
 @@ -254,7 +255,7 @@ unixdomainpr(struct xunpcb *xunp, struct
  	else
  		sa = (struct sockaddr_un *)0;
  
 -	if (first) {
 +	if (first && !Lflag) {
  		printf("Active UNIX domain sockets\n");
  		printf(
  "%-8.8s %-6.6s %-6.6s %-6.6s %8.8s %8.8s %8.8s %8.8s Addr\n",
 @@ -262,11 +263,21 @@ unixdomainpr(struct xunpcb *xunp, struct
  		    "Inode", "Conn", "Refs", "Nextref");
  		first = 0;
  	}
 -	printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
 -	       (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
 -	       so->so_snd.sb_cc,
 -	       (long)unp->unp_vnode, (long)unp->unp_conn,
 -	       (long)LIST_FIRST(&unp->unp_refs), (long)LIST_NEXT(unp, unp_reflink));
 +
 +	if (Lflag && so->so_qlimit == 0)
 +		return;
 +
 +	if (Lflag) {
 +		snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
 +		    so->so_incqlen, so->so_qlimit);
 +		printf("unix  %-14.14s", buf1);
 +	} else {
 +		printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
 +		    (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
 +		    so->so_snd.sb_cc, (long)unp->unp_vnode, (long)unp->unp_conn,
 +		    (long)LIST_FIRST(&unp->unp_refs),
 +		    (long)LIST_NEXT(unp, unp_reflink));
 +	}
  	if (sa)
  		printf(" %.*s",
  		    (int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
Responsible-Changed-From-To: freebsd-bugs->maxim 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Wed Dec 31 15:24:36 UTC 2008 
Responsible-Changed-Why:  
assign to Maxim for MFCing who has committed the patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128871 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Wed Feb 11 10:29:08 UTC 2009 
State-Changed-Why:  
Merged to RELENG_7. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128871 
>Unformatted:
