bin/128871: [patch] show unix sockets in netstat -Lan
Anton Yuzhaninov
citrin at mx3.rambler.ru
Fri Nov 14 07:50:05 PST 2008
>Number: 128871
>Category: bin
>Synopsis: [patch] show unix sockets in netstat -Lan
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Nov 14 15:50:04 UTC 2008
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list