Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/netstat Do not display expired or reclaimed vestigia...
details: https://anonhg.NetBSD.org/src/rev/5c26cd0b4cbc
branches: trunk
changeset: 764778:5c26cd0b4cbc
user: dyoung <dyoung%NetBSD.org@localhost>
date: Tue May 03 23:36:26 2011 +0000
description:
Do not display expired or reclaimed vestigial TIME_WAIT entries.
diffstat:
usr.bin/netstat/inet.c | 21 ++++++++++++++-------
usr.bin/netstat/inet6.c | 21 ++++++++++++++-------
2 files changed, 28 insertions(+), 14 deletions(-)
diffs (134 lines):
diff -r 95f551ac5dd7 -r 5c26cd0b4cbc usr.bin/netstat/inet.c
--- a/usr.bin/netstat/inet.c Tue May 03 21:36:59 2011 +0000
+++ b/usr.bin/netstat/inet.c Tue May 03 23:36:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet.c,v 1.96 2011/05/03 18:28:46 dyoung Exp $ */
+/* $NetBSD: inet.c,v 1.97 2011/05/03 23:36:26 dyoung Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-__RCSID("$NetBSD: inet.c,v 1.96 2011/05/03 18:28:46 dyoung Exp $");
+__RCSID("$NetBSD: inet.c,v 1.97 2011/05/03 23:36:26 dyoung Exp $");
#endif
#endif /* not lint */
@@ -162,14 +162,15 @@
tcpstates[t_state]);
}
if (Vflag && expires != NULL) {
- if (expires->tv_sec != 0 || expires->tv_usec != -1) {
+ if (expires->tv_sec == 0 && expires->tv_usec == -1)
+ printf(" reclaimed");
+ else {
struct timeval delta;
timersub(expires, &now, &delta);
printf(" %.3fms",
delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0);
- } else
- printf(" expired");
+ }
}
putchar('\n');
}
@@ -187,6 +188,7 @@
struct timeval delta;
struct in_addr la, fa;
char buf[2][32];
+ static const struct timeval zero = {.tv_sec = 0, .tv_usec = 0};
la.s_addr = v4->laddr;
fa.s_addr = v4->faddr;
@@ -197,14 +199,19 @@
timersub(&vtw->expire, &now, &delta);
if (vtw->expire.tv_sec == 0 && vtw->expire.tv_usec == -1) {
- dbg_printf("%15.15s:%d %15.15s:%d expired\n"
+ dbg_printf("%15.15s:%d %15.15s:%d reclaimed\n"
,buf[0], ntohs(v4->lport)
,buf[1], ntohs(v4->fport));
if (!(Vflag && vflag))
return;
} else if (vtw->expire.tv_sec == 0)
return;
- else {
+ else if (timercmp(&delta, &zero, <) && !(Vflag && vflag)) {
+ dbg_printf("%15.15s:%d %15.15s:%d expired\n"
+ ,buf[0], ntohs(v4->lport)
+ ,buf[1], ntohs(v4->fport));
+ return;
+ } else {
dbg_printf("%15.15s:%d %15.15s:%d expires in %.3fms\n"
,buf[0], ntohs(v4->lport)
,buf[1], ntohs(v4->fport)
diff -r 95f551ac5dd7 -r 5c26cd0b4cbc usr.bin/netstat/inet6.c
--- a/usr.bin/netstat/inet6.c Tue May 03 21:36:59 2011 +0000
+++ b/usr.bin/netstat/inet6.c Tue May 03 23:36:26 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet6.c,v 1.54 2011/05/03 18:28:46 dyoung Exp $ */
+/* $NetBSD: inet6.c,v 1.55 2011/05/03 23:36:26 dyoung Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
@@ -64,7 +64,7 @@
#if 0
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-__RCSID("$NetBSD: inet6.c,v 1.54 2011/05/03 18:28:46 dyoung Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.55 2011/05/03 23:36:26 dyoung Exp $");
#endif
#endif /* not lint */
@@ -217,14 +217,15 @@
#endif
}
if (Vflag && expires != NULL) {
- if (expires->tv_sec != 0 || expires->tv_usec != -1) {
+ if (expires->tv_sec == 0 && expires->tv_usec == -1)
+ printf(" reclaimed");
+ else {
struct timeval delta;
timersub(expires, &now, &delta);
printf(" %.3fms",
delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0);
- } else
- printf(" expired");
+ }
}
putchar('\n');
}
@@ -241,6 +242,7 @@
const vtw_v6_t *v6 = (const vtw_v6_t *)vtw;
struct timeval delta;
char buf[2][128];
+ static const struct timeval zero = {.tv_sec = 0, .tv_usec = 0};
inet_ntop(AF_INET6, &v6->laddr, buf[0], sizeof(buf[0]));
inet_ntop(AF_INET6, &v6->faddr, buf[1], sizeof(buf[1]));
@@ -248,14 +250,19 @@
timersub(&vtw->expire, &now, &delta);
if (vtw->expire.tv_sec == 0 && vtw->expire.tv_usec == -1) {
- dbg_printf("%15.15s:%d %15.15s:%d expired\n"
+ dbg_printf("%15.15s:%d %15.15s:%d reclaimed\n"
,buf[0], ntohs(v6->lport)
,buf[1], ntohs(v6->fport));
if (!(Vflag && vflag))
return;
} else if (vtw->expire.tv_sec == 0)
return;
- else {
+ else if (timercmp(&delta, &zero, <) && !(Vflag && vflag)) {
+ dbg_printf("%15.15s:%d %15.15s:%d expired\n"
+ ,buf[0], ntohs(v6->lport)
+ ,buf[1], ntohs(v6->fport));
+ return;
+ } else {
dbg_printf("%15.15s:%d %15.15s:%d expires in %.3fms\n"
,buf[0], ntohs(v6->lport)
,buf[1], ntohs(v6->fport)
Home |
Main Index |
Thread Index |
Old Index