Module Name: src Committed By: msaitoh Date: Thu Sep 1 10:10:20 UTC 2022
Modified Files: src/usr.bin/netstat: atalk.c bpf.c fast_ipsec.c if.c inet.c inet6.c main.c mbuf.c mroute.c mroute6.c netstat.h pfkey.c pfsync.c route.c unix.c vtw.c Log Message: KNF. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.bin/netstat/atalk.c cvs rdiff -u -r1.15 -r1.16 src/usr.bin/netstat/bpf.c \ src/usr.bin/netstat/mroute6.c cvs rdiff -u -r1.23 -r1.24 src/usr.bin/netstat/fast_ipsec.c cvs rdiff -u -r1.97 -r1.98 src/usr.bin/netstat/if.c cvs rdiff -u -r1.114 -r1.115 src/usr.bin/netstat/inet.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/netstat/inet6.c cvs rdiff -u -r1.101 -r1.102 src/usr.bin/netstat/main.c cvs rdiff -u -r1.34 -r1.35 src/usr.bin/netstat/mbuf.c cvs rdiff -u -r1.26 -r1.27 src/usr.bin/netstat/mroute.c cvs rdiff -u -r1.52 -r1.53 src/usr.bin/netstat/netstat.h cvs rdiff -u -r1.3 -r1.4 src/usr.bin/netstat/pfkey.c \ src/usr.bin/netstat/pfsync.c cvs rdiff -u -r1.86 -r1.87 src/usr.bin/netstat/route.c cvs rdiff -u -r1.35 -r1.36 src/usr.bin/netstat/unix.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/netstat/vtw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/netstat/atalk.c diff -u src/usr.bin/netstat/atalk.c:1.19 src/usr.bin/netstat/atalk.c:1.20 --- src/usr.bin/netstat/atalk.c:1.19 Fri Aug 28 07:23:48 2020 +++ src/usr.bin/netstat/atalk.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: atalk.c,v 1.19 2020/08/28 07:23:48 ozaki-r Exp $ */ +/* $NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 msaitoh 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.19 2020/08/28 07:23:48 ozaki-r Exp $"); +__RCSID("$NetBSD: atalk.c,v 1.20 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -82,11 +82,12 @@ at_pr_net(const struct sockaddr_at *sat, 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 * @@ -99,12 +100,12 @@ at_pr_host(const struct sockaddr_at *sat 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 * @@ -114,13 +115,13 @@ at_pr_port(const struct sockaddr_at *sat 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; } } @@ -138,7 +139,7 @@ at_pr_range(const struct sockaddr_at *sa (void)snprintf(mybuf, sizeof(mybuf), "%d", ntohs(sat->sat_range.r_netrange.nr_firstnet)); } - return (mybuf); + return mybuf; } @@ -180,7 +181,7 @@ atalk_print(const struct sockaddr *sa, i (void)snprintf(mybuf + strlen(mybuf), sizeof(mybuf) - strlen(mybuf), ".%s", at_pr_port(sat)); } - return (mybuf); + return mybuf; } const char * @@ -221,7 +222,7 @@ atalk_print2(const struct sockaddr *sa, if (l > 0) n += l; } - return (buf); + return buf; } void @@ -261,7 +262,7 @@ atalkprotopr(u_long off, const char *nam } 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; } @@ -276,8 +277,9 @@ atalkprotopr(u_long off, const char *nam 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. @@ -308,7 +310,9 @@ ddp_stats(u_long off, const char *name) 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 Index: src/usr.bin/netstat/bpf.c diff -u src/usr.bin/netstat/bpf.c:1.15 src/usr.bin/netstat/bpf.c:1.16 --- src/usr.bin/netstat/bpf.c:1.15 Fri Aug 28 07:23:48 2020 +++ src/usr.bin/netstat/bpf.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.15 2020/08/28 07:23:48 ozaki-r Exp $ */ +/* $NetBSD: bpf.c,v 1.16 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -53,20 +53,19 @@ bpf_stats(void) size_t len = sizeof(bpf_s); if (use_sysctl) { - if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0) == -1 && - errno != ENOMEM) + if (prog_sysctlbyname("net.bpf.stats", &bpf_s, &len, NULL, 0) + == -1 && errno != ENOMEM) 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 @@ -80,7 +79,7 @@ bpf_dump(const char *bpfif) u_int namelen; void *v; struct kinfo_proc2 p; - + /* adapted from sockstat.c by Andrew Brown */ sz = CTL_MAXNAME; @@ -90,7 +89,7 @@ bpf_dump(const char *bpfif) name[namelen++] = sizeof(*dpe); name[namelen++] = INT_MAX; - + v = NULL; sz = 0; do { @@ -118,19 +117,19 @@ bpf_dump(const char *bpfif) #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"); @@ -145,11 +144,12 @@ bpf_dump(const char *bpfif) 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)); @@ -162,7 +162,7 @@ bpf_dump(const char *bpfif) 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 @@ -171,7 +171,7 @@ bpf_dump(const char *bpfif) } free(v); } else { - /* XXX */ - errx(1, "bpf_dump not implemented using kvm"); - } + /* XXX */ + errx(1, "bpf_dump not implemented using kvm"); + } } Index: src/usr.bin/netstat/mroute6.c diff -u src/usr.bin/netstat/mroute6.c:1.15 src/usr.bin/netstat/mroute6.c:1.16 --- src/usr.bin/netstat/mroute6.c:1.15 Thu Nov 6 21:30:09 2014 +++ src/usr.bin/netstat/mroute6.c Thu Sep 1 10:10:20 2022 @@ -1,9 +1,9 @@ -/* $NetBSD: mroute6.c,v 1.15 2014/11/06 21:30:09 christos Exp $ */ +/* $NetBSD: mroute6.c,v 1.16 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,7 +15,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -121,8 +121,10 @@ #ifdef INET6 -#define WID_ORG (lflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */ -#define WID_GRP (lflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */ +/* Width of origin column */ +#define WID_ORG (lflag ? 39 : (numeric_addr ? 29 : 18)) +/* Width of group column */ +#define WID_GRP (lflag ? 18 : (numeric_addr ? 16 : 18)) void mroute6pr(u_long mrpaddr, u_long mfcaddr, u_long mifaddr) @@ -201,7 +203,7 @@ mroute6pr(u_long mrpaddr, u_long mfcaddr banner_printed = 0; for (i = 0; i < MF6CTBLSIZ; ++i) { mfcp = mf6ctable[i]; - while(mfcp) { + while (mfcp) { kread((u_long)mfcp, (char *)&mfc, sizeof(mfc)); if (!banner_printed) { printf ("\nIPv6 Multicast Forwarding Cache\n"); @@ -211,7 +213,7 @@ mroute6pr(u_long mrpaddr, u_long mfcaddr " Packets Waits In-Mif Out-Mifs\n"); banner_printed = 1; } - + printf(" %-*.*s", WID_ORG, WID_ORG, routename6(&mfc.mf6c_origin, nflag)); printf(" %-*.*s", WID_GRP, WID_GRP, Index: src/usr.bin/netstat/fast_ipsec.c diff -u src/usr.bin/netstat/fast_ipsec.c:1.23 src/usr.bin/netstat/fast_ipsec.c:1.24 --- src/usr.bin/netstat/fast_ipsec.c:1.23 Sun Aug 18 04:14:40 2019 +++ src/usr.bin/netstat/fast_ipsec.c Thu Sep 1 10:10:20 2022 @@ -1,5 +1,5 @@ -/* $NetBSD: fast_ipsec.c,v 1.23 2019/08/18 04:14:40 kamil Exp $ */ -/* $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */ +/* $NetBSD: fast_ipsec.c,v 1.24 2022/09/01 10:10:20 msaitoh Exp $ */ +/* $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */ /*- * Copyright (c) 2003, 2004 Jonathan Stone @@ -33,7 +33,7 @@ #include <sys/cdefs.h> #ifndef lint #ifdef __NetBSD__ -__RCSID("$NetBSD: fast_ipsec.c,v 1.23 2019/08/18 04:14:40 kamil Exp $"); +__RCSID("$NetBSD: fast_ipsec.c,v 1.24 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint*/ @@ -89,7 +89,7 @@ algname(size_t a, const char *algs[], si /* * 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 @@ fast_ipsec_stats(u_long off, const char memset(ipips, 0, sizeof(ipips)); slen = sizeof(ipsecstats); - status = prog_sysctlbyname("net.inet.ipsec.ipsecstats", ipsecstats, &slen, - NULL, 0); + status = prog_sysctlbyname("net.inet.ipsec.ipsecstats", + ipsecstats, &slen, NULL, 0); if (status < 0) { if (errno == ENOENT) return; @@ -127,146 +127,164 @@ fast_ipsec_stats(u_long off, const char } slen = sizeof (ahstats); - status = prog_sysctlbyname("net.inet.ah.ah_stats", ahstats, &slen, NULL, 0); + status = prog_sysctlbyname("net.inet.ah.ah_stats", + ahstats, &slen, NULL, 0); if (status < 0 && errno != ENOMEM) err(1, "net.inet.ah.ah_stats"); slen = sizeof (espstats); - status = prog_sysctlbyname("net.inet.esp.esp_stats", espstats, &slen, NULL, 0); + status = prog_sysctlbyname("net.inet.esp.esp_stats", + espstats, &slen, NULL, 0); if (status < 0 && errno != ENOMEM) err(1, "net.inet.esp.esp_stats"); slen = sizeof(ipcs); - status = prog_sysctlbyname("net.inet.ipcomp.ipcomp_stats", ipcs, &slen, NULL, 0); + status = prog_sysctlbyname("net.inet.ipcomp.ipcomp_stats", + ipcs, &slen, NULL, 0); if (status < 0 && errno != ENOMEM) err(1, "net.inet.ipcomp.ipcomp_stats"); slen = sizeof(ipips); - status = prog_sysctlbyname("net.inet.ipip.ipip_stats", ipips, &slen, NULL, 0); + status = prog_sysctlbyname("net.inet.ipip.ipip_stats", + ipips, &slen, NULL, 0); if (status < 0 && errno != ENOMEM) err(1, "net.inet.ipip.ipip_stats"); printf("%s:\n", name); -#define STAT(x,fmt) if ((x) || sflag <= 1) printf("\t%"PRIu64" " fmt "\n", x) +#define STAT(x, fmt) \ + if (ipsecstats[x] || sflag <= 1) \ + printf("\t%"PRIu64" " fmt "\n", ipsecstats[x]) + if (ipsecstats[IPSEC_STAT_IN_POLVIO]+ipsecstats[IPSEC_STAT_OUT_POLVIO]) - printf("\t%"PRIu64" policy violations: %"PRIu64" input %"PRIu64" output\n", - ipsecstats[IPSEC_STAT_IN_POLVIO] + ipsecstats[IPSEC_STAT_OUT_POLVIO], - ipsecstats[IPSEC_STAT_IN_POLVIO], ipsecstats[IPSEC_STAT_OUT_POLVIO]); - STAT(ipsecstats[IPSEC_STAT_OUT_NOSA], "no SA found (output)"); - STAT(ipsecstats[IPSEC_STAT_OUT_NOMEM], "no memory available (output)"); - STAT(ipsecstats[IPSEC_STAT_OUT_NOROUTE], "no route available (output)"); - STAT(ipsecstats[IPSEC_STAT_OUT_INVAL], "generic errors (output)"); - STAT(ipsecstats[IPSEC_STAT_OUT_BUNDLESA], "bundled SA processed (output)"); - STAT(ipsecstats[IPSEC_STAT_SPDCACHELOOKUP], "SPD cache lookups"); - STAT(ipsecstats[IPSEC_STAT_SPDCACHEMISS], "SPD cache misses"); + printf("\t%"PRIu64" policy violations: %"PRIu64" input %" + PRIu64" output\n", + ipsecstats[IPSEC_STAT_IN_POLVIO] + ipsecstats[IPSEC_STAT_OUT_POLVIO], + ipsecstats[IPSEC_STAT_IN_POLVIO], ipsecstats[IPSEC_STAT_OUT_POLVIO]); + STAT(IPSEC_STAT_OUT_NOSA, "no SA found (output)"); + STAT(IPSEC_STAT_OUT_NOMEM, "no memory available (output)"); + STAT(IPSEC_STAT_OUT_NOROUTE, "no route available (output)"); + STAT(IPSEC_STAT_OUT_INVAL, "generic errors (output)"); + STAT(IPSEC_STAT_OUT_BUNDLESA, "bundled SA processed (output)"); + STAT(IPSEC_STAT_SPDCACHELOOKUP, "SPD cache lookups"); + STAT(IPSEC_STAT_SPDCACHEMISS, "SPD cache misses"); #undef STAT - + printf("\tah:\n"); -#define AHSTAT(x,fmt) if ((x) || sflag <= 1) printf("\t\t%"PRIu64" ah " fmt "\n", x) - AHSTAT(ahstats[AH_STAT_INPUT], "input packets processed"); - AHSTAT(ahstats[AH_STAT_OUTPUT], "output packets processed"); - AHSTAT(ahstats[AH_STAT_HDROPS], "headers too short"); - AHSTAT(ahstats[AH_STAT_NOPF], "headers for unsupported address family"); - AHSTAT(ahstats[AH_STAT_NOTDB], "packets with no SA"); - AHSTAT(ahstats[AH_STAT_BADKCR], "packets dropped by crypto returning NULL mbuf"); - AHSTAT(ahstats[AH_STAT_BADAUTH], "packets with bad authentication"); - AHSTAT(ahstats[AH_STAT_NOXFORM], "packets with no xform"); - AHSTAT(ahstats[AH_STAT_QFULL], "packets dropped due to queue full"); - AHSTAT(ahstats[AH_STAT_WRAP], "packets dropped for replay counter wrap"); - AHSTAT(ahstats[AH_STAT_REPLAY], "packets dropped for possible replay"); - AHSTAT(ahstats[AH_STAT_BADAUTHL],"packets dropped for bad authenticator length"); - AHSTAT(ahstats[AH_STAT_INVALID], "packets with an invalid SA"); - AHSTAT(ahstats[AH_STAT_TOOBIG], "packets too big"); - AHSTAT(ahstats[AH_STAT_PDROPS], "packets blocked due to policy"); - AHSTAT(ahstats[AH_STAT_CRYPTO], "failed crypto requests"); - AHSTAT(ahstats[AH_STAT_TUNNEL], "tunnel sanity check failures"); +#define AHSTAT(x, fmt) \ + if (ahstats[x] || sflag <= 1) \ + printf("\t\t%"PRIu64" ah " fmt "\n", ahstats[x]) + + AHSTAT(AH_STAT_INPUT, "input packets processed"); + AHSTAT(AH_STAT_OUTPUT, "output packets processed"); + AHSTAT(AH_STAT_HDROPS, "headers too short"); + AHSTAT(AH_STAT_NOPF, "headers for unsupported address family"); + AHSTAT(AH_STAT_NOTDB, "packets with no SA"); + AHSTAT(AH_STAT_BADKCR, + "packets dropped by crypto returning NULL mbuf"); + AHSTAT(AH_STAT_BADAUTH, "packets with bad authentication"); + AHSTAT(AH_STAT_NOXFORM, "packets with no xform"); + AHSTAT(AH_STAT_QFULL, "packets dropped due to queue full"); + AHSTAT(AH_STAT_WRAP, "packets dropped for replay counter wrap"); + AHSTAT(AH_STAT_REPLAY, "packets dropped for possible replay"); + AHSTAT(AH_STAT_BADAUTHL, + "packets dropped for bad authenticator length"); + AHSTAT(AH_STAT_INVALID, "packets with an invalid SA"); + AHSTAT(AH_STAT_TOOBIG, "packets too big"); + AHSTAT(AH_STAT_PDROPS, "packets blocked due to policy"); + AHSTAT(AH_STAT_CRYPTO, "failed crypto requests"); + AHSTAT(AH_STAT_TUNNEL, "tunnel sanity check failures"); printf("\tah histogram:\n"); for (i = 0; i < AH_ALG_MAX; i++) if (ahstats[AH_STAT_HIST + i]) - printf("\t\tah packets with %s: %"PRIu64"\n" - , algname(i, ahalgs, __arraycount(ahalgs)) - , ahstats[AH_STAT_HIST + i] - ); - AHSTAT(ahstats[AH_STAT_IBYTES], "bytes received"); - AHSTAT(ahstats[AH_STAT_OBYTES], "bytes transmitted"); + printf("\t\tah packets with %s: %"PRIu64"\n", + algname(i, ahalgs, __arraycount(ahalgs)), + ahstats[AH_STAT_HIST + i]); + AHSTAT(AH_STAT_IBYTES, "bytes received"); + AHSTAT(AH_STAT_OBYTES, "bytes transmitted"); #undef AHSTAT printf("\tesp:\n"); -#define ESPSTAT(x,fmt) if ((x) || sflag <= 1) printf("\t\t%"PRIu64" esp " fmt "\n", x) - ESPSTAT(espstats[ESP_STAT_INPUT],"input packets processed"); - ESPSTAT(espstats[ESP_STAT_OUTPUT],"output packets processed"); - ESPSTAT(espstats[ESP_STAT_HDROPS],"headers too short"); - ESPSTAT(espstats[ESP_STAT_NOPF], "headers for unsupported address family"); - ESPSTAT(espstats[ESP_STAT_NOTDB],"packets with no SA"); - ESPSTAT(espstats[ESP_STAT_BADKCR],"packets dropped by crypto returning NULL mbuf"); - ESPSTAT(espstats[ESP_STAT_QFULL],"packets dropped due to queue full"); - ESPSTAT(espstats[ESP_STAT_NOXFORM],"packets with no xform"); - ESPSTAT(espstats[ESP_STAT_BADILEN],"packets with bad ilen"); - ESPSTAT(espstats[ESP_STAT_BADENC],"packets with bad encryption"); - ESPSTAT(espstats[ESP_STAT_BADAUTH],"packets with bad authentication"); - ESPSTAT(espstats[ESP_STAT_WRAP], "packets dropped for replay counter wrap"); - ESPSTAT(espstats[ESP_STAT_REPLAY],"packets dropped for possible replay"); - ESPSTAT(espstats[ESP_STAT_INVALID],"packets with an invalid SA"); - ESPSTAT(espstats[ESP_STAT_TOOBIG],"packets too big"); - ESPSTAT(espstats[ESP_STAT_PDROPS],"packets blocked due to policy"); - ESPSTAT(espstats[ESP_STAT_CRYPTO],"failed crypto requests"); - ESPSTAT(espstats[ESP_STAT_TUNNEL],"tunnel sanity check failures"); +#define ESPSTAT(x, fmt) \ + if (espstats[x] || sflag <= 1) \ + printf("\t\t%"PRIu64" esp " fmt "\n", espstats[x]) + + ESPSTAT(ESP_STAT_INPUT, "input packets processed"); + ESPSTAT(ESP_STAT_OUTPUT, "output packets processed"); + ESPSTAT(ESP_STAT_HDROPS, "headers too short"); + ESPSTAT(ESP_STAT_NOPF, "headers for unsupported address family"); + ESPSTAT(ESP_STAT_NOTDB, "packets with no SA"); + ESPSTAT(ESP_STAT_BADKCR, + "packets dropped by crypto returning NULL mbuf"); + ESPSTAT(ESP_STAT_QFULL, "packets dropped due to queue full"); + ESPSTAT(ESP_STAT_NOXFORM, "packets with no xform"); + ESPSTAT(ESP_STAT_BADILEN, "packets with bad ilen"); + ESPSTAT(ESP_STAT_BADENC, "packets with bad encryption"); + ESPSTAT(ESP_STAT_BADAUTH, "packets with bad authentication"); + ESPSTAT(ESP_STAT_WRAP, "packets dropped for replay counter wrap"); + ESPSTAT(ESP_STAT_REPLAY, "packets dropped for possible replay"); + ESPSTAT(ESP_STAT_INVALID, "packets with an invalid SA"); + ESPSTAT(ESP_STAT_TOOBIG, "packets too big"); + ESPSTAT(ESP_STAT_PDROPS, "packets blocked due to policy"); + ESPSTAT(ESP_STAT_CRYPTO, "failed crypto requests"); + ESPSTAT(ESP_STAT_TUNNEL, "tunnel sanity check failures"); printf("\tesp histogram:\n"); for (i = 0; i < ESP_ALG_MAX; i++) if (espstats[ESP_STAT_HIST + i]) - printf("\t\tesp packets with %s: %"PRIu64"\n" - , algname(i, espalgs, __arraycount(espalgs)) - , espstats[ESP_STAT_HIST + i] - ); - ESPSTAT(espstats[ESP_STAT_IBYTES], "bytes received"); - ESPSTAT(espstats[ESP_STAT_OBYTES], "bytes transmitted"); + printf("\t\tesp packets with %s: %"PRIu64"\n", + algname(i, espalgs, __arraycount(espalgs)), + espstats[ESP_STAT_HIST + i]); + ESPSTAT(ESP_STAT_IBYTES, "bytes received"); + ESPSTAT(ESP_STAT_OBYTES, "bytes transmitted"); #undef ESPSTAT printf("\tipip:\n"); -#define IPIPSTAT(x,fmt) \ - if ((x) || sflag <= 1) printf("\t\t%"PRIu64" ipip " fmt "\n", x) - IPIPSTAT(ipips[IPIP_STAT_IPACKETS],"total input packets"); - IPIPSTAT(ipips[IPIP_STAT_OPACKETS],"total output packets"); - IPIPSTAT(ipips[IPIP_STAT_HDROPS],"packets too short for header length"); - IPIPSTAT(ipips[IPIP_STAT_QFULL],"packets dropped due to queue full"); - IPIPSTAT(ipips[IPIP_STAT_PDROPS],"packets blocked due to policy"); - IPIPSTAT(ipips[IPIP_STAT_SPOOF],"IP spoofing attempts"); - IPIPSTAT(ipips[IPIP_STAT_FAMILY],"protocol family mismatched"); - IPIPSTAT(ipips[IPIP_STAT_UNSPEC],"missing tunnel-endpoint address"); - IPIPSTAT(ipips[IPIP_STAT_IBYTES],"input bytes received"); - IPIPSTAT(ipips[IPIP_STAT_OBYTES],"output bytes processed"); +#define IPIPSTAT(x, fmt) \ + if (ipips[x] || sflag <= 1) \ + printf("\t\t%"PRIu64" ipip " fmt "\n", ipips[x]) + + IPIPSTAT(IPIP_STAT_IPACKETS, "total input packets"); + IPIPSTAT(IPIP_STAT_OPACKETS, "total output packets"); + IPIPSTAT(IPIP_STAT_HDROPS, "packets too short for header length"); + IPIPSTAT(IPIP_STAT_QFULL, "packets dropped due to queue full"); + IPIPSTAT(IPIP_STAT_PDROPS, "packets blocked due to policy"); + IPIPSTAT(IPIP_STAT_SPOOF, "IP spoofing attempts"); + IPIPSTAT(IPIP_STAT_FAMILY, "protocol family mismatched"); + IPIPSTAT(IPIP_STAT_UNSPEC, "missing tunnel-endpoint address"); + IPIPSTAT(IPIP_STAT_IBYTES, "input bytes received"); + IPIPSTAT(IPIP_STAT_OBYTES, "output bytes processed"); #undef IPIPSTAT printf("\tipcomp:\n"); -#define IPCOMP(x,fmt) \ - if ((x) || sflag <= 1) printf("\t\t%"PRIu64" ipcomp " fmt "\n", x) - - IPCOMP(ipcs[IPCOMP_STAT_HDROPS],"packets too short for header length"); - IPCOMP(ipcs[IPCOMP_STAT_NOPF], "protocol family not supported"); - IPCOMP(ipcs[IPCOMP_STAT_NOTDB], "packets with no SA"); - IPCOMP(ipcs[IPCOMP_STAT_BADKCR],"packets dropped by crypto returning NULL mbuf"); - IPCOMP(ipcs[IPCOMP_STAT_QFULL], "queue full"); - IPCOMP(ipcs[IPCOMP_STAT_NOXFORM],"no support for transform"); - IPCOMP(ipcs[IPCOMP_STAT_WRAP], "packets dropped for replay counter wrap"); - IPCOMP(ipcs[IPCOMP_STAT_INPUT], "input IPcomp packets"); - IPCOMP(ipcs[IPCOMP_STAT_OUTPUT],"output IPcomp packets"); - IPCOMP(ipcs[IPCOMP_STAT_INVALID],"packets with an invalid SA"); - IPCOMP(ipcs[IPCOMP_STAT_TOOBIG],"packets decompressed as too big"); - IPCOMP(ipcs[IPCOMP_STAT_MINLEN], "packets too short to be compressed"); - IPCOMP(ipcs[IPCOMP_STAT_USELESS],"packet for which compression was useless"); - IPCOMP(ipcs[IPCOMP_STAT_PDROPS],"packets blocked due to policy"); - IPCOMP(ipcs[IPCOMP_STAT_CRYPTO],"failed crypto requests"); +#define IPCOMP(x, fmt) \ + if (ipcs[x] || sflag <= 1) \ + printf("\t\t%"PRIu64" ipcomp " fmt "\n", ipcs[x]) + + IPCOMP(IPCOMP_STAT_HDROPS, "packets too short for header length"); + IPCOMP(IPCOMP_STAT_NOPF, "protocol family not supported"); + IPCOMP(IPCOMP_STAT_NOTDB, "packets with no SA"); + IPCOMP(IPCOMP_STAT_BADKCR, + "packets dropped by crypto returning NULL mbuf"); + IPCOMP(IPCOMP_STAT_QFULL, "queue full"); + IPCOMP(IPCOMP_STAT_NOXFORM, "no support for transform"); + IPCOMP(IPCOMP_STAT_WRAP, "packets dropped for replay counter wrap"); + IPCOMP(IPCOMP_STAT_INPUT, "input IPcomp packets"); + IPCOMP(IPCOMP_STAT_OUTPUT, "output IPcomp packets"); + IPCOMP(IPCOMP_STAT_INVALID, "packets with an invalid SA"); + IPCOMP(IPCOMP_STAT_TOOBIG, "packets decompressed as too big"); + IPCOMP(IPCOMP_STAT_MINLEN, "packets too short to be compressed"); + IPCOMP(IPCOMP_STAT_USELESS,"packet for which compression was useless"); + IPCOMP(IPCOMP_STAT_PDROPS, "packets blocked due to policy"); + IPCOMP(IPCOMP_STAT_CRYPTO, "failed crypto requests"); printf("\tipcomp histogram:\n"); for (i = 0; i < IPCOMP_ALG_MAX; i++) if (ipcs[IPCOMP_STAT_HIST + i]) - printf("\t\tIPcomp packets with %s: %"PRIu64"\n" - , algname(i, ipcompalgs, __arraycount(ipcompalgs)) - , ipcs[IPCOMP_STAT_HIST + i] - ); - IPCOMP(ipcs[IPCOMP_STAT_IBYTES],"input bytes"); - IPCOMP(ipcs[IPCOMP_STAT_OBYTES],"output bytes"); + printf("\t\tIPcomp packets with %s: %"PRIu64"\n", + algname(i, ipcompalgs, __arraycount(ipcompalgs)), + ipcs[IPCOMP_STAT_HIST + i]); + IPCOMP(IPCOMP_STAT_IBYTES, "input bytes"); + IPCOMP(IPCOMP_STAT_OBYTES, "output bytes"); #undef IPCOMP } Index: src/usr.bin/netstat/if.c diff -u src/usr.bin/netstat/if.c:1.97 src/usr.bin/netstat/if.c:1.98 --- src/usr.bin/netstat/if.c:1.97 Thu Aug 18 12:25:32 2022 +++ src/usr.bin/netstat/if.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.97 2022/08/18 12:25:32 msaitoh Exp $ */ +/* $NetBSD: if.c,v 1.98 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94"; #else -__RCSID("$NetBSD: if.c,v 1.97 2022/08/18 12:25:32 msaitoh Exp $"); +__RCSID("$NetBSD: if.c,v 1.98 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -147,9 +147,9 @@ intpr_header(void) if (!sflag && !pflag) { if (bflag) { printf("%-5.5s %-5.5s %-13.13s %-17.17s " - "%10.10s %10.10s", - "Name", "Mtu", "Network", "Address", - "Ibytes", "Obytes"); + "%10.10s %10.10s", + "Name", "Mtu", "Network", "Address", + "Ibytes", "Obytes"); } else { printf("%-5.5s %-5.5s %-13.13s %-17.17s " "%8.8s %5.5s", @@ -220,7 +220,7 @@ intpr_sysctl(void) bzero(name, sizeof(name)); if (sdl->sdl_nlen >= IFNAMSIZ) memcpy(name, sdl->sdl_data, IFNAMSIZ - 1); - else if (sdl->sdl_nlen > 0) + else if (sdl->sdl_nlen > 0) memcpy(name, sdl->sdl_data, sdl->sdl_nlen); if (interface != NULL && strcmp(name, interface) != 0) @@ -375,7 +375,8 @@ intpr_kvm(u_long ifnetaddr, void (*pfunc } else { struct sockaddr *sa; - if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { + if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) + { ifaddraddr = 0; continue; } @@ -505,7 +506,8 @@ print_addr(const int ifindex, struct soc case AF_INET: sin = (struct sockaddr_in *)sa; if (use_sysctl) { - netmask = *((struct sockaddr_in *)rtinfo[RTAX_NETMASK]); + netmask = + *((struct sockaddr_in *)rtinfo[RTAX_NETMASK]); } else { struct in_ifaddr *ifaddr_in = (void *)rtinfo; netmask.sin_addr.s_addr = ifaddr_in->ia_subnetmask; @@ -575,13 +577,13 @@ print_addr(const int ifindex, struct soc n = 17; printf("%-*.*s ", n, n, cp); - if (!aflag) + if (!aflag) break; if (ifnet) { u_long multiaddr; struct in6_multi inm; union ifaddr_u *ifaddr = (union ifaddr_u *)rtinfo; - + multiaddr = (u_long)ifaddr->in6._ia6_multiaddrs.lh_first; while (multiaddr != 0) { kread(multiaddr, (char *)&inm, sizeof inm); @@ -595,9 +597,8 @@ print_addr(const int ifindex, struct soc #endif /*INET6*/ #ifndef SMALL case AF_APPLETALK: - printf("atalk:%-7.7s ", - atalk_print(sa,0x10)); - printf("%-17.17s ", atalk_print(sa,0x0b)); + printf("atalk:%-7.7s ", atalk_print(sa, 0x10)); + printf("%-17.17s ", atalk_print(sa, 0x0b)); break; #endif case AF_LINK: @@ -796,9 +797,9 @@ loop: putchar('\n'); fflush(stdout); line++; - if (signalled == 0) { + if (signalled == 0) sigsuspend(&emptyset); - } + signalled = 0; if (line == redraw_lines) goto banner; @@ -944,7 +945,7 @@ loop: HN_AUTOSCALE, HN_NOSPACE | HN_B) > 0) printf("%10s %8.8s ", humbuf, " "); else - printf("%10llu %8.8s ", + printf("%10llu %8.8s ", (unsigned long long) (ifd.ifi_ibytes-ip->ift_ib), " "); @@ -954,7 +955,7 @@ loop: HN_AUTOSCALE, HN_NOSPACE | HN_B) > 0) printf("%10s %5.5s", humbuf, " "); else - printf("%10llu %5.5s", + printf("%10llu %5.5s", (unsigned long long) (ifd.ifi_obytes-ip->ift_ob), " "); } else { @@ -1001,7 +1002,7 @@ loop: HN_AUTOSCALE, HN_NOSPACE | HN_B) > 0) printf(" %10s %8.8s ", humbuf, " "); else - printf(" %10llu %8.8s ", + printf(" %10llu %8.8s ", (unsigned long long) (sum->ift_ib - total->ift_ib), " "); @@ -1010,7 +1011,7 @@ loop: HN_AUTOSCALE, HN_NOSPACE | HN_B) > 0) printf("%10s %5.5s", humbuf, " "); else - printf("%10llu %5.5s", + printf("%10llu %5.5s", (unsigned long long) (sum->ift_ob - total->ift_ob), " "); } else { @@ -1034,9 +1035,9 @@ loop: putchar('\n'); fflush(stdout); line++; - if (signalled == 0) { + if (signalled == 0) sigsuspend(&emptyset); - } + signalled = 0; if (line == redraw_lines) goto banner; @@ -1054,11 +1055,10 @@ static void sidewaysintpr(unsigned int interval, u_long off) { - if (use_sysctl) { + if (use_sysctl) sidewaysintpr_sysctl(interval); - } else { + else sidewaysintpr_kvm(interval, off); - } } /* @@ -1074,7 +1074,7 @@ catchalarm(int signo) static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) -{ +{ int i; for (i = 0; i < RTAX_MAX; i++) { @@ -1082,7 +1082,7 @@ get_rtaddrs(int addrs, struct sockaddr * rti_info[i] = sa; sa = (struct sockaddr *)((char *)(sa) + RT_ROUNDUP(sa->sa_len)); - } else + } else rti_info[i] = NULL; } } @@ -1132,7 +1132,7 @@ fetchifs(void) bzero(name, sizeof(name)); if (sdl->sdl_nlen >= IFNAMSIZ) memcpy(name, sdl->sdl_data, IFNAMSIZ - 1); - else if (sdl->sdl_nlen > 0) + else if (sdl->sdl_nlen > 0) memcpy(name, sdl->sdl_data, sdl->sdl_nlen); if (interface != NULL && !strcmp(name, interface)) { Index: src/usr.bin/netstat/inet.c diff -u src/usr.bin/netstat/inet.c:1.114 src/usr.bin/netstat/inet.c:1.115 --- src/usr.bin/netstat/inet.c:1.114 Sat Oct 30 11:23:07 2021 +++ src/usr.bin/netstat/inet.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: inet.c,v 1.114 2021/10/30 11:23:07 nia Exp $ */ +/* $NetBSD: inet.c,v 1.115 2022/09/01 10:10:20 msaitoh 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.114 2021/10/30 11:23:07 nia Exp $"); +__RCSID("$NetBSD: inet.c,v 1.115 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -94,7 +94,7 @@ __RCSID("$NetBSD: inet.c,v 1.114 2021/10 #include "prog_ops.h" char *inetname(struct in_addr *); -void inetprint(struct in_addr *, u_int16_t, const char *, int); +void inetprint(struct in_addr *, uint16_t, const char *, int); void print_vtw_v4(const vtw_t *); @@ -121,7 +121,7 @@ protoprhdr(void) printf("%-8.8s ", "PCB"); printf( Vflag ? "%-5.5s %-6.6s %-6.6s %s%-*.*s %-*.*s %-13.13s Expires\n" - : "%-5.5s %-6.6s %-6.6s %s%-*.*s %-*.*s %s\n", + : "%-5.5s %-6.6s %-6.6s %s%-*.*s %-*.*s %s\n", "Proto", "Recv-Q", "Send-Q", compact ? "" : " ", width, width, "Local Address", width, width, "Foreign Address", @@ -130,25 +130,25 @@ protoprhdr(void) static void protopr0(intptr_t ppcb, u_long rcv_sb_cc, u_long snd_sb_cc, - struct in_addr *laddr, u_int16_t lport, - struct in_addr *faddr, u_int16_t fport, + struct in_addr *laddr, uint16_t lport, + struct in_addr *faddr, uint16_t fport, short t_state, const char *name, int inp_flags, const struct timeval *expires) { static const char *shorttcpstates[] = { "CLOSED", "LISTEN", "SYNSEN", "SYSRCV", "ESTABL", "CLWAIT", "FWAIT1", "CLOSNG", - "LASTAK", "FWAIT2", "TMWAIT", + "LASTAK", "FWAIT2", "TMWAIT" }; int istcp; istcp = strcmp(name, "tcp") == 0; - if (Aflag) { + if (Aflag) printf("%8" PRIxPTR " ", ppcb); - } + printf("%-5.5s %6ld %6ld%s", name, rcv_sb_cc, snd_sb_cc, - compact ? "" : " "); + compact ? "" : " "); if (numeric_port) { inetprint(laddr, lport, name, 1); inetprint(faddr, fport, name, 1); @@ -164,7 +164,7 @@ protopr0(intptr_t ppcb, u_long rcv_sb_cc printf(" %d", t_state); else printf(" %s", compact ? shorttcpstates[t_state] : - tcpstates[t_state]); + tcpstates[t_state]); } if (Vflag && expires != NULL) { if (expires->tv_sec == 0 && expires->tv_usec == -1) @@ -186,7 +186,7 @@ dbg_printf(const char *fmt, ...) return; } -void +void print_vtw_v4(const vtw_t *vtw) { const vtw_v4_t *v4 = (const vtw_v4_t *)vtw; @@ -204,23 +204,23 @@ print_vtw_v4(const vtw_t *vtw) timersub(&vtw->expire, &now, &delta); if (vtw->expire.tv_sec == 0 && vtw->expire.tv_usec == -1) { - dbg_printf("%15.15s:%d %15.15s:%d reclaimed\n" - ,buf[0], ntohs(v4->lport) - ,buf[1], ntohs(v4->fport)); + 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 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)); + 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) - ,delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0); + dbg_printf("%15.15s:%d %15.15s:%d expires in %.3fms\n", + buf[0], ntohs(v4->lport), + buf[1], ntohs(v4->fport), + delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0); } protopr0(0, 0, 0, &la, v4->lport, @@ -229,7 +229,8 @@ print_vtw_v4(const vtw_t *vtw) } struct kinfo_pcb * -getpcblist_sysctl(const char *name, size_t *len) { +getpcblist_sysctl(const char *name, size_t *len) +{ int mib[8]; size_t namelen = 0, size = 0; char *mibname = NULL; @@ -246,7 +247,7 @@ getpcblist_sysctl(const char *name, size *len = 0; return NULL; } - + err(1, "sysctlnametomib: %s", mibname); } @@ -271,7 +272,8 @@ getpcblist_sysctl(const char *name, size } static struct kinfo_pcb * -getpcblist_kmem(u_long off, const char *name, size_t *len) { +getpcblist_kmem(u_long off, const char *name, size_t *len) +{ struct inpcbtable table; struct inpcb_hdr *next, *prev; struct inpcb inpcb; @@ -280,7 +282,7 @@ getpcblist_kmem(u_long off, const char * int istcp = strcmp(name, "tcp") == 0; struct kinfo_pcb *pcblist; size_t size = 100, i; - struct sockaddr_in sin; + struct sockaddr_in sin; struct inpcbqueue *head; if (off == 0) { @@ -355,7 +357,7 @@ protopr(u_long off, const char *name) if (use_sysctl) pcblist = getpcblist_sysctl(name, &len); else - pcblist = getpcblist_kmem(off, name, &len); + pcblist = getpcblist_kmem(off, name, &len); for (i = 0; i < len; i++) { struct sockaddr_in src, dst; @@ -725,14 +727,14 @@ igmp_stats(u_long off, const char *name) #define py(f, m) if (igmpstat[f] || sflag <= 1) \ printf(m, igmpstat[f], igmpstat[f] != 1 ? "ies" : "y") p(IGMP_STAT_RCV_TOTAL, "\t%" PRIu64 " message%s received\n"); - p(IGMP_STAT_RCV_TOOSHORT, "\t%" PRIu64 " message%s received with too few bytes\n"); - p(IGMP_STAT_RCV_BADSUM, "\t%" PRIu64 " message%s received with bad checksum\n"); - py(IGMP_STAT_RCV_QUERIES, "\t%" PRIu64 " membership quer%s received\n"); - py(IGMP_STAT_RCV_BADQUERIES, "\t%" PRIu64 " membership quer%s received with invalid field(s)\n"); - p(IGMP_STAT_RCV_REPORTS, "\t%" PRIu64 " membership report%s received\n"); - p(IGMP_STAT_RCV_BADREPORTS, "\t%" PRIu64 " membership report%s received with invalid field(s)\n"); - p(IGMP_STAT_RCV_OURREPORTS, "\t%" PRIu64 " membership report%s received for groups to which we belong\n"); - p(IGMP_STAT_SND_REPORTS, "\t%" PRIu64 " membership report%s sent\n"); + p(IGMP_STAT_RCV_TOOSHORT, "\t%" PRIu64 " message%s received with too few bytes\n"); + p(IGMP_STAT_RCV_BADSUM, "\t%" PRIu64 " message%s received with bad checksum\n"); + py(IGMP_STAT_RCV_QUERIES, "\t%" PRIu64 " membership quer%s received\n"); + py(IGMP_STAT_RCV_BADQUERIES, "\t%" PRIu64 " membership quer%s received with invalid field(s)\n"); + p(IGMP_STAT_RCV_REPORTS, "\t%" PRIu64 " membership report%s received\n"); + p(IGMP_STAT_RCV_BADREPORTS, "\t%" PRIu64 " membership report%s received with invalid field(s)\n"); + p(IGMP_STAT_RCV_OURREPORTS, "\t%" PRIu64 " membership report%s received for groups to which we belong\n"); + p(IGMP_STAT_SND_REPORTS, "\t%" PRIu64 " membership report%s sent\n"); #undef p #undef py } @@ -812,7 +814,7 @@ pim_stats(u_long off, const char *name) p(pims_rcv_total_msgs, "\t%" PRIu64 " message%s received\n"); p(pims_rcv_total_bytes, "\t%" PRIu64 " byte%s received\n"); p(pims_rcv_tooshort, "\t%" PRIu64 " message%s received with too few bytes\n"); - p(pims_rcv_badsum, "\t%" PRIu64 " message%s received with bad checksum\n"); + p(pims_rcv_badsum, "\t%" PRIu64 " message%s received with bad checksum\n"); p(pims_rcv_badversion, "\t%" PRIu64 " message%s received with bad version\n"); p(pims_rcv_registers_msgs, "\t%" PRIu64 " data register message%s received\n"); p(pims_rcv_registers_bytes, "\t%" PRIu64 " data register byte%s received\n"); @@ -965,7 +967,7 @@ inetname(struct in_addr *inp) C(inp->s_addr >> 8), C(inp->s_addr)); #undef C } - return (line); + return line; } /* @@ -981,9 +983,9 @@ tcp_dump(u_long off, const char *name, u size_t j, len; if (use_sysctl) - pcblist = getpcblist_sysctl(name, &len); + pcblist = getpcblist_sysctl(name, &len); else - pcblist = getpcblist_kmem(off, name, &len); + pcblist = getpcblist_kmem(off, name, &len); for (j = 0; j < len; j++) if (pcblist[j].ki_ppcbaddr == pcbaddr) @@ -1020,7 +1022,7 @@ tcp_dump(u_long off, const char *name, u printf("rxtshift %d, rxtcur %d, dupacks %d\n", tcpcb.t_rxtshift, tcpcb.t_rxtcur, tcpcb.t_dupacks); - printf("peermss %u, ourmss %u, segsz %u, segqlen %u\n\n", + printf("peermss %u, ourmss %u, segsz %u, segqlen %u\n\n", tcpcb.t_peermss, tcpcb.t_ourmss, tcpcb.t_segsz, tcpcb.t_segqlen); printf("snd_una %u, snd_nxt %u, snd_up %u\n", Index: src/usr.bin/netstat/inet6.c diff -u src/usr.bin/netstat/inet6.c:1.79 src/usr.bin/netstat/inet6.c:1.80 --- src/usr.bin/netstat/inet6.c:1.79 Sat Oct 30 11:23:07 2021 +++ src/usr.bin/netstat/inet6.c Thu Sep 1 10:10:20 2022 @@ -1,10 +1,10 @@ -/* $NetBSD: inet6.c,v 1.79 2021/10/30 11:23:07 nia Exp $ */ +/* $NetBSD: inet6.c,v 1.80 2022/09/01 10:10:20 msaitoh Exp $ */ /* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -64,7 +64,7 @@ #if 0 static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94"; #else -__RCSID("$NetBSD: inet6.c,v 1.79 2021/10/30 11:23:07 nia Exp $"); +__RCSID("$NetBSD: inet6.c,v 1.80 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -167,20 +167,20 @@ static struct timeval now; static void ip6protoprhdr(void) { - + printf("Active Internet6 connections"); - + if (aflag) printf(" (including servers)"); putchar('\n'); - + if (Aflag) { printf("%-8.8s ", "PCB"); width = 18; } printf( Vflag ? "%-5.5s %-6.6s %-6.6s %*.*s %*.*s %-13.13s Expires\n" - : "%-5.5s %-6.6s %-6.6s %*.*s %*.*s %s\n", + : "%-5.5s %-6.6s %-6.6s %*.*s %*.*s %s\n", "Proto", "Recv-Q", "Send-Q", -width, width, "Local Address", -width, width, "Foreign Address", "(state)"); @@ -188,14 +188,14 @@ ip6protoprhdr(void) static void ip6protopr0(intptr_t ppcb, u_long rcv_sb_cc, u_long snd_sb_cc, - const struct in6_addr *laddr, u_int16_t lport, - const struct in6_addr *faddr, u_int16_t fport, + const struct in6_addr *laddr, uint16_t lport, + const struct in6_addr *faddr, uint16_t fport, short t_state, const char *name, const struct timeval *expires) { static const char *shorttcpstates[] = { "CLOSED", "LISTEN", "SYNSEN", "SYSRCV", "ESTABL", "CLWAIT", "FWAIT1", "CLOSNG", - "LASTAK", "FWAIT2", "TMWAIT", + "LASTAK", "FWAIT2", "TMWAIT" }; int istcp; @@ -239,10 +239,11 @@ ip6protopr0(intptr_t ppcb, u_long rcv_sb static void dbg_printf(const char *fmt, ...) { + return; } -void +void print_vtw_v6(const vtw_t *vtw) { const vtw_v6_t *v6 = (const vtw_v6_t *)vtw; @@ -256,23 +257,23 @@ print_vtw_v6(const vtw_t *vtw) timersub(&vtw->expire, &now, &delta); if (vtw->expire.tv_sec == 0 && vtw->expire.tv_usec == -1) { - dbg_printf("%15.15s:%d %15.15s:%d reclaimed\n" - ,buf[0], ntohs(v6->lport) - ,buf[1], ntohs(v6->fport)); + 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 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)); + 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) - ,delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0); + dbg_printf("%15.15s:%d %15.15s:%d expires in %.3fms\n", + buf[0], ntohs(v6->lport), + buf[1], ntohs(v6->fport), + delta.tv_sec * 1000.0 + delta.tv_usec / 1000.0); } ip6protopr0(0, 0, 0, &v6->laddr, v6->lport, @@ -315,7 +316,7 @@ getpcblist_kmem(u_long off, const char * if (in6pcb.in6p_af != AF_INET6) continue; - kread((u_long)in6pcb.in6p_socket, (char *)&sockb, + kread((u_long)in6pcb.in6p_socket, (char *)&sockb, sizeof (sockb)); if (istcp) { #ifdef TCP6 @@ -326,7 +327,7 @@ getpcblist_kmem(u_long off, const char * (char *)&tcpcb, sizeof (tcpcb)); #endif } - pcblist[i].ki_ppcbaddr = + pcblist[i].ki_ppcbaddr = istcp ? (uintptr_t) in6pcb.in6p_ppcb : (uintptr_t) prev; pcblist[i].ki_rcvq = (uint64_t)sockb.so_rcv.sb_cc; pcblist[i].ki_sndq = (uint64_t)sockb.so_snd.sb_cc; @@ -424,12 +425,13 @@ tcp6_stats(u_long off, const char *name) printf ("%s:\n", name); -#define p(f, m) if (tcp6stat.f || sflag <= 1) \ - printf(m, tcp6stat.f, plural(tcp6stat.f)) -#define p2(f1, f2, m) if (tcp6stat.f1 || tcp6stat.f2 || sflag <= 1) \ - printf(m, tcp6stat.f1, plural(tcp6stat.f1), tcp6stat.f2, plural(tcp6stat.f2)) -#define p3(f, m) if (tcp6stat.f || sflag <= 1) \ - printf(m, tcp6stat.f, plurales(tcp6stat.f)) +#define p(f, m) if (tcp6stat.f || sflag <= 1) \ + printf(m, tcp6stat.f, plural(tcp6stat.f)) +#define p2(f1, f2, m) if (tcp6stat.f1 || tcp6stat.f2 || sflag <= 1) \ + printf(m, tcp6stat.f1, plural(tcp6stat.f1), tcp6stat.f2, \ + plural(tcp6stat.f2)) +#define p3(f, m) if (tcp6stat.f || sflag <= 1) \ + printf(m, tcp6stat.f, plurales(tcp6stat.f)) p(tcp6s_sndtotal, "\t%ld packet%s sent\n"); p2(tcp6s_sndpack,tcp6s_sndbyte, @@ -508,10 +510,10 @@ udp6_stats(u_long off, const char *name) return; } printf("%s:\n", name); -#define p(f, m) if (udp6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)udp6stat[f], plural(udp6stat[f])) -#define p1(f, m) if (udp6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)udp6stat[f]) +#define p(f, m) if (udp6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)udp6stat[f], plural(udp6stat[f])) +#define p1(f, m) if (udp6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)udp6stat[f]) p(UDP6_STAT_IPACKETS, "\t%llu datagram%s received\n"); p1(UDP6_STAT_HDROPS, "\t%llu with incomplete header\n"); p1(UDP6_STAT_BADLEN, "\t%llu with bad data length field\n"); @@ -627,7 +629,7 @@ static const char *ip6nh[] = { /*220*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*240*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL }; /* @@ -653,10 +655,10 @@ ip6_stats(u_long off, const char *name) } printf("%s:\n", name); -#define p(f, m) if (ip6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)ip6stat[f], plural(ip6stat[f])) -#define p1(f, m) if (ip6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)ip6stat[f]) +#define p(f, m) if (ip6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)ip6stat[f], plural(ip6stat[f])) +#define p1(f, m) if (ip6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)ip6stat[f]) p(IP6_STAT_TOTAL, "\t%llu total packet%s received\n"); p1(IP6_STAT_TOOSMALL, "\t%llu with size smaller than minimum\n"); @@ -672,7 +674,7 @@ ip6_stats(u_long off, const char *name) p(IP6_STAT_DELIVERED, "\t%llu packet%s for this host\n"); p(IP6_STAT_FORWARD, "\t%llu packet%s forwarded\n"); p(IP6_STAT_FASTFORWARD, "\t%llu packet%s fast forwarded\n"); - p1(IP6_STAT_FASTFORWARDFLOWS, "\t%llu fast forward flows\n"); + p1(IP6_STAT_FASTFORWARDFLOWS, "\t%llu fast forward flows\n"); p(IP6_STAT_CANTFORWARD, "\t%llu packet%s not forwardable\n"); p(IP6_STAT_REDIRECTSENT, "\t%llu redirect%s sent\n"); p(IP6_STAT_LOCALOUT, "\t%llu packet%s sent from this host\n"); @@ -707,14 +709,14 @@ ip6_stats(u_long off, const char *name) p(IP6_STAT_M1, "\t\t%llu one mbuf%s\n"); for (first = 1, i = 0; i < 32; i++) { char ifbuf[IFNAMSIZ]; - if (ip6stat[IP6_STAT_M2M + i] != 0) { + if (ip6stat[IP6_STAT_M2M + i] != 0) { if (first) { printf("\t\ttwo or more mbuf:\n"); first = 0; } printf("\t\t\t%s = %llu\n", - if_indextoname(i, ifbuf), - (unsigned long long)ip6stat[IP6_STAT_M2M + i]); + if_indextoname(i, ifbuf), + (unsigned long long)ip6stat[IP6_STAT_M2M + i]); } } p(IP6_STAT_MEXT1, "\t\t%llu one ext mbuf%s\n"); @@ -727,24 +729,24 @@ ip6_stats(u_long off, const char *name) "\t%llu packet%s discarded due to too many headers\n"); /* for debugging source address selection */ -#define PRINT_SCOPESTAT(s,i) do {\ - switch(i) { /* XXX hardcoding in each case */\ - case 1:\ - p(s, "\t\t%llu node-local%s\n");\ - break;\ - case 2:\ - p(s, "\t\t%llu link-local%s\n");\ - break;\ - case 5:\ - p(s, "\t\t%llu site-local%s\n");\ - break;\ - case 14:\ - p(s, "\t\t%llu global%s\n");\ - break;\ - default:\ - printf("\t\t%llu addresses scope=%x\n",\ - (unsigned long long)ip6stat[s], i);\ - }\ +#define PRINT_SCOPESTAT(s, i) do { \ + switch (i) { /* XXX hardcoding in each case */ \ + case 1: \ + p(s, "\t\t%llu node-local%s\n"); \ + break; \ + case 2: \ + p(s, "\t\t%llu link-local%s\n"); \ + break; \ + case 5: \ + p(s, "\t\t%llu site-local%s\n"); \ + break; \ + case 14: \ + p(s, "\t\t%llu global%s\n"); \ + break; \ + default: \ + printf("\t\t%llu addresses scope=%x\n", \ + (unsigned long long)ip6stat[s], i); \ + } \ } while(0); p(IP6_STAT_SOURCES_NONE, @@ -818,11 +820,11 @@ ip6_ifstats(const char *ifname) { struct in6_ifreq ifr; int s; -#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \ - printf(m, (unsigned long long)ifr.ifr_ifru.ifru_stat.f, \ - plural(ifr.ifr_ifru.ifru_stat.f)) -#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \ - printf(m, (unsigned long long)ip6stat.f) +#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \ + printf(m, (unsigned long long)ifr.ifr_ifru.ifru_stat.f, \ + plural(ifr.ifr_ifru.ifru_stat.f)) +#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \ + printf(m, (unsigned long long)ip6stat.f) if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { perror("Warning: socket(AF_INET6)"); @@ -887,7 +889,7 @@ static const char *icmp6names[256] = { "#16", "#17", "#18", - "#19", + "#19", "#20", "#21", "#22", @@ -897,7 +899,7 @@ static const char *icmp6names[256] = { "#26", "#27", "#28", - "#29", + "#29", "#30", "#31", "#32", @@ -907,7 +909,7 @@ static const char *icmp6names[256] = { "#36", "#37", "#38", - "#39", + "#39", "#40", "#41", "#42", @@ -917,7 +919,7 @@ static const char *icmp6names[256] = { "#46", "#47", "#48", - "#49", + "#49", "#50", "#51", "#52", @@ -927,7 +929,7 @@ static const char *icmp6names[256] = { "#56", "#57", "#58", - "#59", + "#59", "#60", "#61", "#62", @@ -937,7 +939,7 @@ static const char *icmp6names[256] = { "#66", "#67", "#68", - "#69", + "#69", "#70", "#71", "#72", @@ -947,7 +949,7 @@ static const char *icmp6names[256] = { "#76", "#77", "#78", - "#79", + "#79", "#80", "#81", "#82", @@ -957,7 +959,7 @@ static const char *icmp6names[256] = { "#86", "#87", "#88", - "#89", + "#89", "#80", "#91", "#92", @@ -967,7 +969,7 @@ static const char *icmp6names[256] = { "#96", "#97", "#98", - "#99", + "#99", "#100", "#101", "#102", @@ -977,7 +979,7 @@ static const char *icmp6names[256] = { "#106", "#107", "#108", - "#109", + "#109", "#110", "#111", "#112", @@ -987,7 +989,7 @@ static const char *icmp6names[256] = { "#116", "#117", "#118", - "#119", + "#119", "#120", "#121", "#122", @@ -997,7 +999,7 @@ static const char *icmp6names[256] = { "#126", "#127", "echo", - "echo reply", + "echo reply", "multicast listener query", "multicast listener report", "multicast listener done", @@ -1017,7 +1019,7 @@ static const char *icmp6names[256] = { "mobile prefix solicitation", "mobile prefix advertisement", "#148", - "#149", + "#149", "#150", "multicast router advertisement", "multicast router solicitation", @@ -1027,7 +1029,7 @@ static const char *icmp6names[256] = { "#156", "#157", "#158", - "#159", + "#159", "#160", "#161", "#162", @@ -1037,7 +1039,7 @@ static const char *icmp6names[256] = { "#166", "#167", "#168", - "#169", + "#169", "#170", "#171", "#172", @@ -1047,7 +1049,7 @@ static const char *icmp6names[256] = { "#176", "#177", "#178", - "#179", + "#179", "#180", "#181", "#182", @@ -1057,7 +1059,7 @@ static const char *icmp6names[256] = { "#186", "#187", "#188", - "#189", + "#189", "#180", "#191", "#192", @@ -1067,7 +1069,7 @@ static const char *icmp6names[256] = { "#196", "#197", "#198", - "#199", + "#199", "#200", "#201", "#202", @@ -1077,7 +1079,7 @@ static const char *icmp6names[256] = { "#206", "#207", "#208", - "#209", + "#209", "#210", "#211", "#212", @@ -1087,7 +1089,7 @@ static const char *icmp6names[256] = { "#216", "#217", "#218", - "#219", + "#219", "#220", "#221", "#222", @@ -1097,7 +1099,7 @@ static const char *icmp6names[256] = { "#226", "#227", "#228", - "#229", + "#229", "#230", "#231", "#232", @@ -1107,7 +1109,7 @@ static const char *icmp6names[256] = { "#236", "#237", "#238", - "#239", + "#239", "#240", "#241", "#242", @@ -1117,13 +1119,13 @@ static const char *icmp6names[256] = { "#246", "#247", "#248", - "#249", + "#249", "#250", "#251", "#252", "#253", "#254", - "#255", + "#255" }; /* @@ -1138,20 +1140,22 @@ icmp6_stats(u_long off, const char *name if (use_sysctl) { size_t size = sizeof(icmp6stat); - if (prog_sysctlbyname("net.inet6.icmp6.stats", icmp6stat, &size, - NULL, 0) == -1 && errno != ENOMEM) + if (prog_sysctlbyname("net.inet6.icmp6.stats", icmp6stat, + &size, NULL, 0) == -1 && errno != ENOMEM) return; } else { warnx("%s stats not available via KVM.", name); return; } - + printf("%s:\n", name); -#define p(f, m) if (icmp6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)icmp6stat[f], plural(icmp6stat[f])) +#define p(f, m) if (icmp6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)icmp6stat[f], \ + plural(icmp6stat[f])) #define p_oerr(f, m) if (icmp6stat[ICMP6_STAT_OUTERRHIST + f] || sflag <= 1) \ - printf(m, (unsigned long long)icmp6stat[ICMP6_STAT_OUTERRHIST + f]) + printf(m, \ + (unsigned long long)icmp6stat[ICMP6_STAT_OUTERRHIST + f]) p(ICMP6_STAT_ERROR, "\t%llu call%s to icmp6_error\n"); p(ICMP6_STAT_CANTERROR, @@ -1217,9 +1221,9 @@ icmp6_ifstats(const char *ifname) { struct in6_ifreq ifr; int s; -#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \ - printf(m, (unsigned long long)ifr.ifr_ifru.ifru_icmp6stat.f, \ - plural(ifr.ifr_ifru.ifru_icmp6stat.f)) +#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \ + printf(m, (unsigned long long)ifr.ifr_ifru.ifru_icmp6stat.f, \ + plural(ifr.ifr_ifru.ifru_icmp6stat.f)) if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { perror("Warning: socket(AF_INET6)"); @@ -1235,7 +1239,7 @@ icmp6_ifstats(const char *ifname) } p(ifs6_in_msg, "\t%llu total input message%s\n"); - p(ifs6_in_error, "\t%llu total input error message%s\n"); + p(ifs6_in_error, "\t%llu total input error message%s\n"); p(ifs6_in_dstunreach, "\t%llu input destination unreachable error%s\n"); p(ifs6_in_adminprohib, "\t%llu input administratively prohibited error%s\n"); p(ifs6_in_timeexceed, "\t%llu input time exceeded error%s\n"); @@ -1289,14 +1293,15 @@ pim6_stats(u_long off, const char *name) if (prog_sysctlbyname("net.inet6.pim6.stats", pim6stat, &size, NULL, 0) == -1 && errno != ENOMEM) return; - } else { + } else { warnx("%s stats not available via KVM.", name); return; } printf("%s:\n", name); -#define p(f, m) if (pim6stat[f] || sflag <= 1) \ - printf(m, (unsigned long long)pim6stat[f], plural(pim6stat[f])) +#define p(f, m) if (pim6stat[f] || sflag <= 1) \ + printf(m, (unsigned long long)pim6stat[f], plural(pim6stat[f])) + p(PIM6_STAT_RCV_TOTAL, "\t%llu message%s received\n"); p(PIM6_STAT_RCV_TOOSHORT, "\t%llu message%s received with too few bytes\n"); p(PIM6_STAT_RCV_BADSUM, "\t%llu message%s received with bad checksum\n"); @@ -1433,14 +1438,14 @@ inet6name(const struct in6_addr *in6p) sin6.sin6_len = sizeof(sin6); sin6.sin6_family = AF_INET6; sin6.sin6_addr = *in6p; - inet6_getscopeid(&sin6, INET6_IS_ADDR_LINKLOCAL| - INET6_IS_ADDR_MC_LINKLOCAL); + inet6_getscopeid(&sin6, + INET6_IS_ADDR_LINKLOCAL | INET6_IS_ADDR_MC_LINKLOCAL); if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, hbuf, sizeof(hbuf), NULL, 0, niflag) != 0) strlcpy(hbuf, "?", sizeof(hbuf)); strlcpy(line, hbuf, sizeof(line)); } - return (line); + return line; } /* @@ -1460,9 +1465,9 @@ tcp6_dump(u_long off, const char *name, size_t j, len; if (use_sysctl) - pcblist = getpcblist_sysctl(name, &len); + pcblist = getpcblist_sysctl(name, &len); else - pcblist = getpcblist_kmem(off, name, &len); + pcblist = getpcblist_kmem(off, name, &len); for (j = 0; j < len; j++) if (pcblist[j].ki_ppcbaddr == pcbaddr) @@ -1502,7 +1507,7 @@ tcp6_dump(u_long off, const char *name, printf("peermaxseg %u, maxseg %u, force %d\n\n", mypcb.t_peermaxseg, mypcb.t_maxseg, mypcb.t_force); #else - printf("peermss %u, ourmss %u, segsz %u, segqlen %u\n\n", + printf("peermss %u, ourmss %u, segsz %u, segqlen %u\n\n", tcpcb.t_peermss, tcpcb.t_ourmss, tcpcb.t_segsz, tcpcb.t_segqlen); #endif Index: src/usr.bin/netstat/main.c diff -u src/usr.bin/netstat/main.c:1.101 src/usr.bin/netstat/main.c:1.102 --- src/usr.bin/netstat/main.c:1.101 Wed Mar 10 00:32:15 2021 +++ src/usr.bin/netstat/main.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.101 2021/03/10 00:32:15 simonb Exp $ */ +/* $NetBSD: main.c,v 1.102 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94"; #else -__RCSID("$NetBSD: main.c,v 1.101 2021/03/10 00:32:15 simonb Exp $"); +__RCSID("$NetBSD: main.c,v 1.102 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -205,8 +205,8 @@ struct protox { (u_long, const char *); void (*pr_stats) /* statistics printing routine */ (u_long, const char *); - void (*pr_istats) - (const char *); /* per/if statistics printing routine */ + void (*pr_istats) /* per/if statistics printing routine */ + (const char *); void (*pr_dump) /* PCB state dump routine */ (u_long, const char *, u_long); const char *pr_name; /* well-known name */ @@ -230,7 +230,7 @@ struct protox { { -1, N_PIMSTAT, 1, 0, pim_stats, NULL, 0, "pim" }, { -1, N_PFSYNCSTAT, 1, 0, - pfsync_stats, NULL, 0, "pfsync" }, + pfsync_stats, NULL, 0, "pfsync" }, { -1, -1, 0, 0, 0, NULL, 0, 0 } }; @@ -491,7 +491,8 @@ main(int argc, char *argv[]) break; case 'p': if ((tp = name2protox(optarg)) == NULL) - errx(1, "%s: unknown or uninstrumented protocol", + errx(1, + "%s: unknown or uninstrumented protocol", optarg); pflag = 1; break; @@ -586,7 +587,8 @@ main(int argc, char *argv[]) } if (pflag) { if (iflag && tp->pr_istats) - intpr(interval, nl[N_IFNET_LIST].n_value, tp->pr_istats); + intpr(interval, nl[N_IFNET_LIST].n_value, + tp->pr_istats); else if (tp->pr_stats) (*tp->pr_stats)(nl[tp->pr_sindex].n_value, tp->pr_name); @@ -645,7 +647,8 @@ main(int argc, char *argv[]) } if (rflag) { if (sflag) - rt_stats(use_sysctl ? 0 : nl[N_RTSTAT].n_value); + rt_stats(use_sysctl ? 0 : + nl[N_RTSTAT].n_value); else { if (use_sysctl) p_rttables(af, @@ -741,7 +744,7 @@ printproto(struct protox *tp, const char if (iflag) { if (tp->pr_istats) intpr(interval, nl[N_IFNET_LIST].n_value, - tp->pr_istats); + tp->pr_istats); return; } else { @@ -789,9 +792,9 @@ kread(u_long addr, char *buf, int size) if (kvm_read(kvmd, addr, buf, size) != size) { warnx("%s", kvm_geterr(kvmd)); - return (-1); + return -1; } - return (0); + return 0; } const char * @@ -815,7 +818,7 @@ get_hardticks(void) kread(nl[N_HARDCLOCK_TICKS].n_value, (char *)&hardticks, sizeof(hardticks)); - return (hardticks); + return hardticks; } /* @@ -829,8 +832,8 @@ knownname(const char *name) for (tpp = protoprotox; *tpp; tpp++) for (tp = *tpp; tp->pr_name; tp++) if (strcmp(tp->pr_name, name) == 0) - return (tp); - return (NULL); + return tp; + return NULL; } /* @@ -848,7 +851,7 @@ name2protox(const char *name) * fails, check if name is an alias for an Internet protocol. */ if ((tp = knownname(name)) != NULL) - return (tp); + return tp; setprotoent(1); /* make protocol lookup cheaper */ while ((p = getprotoent()) != NULL) { @@ -856,11 +859,11 @@ name2protox(const char *name) for (alias = p->p_aliases; *alias; alias++) if (strcmp(name, *alias) == 0) { endprotoent(); - return (knownname(p->p_name)); + return knownname(p->p_name); } } endprotoent(); - return (NULL); + return NULL; } static void @@ -871,7 +874,7 @@ usage(void) (void)fprintf(stderr, "usage: %s [-Aan] [-f address_family[,family ...]] [-M core] [-N system]\n", progname); (void)fprintf(stderr, -" %s [-bdgiLmnqrsSv] [-f address_family[,family ...]] [-M core] [-N system]\n", +" %s [-bdgiLmnqrsSv] [-f address_family[,family ...]] [-M core] [-N system]\n", progname); (void)fprintf(stderr, " %s [-dn] [-I interface] [-M core] [-N system] [-w wait]\n", progname); Index: src/usr.bin/netstat/mbuf.c diff -u src/usr.bin/netstat/mbuf.c:1.34 src/usr.bin/netstat/mbuf.c:1.35 --- src/usr.bin/netstat/mbuf.c:1.34 Tue Jun 25 14:52:55 2019 +++ src/usr.bin/netstat/mbuf.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mbuf.c,v 1.34 2019/06/25 14:52:55 martin Exp $ */ +/* $NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)mbuf.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: mbuf.c,v 1.34 2019/06/25 14:52:55 martin Exp $"); +__RCSID("$NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -101,7 +101,7 @@ mbpr(u_long mbaddr, u_long msizeaddr, u_ if (nmbtypes != 256) { fprintf(stderr, "%s: unexpected change to mbstat; check source\n", - getprogname()); + getprogname()); return; } @@ -172,29 +172,29 @@ mbpr(u_long mbaddr, u_long msizeaddr, u_ goto dump_drain; printf("%lu/%lu mapped pages in use\n", - (u_long)(mclpool.pr_nget - mclpool.pr_nput), - ((u_long)mclpool.pr_npages * mclpool.pr_itemsperpage)); + (u_long)(mclpool.pr_nget - mclpool.pr_nput), + ((u_long)mclpool.pr_npages * mclpool.pr_itemsperpage)); totmem = (mbpool.pr_npages << mbpa.pa_pageshift) + (mclpool.pr_npages << mclpa.pa_pageshift); totused = (mbpool.pr_nget - mbpool.pr_nput) * mbpool.pr_size + (mclpool.pr_nget - mclpool.pr_nput) * mclpool.pr_size; if (totmem == 0) totpct = 0; - else if (totused < (ULONG_MAX/100)) + else if (totused < (ULONG_MAX / 100)) totpct = (totused * 100)/totmem; else { - u_long totmem1 = totmem/100; - u_long totused1 = totused/100; - totpct = (totused1 * 100)/totmem1; + u_long totmem1 = totmem / 100; + u_long totused1 = totused / 100; + totpct = (totused1 * 100) / totmem1; } - + printf("%lu Kbytes allocated to network (%lu%% in use)\n", totmem / 1024, totpct); dump_drain: printf("%lu calls to protocol drain routines\n", mbstat.m_drain); - if (sflag < 2) + if (sflag < 2) return; if (!use_sysctl) Index: src/usr.bin/netstat/mroute.c diff -u src/usr.bin/netstat/mroute.c:1.26 src/usr.bin/netstat/mroute.c:1.27 --- src/usr.bin/netstat/mroute.c:1.26 Sun Oct 6 00:27:50 2019 +++ src/usr.bin/netstat/mroute.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mroute.c,v 1.26 2019/10/06 00:27:50 mrg Exp $ */ +/* $NetBSD: mroute.c,v 1.27 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -76,7 +76,7 @@ #if 0 static char sccsid[] = "from: @(#)mroute.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: mroute.c,v 1.26 2019/10/06 00:27:50 mrg Exp $"); +__RCSID("$NetBSD: mroute.c,v 1.27 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -125,7 +125,7 @@ pktscale(u_long n) } (void)snprintf(buf, sizeof buf, "%lu%c", n, t); - return (buf); + return buf; } void @@ -230,7 +230,8 @@ mroutepr(u_long mrpaddr, u_long mfchasht pktscale(mfc.mfc_pkt_cnt), mfc.mfc_parent); for (vifi = 0; vifi <= numvifs; ++vifi) if (mfc.mfc_ttls[vifi]) - printf(" %u/%u", vifi, mfc.mfc_ttls[vifi]); + printf(" %u/%u", vifi, + mfc.mfc_ttls[vifi]); printf("\n"); @@ -241,12 +242,12 @@ mroutepr(u_long mrpaddr, u_long mfchasht bwm = mfc.mfc_bw_meter; while (bwm) { - kread((u_long)bwm, - (char *)&bw_meter, - sizeof bw_meter); - print_bw_meter(&bw_meter, - &banner_printed2); - bwm = bw_meter.bm_mfc_next; + kread((u_long)bwm, + (char *)&bw_meter, + sizeof bw_meter); + print_bw_meter(&bw_meter, + &banner_printed2); + bwm = bw_meter.bm_mfc_next; } #if 0 /* Don't ever print it? */ if (! banner_printed2) @@ -286,11 +287,13 @@ print_bw_meter(struct bw_meter *bw_meter /* The measured values */ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) - snprintf(s1, sizeof s1, "%llu", (unsigned long long)bw_meter->bm_measured.b_packets); + snprintf(s1, sizeof s1, "%llu", + (unsigned long long)bw_meter->bm_measured.b_packets); else snprintf(s1, sizeof s1, "?"); if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) - snprintf(s2, sizeof s2, "%llu", (unsigned long long)bw_meter->bm_measured.b_bytes); + snprintf(s2, sizeof s2, "%llu", + (unsigned long long)bw_meter->bm_measured.b_bytes); else snprintf(s2, sizeof s2, "?"); snprintf(s0, sizeof s0, "%lld.%ld|%s|%s", @@ -309,11 +312,13 @@ print_bw_meter(struct bw_meter *bw_meter /* The threshold values */ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) - snprintf(s1, sizeof s1, "%llu", (unsigned long long)bw_meter->bm_threshold.b_packets); + snprintf(s1, sizeof s1, "%llu", + (unsigned long long)bw_meter->bm_threshold.b_packets); else snprintf(s1, sizeof s1, "?"); if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) - snprintf(s2, sizeof s2, "%llu", (unsigned long long)bw_meter->bm_threshold.b_bytes); + snprintf(s2, sizeof s2, "%llu", + (unsigned long long)bw_meter->bm_threshold.b_bytes); else snprintf(s2, sizeof s2, "?"); snprintf(s0, sizeof s0, "%lld.%ld|%s|%s", Index: src/usr.bin/netstat/netstat.h diff -u src/usr.bin/netstat/netstat.h:1.52 src/usr.bin/netstat/netstat.h:1.53 --- src/usr.bin/netstat/netstat.h:1.52 Thu Apr 23 00:24:50 2020 +++ src/usr.bin/netstat/netstat.h Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: netstat.h,v 1.52 2020/04/23 00:24:50 joerg Exp $ */ +/* $NetBSD: netstat.h,v 1.53 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -57,14 +57,14 @@ extern int rflag; /* show routing table extern int sflag; /* show protocol statistics */ extern int tagflag; /* show route tags */ extern int tflag; /* show i/f watchdog timers */ -extern int Vflag; /* show Vestigial TIME_WAIT (VTW) information */ -extern int vflag; /* verbose route information or don't truncate names */ +extern int Vflag; /* show Vestigial TIME_WAIT (VTW) information */ +extern int vflag; /* verbose route information or don't truncate names */ -extern char *interface; /* desired i/f for stats, or NULL for all i/fs */ +extern char *interface; /* desired i/f for stats, or NULL for all i/fs */ extern int af; /* address family */ extern int use_sysctl; /* use sysctl instead of kmem */ -extern int force_sysctl; /* force use of sysctl (or exit) - for testing */ +extern int force_sysctl; /* force use of sysctl (or exit) - for testing */ int kread(u_long addr, char *buf, int size); Index: src/usr.bin/netstat/pfkey.c diff -u src/usr.bin/netstat/pfkey.c:1.3 src/usr.bin/netstat/pfkey.c:1.4 --- src/usr.bin/netstat/pfkey.c:1.3 Fri Aug 28 07:23:48 2020 +++ src/usr.bin/netstat/pfkey.c Thu Sep 1 10:10:20 2022 @@ -1,10 +1,10 @@ -/* $NetBSD: pfkey.c,v 1.3 2020/08/28 07:23:48 ozaki-r Exp $ */ +/* $NetBSD: pfkey.c,v 1.4 2022/09/01 10:10:20 msaitoh Exp $ */ /* $KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -65,7 +65,7 @@ static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else #ifdef __NetBSD__ -__RCSID("$NetBSD: pfkey.c,v 1.3 2020/08/28 07:23:48 ozaki-r Exp $"); +__RCSID("$NetBSD: pfkey.c,v 1.4 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif #endif /* not lint */ @@ -87,7 +87,7 @@ __RCSID("$NetBSD: pfkey.c,v 1.3 2020/08/ #include "netstat.h" #include "prog_ops.h" -#ifdef IPSEC +#ifdef IPSEC static const char *pfkey_msgtypenames[] = { "reserved", "getspi", "update", "add", "delete", Index: src/usr.bin/netstat/pfsync.c diff -u src/usr.bin/netstat/pfsync.c:1.3 src/usr.bin/netstat/pfsync.c:1.4 --- src/usr.bin/netstat/pfsync.c:1.3 Fri Aug 28 07:23:48 2020 +++ src/usr.bin/netstat/pfsync.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pfsync.c,v 1.3 2020/08/28 07:23:48 ozaki-r Exp $ */ +/* $NetBSD: pfsync.c,v 1.4 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: pfsync.c,v 1.3 2020/08/28 07:23:48 ozaki-r Exp $"); +__RCSID("$NetBSD: pfsync.c,v 1.4 2022/09/01 10:10:20 msaitoh Exp $"); #endif /* not lint */ #define _CALLOUT_PRIVATE /* for defs in sys/callout.h */ @@ -82,8 +82,8 @@ pfsync_stats(u_long off, const char *nam if (use_sysctl) { size_t size = sizeof(pfsyncstat); - if (prog_sysctlbyname("net.inet.pfsync.stats", pfsyncstat, &size, - NULL, 0) == -1 && errno != ENOMEM) + if (prog_sysctlbyname("net.inet.pfsync.stats", pfsyncstat, + &size, NULL, 0) == -1 && errno != ENOMEM) return; } else { warnx("%s stats not available via KVM.", name); Index: src/usr.bin/netstat/route.c diff -u src/usr.bin/netstat/route.c:1.86 src/usr.bin/netstat/route.c:1.87 --- src/usr.bin/netstat/route.c:1.86 Wed May 27 05:59:16 2020 +++ src/usr.bin/netstat/route.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.86 2020/05/27 05:59:16 yamaguchi Exp $ */ +/* $NetBSD: route.c,v 1.87 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -__RCSID("$NetBSD: route.c,v 1.86 2020/05/27 05:59:16 yamaguchi Exp $"); +__RCSID("$NetBSD: route.c,v 1.87 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -101,7 +101,7 @@ void routepr(u_long rtree) { struct radix_node_head *rnh, head; - struct radix_node_head *rt_nodes[AF_MAX+1]; + struct radix_node_head *rt_nodes[AF_MAX + 1]; int i; printf("Routing tables\n"); @@ -159,8 +159,9 @@ again: if (Aflag) p_rtnode(); } else { - p_sockaddr(kgetsa((const struct sockaddr *)rnode.rn_key), - NULL, 0, 44, nflag); + p_sockaddr( + kgetsa((const struct sockaddr *)rnode.rn_key), + NULL, 0, 44, nflag); putchar('\n'); } if ((rn = rnode.rn_dupedkey) != NULL) @@ -185,8 +186,9 @@ p_rtnode(void) if (rnode.rn_b < 0) { if (rnode.rn_mask) { printf("\t mask "); - p_sockaddr(kgetsa((const struct sockaddr *)rnode.rn_mask), - NULL, 0, -1, nflag); + p_sockaddr( + kgetsa((const struct sockaddr *)rnode.rn_mask), + NULL, 0, -1, nflag); } else if (rm == 0) return; } else { @@ -204,10 +206,11 @@ p_rtnode(void) printf(" <normal>, "); kget(rmask.rm_leaf, rnode_aux); p_sockaddr(kgetsa((const struct sockaddr *)rnode_aux.rn_mask), - NULL, 0, -1, nflag); - } else - p_sockaddr(kgetsa((const struct sockaddr *)rmask.rm_mask), NULL, 0, -1, nflag); + } else + p_sockaddr( + kgetsa((const struct sockaddr *)rmask.rm_mask), + NULL, 0, -1, nflag); putchar('}'); if ((rm = rmask.rm_mklist) != NULL) printf(" ->"); @@ -250,11 +253,12 @@ p_krtentry(struct rtentry *rt) else mask = sockcopy(NULL, &mask_un); p_addr(addr, mask, rt->rt_flags, nflag); - p_gwaddr(kgetsa(rt->rt_gateway), kgetsa(rt->rt_gateway)->sa_family, nflag); + p_gwaddr(kgetsa(rt->rt_gateway), kgetsa(rt->rt_gateway)->sa_family, + nflag); p_flags(rt->rt_flags); printf("%6d %8"PRIu64" ", rt->rt_refcnt, rt->rt_use); if (rt->rt_rmx.rmx_mtu) - printf("%6"PRIu64, rt->rt_rmx.rmx_mtu); + printf("%6"PRIu64, rt->rt_rmx.rmx_mtu); else printf("%6s", "-"); putchar((rt->rt_rmx.rmx_locks & RTV_MTU) ? 'L' : ' '); @@ -270,8 +274,7 @@ p_krtentry(struct rtentry *rt) printf("%7s", tagstr); else printf("%s", tagstr); - } - else + } else printf("%7s", "-"); } else #endif @@ -306,7 +309,7 @@ rt_stats(u_long off) if (sysctlbyname("net.rtable.stats", &rtstats, &rtsize, NULL, 0) == -1) err(1, "rt_stats: sysctl"); - } else if (off == 0) { + } else if (off == 0) { printf("rtstat: symbol not in namelist\n"); return; } else Index: src/usr.bin/netstat/unix.c diff -u src/usr.bin/netstat/unix.c:1.35 src/usr.bin/netstat/unix.c:1.36 --- src/usr.bin/netstat/unix.c:1.35 Fri Jan 13 04:22:51 2017 +++ src/usr.bin/netstat/unix.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: unix.c,v 1.35 2017/01/13 04:22:51 christos Exp $ */ +/* $NetBSD: unix.c,v 1.36 2022/09/01 10:10:20 msaitoh Exp $ */ /*- * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)unix.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: unix.c,v 1.35 2017/01/13 04:22:51 christos Exp $"); +__RCSID("$NetBSD: unix.c,v 1.36 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -79,8 +79,8 @@ unixdomainprhdr(void) { 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", - "Address", "Type", "Recv-Q", "Send-Q", "Inode", "Conn", "Refs", - "Nextref"); + "Address", "Type", "Recv-Q", "Send-Q", "Inode", "Conn", "Refs", + "Nextref"); } static const char * const socktype[] = @@ -92,12 +92,12 @@ unixdomainpr0(u_long so_pcb, u_long so_t u_long addr, struct sockaddr_un *sun, int remote) { printf("%8lx %-6.6s %6ld %6ld %8lx %8lx %8lx %8lx", - so_pcb, socktype[so_type], rcvq, sndq, inode, conn, refs, - nextref); + so_pcb, socktype[so_type], rcvq, sndq, inode, conn, refs, + nextref); if (addr || remote) printf((remote ? " -> %.*s" : " %.*s"), - (int)(sun->sun_len - (sizeof(*sun) - sizeof(sun->sun_path))), - sun->sun_path); + (int)(sun->sun_len - (sizeof(*sun) - sizeof(sun->sun_path))), + sun->sun_path); putchar('\n'); } @@ -176,7 +176,7 @@ unixpr(u_long off) mib[6] = sizeof(*pcblist); mib[7] = size / sizeof(*pcblist); - if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib), + if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist, &size, NULL, 0) == -1) err(1, "sysctl (copy)"); @@ -197,10 +197,10 @@ unixpr(u_long off) sun = (struct sockaddr_un *)&ki->ki_src; } - unixdomainpr0(ki->ki_pcbaddr, ki->ki_type, + unixdomainpr0(ki->ki_pcbaddr, ki->ki_type, ki->ki_rcvq, ki->ki_sndq, - ki->ki_vnode, ki->ki_conn, - ki->ki_refs, ki->ki_nextref, + ki->ki_vnode, ki->ki_conn, + ki->ki_refs, ki->ki_nextref, ki->ki_sockaddr, sun, remote); } @@ -208,10 +208,10 @@ unixpr(u_long off) } } else { - filebuf = (char *)kvm_getfiles(get_kvmd(), KERN_FILE, + filebuf = (char *)kvm_getfiles(get_kvmd(), KERN_FILE, 0, &ns_nfiles); if (filebuf == 0) { - printf("file table read error: %s", + printf("file table read error: %s", kvm_geterr(get_kvmd())); return; } @@ -223,7 +223,8 @@ unixpr(u_long off) if (kread((u_long)fp->f_data, (char *)so, sizeof (*so))) continue; /* kludge */ - if (so->so_proto >= unixsw && so->so_proto <= unixsw + 2) + if (so->so_proto >= unixsw && + so->so_proto <= unixsw + 2) if (so->so_pcb) unixdomainpr(so, fp->f_data); } Index: src/usr.bin/netstat/vtw.c diff -u src/usr.bin/netstat/vtw.c:1.12 src/usr.bin/netstat/vtw.c:1.13 --- src/usr.bin/netstat/vtw.c:1.12 Sat Oct 30 11:23:07 2021 +++ src/usr.bin/netstat/vtw.c Thu Sep 1 10:10:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vtw.c,v 1.12 2021/10/30 11:23:07 nia Exp $ */ +/* $NetBSD: vtw.c,v 1.13 2022/09/01 10:10:20 msaitoh Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #if 0 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else -__RCSID("$NetBSD: vtw.c,v 1.12 2021/10/30 11:23:07 nia Exp $"); +__RCSID("$NetBSD: vtw.c,v 1.13 2022/09/01 10:10:20 msaitoh Exp $"); #endif #endif /* not lint */ @@ -132,12 +132,11 @@ vtw_enabled(void) &enabled, &size, NULL, 0) == -1) return true; return enabled ? true : false; - } else { + } else return true; - } } -static void +static void snarf(const void *addr, void *buf, size_t len) { size_t cc; @@ -202,7 +201,7 @@ timebase(struct timeval *tv) bintime2timeval(&timebasebin, tv); } -static void +static void process_vtw(const vtw_ctl_t * ctl, void (*print)(const vtw_t *)) { vtw_t *vp; @@ -262,7 +261,7 @@ show_vtw_stats(void) printf("\t\t%" PRIu64 " max_loss\n", stats.max_loss[1]); } -void +void show_vtw_v4(void (*print)(const vtw_t *)) { fatp_t *base, *lim; @@ -309,9 +308,8 @@ show_vtw_v4(void (*print)(const vtw_t *) snarf(kbase, ubase, n * sizeof(*ubase)); mem += n * sizeof(*ubase); - } else { + } else ubase = vtw_tcpv4[0].base.v4; - } delta = ubase - kbase; @@ -364,14 +362,14 @@ end: #if 0 if (Vflag && vflag) { - printf("total memory for VTW in current config: %d bytes %f MB\n" - ,mem - ,mem / (1024.0 * 1024)); + printf("total memory for VTW in current config: " + "%d bytes %f MB\n", + mem, mem / (1024.0 * 1024)); } #endif } -void +void show_vtw_v6(void (*print)(const vtw_t *)) { fatp_t *base, *lim; @@ -417,9 +415,8 @@ show_vtw_v6(void (*print)(const vtw_t *) snarf(kbase, ubase, n * sizeof(*ubase)); mem += n * sizeof(*ubase); - } else { + } else ubase = vtw_tcpv6[0].base.v6; - } delta = ubase - kbase; @@ -471,9 +468,9 @@ end: process_vtw(&vtw_tcpv6[0], print); #if 0 if (Vflag && vflag) { - printf("total memory for VTW in current config: %d bytes %f MB\n" - ,mem - ,mem / (1024.0 * 1024)); + printf("total memory for VTW in current config: " + "%d bytes %f MB\n", + mem, mem / (1024.0 * 1024)); } #endif }