Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/netstat Pull up the following, requested by msait...
details: https://anonhg.NetBSD.org/src/rev/caeda1e38aa3
branches: netbsd-9
changeset: 370015:caeda1e38aa3
user: martin <martin%NetBSD.org@localhost>
date: Mon Sep 12 14:23:41 2022 +0000
description:
Pull up the following, requested by msaitoh in ticket #1522:
usr.bin/netstat/atalk.c 1.18,1.20-1.21
usr.bin/netstat/bpf.c 1.16 via patch
usr.bin/netstat/fast_ipsec.c 1.24
usr.bin/netstat/if.c 1.97-1.99,1.101-1.104 via patch
usr.bin/netstat/inet.c 1.111,1.115-1.116 via patch
usr.bin/netstat/inet6.c 1.74-1.75,1.80-1.81 via patch
usr.bin/netstat/main.c 1.100-1.103
usr.bin/netstat/mbuf.c 1.35
usr.bin/netstat/mroute.c 1.26-1.27
usr.bin/netstat/mroute6.c 1.16
usr.bin/netstat/netstat.h 1.52-1.53
usr.bin/netstat/pfkey.c 1.4-1.5 via patch
usr.bin/netstat/pfsync.c 1.4-1.5 via patch
usr.bin/netstat/route.c 1.86-1.88
usr.bin/netstat/unix.c 1.36-1.37
usr.bin/netstat/vtw.c 1.11,1.13
- sprintf() -> snprintf(), and adjust a buffer size to avoid any
potential for overflow.
- Fix netstat -rs to print it correctly.
- Add missing {IP,IP6}_STAT_NOIPSEC to netstat.
- Don't show any of the completely and utterly undocumented VTW info
if the feature isn't enabled.
- Print oqdrops correctly.
- Remove Network ATM soft intr queue reporting, we don't have that
in the kernel anymore.
- netstat.1: Add various xrefs present in the body to "See Also".
- KNF. Style fixes.
diffstat:
usr.bin/netstat/atalk.c | 48 +++--
usr.bin/netstat/bpf.c | 47 ++--
usr.bin/netstat/fast_ipsec.c | 228 +++++++++++++++------------
usr.bin/netstat/if.c | 173 +++++++++++++-------
usr.bin/netstat/inet.c | 345 +++++++++++++++++++++++++-----------------
usr.bin/netstat/inet6.c | 349 +++++++++++++++++++++++-------------------
usr.bin/netstat/main.c | 95 +++++++---
usr.bin/netstat/mbuf.c | 22 +-
usr.bin/netstat/mroute.c | 57 +++---
usr.bin/netstat/mroute6.c | 16 +-
usr.bin/netstat/netstat.1 | 9 +-
usr.bin/netstat/netstat.h | 56 +++---
usr.bin/netstat/pfkey.c | 42 +++-
usr.bin/netstat/pfsync.c | 50 +++--
usr.bin/netstat/route.c | 55 +++---
usr.bin/netstat/unix.c | 36 ++--
usr.bin/netstat/vtw.c | 61 +++++-
17 files changed, 975 insertions(+), 714 deletions(-)
diffs (truncated from 3774 to 300 lines):
diff -r ff77dcc4db35 -r caeda1e38aa3 usr.bin/netstat/atalk.c
--- a/usr.bin/netstat/atalk.c Sun Sep 11 18:26:10 2022 +0000
+++ b/usr.bin/netstat/atalk.c Mon Sep 12 14:23:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atalk.c,v 1.16.18.1 2019/08/19 15:56:49 martin Exp $ */
+/* $NetBSD: atalk.c,v 1.16.18.2 2022/09/12 14:23:41 martin Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from @(#)atalk.c 1.1 (Whistle) 6/6/96";
#else
-__RCSID("$NetBSD: atalk.c,v 1.16.18.1 2019/08/19 15:56:49 martin Exp $");
+__RCSID("$NetBSD: atalk.c,v 1.16.18.2 2022/09/12 14:23:41 martin Exp $");
#endif
#endif /* not lint */
@@ -63,9 +63,6 @@
#include "netstat.h"
#include "prog_ops.h"
-struct ddpcb ddpcb;
-struct socket sockb;
-
static int first = 1;
/*
@@ -85,11 +82,12 @@
case 0xffff:
return "????";
case ATADDR_ANYNET:
- return ("*");
+ return "*";
}
}
- (void)snprintf(mybuf, sizeof(mybuf), "%hu", ntohs(sat->sat_addr.s_net));
- return (mybuf);
+ (void)snprintf(mybuf, sizeof(mybuf), "%hu",
+ ntohs(sat->sat_addr.s_net));
+ return mybuf;
}
static const char *
@@ -102,12 +100,12 @@
case ATADDR_BCAST:
return "bcast";
case ATADDR_ANYNODE:
- return ("*");
+ return "*";
}
}
- (void)snprintf(mybuf, sizeof(mybuf), "%d",
+ (void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int)sat->sat_addr.s_node);
- return (mybuf);
+ return mybuf;
}
static const char *
@@ -117,13 +115,13 @@
switch (sat->sat_port) {
case ATADDR_ANYPORT:
- return ("*");
+ return "*";
case 0xff:
return "????";
default:
(void)snprintf(mybuf, sizeof(mybuf), "%d",
(unsigned int)sat->sat_port);
- return (mybuf);
+ return mybuf;
}
}
@@ -141,7 +139,7 @@
(void)snprintf(mybuf, sizeof(mybuf), "%d",
ntohs(sat->sat_range.r_netrange.nr_firstnet));
}
- return (mybuf);
+ return mybuf;
}
@@ -183,7 +181,7 @@
(void)snprintf(mybuf + strlen(mybuf),
sizeof(mybuf) - strlen(mybuf), ".%s", at_pr_port(sat));
}
- return (mybuf);
+ return mybuf;
}
const char *
@@ -224,12 +222,14 @@
if (l > 0)
n += l;
}
- return (buf);
+ return buf;
}
void
atalkprotopr(u_long off, const char *name)
{
+ struct ddpcb ddpcb;
+ struct socket sockb;
struct ddpcb *next;
struct ddpcb *initial;
int width = 22;
@@ -244,9 +244,8 @@
return;
next = ddpcb.ddp_next;
#if 0
- if (!aflag && atalk_nullhost(ddpcb.ddp_lsat)) {
+ if (!aflag && atalk_nullhost(ddpcb.ddp_lsat))
continue;
- }
#endif
if (kread((u_long)ddpcb.ddp_socket,
(char *)&sockb, sizeof(sockb)) < 0)
@@ -262,7 +261,7 @@
}
printf("%-5.5s %-6.6s %-6.6s %*.*s %*.*s %s\n",
"Proto", "Recv-Q", "Send-Q",
- -width, width, "Local Address",
+ -width, width, "Local Address",
-width, width, "Foreign Address", "(state)");
first = 0;
}
@@ -277,8 +276,9 @@
putchar('\n');
}
}
-#define ANY(x,y,z) \
- ((sflag==1 || (x)) ? printf("\t%llu %s%s%s\n",(unsigned long long)x,y,plural(x),z) : 0)
+#define ANY(x,y,z) \
+ ((sflag==1 || (x)) ? \
+ printf("\t%llu %s%s%s\n",(unsigned long long)x,y,plural(x),z) : 0)
/*
* Dump DDP statistics structure.
@@ -309,7 +309,9 @@
ANY(ddpstat[DDP_STAT_TOOSMALL], "packet", " with not enough data ");
ANY(ddpstat[DDP_STAT_FORWARD], "packet", " forwarded ");
ANY(ddpstat[DDP_STAT_ENCAP], "packet", " encapsulated ");
- ANY(ddpstat[DDP_STAT_CANTFORWARD], "packet", " rcvd for unreachable dest ");
- ANY(ddpstat[DDP_STAT_NOSOCKSPACE], "packet", " dropped due to no socket space ");
+ ANY(ddpstat[DDP_STAT_CANTFORWARD], "packet",
+ " rcvd for unreachable dest ");
+ ANY(ddpstat[DDP_STAT_NOSOCKSPACE], "packet",
+ " dropped due to no socket space ");
}
#undef ANY
diff -r ff77dcc4db35 -r caeda1e38aa3 usr.bin/netstat/bpf.c
--- a/usr.bin/netstat/bpf.c Sun Sep 11 18:26:10 2022 +0000
+++ b/usr.bin/netstat/bpf.c Mon Sep 12 14:23:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf.c,v 1.13.4.1 2019/08/19 15:56:49 martin Exp $ */
+/* $NetBSD: bpf.c,v 1.13.4.2 2022/09/12 14:23:41 martin Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -53,19 +53,19 @@
size_t len = sizeof(bpf_s);
if (use_sysctl) {
- if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0) == -1)
+ if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0)
+ == -1)
err(1, "net.bpf.stats");
-
+
printf("bpf:\n");
- printf("\t%" PRIu64 " total packets received\n",
+ printf("\t%" PRIu64 " total packets received\n",
bpf_s.bs_recv);
- printf("\t%" PRIu64 " total packets captured\n",
+ printf("\t%" PRIu64 " total packets captured\n",
bpf_s.bs_capt);
- printf("\t%" PRIu64 " total packets dropped\n",
+ printf("\t%" PRIu64 " total packets dropped\n",
bpf_s.bs_drop);
- } else {
+ } else
warnx("BPF stats not available via KVM.");
- }
}
void
@@ -79,7 +79,7 @@
u_int namelen;
void *v;
struct kinfo_proc2 p;
-
+
/* adapted from sockstat.c by Andrew Brown */
sz = CTL_MAXNAME;
@@ -89,7 +89,7 @@
name[namelen++] = sizeof(*dpe);
name[namelen++] = INT_MAX;
-
+
v = NULL;
sz = 0;
do {
@@ -117,19 +117,19 @@
#define BPFEXT(entry) dpe->entry
for (i = 0; i < (sz / sizeof(*dpe)); i++, dpe++) {
- if (bpfif &&
+ if (bpfif &&
strncmp(BPFEXT(bde_ifname), bpfif, IFNAMSIZ))
continue;
-
+
printf("%-7d ", BPFEXT(bde_pid));
printf("%-7s ",
- (BPFEXT(bde_ifname)[0] == '\0') ? "-" :
+ (BPFEXT(bde_ifname)[0] == '\0') ? "-" :
BPFEXT(bde_ifname));
- printf("%-8" PRIu64 " %-8" PRIu64 " %-8" PRIu64 " ",
- BPFEXT(bde_rcount), BPFEXT(bde_dcount),
+ printf("%-8" PRIu64 " %-8" PRIu64 " %-8" PRIu64 " ",
+ BPFEXT(bde_rcount), BPFEXT(bde_dcount),
BPFEXT(bde_ccount));
-
+
switch (BPFEXT(bde_state)) {
case BPF_IDLE:
printf("I");
@@ -144,11 +144,12 @@
printf("-");
break;
}
-
+
printf("%c", BPFEXT(bde_promisc) ? 'P' : '-');
printf("%c", BPFEXT(bde_immediate) ? 'R' : '-');
- printf("%c", (BPFEXT(bde_direction) == BPF_D_IN) ? '-'
- : (BPFEXT(bde_direction) == BPF_D_OUT) ? 'O' : 'S');
+ printf("%c", (BPFEXT(bde_direction) == BPF_D_IN) ?
+ '-' : (BPFEXT(bde_direction) == BPF_D_OUT) ?
+ 'O' : 'S');
printf("%c", BPFEXT(bde_hdrcmplt) ? 'H' : '-');
printf(" %-8d ", BPFEXT(bde_bufsize));
@@ -161,7 +162,7 @@
name[namelen++] = szproc;
name[namelen++] = 1;
- if (prog_sysctl(&name[0], namelen, &p, &szproc,
+ if (prog_sysctl(&name[0], namelen, &p, &szproc,
NULL, 0) == -1)
printf("-\n");
else
@@ -170,7 +171,7 @@
}
free(v);
} else {
- /* XXX */
- errx(1, "bpf_dump not implemented using kvm");
- }
+ /* XXX */
+ errx(1, "bpf_dump not implemented using kvm");
+ }
}
diff -r ff77dcc4db35 -r caeda1e38aa3 usr.bin/netstat/fast_ipsec.c
--- a/usr.bin/netstat/fast_ipsec.c Sun Sep 11 18:26:10 2022 +0000
+++ b/usr.bin/netstat/fast_ipsec.c Mon Sep 12 14:23:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fast_ipsec.c,v 1.22.8.1 2019/08/19 15:56:49 martin Exp $ */
+/* $NetBSD: fast_ipsec.c,v 1.22.8.2 2022/09/12 14:23:41 martin Exp $ */
/* $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */
/*-
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
#ifdef __NetBSD__
-__RCSID("$NetBSD: fast_ipsec.c,v 1.22.8.1 2019/08/19 15:56:49 martin Exp $");
+__RCSID("$NetBSD: fast_ipsec.c,v 1.22.8.2 2022/09/12 14:23:41 martin Exp $");
#endif
#endif /* not lint*/
@@ -89,7 +89,7 @@
/*
* Print the fast_ipsec statistics.
- * Since NetBSD's netstat(1) seems not to find us for "netstat -s",
+ * Since NetBSD's netstat(1) seems not to find us for "netstat -s",
* but does(?) find KAME, be prepared to be called explicitly from
* netstat's main program for "netstat -s"; but silently do nothing
* if that happens when we are running on KAME IPsec.
@@ -117,8 +117,8 @@
memset(ipips, 0, sizeof(ipips));
Home |
Main Index |
Thread Index |
Old Index