mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 05:11:15 +08:00
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 Christian S.J. Peron
|
||||
* All rights reserved.
|
||||
@@ -26,6 +30,9 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -38,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/user.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/bpfdesc.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -48,10 +54,15 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libxo/xo.h>
|
||||
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-bpf-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* print bpf stats */
|
||||
|
||||
@@ -70,7 +81,7 @@ bpf_pidname(pid_t pid)
|
||||
size = sizeof(newkp);
|
||||
error = sysctl(mib, 4, &newkp, &size, NULL, 0);
|
||||
if (error < 0) {
|
||||
warn("kern.proc.pid failed");
|
||||
xo_warn("kern.proc.pid failed");
|
||||
return (strdup("??????"));
|
||||
}
|
||||
return (strdup(newkp.ki_comm));
|
||||
@@ -92,6 +103,23 @@ bpf_flags(struct xbpf_d *bd, char *flagbuf)
|
||||
#endif /* __rtems__ */
|
||||
*flagbuf++ = bd->bd_locked ? 'l' : '-';
|
||||
*flagbuf++ = '\0';
|
||||
|
||||
if (bd->bd_promisc)
|
||||
xo_emit("{e:promiscuous/}");
|
||||
if (bd->bd_immediate)
|
||||
xo_emit("{e:immediate/}");
|
||||
if (bd->bd_hdrcmplt)
|
||||
xo_emit("{e:header-complete/}");
|
||||
xo_emit("{e:direction}", (bd->bd_direction == BPF_D_IN) ? "input" :
|
||||
(bd->bd_direction == BPF_D_OUT) ? "output" : "bidirectional");
|
||||
if (bd->bd_feedback)
|
||||
xo_emit("{e:feedback/}");
|
||||
#ifndef __rtems__
|
||||
if (bd->bd_async)
|
||||
xo_emit("{e:async/}");
|
||||
#endif /* __rtems__ */
|
||||
if (bd->bd_locked)
|
||||
xo_emit("{e:locked/}");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -105,50 +133,61 @@ bpf_stats(char *ifname)
|
||||
bzero(&zerostat, sizeof(zerostat));
|
||||
if (sysctlbyname("net.bpf.stats", NULL, NULL,
|
||||
&zerostat, sizeof(zerostat)) < 0)
|
||||
warn("failed to zero bpf counters");
|
||||
xo_warn("failed to zero bpf counters");
|
||||
return;
|
||||
}
|
||||
if (sysctlbyname("net.bpf.stats", NULL, &size,
|
||||
NULL, 0) < 0) {
|
||||
warn("net.bpf.stats");
|
||||
xo_warn("net.bpf.stats");
|
||||
return;
|
||||
}
|
||||
if (size == 0)
|
||||
return;
|
||||
bd = malloc(size);
|
||||
if (bd == NULL) {
|
||||
warn("malloc failed");
|
||||
xo_warn("malloc failed");
|
||||
return;
|
||||
}
|
||||
if (sysctlbyname("net.bpf.stats", bd, &size,
|
||||
NULL, 0) < 0) {
|
||||
warn("net.bpf.stats");
|
||||
xo_warn("net.bpf.stats");
|
||||
free(bd);
|
||||
return;
|
||||
}
|
||||
(void) printf("%5s %6s %7s %9s %9s %9s %5s %5s %s\n",
|
||||
"Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
|
||||
"Hblen", "Command");
|
||||
xo_emit("{T:/%5s} {T:/%6s} {T:/%7s} {T:/%9s} {T:/%9s} {T:/%9s} "
|
||||
"{T:/%5s} {T:/%5s} {T:/%s}\n",
|
||||
"Pid", "Netif", "Flags", "Recv", "Drop", "Match",
|
||||
"Sblen", "Hblen", "Command");
|
||||
xo_open_container("bpf-statistics");
|
||||
xo_open_list("bpf-entry");
|
||||
for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
|
||||
if (d->bd_structsize != sizeof(*d)) {
|
||||
warnx("bpf_stats_extended: version mismatch");
|
||||
xo_warnx("bpf_stats_extended: version mismatch");
|
||||
return;
|
||||
}
|
||||
if (ifname && strcmp(ifname, d->bd_ifname) != 0)
|
||||
continue;
|
||||
bpf_flags(d, flagbuf);
|
||||
xo_open_instance("bpf-entry");
|
||||
#ifndef __rtems__
|
||||
pname = bpf_pidname(d->bd_pid);
|
||||
#else /* __rtems__ */
|
||||
pname = "??????";
|
||||
#endif /* __rtems__ */
|
||||
(void) printf("%5d %6s %7s %9ju %9ju %9ju %5d %5d %s\n",
|
||||
d->bd_pid, d->bd_ifname, flagbuf,
|
||||
d->bd_rcount, d->bd_dcount, d->bd_fcount,
|
||||
d->bd_slen, d->bd_hlen, pname);
|
||||
xo_emit("{k:pid/%5d} {k:interface-name/%6s} ",
|
||||
d->bd_pid, d->bd_ifname);
|
||||
bpf_flags(d, flagbuf);
|
||||
xo_emit("{d:flags/%7s} {:received-packets/%9ju} "
|
||||
"{:dropped-packets/%9ju} {:filter-packets/%9ju} "
|
||||
"{:store-buffer-length/%5d} {:hold-buffer-length/%5d} "
|
||||
"{:process/%s}\n",
|
||||
flagbuf, (uintmax_t)d->bd_rcount, (uintmax_t)d->bd_dcount,
|
||||
(uintmax_t)d->bd_fcount, d->bd_slen, d->bd_hlen, pname);
|
||||
#ifndef __rtems__
|
||||
free(pname);
|
||||
#endif /* __rtems__ */
|
||||
xo_close_instance("bpf-entry");
|
||||
}
|
||||
xo_close_list("bpf-entry");
|
||||
xo_close_container("bpf-statistics");
|
||||
free(bd);
|
||||
}
|
||||
|
100
freebsd/usr.bin/netstat/flowtable.c
Normal file
100
freebsd/usr.bin/netstat/flowtable.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Gleb Smirnoff <glebius@FreeBSD.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University 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 REGENTS 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
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
|
||||
#include <net/flowtable.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-flowtable-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Print flowtable statistics.
|
||||
*/
|
||||
|
||||
static void
|
||||
print_stats(struct flowtable_stat *stat)
|
||||
{
|
||||
|
||||
#define p(f, m) if (stat->f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)stat->f, plural(stat->f))
|
||||
#define p2(f, m) if (stat->f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)stat->f, plurales(stat->f))
|
||||
|
||||
p(ft_lookups, "\t%ju lookup%s\n");
|
||||
p(ft_hits, "\t%ju hit%s\n");
|
||||
p2(ft_misses, "\t%ju miss%s\n");
|
||||
p(ft_inserts, "\t%ju insert%s\n");
|
||||
p(ft_collisions, "\t%ju collision%s\n");
|
||||
p(ft_free_checks, "\t%ju free check%s\n");
|
||||
p(ft_frees, "\t%ju free%s\n");
|
||||
p(ft_fail_lle_invalid,
|
||||
"\t%ju lookup%s with not resolved Layer 2 address\n");
|
||||
|
||||
#undef p2
|
||||
#undef p
|
||||
}
|
||||
|
||||
void
|
||||
flowtable_stats(void)
|
||||
{
|
||||
struct flowtable_stat stat;
|
||||
|
||||
if (!live)
|
||||
return;
|
||||
|
||||
if (fetch_stats("net.flowtable.ip4.stat", 0, &stat,
|
||||
sizeof(stat), NULL) == 0) {
|
||||
printf("flowtable for IPv4:\n");
|
||||
print_stats(&stat);
|
||||
}
|
||||
|
||||
if (fetch_stats("net.flowtable.ip6.stat", 0, &stat,
|
||||
sizeof(stat), NULL) == 0) {
|
||||
printf("flowtable for IPv6:\n");
|
||||
print_stats(&stat);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* $KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
@@ -90,6 +94,9 @@ static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -109,9 +116,14 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libxo/xo.h>
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-ipsec-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef IPSEC
|
||||
struct val2str {
|
||||
@@ -156,6 +168,9 @@ static struct val2str ipsec_espnames[] = {
|
||||
#endif
|
||||
#ifdef SADB_X_EALG_AESCTR
|
||||
{ SADB_X_EALG_AESCTR, "aes-ctr", },
|
||||
#endif
|
||||
#ifdef SADB_X_EALG_AESGCM16
|
||||
{ SADB_X_EALG_AESGCM16, "aes-gcm-16", },
|
||||
#endif
|
||||
{ -1, NULL },
|
||||
};
|
||||
@@ -168,98 +183,44 @@ static struct val2str ipsec_compnames[] = {
|
||||
{ -1, NULL },
|
||||
};
|
||||
|
||||
static void ipsec_hist(const u_quad_t *hist, size_t histmax,
|
||||
const struct val2str *name, const char *title);
|
||||
static void print_ipsecstats(const struct ipsecstat *ipsecstat);
|
||||
|
||||
|
||||
/*
|
||||
* Dump IPSEC statistics structure.
|
||||
*/
|
||||
static void
|
||||
ipsec_hist(const u_quad_t *hist, size_t histmax, const struct val2str *name,
|
||||
const char *title)
|
||||
{
|
||||
int first;
|
||||
size_t proto;
|
||||
const struct val2str *p;
|
||||
|
||||
first = 1;
|
||||
for (proto = 0; proto < histmax; proto++) {
|
||||
if (hist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\t%s histogram:\n", title);
|
||||
first = 0;
|
||||
}
|
||||
for (p = name; p && p->str; p++) {
|
||||
if (p->val == (int)proto)
|
||||
break;
|
||||
}
|
||||
if (p && p->str) {
|
||||
printf("\t\t%s: %ju\n", p->str, (uintmax_t)hist[proto]);
|
||||
} else {
|
||||
printf("\t\t#%ld: %ju\n", (long)proto,
|
||||
(uintmax_t)hist[proto]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_ipsecstats(const struct ipsecstat *ipsecstat)
|
||||
{
|
||||
xo_open_container("ipsec-statistics");
|
||||
|
||||
#define p(f, m) if (ipsecstat->f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f))
|
||||
#define pes(f, m) if (ipsecstat->f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)ipsecstat->f, plurales(ipsecstat->f))
|
||||
#define hist(f, n, t) \
|
||||
ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
||||
xo_emit(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f))
|
||||
|
||||
p(in_success, "\t%ju inbound packet%s processed successfully\n");
|
||||
p(in_polvio, "\t%ju inbound packet%s violated process security "
|
||||
"policy\n");
|
||||
p(in_nosa, "\t%ju inbound packet%s with no SA available\n");
|
||||
p(in_inval, "\t%ju invalid inbound packet%s\n");
|
||||
p(in_nomem, "\t%ju inbound packet%s failed due to insufficient memory\n");
|
||||
p(in_badspi, "\t%ju inbound packet%s failed getting SPI\n");
|
||||
p(in_ahreplay, "\t%ju inbound packet%s failed on AH replay check\n");
|
||||
p(in_espreplay, "\t%ju inbound packet%s failed on ESP replay check\n");
|
||||
p(in_ahauthsucc, "\t%ju inbound packet%s considered authentic\n");
|
||||
p(in_ahauthfail, "\t%ju inbound packet%s failed on authentication\n");
|
||||
hist(ipsecstat->in_ahhist, ipsec_ahnames, "AH input");
|
||||
hist(ipsecstat->in_esphist, ipsec_espnames, "ESP input");
|
||||
hist(ipsecstat->in_comphist, ipsec_compnames, "IPComp input");
|
||||
|
||||
p(out_success, "\t%ju outbound packet%s processed successfully\n");
|
||||
p(out_polvio, "\t%ju outbound packet%s violated process security "
|
||||
"policy\n");
|
||||
p(out_nosa, "\t%ju outbound packet%s with no SA available\n");
|
||||
p(out_inval, "\t%ju invalid outbound packet%s\n");
|
||||
p(out_nomem, "\t%ju outbound packet%s failed due to insufficient memory\n");
|
||||
p(out_noroute, "\t%ju outbound packet%s with no route\n");
|
||||
hist(ipsecstat->out_ahhist, ipsec_ahnames, "AH output");
|
||||
hist(ipsecstat->out_esphist, ipsec_espnames, "ESP output");
|
||||
hist(ipsecstat->out_comphist, ipsec_compnames, "IPComp output");
|
||||
p(spdcachelookup, "\t%ju SPD cache lookup%s\n");
|
||||
pes(spdcachemiss, "\t%ju SPD cache miss%s\n");
|
||||
#undef pes
|
||||
#undef hist
|
||||
p(ips_in_polvio, "\t%ju inbound packet%s violated process "
|
||||
"security policy\n");
|
||||
p(ips_out_polvio, "\t%ju outbound packet%s violated process "
|
||||
"security policy\n");
|
||||
p(ips_out_nosa, "\t%ju outbound packet%s with no SA available\n");
|
||||
p(ips_out_nomem, "\t%ju outbound packet%s failed due to "
|
||||
"insufficient memory\n");
|
||||
p(ips_out_noroute, "\t%ju outbound packet%s with no route "
|
||||
"available\n");
|
||||
p(ips_out_inval, "\t%ju invalid outbound packet%s\n");
|
||||
p(ips_out_bundlesa, "\t%ju outbound packet%s with bundled SAs\n");
|
||||
p(ips_mbcoalesced, "\t%ju mbuf%s coalesced during clone\n");
|
||||
p(ips_clcoalesced, "\t%ju cluster%s coalesced during clone\n");
|
||||
p(ips_clcopied, "\t%ju cluster%s copied during clone\n");
|
||||
p(ips_mbinserted, "\t%ju mbuf%s inserted during makespace\n");
|
||||
p(ips_in_polvio, "\t{:dropped-policy-violation/%ju} "
|
||||
"{N:/inbound packet%s violated process security policy}\n");
|
||||
p(ips_in_nomem, "\t{:dropped-no-memory/%ju} "
|
||||
"{N:/inbound packet%s failed due to insufficient memory}\n");
|
||||
p(ips_in_inval, "\t{:dropped-invalid/%ju} "
|
||||
"{N:/invalid inbound packet%s}\n");
|
||||
p(ips_out_polvio, "\t{:discarded-policy-violation/%ju} "
|
||||
"{N:/outbound packet%s violated process security policy}\n");
|
||||
p(ips_out_nosa, "\t{:discarded-no-sa/%ju} "
|
||||
"{N:/outbound packet%s with no SA available}\n");
|
||||
p(ips_out_nomem, "\t{:discarded-no-memory/%ju} "
|
||||
"{N:/outbound packet%s failed due to insufficient memory}\n");
|
||||
p(ips_out_noroute, "\t{:discarded-no-route/%ju} "
|
||||
"{N:/outbound packet%s with no route available}\n");
|
||||
p(ips_out_inval, "\t{:discarded-invalid/%ju} "
|
||||
"{N:/invalid outbound packet%s}\n");
|
||||
p(ips_out_bundlesa, "\t{:send-bundled-sa/%ju} "
|
||||
"{N:/outbound packet%s with bundled SAs}\n");
|
||||
p(ips_mbcoalesced, "\t{:mbufs-coalesced-during-clone/%ju} "
|
||||
"{N:/mbuf%s coalesced during clone}\n");
|
||||
p(ips_clcoalesced, "\t{:clusters-coalesced-during-clone/%ju} "
|
||||
"{N:/cluster%s coalesced during clone}\n");
|
||||
p(ips_clcopied, "\t{:clusters-copied-during-clone/%ju} "
|
||||
"{N:/cluster%s copied during clone}\n");
|
||||
p(ips_mbinserted, "\t{:mbufs-inserted/%ju} "
|
||||
"{N:/mbuf%s inserted during makespace}\n");
|
||||
#undef p
|
||||
xo_close_container("ipsec-statistics");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -267,17 +228,22 @@ ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
{
|
||||
struct ipsecstat ipsecstat;
|
||||
|
||||
if (off == 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&ipsecstat, sizeof(ipsecstat));
|
||||
if (strcmp(name, "ipsec6") == 0) {
|
||||
if (fetch_stats("net.inet6.ipsec6.ipsecstats", off,&ipsecstat,
|
||||
sizeof(ipsecstat), kread_counters) != 0)
|
||||
return;
|
||||
} else {
|
||||
if (fetch_stats("net.inet.ipsec.ipsecstats", off, &ipsecstat,
|
||||
sizeof(ipsecstat), kread_counters) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
|
||||
print_ipsecstats(&ipsecstat);
|
||||
}
|
||||
|
||||
|
||||
static void ipsec_hist_new(const u_int32_t *hist, size_t histmax,
|
||||
const struct val2str *name, const char *title);
|
||||
static void print_ahstats(const struct ahstat *ahstat);
|
||||
static void print_espstats(const struct espstat *espstat);
|
||||
static void print_ipcompstats(const struct ipcompstat *ipcompstat);
|
||||
@@ -286,8 +252,8 @@ static void print_ipcompstats(const struct ipcompstat *ipcompstat);
|
||||
* Dump IPSEC statistics structure.
|
||||
*/
|
||||
static void
|
||||
ipsec_hist_new(const u_int32_t *hist, size_t histmax,
|
||||
const struct val2str *name, const char *title)
|
||||
ipsec_hist_new(const uint64_t *hist, size_t histmax,
|
||||
const struct val2str *name, const char *title, const char *cname)
|
||||
{
|
||||
int first;
|
||||
size_t proto;
|
||||
@@ -298,56 +264,72 @@ ipsec_hist_new(const u_int32_t *hist, size_t histmax,
|
||||
if (hist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\t%s histogram:\n", title);
|
||||
xo_open_list(cname);
|
||||
xo_emit("\t{T:/%s histogram}:\n", title);
|
||||
first = 0;
|
||||
}
|
||||
xo_open_instance(cname);
|
||||
for (p = name; p && p->str; p++) {
|
||||
if (p->val == (int)proto)
|
||||
break;
|
||||
}
|
||||
if (p && p->str) {
|
||||
printf("\t\t%s: %u\n", p->str, hist[proto]);
|
||||
xo_emit("\t\t{k:name}: {:count/%ju}\n", p->str,
|
||||
(uintmax_t)hist[proto]);
|
||||
} else {
|
||||
printf("\t\t#%lu: %u\n", (unsigned long)proto,
|
||||
hist[proto]);
|
||||
xo_emit("\t\t#{k:name/%lu}: {:count/%ju}\n",
|
||||
(unsigned long)proto, (uintmax_t)hist[proto]);
|
||||
}
|
||||
xo_close_instance(cname);
|
||||
}
|
||||
if (!first)
|
||||
xo_close_list(cname);
|
||||
}
|
||||
|
||||
static void
|
||||
print_ahstats(const struct ahstat *ahstat)
|
||||
{
|
||||
#define p32(f, m) if (ahstat->f || sflag <= 1) \
|
||||
printf("\t%u" m, (unsigned int)ahstat->f, plural(ahstat->f))
|
||||
#define p64(f, m) if (ahstat->f || sflag <= 1) \
|
||||
printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f))
|
||||
#define hist(f, n, t) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
||||
xo_open_container("ah-statictics");
|
||||
|
||||
p32(ahs_hdrops, " packet%s shorter than header shows\n");
|
||||
p32(ahs_nopf, " packet%s dropped; protocol family not supported\n");
|
||||
p32(ahs_notdb, " packet%s dropped; no TDB\n");
|
||||
p32(ahs_badkcr, " packet%s dropped; bad KCR\n");
|
||||
p32(ahs_qfull, " packet%s dropped; queue full\n");
|
||||
p32(ahs_noxform, " packet%s dropped; no transform\n");
|
||||
p32(ahs_wrap, " replay counter wrap%s\n");
|
||||
p32(ahs_badauth, " packet%s dropped; bad authentication detected\n");
|
||||
p32(ahs_badauthl, " packet%s dropped; bad authentication length\n");
|
||||
p32(ahs_replay, " possible replay packet%s detected\n");
|
||||
p32(ahs_input, " packet%s in\n");
|
||||
p32(ahs_output, " packet%s out\n");
|
||||
p32(ahs_invalid, " packet%s dropped; invalid TDB\n");
|
||||
p64(ahs_ibytes, " byte%s in\n");
|
||||
p64(ahs_obytes, " byte%s out\n");
|
||||
p32(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
||||
p32(ahs_pdrops, " packet%s blocked due to policy\n");
|
||||
p32(ahs_crypto, " crypto processing failure%s\n");
|
||||
p32(ahs_tunnel, " tunnel sanity check failure%s\n");
|
||||
hist(ahstat->ahs_hist, ipsec_ahnames, "AH output");
|
||||
#define p(f, n, m) if (ahstat->f || sflag <= 1) \
|
||||
xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
|
||||
(uintmax_t)ahstat->f, plural(ahstat->f))
|
||||
#define hist(f, n, t, c) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c))
|
||||
|
||||
#undef p32
|
||||
#undef p64
|
||||
p(ahs_hdrops, "dropped-short-header",
|
||||
"packet%s shorter than header shows");
|
||||
p(ahs_nopf, "dropped-bad-protocol",
|
||||
"packet%s dropped; protocol family not supported");
|
||||
p(ahs_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
|
||||
p(ahs_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
|
||||
p(ahs_qfull, "dropped-queue-full", "packet%s dropped; queue full");
|
||||
p(ahs_noxform, "dropped-no-transform",
|
||||
"packet%s dropped; no transform");
|
||||
p(ahs_wrap, "replay-counter-wraps", "replay counter wrap%s");
|
||||
p(ahs_badauth, "dropped-bad-auth",
|
||||
"packet%s dropped; bad authentication detected");
|
||||
p(ahs_badauthl, "dropped-bad-auth-level",
|
||||
"packet%s dropped; bad authentication length");
|
||||
p(ahs_replay, "possile-replay-detected",
|
||||
"possible replay packet%s detected");
|
||||
p(ahs_input, "received-packets", "packet%s in");
|
||||
p(ahs_output, "send-packets", "packet%s out");
|
||||
p(ahs_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
|
||||
p(ahs_ibytes, "received-bytes", "byte%s in");
|
||||
p(ahs_obytes, "send-bytes", "byte%s out");
|
||||
p(ahs_toobig, "dropped-too-large",
|
||||
"packet%s dropped; larger than IP_MAXPACKET");
|
||||
p(ahs_pdrops, "dropped-policy-violation",
|
||||
"packet%s blocked due to policy");
|
||||
p(ahs_crypto, "crypto-failures", "crypto processing failure%s");
|
||||
p(ahs_tunnel, "tunnel-failures", "tunnel sanity check failure%s");
|
||||
hist(ahstat->ahs_hist, ipsec_ahnames,
|
||||
"AH output", "ah-output-histogram");
|
||||
|
||||
#undef p
|
||||
#undef hist
|
||||
xo_close_container("ah-statictics");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -355,10 +337,11 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
||||
{
|
||||
struct ahstat ahstat;
|
||||
|
||||
if (off == 0)
|
||||
if (fetch_stats("net.inet.ah.stats", off, &ahstat,
|
||||
sizeof(ahstat), kread_counters) != 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&ahstat, sizeof(ahstat));
|
||||
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
|
||||
print_ahstats(&ahstat);
|
||||
}
|
||||
@@ -366,38 +349,47 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
||||
static void
|
||||
print_espstats(const struct espstat *espstat)
|
||||
{
|
||||
#define p32(f, m) if (espstat->f || sflag <= 1) \
|
||||
printf("\t%u" m, (unsigned int)espstat->f, plural(espstat->f))
|
||||
#define p64(f, m) if (espstat->f || sflag <= 1) \
|
||||
printf("\t%ju" m, (uintmax_t)espstat->f, plural(espstat->f))
|
||||
#define hist(f, n, t) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
||||
xo_open_container("esp-statictics");
|
||||
#define p(f, n, m) if (espstat->f || sflag <= 1) \
|
||||
xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
|
||||
(uintmax_t)espstat->f, plural(espstat->f))
|
||||
#define hist(f, n, t, c) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c));
|
||||
|
||||
p32(esps_hdrops, " packet%s shorter than header shows\n");
|
||||
p32(esps_nopf, " packet%s dropped; protocol family not supported\n");
|
||||
p32(esps_notdb, " packet%s dropped; no TDB\n");
|
||||
p32(esps_badkcr, " packet%s dropped; bad KCR\n");
|
||||
p32(esps_qfull, " packet%s dropped; queue full\n");
|
||||
p32(esps_noxform, " packet%s dropped; no transform\n");
|
||||
p32(esps_badilen, " packet%s dropped; bad ilen\n");
|
||||
p32(esps_wrap, " replay counter wrap%s\n");
|
||||
p32(esps_badenc, " packet%s dropped; bad encryption detected\n");
|
||||
p32(esps_badauth, " packet%s dropped; bad authentication detected\n");
|
||||
p32(esps_replay, " possible replay packet%s detected\n");
|
||||
p32(esps_input, " packet%s in\n");
|
||||
p32(esps_output, " packet%s out\n");
|
||||
p32(esps_invalid, " packet%s dropped; invalid TDB\n");
|
||||
p64(esps_ibytes, " byte%s in\n");
|
||||
p64(esps_obytes, " byte%s out\n");
|
||||
p32(esps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
||||
p32(esps_pdrops, " packet%s blocked due to policy\n");
|
||||
p32(esps_crypto, " crypto processing failure%s\n");
|
||||
p32(esps_tunnel, " tunnel sanity check failure%s\n");
|
||||
hist(espstat->esps_hist, ipsec_espnames, "ESP output");
|
||||
p(esps_hdrops, "dropped-short-header",
|
||||
"packet%s shorter than header shows");
|
||||
p(esps_nopf, "dropped-bad-protocol",
|
||||
"packet%s dropped; protocol family not supported");
|
||||
p(esps_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
|
||||
p(esps_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
|
||||
p(esps_qfull, "dropped-queue-full", "packet%s dropped; queue full");
|
||||
p(esps_noxform, "dropped-no-transform",
|
||||
"packet%s dropped; no transform");
|
||||
p(esps_badilen, "dropped-bad-length", "packet%s dropped; bad ilen");
|
||||
p(esps_wrap, "replay-counter-wraps", "replay counter wrap%s");
|
||||
p(esps_badenc, "dropped-bad-crypto",
|
||||
"packet%s dropped; bad encryption detected");
|
||||
p(esps_badauth, "dropped-bad-auth",
|
||||
"packet%s dropped; bad authentication detected");
|
||||
p(esps_replay, "possible-replay-detected",
|
||||
"possible replay packet%s detected");
|
||||
p(esps_input, "received-packets", "packet%s in");
|
||||
p(esps_output, "sent-packets", "packet%s out");
|
||||
p(esps_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
|
||||
p(esps_ibytes, "receieve-bytes", "byte%s in");
|
||||
p(esps_obytes, "sent-bytes", "byte%s out");
|
||||
p(esps_toobig, "dropped-too-large",
|
||||
"packet%s dropped; larger than IP_MAXPACKET");
|
||||
p(esps_pdrops, "dropped-policy-violation",
|
||||
"packet%s blocked due to policy");
|
||||
p(esps_crypto, "crypto-failures", "crypto processing failure%s");
|
||||
p(esps_tunnel, "tunnel-failures", "tunnel sanity check failure%s");
|
||||
hist(espstat->esps_hist, ipsec_espnames,
|
||||
"ESP output", "esp-output-histogram");
|
||||
|
||||
#undef p32
|
||||
#undef p64
|
||||
#undef p
|
||||
#undef hist
|
||||
xo_close_container("esp-statictics");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -405,10 +397,11 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
||||
{
|
||||
struct espstat espstat;
|
||||
|
||||
if (off == 0)
|
||||
if (fetch_stats("net.inet.esp.stats", off, &espstat,
|
||||
sizeof(espstat), kread_counters) != 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&espstat, sizeof(espstat));
|
||||
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
|
||||
print_espstats(&espstat);
|
||||
}
|
||||
@@ -416,43 +409,44 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
||||
static void
|
||||
print_ipcompstats(const struct ipcompstat *ipcompstat)
|
||||
{
|
||||
uint32_t version;
|
||||
#define p32(f, m) if (ipcompstat->f || sflag <= 1) \
|
||||
printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f))
|
||||
#define p64(f, m) if (ipcompstat->f || sflag <= 1) \
|
||||
printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
|
||||
#define hist(f, n, t) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
||||
xo_open_container("ipcomp-statictics");
|
||||
|
||||
#ifndef IPCOMPSTAT_VERSION
|
||||
version = 0;
|
||||
#else
|
||||
version = ipcompstat->version;
|
||||
#endif
|
||||
p32(ipcomps_hdrops, " packet%s shorter than header shows\n");
|
||||
p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
|
||||
p32(ipcomps_notdb, " packet%s dropped; no TDB\n");
|
||||
p32(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
|
||||
p32(ipcomps_qfull, " packet%s dropped; queue full\n");
|
||||
p32(ipcomps_noxform, " packet%s dropped; no transform\n");
|
||||
p32(ipcomps_wrap, " replay counter wrap%s\n");
|
||||
p32(ipcomps_input, " packet%s in\n");
|
||||
p32(ipcomps_output, " packet%s out\n");
|
||||
p32(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
|
||||
p64(ipcomps_ibytes, " byte%s in\n");
|
||||
p64(ipcomps_obytes, " byte%s out\n");
|
||||
p32(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
||||
p32(ipcomps_pdrops, " packet%s blocked due to policy\n");
|
||||
p32(ipcomps_crypto, " crypto processing failure%s\n");
|
||||
hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output");
|
||||
if (version >= 1) {
|
||||
p32(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n");
|
||||
p32(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n");
|
||||
}
|
||||
#define p(f, n, m) if (ipcompstat->f || sflag <= 1) \
|
||||
xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
|
||||
(uintmax_t)ipcompstat->f, plural(ipcompstat->f))
|
||||
#define hist(f, n, t, c) \
|
||||
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c));
|
||||
|
||||
#undef p32
|
||||
#undef p64
|
||||
p(ipcomps_hdrops, "dropped-short-header",
|
||||
"packet%s shorter than header shows");
|
||||
p(ipcomps_nopf, "dropped-bad-protocol",
|
||||
"packet%s dropped; protocol family not supported");
|
||||
p(ipcomps_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
|
||||
p(ipcomps_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
|
||||
p(ipcomps_qfull, "dropped-queue-full", "packet%s dropped; queue full");
|
||||
p(ipcomps_noxform, "dropped-no-transform",
|
||||
"packet%s dropped; no transform");
|
||||
p(ipcomps_wrap, "replay-counter-wraps", "replay counter wrap%s");
|
||||
p(ipcomps_input, "receieve-packets", "packet%s in");
|
||||
p(ipcomps_output, "sent-packets", "packet%s out");
|
||||
p(ipcomps_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
|
||||
p(ipcomps_ibytes, "receieved-bytes", "byte%s in");
|
||||
p(ipcomps_obytes, "sent-bytes", "byte%s out");
|
||||
p(ipcomps_toobig, "dropped-too-large",
|
||||
"packet%s dropped; larger than IP_MAXPACKET");
|
||||
p(ipcomps_pdrops, "dropped-policy-violation",
|
||||
"packet%s blocked due to policy");
|
||||
p(ipcomps_crypto, "crypto-failure", "crypto processing failure%s");
|
||||
hist(ipcompstat->ipcomps_hist, ipsec_compnames,
|
||||
"COMP output", "comp-output-histogram");
|
||||
p(ipcomps_threshold, "sent-uncompressed-small-packets",
|
||||
"packet%s sent uncompressed; size < compr. algo. threshold");
|
||||
p(ipcomps_uncompr, "sent-uncompressed-useless-packets",
|
||||
"packet%s sent uncompressed; compression was useless");
|
||||
|
||||
#undef p
|
||||
#undef hist
|
||||
xo_close_container("ipcomp-statictics");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -461,10 +455,11 @@ ipcomp_stats(u_long off, const char *name, int family __unused,
|
||||
{
|
||||
struct ipcompstat ipcompstat;
|
||||
|
||||
if (off == 0)
|
||||
if (fetch_stats("net.inet.ipcomp.stats", off, &ipcompstat,
|
||||
sizeof(ipcompstat), kread_counters) != 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&ipcompstat, sizeof(ipcompstat));
|
||||
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
|
||||
print_ipcompstats(&ipcompstat);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
* The Regents of the University of California.
|
||||
@@ -41,12 +45,16 @@ static char sccsid[] = "@(#)mbuf.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/sf_buf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
@@ -57,8 +65,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <libxo/xo.h>
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-mbuf-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Print mbuf statistics.
|
||||
@@ -70,26 +83,26 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
struct memory_type *mtp;
|
||||
uintmax_t mbuf_count, mbuf_bytes, mbuf_free, mbuf_failures, mbuf_size;
|
||||
uintmax_t mbuf_sleeps;
|
||||
uintmax_t cluster_count, cluster_bytes, cluster_limit, cluster_free;
|
||||
uintmax_t cluster_count, cluster_limit, cluster_free;
|
||||
uintmax_t cluster_failures, cluster_size, cluster_sleeps;
|
||||
uintmax_t packet_count, packet_bytes, packet_free, packet_failures;
|
||||
uintmax_t packet_sleeps;
|
||||
uintmax_t tag_count, tag_bytes;
|
||||
uintmax_t jumbop_count, jumbop_bytes, jumbop_limit, jumbop_free;
|
||||
uintmax_t tag_bytes;
|
||||
uintmax_t jumbop_count, jumbop_limit, jumbop_free;
|
||||
uintmax_t jumbop_failures, jumbop_sleeps, jumbop_size;
|
||||
uintmax_t jumbo9_count, jumbo9_bytes, jumbo9_limit, jumbo9_free;
|
||||
uintmax_t jumbo9_count, jumbo9_limit, jumbo9_free;
|
||||
uintmax_t jumbo9_failures, jumbo9_sleeps, jumbo9_size;
|
||||
uintmax_t jumbo16_count, jumbo16_bytes, jumbo16_limit, jumbo16_free;
|
||||
uintmax_t jumbo16_count, jumbo16_limit, jumbo16_free;
|
||||
uintmax_t jumbo16_failures, jumbo16_sleeps, jumbo16_size;
|
||||
uintmax_t bytes_inuse, bytes_incache, bytes_total;
|
||||
int nsfbufs, nsfbufspeak, nsfbufsused;
|
||||
struct mbstat mbstat;
|
||||
struct sfstat sfstat;
|
||||
size_t mlen;
|
||||
int error;
|
||||
|
||||
mtlp = memstat_mtl_alloc();
|
||||
if (mtlp == NULL) {
|
||||
warn("memstat_mtl_alloc");
|
||||
xo_warn("memstat_mtl_alloc");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,7 +112,7 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
*/
|
||||
if (live) {
|
||||
if (memstat_sysctl_all(mtlp, 0) < 0) {
|
||||
warnx("memstat_sysctl_all: %s",
|
||||
xo_warnx("memstat_sysctl_all: %s",
|
||||
memstat_strerror(memstat_mtl_geterror(mtlp)));
|
||||
goto out;
|
||||
}
|
||||
@@ -108,10 +121,10 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
if (memstat_kvm_all(mtlp, kvmd) < 0) {
|
||||
error = memstat_mtl_geterror(mtlp);
|
||||
if (error == MEMSTAT_ERROR_KVM)
|
||||
warnx("memstat_kvm_all: %s",
|
||||
xo_warnx("memstat_kvm_all: %s",
|
||||
kvm_geterr(kvmd));
|
||||
else
|
||||
warnx("memstat_kvm_all: %s",
|
||||
xo_warnx("memstat_kvm_all: %s",
|
||||
memstat_strerror(error));
|
||||
goto out;
|
||||
}
|
||||
@@ -123,7 +136,7 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found", MBUF_MEM_NAME);
|
||||
xo_warnx("memstat_mtl_find: zone %s not found", MBUF_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
mbuf_count = memstat_get_count(mtp);
|
||||
@@ -135,7 +148,7 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_PACKET_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found",
|
||||
xo_warnx("memstat_mtl_find: zone %s not found",
|
||||
MBUF_PACKET_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
@@ -147,12 +160,11 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_CLUSTER_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found",
|
||||
xo_warnx("memstat_mtl_find: zone %s not found",
|
||||
MBUF_CLUSTER_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
cluster_count = memstat_get_count(mtp);
|
||||
cluster_bytes = memstat_get_bytes(mtp);
|
||||
cluster_limit = memstat_get_countlimit(mtp);
|
||||
cluster_free = memstat_get_free(mtp);
|
||||
cluster_failures = memstat_get_failures(mtp);
|
||||
@@ -162,25 +174,22 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
#ifndef __rtems__
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_MALLOC, MBUF_TAG_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: malloc type %s not found",
|
||||
xo_warnx("memstat_mtl_find: malloc type %s not found",
|
||||
MBUF_TAG_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
tag_count = memstat_get_count(mtp);
|
||||
tag_bytes = memstat_get_bytes(mtp);
|
||||
#else /* __rtems__ */
|
||||
tag_count = 0;
|
||||
tag_bytes = 0;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBOP_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found",
|
||||
xo_warnx("memstat_mtl_find: zone %s not found",
|
||||
MBUF_JUMBOP_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
jumbop_count = memstat_get_count(mtp);
|
||||
jumbop_bytes = memstat_get_bytes(mtp);
|
||||
jumbop_limit = memstat_get_countlimit(mtp);
|
||||
jumbop_free = memstat_get_free(mtp);
|
||||
jumbop_failures = memstat_get_failures(mtp);
|
||||
@@ -189,12 +198,11 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO9_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found",
|
||||
xo_warnx("memstat_mtl_find: zone %s not found",
|
||||
MBUF_JUMBO9_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
jumbo9_count = memstat_get_count(mtp);
|
||||
jumbo9_bytes = memstat_get_bytes(mtp);
|
||||
jumbo9_limit = memstat_get_countlimit(mtp);
|
||||
jumbo9_free = memstat_get_free(mtp);
|
||||
jumbo9_failures = memstat_get_failures(mtp);
|
||||
@@ -203,48 +211,55 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
|
||||
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO16_MEM_NAME);
|
||||
if (mtp == NULL) {
|
||||
warnx("memstat_mtl_find: zone %s not found",
|
||||
xo_warnx("memstat_mtl_find: zone %s not found",
|
||||
MBUF_JUMBO16_MEM_NAME);
|
||||
goto out;
|
||||
}
|
||||
jumbo16_count = memstat_get_count(mtp);
|
||||
jumbo16_bytes = memstat_get_bytes(mtp);
|
||||
jumbo16_limit = memstat_get_countlimit(mtp);
|
||||
jumbo16_free = memstat_get_free(mtp);
|
||||
jumbo16_failures = memstat_get_failures(mtp);
|
||||
jumbo16_sleeps = memstat_get_sleeps(mtp);
|
||||
jumbo16_size = memstat_get_size(mtp);
|
||||
|
||||
printf("%ju/%ju/%ju mbufs in use (current/cache/total)\n",
|
||||
xo_open_container("mbuf-statistics");
|
||||
|
||||
xo_emit("{:mbuf-current/%ju}/{:mbuf-cache/%ju}/{:mbuf-total/%ju} "
|
||||
"{N:mbufs in use (current\\/cache\\/total)}\n",
|
||||
mbuf_count + packet_count, mbuf_free + packet_free,
|
||||
mbuf_count + packet_count + mbuf_free + packet_free);
|
||||
|
||||
printf("%ju/%ju/%ju/%ju mbuf clusters in use "
|
||||
"(current/cache/total/max)\n",
|
||||
xo_emit("{:cluster-current/%ju}/{:cluster-cache/%ju}/"
|
||||
"{:cluster-total/%ju}/{:cluster-max/%ju} "
|
||||
"{N:mbuf clusters in use (current\\/cache\\/total\\/max)}\n",
|
||||
cluster_count - packet_free, cluster_free + packet_free,
|
||||
cluster_count + cluster_free, cluster_limit);
|
||||
|
||||
printf("%ju/%ju mbuf+clusters out of packet secondary zone in use "
|
||||
"(current/cache)\n",
|
||||
xo_emit("{:packet-count/%ju}/{:packet-free/%ju} "
|
||||
"{N:mbuf+clusters out of packet secondary zone in use "
|
||||
"(current\\/cache)}\n",
|
||||
packet_count, packet_free);
|
||||
|
||||
printf("%ju/%ju/%ju/%ju %juk (page size) jumbo clusters in use "
|
||||
"(current/cache/total/max)\n",
|
||||
xo_emit("{:jumbo-count/%ju}/{:jumbo-cache/%ju}/{:jumbo-total/%ju}/"
|
||||
"{:jumbo-max/%ju} {:jumbo-page-size/%ju}{U:k} {N:(page size)} "
|
||||
"{N:jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
|
||||
jumbop_count, jumbop_free, jumbop_count + jumbop_free,
|
||||
jumbop_limit, jumbop_size / 1024);
|
||||
|
||||
printf("%ju/%ju/%ju/%ju 9k jumbo clusters in use "
|
||||
"(current/cache/total/max)\n",
|
||||
xo_emit("{:jumbo9-count/%ju}/{:jumbo9-cache/%ju}/"
|
||||
"{:jumbo9-total/%ju}/{:jumbo9-max/%ju} "
|
||||
"{N:9k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
|
||||
jumbo9_count, jumbo9_free, jumbo9_count + jumbo9_free,
|
||||
jumbo9_limit);
|
||||
|
||||
printf("%ju/%ju/%ju/%ju 16k jumbo clusters in use "
|
||||
"(current/cache/total/max)\n",
|
||||
xo_emit("{:jumbo16-count/%ju}/{:jumbo16-cache/%ju}/"
|
||||
"{:jumbo16-total/%ju}/{:jumbo16-limit/%ju} "
|
||||
"{N:16k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
|
||||
jumbo16_count, jumbo16_free, jumbo16_count + jumbo16_free,
|
||||
jumbo16_limit);
|
||||
|
||||
#if 0
|
||||
printf("%ju mbuf tags in use\n", tag_count);
|
||||
xo_emit("{:tag-count/%ju} {N:mbuf tags in use}\n", tag_count);
|
||||
#endif
|
||||
|
||||
/*-
|
||||
@@ -292,48 +307,74 @@ mbpr(void *kvmd, u_long mbaddr)
|
||||
*/
|
||||
bytes_total = bytes_inuse + bytes_incache;
|
||||
|
||||
printf("%juK/%juK/%juK bytes allocated to network "
|
||||
"(current/cache/total)\n", bytes_inuse / 1024,
|
||||
bytes_incache / 1024, bytes_total / 1024);
|
||||
xo_emit("{:bytes-in-use/%ju}{U:K}/{:bytes-in-cache/%ju}{U:K}/"
|
||||
"{:bytes-total/%ju}{U:K} "
|
||||
"{N:bytes allocated to network (current\\/cache\\/total)}\n",
|
||||
bytes_inuse / 1024, bytes_incache / 1024, bytes_total / 1024);
|
||||
|
||||
printf("%ju/%ju/%ju requests for mbufs denied (mbufs/clusters/"
|
||||
"mbuf+clusters)\n", mbuf_failures, cluster_failures,
|
||||
packet_failures);
|
||||
printf("%ju/%ju/%ju requests for mbufs delayed (mbufs/clusters/"
|
||||
"mbuf+clusters)\n", mbuf_sleeps, cluster_sleeps,
|
||||
packet_sleeps);
|
||||
xo_emit("{:mbuf-failures/%ju}/{:cluster-failures/%ju}/"
|
||||
"{:packet-failures/%ju} {N:requests for mbufs denied "
|
||||
"(mbufs\\/clusters\\/mbuf+clusters)}\n",
|
||||
mbuf_failures, cluster_failures, packet_failures);
|
||||
xo_emit("{:mbuf-sleeps/%ju}/{:cluster-sleeps/%ju}/{:packet-sleeps/%ju} "
|
||||
"{N:requests for mbufs delayed "
|
||||
"(mbufs\\/clusters\\/mbuf+clusters)}\n",
|
||||
mbuf_sleeps, cluster_sleeps, packet_sleeps);
|
||||
|
||||
printf("%ju/%ju/%ju requests for jumbo clusters delayed "
|
||||
"(%juk/9k/16k)\n", jumbop_sleeps, jumbo9_sleeps,
|
||||
jumbo16_sleeps, jumbop_size / 1024);
|
||||
printf("%ju/%ju/%ju requests for jumbo clusters denied "
|
||||
"(%juk/9k/16k)\n", jumbop_failures, jumbo9_failures,
|
||||
jumbo16_failures, jumbop_size / 1024);
|
||||
xo_emit("{:jumbop-sleeps/%ju}/{:jumbo9-sleeps/%ju}/"
|
||||
"{:jumbo16-sleeps/%ju} {N:/requests for jumbo clusters delayed "
|
||||
"(%juk\\/9k\\/16k)}\n",
|
||||
jumbop_sleeps, jumbo9_sleeps, jumbo16_sleeps, jumbop_size / 1024);
|
||||
xo_emit("{:jumbop-failures/%ju}/{:jumbo9-failures/%ju}/"
|
||||
"{:jumbo16-failures/%ju} {N:/requests for jumbo clusters denied "
|
||||
"(%juk\\/9k\\/16k)}\n",
|
||||
jumbop_failures, jumbo9_failures, jumbo16_failures,
|
||||
jumbop_size / 1024);
|
||||
|
||||
if (live) {
|
||||
mlen = sizeof(nsfbufs);
|
||||
if (!sysctlbyname("kern.ipc.nsfbufs", &nsfbufs, &mlen, NULL,
|
||||
0) &&
|
||||
!sysctlbyname("kern.ipc.nsfbufsused", &nsfbufsused,
|
||||
&mlen, NULL, 0) &&
|
||||
!sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak,
|
||||
&mlen, NULL, 0))
|
||||
printf("%d/%d/%d sfbufs in use (current/peak/max)\n",
|
||||
nsfbufsused, nsfbufspeak, nsfbufs);
|
||||
mlen = sizeof(mbstat);
|
||||
if (sysctlbyname("kern.ipc.mbstat", &mbstat, &mlen, NULL, 0)) {
|
||||
warn("kern.ipc.mbstat");
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (kread(mbaddr, (char *)&mbstat, sizeof mbstat) != 0)
|
||||
goto out;
|
||||
}
|
||||
printf("%lu requests for sfbufs denied\n", mbstat.sf_allocfail);
|
||||
printf("%lu requests for sfbufs delayed\n", mbstat.sf_allocwait);
|
||||
printf("%lu requests for I/O initiated by sendfile\n",
|
||||
mbstat.sf_iocnt);
|
||||
printf("%lu calls to protocol drain routines\n", mbstat.m_drain);
|
||||
mlen = sizeof(nsfbufs);
|
||||
if (live &&
|
||||
sysctlbyname("kern.ipc.nsfbufs", &nsfbufs, &mlen, NULL, 0) == 0 &&
|
||||
sysctlbyname("kern.ipc.nsfbufsused", &nsfbufsused, &mlen,
|
||||
NULL, 0) == 0 &&
|
||||
sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak, &mlen,
|
||||
NULL, 0) == 0)
|
||||
xo_emit("{:nsfbufs-current/%d}/{:nsfbufs-peak/%d}/"
|
||||
"{:nsfbufs/%d} "
|
||||
"{N:sfbufs in use (current\\/peak\\/max)}\n",
|
||||
nsfbufsused, nsfbufspeak, nsfbufs);
|
||||
|
||||
if (fetch_stats("kern.ipc.sfstat", mbaddr, &sfstat, sizeof(sfstat),
|
||||
kread_counters) != 0)
|
||||
goto out;
|
||||
|
||||
xo_emit("{:sendfile-syscalls/%ju} {N:sendfile syscalls}\n",
|
||||
(uintmax_t)sfstat.sf_syscalls);
|
||||
xo_emit("{:sendfile-no-io/%ju} "
|
||||
"{N:sendfile syscalls completed without I\\/O request}\n",
|
||||
(uintmax_t)sfstat.sf_noiocnt);
|
||||
xo_emit("{:sendfile-io-count/%ju} "
|
||||
"{N:requests for I\\/O initiated by sendfile}\n",
|
||||
(uintmax_t)sfstat.sf_iocnt);
|
||||
xo_emit("{:sendfile-pages-sent/%ju} "
|
||||
"{N:pages read by sendfile as part of a request}\n",
|
||||
(uintmax_t)sfstat.sf_pages_read);
|
||||
xo_emit("{:sendfile-pages-valid/%ju} "
|
||||
"{N:pages were valid at time of a sendfile request}\n",
|
||||
(uintmax_t)sfstat.sf_pages_valid);
|
||||
xo_emit("{:sendfile-requested-readahead/%ju} "
|
||||
"{N:pages were requested for read ahead by applications}\n",
|
||||
(uintmax_t)sfstat.sf_rhpages_requested);
|
||||
xo_emit("{:sendfile-readahead/%ju} "
|
||||
"{N:pages were read ahead by sendfile}\n",
|
||||
(uintmax_t)sfstat.sf_rhpages_read);
|
||||
xo_emit("{:sendfile-busy-encounters/%ju} "
|
||||
"{N:times sendfile encountered an already busy page}\n",
|
||||
(uintmax_t)sfstat.sf_busy);
|
||||
xo_emit("{:sfbufs-alloc-failed/%ju} {N:requests for sfbufs denied}\n",
|
||||
(uintmax_t)sfstat.sf_allocfail);
|
||||
xo_emit("{:sfbufs-alloc-wait/%ju} {N:requests for sfbufs delayed}\n",
|
||||
(uintmax_t)sfstat.sf_allocwait);
|
||||
out:
|
||||
xo_close_container("mbuf-statistics");
|
||||
memstat_mtl_free(mtlp);
|
||||
}
|
||||
|
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1989 Stephen Deering
|
||||
* Copyright (c) 1992, 1993
|
||||
@@ -39,6 +43,9 @@
|
||||
* @(#)mroute.c 8.2 (Berkeley) 4/28/95
|
||||
*/
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -70,8 +77,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <libxo/xo.h>
|
||||
#include "netstat.h"
|
||||
|
||||
#include "nl_defs.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-mroute-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void print_bw_meter(struct bw_meter *, int *);
|
||||
static void print_mfc(struct mfc *, int, int *);
|
||||
@@ -79,105 +92,128 @@ static void print_mfc(struct mfc *, int, int *);
|
||||
static void
|
||||
print_bw_meter(struct bw_meter *bw_meter, int *banner_printed)
|
||||
{
|
||||
char s0[256], s1[256], s2[256], s3[256];
|
||||
char s1[256], s2[256], s3[256];
|
||||
struct timeval now, end, delta;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
if (! *banner_printed) {
|
||||
printf(" Bandwidth Meters\n");
|
||||
printf(" %-30s", "Measured(Start|Packets|Bytes)");
|
||||
printf(" %s", "Type");
|
||||
printf(" %-30s", "Thresh(Interval|Packets|Bytes)");
|
||||
printf(" Remain");
|
||||
printf("\n");
|
||||
xo_open_list("bandwidth-meter");
|
||||
xo_emit(" {T:Bandwidth Meters}\n");
|
||||
xo_emit(" {T:/%-30s}", "Measured(Start|Packets|Bytes)");
|
||||
xo_emit(" {T:/%s}", "Type");
|
||||
xo_emit(" {T:/%-30s}", "Thresh(Interval|Packets|Bytes)");
|
||||
xo_emit(" {T:Remain}");
|
||||
xo_emit("\n");
|
||||
*banner_printed = 1;
|
||||
}
|
||||
|
||||
xo_open_instance("bandwidth-meter");
|
||||
|
||||
/* The measured values */
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) {
|
||||
sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_measured.b_packets);
|
||||
else
|
||||
xo_emit("{e:measured-packets/%ju}",
|
||||
(uintmax_t)bw_meter->bm_measured.b_packets);
|
||||
} else
|
||||
sprintf(s1, "?");
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) {
|
||||
sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_measured.b_bytes);
|
||||
else
|
||||
xo_emit("{e:measured-bytes/%ju}",
|
||||
(uintmax_t)bw_meter->bm_measured.b_bytes);
|
||||
} else
|
||||
sprintf(s2, "?");
|
||||
sprintf(s0, "%lu.%lu|%s|%s",
|
||||
(u_long)bw_meter->bm_start_time.tv_sec,
|
||||
(u_long)bw_meter->bm_start_time.tv_usec,
|
||||
s1, s2);
|
||||
printf(" %-30s", s0);
|
||||
xo_emit(" {[:-30}{:start-time/%lu.%06lu}|{q:measured-packets/%s}"
|
||||
"|{q:measured-bytes%s}{]:}",
|
||||
(u_long)bw_meter->bm_start_time.tv_sec,
|
||||
(u_long)bw_meter->bm_start_time.tv_usec, s1, s2);
|
||||
|
||||
/* The type of entry */
|
||||
sprintf(s0, "%s", "?");
|
||||
if (bw_meter->bm_flags & BW_METER_GEQ)
|
||||
sprintf(s0, "%s", ">=");
|
||||
else if (bw_meter->bm_flags & BW_METER_LEQ)
|
||||
sprintf(s0, "%s", "<=");
|
||||
printf(" %-3s", s0);
|
||||
xo_emit(" {t:type/%-3s}", (bw_meter->bm_flags & BW_METER_GEQ) ? ">=" :
|
||||
(bw_meter->bm_flags & BW_METER_LEQ) ? "<=" : "?");
|
||||
|
||||
/* The threshold values */
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) {
|
||||
sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_threshold.b_packets);
|
||||
else
|
||||
xo_emit("{e:threshold-packets/%ju}",
|
||||
(uintmax_t)bw_meter->bm_threshold.b_packets);
|
||||
} else
|
||||
sprintf(s1, "?");
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
|
||||
if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) {
|
||||
sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_threshold.b_bytes);
|
||||
else
|
||||
xo_emit("{e:threshold-bytes/%ju}",
|
||||
(uintmax_t)bw_meter->bm_threshold.b_bytes);
|
||||
} else
|
||||
sprintf(s2, "?");
|
||||
sprintf(s0, "%lu.%lu|%s|%s",
|
||||
(u_long)bw_meter->bm_threshold.b_time.tv_sec,
|
||||
(u_long)bw_meter->bm_threshold.b_time.tv_usec,
|
||||
s1, s2);
|
||||
printf(" %-30s", s0);
|
||||
|
||||
xo_emit(" {[:-30}{:threshold-time/%lu.%06lu}|{q:threshold-packets/%s}"
|
||||
"|{q:threshold-bytes%s}{]:}",
|
||||
(u_long)bw_meter->bm_threshold.b_time.tv_sec,
|
||||
(u_long)bw_meter->bm_threshold.b_time.tv_usec, s1, s2);
|
||||
|
||||
/* Remaining time */
|
||||
timeradd(&bw_meter->bm_start_time,
|
||||
&bw_meter->bm_threshold.b_time, &end);
|
||||
if (timercmp(&now, &end, <=)) {
|
||||
timersub(&end, &now, &delta);
|
||||
sprintf(s3, "%lu.%lu",
|
||||
sprintf(s3, "%lu.%06lu",
|
||||
(u_long)delta.tv_sec,
|
||||
(u_long)delta.tv_usec);
|
||||
} else {
|
||||
/* Negative time */
|
||||
timersub(&now, &end, &delta);
|
||||
sprintf(s3, "-%lu.%lu",
|
||||
sprintf(s3, "-%lu.06%lu",
|
||||
(u_long)delta.tv_sec,
|
||||
(u_long)delta.tv_usec);
|
||||
}
|
||||
printf(" %s", s3);
|
||||
xo_emit(" {:remaining-time/%s}", s3);
|
||||
|
||||
printf("\n");
|
||||
xo_open_instance("bandwidth-meter");
|
||||
|
||||
xo_emit("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
print_mfc(struct mfc *m, int maxvif, int *banner_printed)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr *sa = (struct sockaddr *)&sin;
|
||||
struct bw_meter bw_meter, *bwm;
|
||||
int bw_banner_printed;
|
||||
int error;
|
||||
vifi_t vifi;
|
||||
|
||||
bw_banner_printed = 0;
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
|
||||
if (! *banner_printed) {
|
||||
printf("\nIPv4 Multicast Forwarding Table\n"
|
||||
" Origin Group "
|
||||
" Packets In-Vif Out-Vifs:Ttls\n");
|
||||
xo_open_list("multicast-forwarding-entry");
|
||||
xo_emit("\n{T:IPv4 Multicast Forwarding Table}\n"
|
||||
" {T:Origin} {T:Group} "
|
||||
" {T:Packets In-Vif} {T:Out-Vifs:Ttls}\n");
|
||||
*banner_printed = 1;
|
||||
}
|
||||
|
||||
printf(" %-15.15s", routename(m->mfc_origin.s_addr));
|
||||
printf(" %-15.15s", routename(m->mfc_mcastgrp.s_addr));
|
||||
printf(" %9lu", m->mfc_pkt_cnt);
|
||||
printf(" %3d ", m->mfc_parent);
|
||||
memcpy(&sin.sin_addr, &m->mfc_origin, sizeof(sin.sin_addr));
|
||||
xo_emit(" {:origin-address/%-15.15s}", routename(sa, numeric_addr));
|
||||
memcpy(&sin.sin_addr, &m->mfc_mcastgrp, sizeof(sin.sin_addr));
|
||||
xo_emit(" {:group-address/%-15.15s}",
|
||||
routename(sa, numeric_addr));
|
||||
xo_emit(" {:sent-packets/%9lu}", m->mfc_pkt_cnt);
|
||||
xo_emit(" {:parent/%3d} ", m->mfc_parent);
|
||||
xo_open_list("vif-ttl");
|
||||
for (vifi = 0; vifi <= maxvif; vifi++) {
|
||||
if (m->mfc_ttls[vifi] > 0)
|
||||
printf(" %u:%u", vifi, m->mfc_ttls[vifi]);
|
||||
if (m->mfc_ttls[vifi] > 0) {
|
||||
xo_open_instance("vif-ttl");
|
||||
xo_emit(" {k:vif/%u}:{:ttl/%u}", vifi,
|
||||
m->mfc_ttls[vifi]);
|
||||
xo_close_instance("vif-ttl");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
xo_close_list("vif-ttl");
|
||||
xo_emit("\n");
|
||||
|
||||
/*
|
||||
* XXX We break the rules and try to use KVM to read the
|
||||
@@ -192,14 +228,19 @@ print_mfc(struct mfc *m, int maxvif, int *banner_printed)
|
||||
print_bw_meter(&bw_meter, &bw_banner_printed);
|
||||
bwm = bw_meter.bm_mfc_next;
|
||||
}
|
||||
if (banner_printed)
|
||||
xo_close_list("bandwidth-meter");
|
||||
}
|
||||
|
||||
void
|
||||
mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
mroutepr()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr *sa = (struct sockaddr *)&sin;
|
||||
struct vif viftable[MAXVIFS];
|
||||
struct vif *v;
|
||||
struct mfc *m;
|
||||
u_long pmfchashtbl, pmfctablesize, pviftbl;
|
||||
int banner_printed;
|
||||
int saved_numeric_addr;
|
||||
size_t len;
|
||||
@@ -208,6 +249,10 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
saved_numeric_addr = numeric_addr;
|
||||
numeric_addr = 1;
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* The VIF table will move to hanging off the struct if_info for
|
||||
@@ -222,23 +267,27 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
* functionality was deprecated, as PIM does not use it.
|
||||
*/
|
||||
maxvif = 0;
|
||||
pmfchashtbl = pmfctablesize = pviftbl = 0;
|
||||
|
||||
len = sizeof(viftable);
|
||||
if (live) {
|
||||
if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL,
|
||||
0) < 0) {
|
||||
warn("sysctl: net.inet.ip.viftable");
|
||||
xo_warn("sysctl: net.inet.ip.viftable");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#ifndef __rtems__
|
||||
} else {
|
||||
pmfchashtbl = nl[N_MFCHASHTBL].n_value;
|
||||
pmfctablesize = nl[N_MFCTABLESIZE].n_value;
|
||||
pviftbl = nl[N_VIFTABLE].n_value;
|
||||
|
||||
if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) {
|
||||
xo_warnx("No IPv4 MROUTING kernel support.");
|
||||
return;
|
||||
}
|
||||
|
||||
kread(pviftbl, (char *)viftable, sizeof(viftable));
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
warnx("mroutepr: not implemented");
|
||||
return;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
banner_printed = 0;
|
||||
for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
|
||||
@@ -247,23 +296,31 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
|
||||
maxvif = vifi;
|
||||
if (!banner_printed) {
|
||||
printf("\nIPv4 Virtual Interface Table\n"
|
||||
" Vif Thresh Local-Address "
|
||||
"Remote-Address Pkts-In Pkts-Out\n");
|
||||
xo_emit("\n{T:IPv4 Virtual Interface Table\n"
|
||||
" Vif Thresh Local-Address "
|
||||
"Remote-Address Pkts-In Pkts-Out}\n");
|
||||
banner_printed = 1;
|
||||
xo_open_list("vif");
|
||||
}
|
||||
|
||||
printf(" %2u %6u %-15.15s",
|
||||
xo_open_instance("vif");
|
||||
memcpy(&sin.sin_addr, &v->v_lcl_addr, sizeof(sin.sin_addr));
|
||||
xo_emit(" {:vif/%2u} {:threshold/%6u} {:route/%-15.15s}",
|
||||
/* opposite math of add_vif() */
|
||||
vifi, v->v_threshold,
|
||||
routename(v->v_lcl_addr.s_addr));
|
||||
printf(" %-15.15s", (v->v_flags & VIFF_TUNNEL) ?
|
||||
routename(v->v_rmt_addr.s_addr) : "");
|
||||
routename(sa, numeric_addr));
|
||||
memcpy(&sin.sin_addr, &v->v_rmt_addr, sizeof(sin.sin_addr));
|
||||
xo_emit(" {:source/%-15.15s}", (v->v_flags & VIFF_TUNNEL) ?
|
||||
routename(sa, numeric_addr) : "");
|
||||
|
||||
printf(" %9lu %9lu\n", v->v_pkt_in, v->v_pkt_out);
|
||||
xo_emit(" {:received-packets/%9lu} {:sent-packets/%9lu}\n",
|
||||
v->v_pkt_in, v->v_pkt_out);
|
||||
xo_close_instance("vif");
|
||||
}
|
||||
if (!banner_printed)
|
||||
printf("\nIPv4 Virtual Interface Table is empty\n");
|
||||
if (banner_printed)
|
||||
xo_close_list("vif");
|
||||
else
|
||||
xo_emit("\n{T:IPv4 Virtual Interface Table is empty}\n");
|
||||
|
||||
banner_printed = 0;
|
||||
|
||||
@@ -283,19 +340,19 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
len = 0;
|
||||
if (sysctlbyname("net.inet.ip.mfctable", NULL, &len, NULL,
|
||||
0) < 0) {
|
||||
warn("sysctl: net.inet.ip.mfctable");
|
||||
xo_warn("sysctl: net.inet.ip.mfctable");
|
||||
return;
|
||||
}
|
||||
|
||||
mfctable = malloc(len);
|
||||
if (mfctable == NULL) {
|
||||
warnx("malloc %lu bytes", (u_long)len);
|
||||
xo_warnx("malloc %lu bytes", (u_long)len);
|
||||
return;
|
||||
}
|
||||
if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL,
|
||||
0) < 0) {
|
||||
free(mfctable);
|
||||
warn("sysctl: net.inet.ip.mfctable");
|
||||
xo_warn("sysctl: net.inet.ip.mfctable");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -304,8 +361,10 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
print_mfc(m++, maxvif, &banner_printed);
|
||||
len -= sizeof(*m);
|
||||
}
|
||||
if (banner_printed)
|
||||
xo_close_list("multicast-forwarding-entry");
|
||||
if (len != 0)
|
||||
warnx("print_mfc: %lu trailing bytes", (u_long)len);
|
||||
xo_warnx("print_mfc: %lu trailing bytes", (u_long)len);
|
||||
|
||||
free(mfctable);
|
||||
} else {
|
||||
@@ -318,14 +377,14 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
error = kread(pmfctablesize, (char *)&mfctablesize,
|
||||
sizeof(u_long));
|
||||
if (error) {
|
||||
warn("kread: mfctablesize");
|
||||
xo_warn("kread: mfctablesize");
|
||||
return;
|
||||
}
|
||||
|
||||
len = sizeof(*mfchashtbl) * mfctablesize;
|
||||
mfchashtbl = malloc(len);
|
||||
if (mfchashtbl == NULL) {
|
||||
warnx("malloc %lu bytes", (u_long)len);
|
||||
xo_warnx("malloc %lu bytes", (u_long)len);
|
||||
return;
|
||||
}
|
||||
kread(pmfchashtbl, (char *)&mfchashtbl, len);
|
||||
@@ -336,6 +395,8 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
print_mfc(m, maxvif, &banner_printed);
|
||||
}
|
||||
}
|
||||
if (banner_printed)
|
||||
xo_close_list("multicast-forwarding-entry");
|
||||
|
||||
free(mfchashtbl);
|
||||
#else /* __rtems__ */
|
||||
@@ -345,55 +406,65 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
|
||||
}
|
||||
|
||||
if (!banner_printed)
|
||||
printf("\nIPv4 Multicast Forwarding Table is empty\n");
|
||||
xo_emit("\n{T:IPv4 Multicast Forwarding Table is empty}\n");
|
||||
|
||||
printf("\n");
|
||||
xo_emit("\n");
|
||||
numeric_addr = saved_numeric_addr;
|
||||
}
|
||||
|
||||
void
|
||||
mrt_stats(u_long mstaddr)
|
||||
mrt_stats()
|
||||
{
|
||||
struct mrtstat mrtstat;
|
||||
size_t len = sizeof mrtstat;
|
||||
u_long mstaddr;
|
||||
|
||||
if (live) {
|
||||
if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL,
|
||||
0) < 0) {
|
||||
warn("sysctl: net.inet.ip.mrtstat");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#ifndef __rtems__
|
||||
kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
warnx("mrt_stats: not implemented");
|
||||
mstaddr = nl[N_MRTSTAT].n_value;
|
||||
|
||||
if (mstaddr == 0) {
|
||||
fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
|
||||
return;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
printf("IPv4 multicast forwarding:\n");
|
||||
if (fetch_stats("net.inet.ip.mrtstat", mstaddr, &mrtstat,
|
||||
sizeof(mrtstat), kread_counters) != 0)
|
||||
return;
|
||||
|
||||
xo_emit("{T:IPv4 multicast forwarding}:\n");
|
||||
|
||||
#define p(f, m) if (mrtstat.f || sflag <= 1) \
|
||||
printf(m, mrtstat.f, plural(mrtstat.f))
|
||||
xo_emit(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
|
||||
#define p2(f, m) if (mrtstat.f || sflag <= 1) \
|
||||
printf(m, mrtstat.f, plurales(mrtstat.f))
|
||||
xo_emit(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
|
||||
|
||||
p(mrts_mfc_lookups, "\t%lu multicast forwarding cache lookup%s\n");
|
||||
p2(mrts_mfc_misses, "\t%lu multicast forwarding cache miss%s\n");
|
||||
p(mrts_upcalls, "\t%lu upcall%s to multicast routing daemon\n");
|
||||
p(mrts_upq_ovflw, "\t%lu upcall queue overflow%s\n");
|
||||
xo_open_container("multicast-statistics");
|
||||
|
||||
p(mrts_mfc_lookups, "\t{:cache-lookups/%ju} "
|
||||
"{N:/multicast forwarding cache lookup%s}\n");
|
||||
p2(mrts_mfc_misses, "\t{:cache-misses/%ju} "
|
||||
"{N:/multicast forwarding cache miss%s}\n");
|
||||
p(mrts_upcalls, "\t{:upcalls-total/%ju} "
|
||||
"{N:/upcall%s to multicast routing daemon}\n");
|
||||
p(mrts_upq_ovflw, "\t{:upcall-overflows/%ju} "
|
||||
"{N:/upcall queue overflow%s}\n");
|
||||
p(mrts_upq_sockfull,
|
||||
"\t%lu upcall%s dropped due to full socket buffer\n");
|
||||
p(mrts_cache_cleanups, "\t%lu cache cleanup%s\n");
|
||||
p(mrts_no_route, "\t%lu datagram%s with no route for origin\n");
|
||||
p(mrts_bad_tunnel, "\t%lu datagram%s arrived with bad tunneling\n");
|
||||
p(mrts_cant_tunnel, "\t%lu datagram%s could not be tunneled\n");
|
||||
p(mrts_wrong_if, "\t%lu datagram%s arrived on wrong interface\n");
|
||||
p(mrts_drop_sel, "\t%lu datagram%s selectively dropped\n");
|
||||
p(mrts_q_overflow, "\t%lu datagram%s dropped due to queue overflow\n");
|
||||
p(mrts_pkt2large, "\t%lu datagram%s dropped for being too large\n");
|
||||
"\t{:upcalls-dropped-full-buffer/%ju} "
|
||||
"{N:/upcall%s dropped due to full socket buffer}\n");
|
||||
p(mrts_cache_cleanups, "\t{:cache-cleanups/%ju} "
|
||||
"{N:/cache cleanup%s}\n");
|
||||
p(mrts_no_route, "\t{:dropped-no-origin/%ju} "
|
||||
"{N:/datagram%s with no route for origin}\n");
|
||||
p(mrts_bad_tunnel, "\t{:dropped-bad-tunnel/%ju} "
|
||||
"{N:/datagram%s arrived with bad tunneling}\n");
|
||||
p(mrts_cant_tunnel, "\t{:dropped-could-not-tunnel/%ju} "
|
||||
"{N:/datagram%s could not be tunneled}\n");
|
||||
p(mrts_wrong_if, "\t{:dropped-wrong-incoming-interface/%ju} "
|
||||
"{N:/datagram%s arrived on wrong interface}\n");
|
||||
p(mrts_drop_sel, "\t{:dropped-selectively/%ju} "
|
||||
"{N:/datagram%s selectively dropped}\n");
|
||||
p(mrts_q_overflow, "\t{:dropped-queue-overflow/%ju} "
|
||||
"{N:/datagram%s dropped due to queue overflow}\n");
|
||||
p(mrts_pkt2large, "\t{:dropped-too-large/%ju} "
|
||||
"{N:/datagram%s dropped for being too large}\n");
|
||||
|
||||
#undef p2
|
||||
#undef p
|
||||
|
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
@@ -67,6 +71,9 @@
|
||||
* @(#)mroute.c 8.2 (Berkeley) 4/28/95
|
||||
*/
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -81,7 +88,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@@ -90,24 +96,29 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <libxo/xo.h>
|
||||
|
||||
#define KERNEL 1
|
||||
#include <netinet6/ip6_mroute.h>
|
||||
#undef KERNEL
|
||||
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-mroute6-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define WID_ORG (Wflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */
|
||||
#define WID_GRP (Wflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */
|
||||
|
||||
void
|
||||
mroute6pr(u_long mfcaddr, u_long mifaddr)
|
||||
mroute6pr()
|
||||
{
|
||||
struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
|
||||
struct mif6 mif6table[MAXMIFS];
|
||||
struct mif6_sctl mif6table[MAXMIFS];
|
||||
struct mf6c mfc;
|
||||
struct rtdetq rte, *rtep;
|
||||
struct mif6 *mifp;
|
||||
struct mif6_sctl *mifp;
|
||||
mifi_t mifi;
|
||||
int i;
|
||||
int banner_printed;
|
||||
@@ -116,72 +127,56 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
|
||||
long int waitings;
|
||||
size_t len;
|
||||
|
||||
if (live == 0)
|
||||
return;
|
||||
|
||||
len = sizeof(mif6table);
|
||||
if (live) {
|
||||
if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
|
||||
NULL, 0) < 0) {
|
||||
warn("sysctl: net.inet6.ip6.mif6table");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#ifndef __rtems__
|
||||
kread(mifaddr, (char *)mif6table, sizeof(mif6table));
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
warnx("mroute6pr: not implemented");
|
||||
if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len, NULL, 0) <
|
||||
0) {
|
||||
xo_warn("sysctl: net.inet6.ip6.mif6table");
|
||||
return;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
saved_numeric_addr = numeric_addr;
|
||||
numeric_addr = 1;
|
||||
banner_printed = 0;
|
||||
|
||||
for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
|
||||
struct ifnet ifnet;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
if (mifp->m6_ifp == NULL)
|
||||
if (mifp->m6_ifp == 0)
|
||||
continue;
|
||||
|
||||
/* XXX KVM */
|
||||
kread((u_long)mifp->m6_ifp, (char *)&ifnet, sizeof(ifnet));
|
||||
|
||||
maxmif = mifi;
|
||||
if (!banner_printed) {
|
||||
printf("\nIPv6 Multicast Interface Table\n"
|
||||
" Mif Rate PhyIF "
|
||||
"Pkts-In Pkts-Out\n");
|
||||
xo_open_list("multicast-interface");
|
||||
xo_emit("\n{T:IPv6 Multicast Interface Table}\n"
|
||||
"{T: Mif Rate PhyIF Pkts-In Pkts-Out}\n");
|
||||
banner_printed = 1;
|
||||
}
|
||||
|
||||
printf(" %2u %4d",
|
||||
mifi, mifp->m6_rate_limit);
|
||||
printf(" %5s", (mifp->m6_flags & MIFF_REGISTER) ?
|
||||
"reg0" : if_indextoname(ifnet.if_index, ifname));
|
||||
xo_open_instance("multicast-interface");
|
||||
xo_emit(" {:mif/%2u} {:rate-limit/%4d}",
|
||||
mifi, mifp->m6_rate_limit);
|
||||
xo_emit(" {:ifname/%5s}", (mifp->m6_flags & MIFF_REGISTER) ?
|
||||
"reg0" : if_indextoname(mifp->m6_ifp, ifname));
|
||||
|
||||
printf(" %9ju %9ju\n", (uintmax_t)mifp->m6_pkt_in,
|
||||
xo_emit(" {:received-packets/%9ju} {:sent-packets/%9ju}\n",
|
||||
(uintmax_t)mifp->m6_pkt_in,
|
||||
(uintmax_t)mifp->m6_pkt_out);
|
||||
xo_close_instance("multicast-interface");
|
||||
}
|
||||
if (!banner_printed)
|
||||
printf("\nIPv6 Multicast Interface Table is empty\n");
|
||||
if (banner_printed)
|
||||
xo_open_list("multicast-interface");
|
||||
else
|
||||
xo_emit("\n{T:IPv6 Multicast Interface Table is empty}\n");
|
||||
|
||||
len = sizeof(mf6ctable);
|
||||
if (live) {
|
||||
if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
|
||||
NULL, 0) < 0) {
|
||||
warn("sysctl: net.inet6.ip6.mf6ctable");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#ifndef __rtems__
|
||||
kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
warnx("mroute6pr: not implemented");
|
||||
if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len, NULL, 0) <
|
||||
0) {
|
||||
xo_warn("sysctl: net.inet6.ip6.mf6ctable");
|
||||
return;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
banner_printed = 0;
|
||||
|
||||
@@ -190,19 +185,26 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
|
||||
while(mfcp) {
|
||||
kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
|
||||
if (!banner_printed) {
|
||||
printf ("\nIPv6 Multicast Forwarding Cache\n");
|
||||
printf(" %-*.*s %-*.*s %s",
|
||||
WID_ORG, WID_ORG, "Origin",
|
||||
WID_GRP, WID_GRP, "Group",
|
||||
" Packets Waits In-Mif Out-Mifs\n");
|
||||
xo_open_list("multicast-forwarding-cache");
|
||||
xo_emit("\n"
|
||||
"{T:IPv6 Multicast Forwarding Cache}\n");
|
||||
xo_emit(" {T:%-*.*s} {T:%-*.*s} {T:%s}",
|
||||
WID_ORG, WID_ORG, "Origin",
|
||||
WID_GRP, WID_GRP, "Group",
|
||||
" Packets Waits In-Mif Out-Mifs\n");
|
||||
banner_printed = 1;
|
||||
}
|
||||
|
||||
printf(" %-*.*s", WID_ORG, WID_ORG,
|
||||
routename6(&mfc.mf6c_origin));
|
||||
printf(" %-*.*s", WID_GRP, WID_GRP,
|
||||
routename6(&mfc.mf6c_mcastgrp));
|
||||
printf(" %9ju", (uintmax_t)mfc.mf6c_pkt_cnt);
|
||||
xo_open_instance("multicast-forwarding-cache");
|
||||
|
||||
xo_emit(" {:origin/%-*.*s}", WID_ORG, WID_ORG,
|
||||
routename(sin6tosa(&mfc.mf6c_origin),
|
||||
numeric_addr));
|
||||
xo_emit(" {:group/%-*.*s}", WID_GRP, WID_GRP,
|
||||
routename(sin6tosa(&mfc.mf6c_mcastgrp),
|
||||
numeric_addr));
|
||||
xo_emit(" {:total-packets/%9ju}",
|
||||
(uintmax_t)mfc.mf6c_pkt_cnt);
|
||||
|
||||
for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
|
||||
waitings++;
|
||||
@@ -210,74 +212,79 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
|
||||
kread((u_long)rtep, (char *)&rte, sizeof(rte));
|
||||
rtep = rte.next;
|
||||
}
|
||||
printf(" %3ld", waitings);
|
||||
xo_emit(" {:waitings/%3ld}", waitings);
|
||||
|
||||
if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)
|
||||
printf(" --- ");
|
||||
xo_emit(" --- ");
|
||||
else
|
||||
printf(" %3d ", mfc.mf6c_parent);
|
||||
xo_emit(" {:parent/%3d} ", mfc.mf6c_parent);
|
||||
xo_open_list("mif");
|
||||
for (mifi = 0; mifi <= maxmif; mifi++) {
|
||||
if (IF_ISSET(mifi, &mfc.mf6c_ifset))
|
||||
printf(" %u", mifi);
|
||||
xo_emit(" {l:%u}", mifi);
|
||||
}
|
||||
printf("\n");
|
||||
xo_close_list("mif");
|
||||
xo_emit("\n");
|
||||
|
||||
mfcp = mfc.mf6c_next;
|
||||
xo_close_instance("multicast-forwarding-cache");
|
||||
}
|
||||
}
|
||||
if (!banner_printed)
|
||||
printf("\nIPv6 Multicast Forwarding Table is empty\n");
|
||||
if (banner_printed)
|
||||
xo_close_list("multicast-forwarding-cache");
|
||||
else
|
||||
xo_emit("\n{T:IPv6 Multicast Forwarding Table is empty}\n");
|
||||
|
||||
printf("\n");
|
||||
xo_emit("\n");
|
||||
numeric_addr = saved_numeric_addr;
|
||||
}
|
||||
|
||||
void
|
||||
mrt6_stats(u_long mstaddr)
|
||||
mrt6_stats()
|
||||
{
|
||||
struct mrt6stat mrtstat;
|
||||
size_t len = sizeof mrtstat;
|
||||
|
||||
if (live) {
|
||||
if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
|
||||
NULL, 0) < 0) {
|
||||
warn("sysctl: net.inet6.ip6.mrt6stat");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#ifndef __rtems__
|
||||
kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
|
||||
#else /* __rtems__ */
|
||||
{
|
||||
warnx("mrt6_stats: not implemented");
|
||||
if (fetch_stats("net.inet6.ip6.mrt6stat", 0, &mrtstat,
|
||||
sizeof(mrtstat), kread_counters) != 0)
|
||||
return;
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
||||
printf("IPv6 multicast forwarding:\n");
|
||||
xo_open_container("multicast-statistics");
|
||||
xo_emit("{T:IPv6 multicast forwarding}:\n");
|
||||
|
||||
#define p(f, m) if (mrtstat.f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
|
||||
xo_emit(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
|
||||
#define p2(f, m) if (mrtstat.f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
|
||||
xo_emit(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
|
||||
|
||||
p(mrt6s_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
|
||||
p2(mrt6s_mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
|
||||
p(mrt6s_upcalls, "\t%ju upcall%s to multicast routing daemon\n");
|
||||
p(mrt6s_upq_ovflw, "\t%ju upcall queue overflow%s\n");
|
||||
p(mrt6s_upq_sockfull,
|
||||
"\t%ju upcall%s dropped due to full socket buffer\n");
|
||||
p(mrt6s_cache_cleanups, "\t%ju cache cleanup%s\n");
|
||||
p(mrt6s_no_route, "\t%ju datagram%s with no route for origin\n");
|
||||
p(mrt6s_bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
|
||||
p(mrt6s_cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
|
||||
p(mrt6s_wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
|
||||
p(mrt6s_drop_sel, "\t%ju datagram%s selectively dropped\n");
|
||||
p(mrt6s_q_overflow,
|
||||
"\t%ju datagram%s dropped due to queue overflow\n");
|
||||
p(mrt6s_pkt2large, "\t%ju datagram%s dropped for being too large\n");
|
||||
p(mrt6s_mfc_lookups, "\t{:cache-lookups/%ju} "
|
||||
"{N:/multicast forwarding cache lookup%s}\n");
|
||||
p2(mrt6s_mfc_misses, "\t{:cache-misses/%ju} "
|
||||
"{N:/multicast forwarding cache miss%s}\n");
|
||||
p(mrt6s_upcalls, "\t{:upcalls/%ju} "
|
||||
"{N:/upcall%s to multicast routing daemon}\n");
|
||||
p(mrt6s_upq_ovflw, "\t{:upcall-overflows/%ju} "
|
||||
"{N:/upcall queue overflow%s}\n");
|
||||
p(mrt6s_upq_sockfull, "\t{:upcalls-dropped-full-buffer/%ju} "
|
||||
"{N:/upcall%s dropped due to full socket buffer}\n");
|
||||
p(mrt6s_cache_cleanups, "\t{:cache-cleanups/%ju} "
|
||||
"{N:/cache cleanup%s}\n");
|
||||
p(mrt6s_no_route, "\t{:dropped-no-origin/%ju} "
|
||||
"{N:/datagram%s with no route for origin}\n");
|
||||
p(mrt6s_bad_tunnel, "\t{:dropped-bad-tunnel/%ju} "
|
||||
"{N:/datagram%s arrived with bad tunneling}\n");
|
||||
p(mrt6s_cant_tunnel, "\t{:dropped-could-not-tunnel/%ju} "
|
||||
"{N:/datagram%s could not be tunneled}\n");
|
||||
p(mrt6s_wrong_if, "\t{:dropped-wrong-incoming-interface/%ju} "
|
||||
"{N:/datagram%s arrived on wrong interface}\n");
|
||||
p(mrt6s_drop_sel, "\t{:dropped-selectively/%ju} "
|
||||
"{N:/datagram%s selectively dropped}\n");
|
||||
p(mrt6s_q_overflow, "\t{:dropped-queue-overflow/%ju} "
|
||||
"{N:/datagram%s dropped due to queue overflow}\n");
|
||||
p(mrt6s_pkt2large, "\t{:dropped-too-large/%ju} "
|
||||
"{N:/datagram%s dropped for being too large}\n");
|
||||
|
||||
#undef p2
|
||||
#undef p
|
||||
xo_close_container("multicast-statistics");
|
||||
}
|
||||
#endif /*INET6*/
|
||||
|
@@ -32,12 +32,10 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#define rt_tables netstat_rt_tables
|
||||
#define routename rtems_shell_netstats_routername
|
||||
#define netname rtems_shell_netstats_netname
|
||||
#define sotoxsocket rtems_shell_netstats_sotoxsocket
|
||||
#endif /* __rtems__ */
|
||||
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
||||
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
|
||||
#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
|
||||
|
||||
extern int Aflag; /* show addresses of protocol control block */
|
||||
extern int aflag; /* show all sockets (including servers) */
|
||||
extern int bflag; /* show i/f total bytes in/out */
|
||||
@@ -51,6 +49,7 @@ extern int noutputs; /* how much outputs before we exit */
|
||||
extern int numeric_addr; /* show addresses numerically */
|
||||
extern int numeric_port; /* show ports numerically */
|
||||
extern int rflag; /* show routing tables (or routing stats) */
|
||||
extern int Rflag; /* show flowid / RSS information */
|
||||
extern int sflag; /* show protocol statistics */
|
||||
extern int Tflag; /* show TCP control block info */
|
||||
extern int Wflag; /* wide display */
|
||||
@@ -62,15 +61,16 @@ extern int interval; /* repeat interval for i/f stats */
|
||||
extern char *interface; /* desired i/f for stats, or NULL for all i/fs */
|
||||
extern int unit; /* unit number for above */
|
||||
|
||||
extern int af; /* address family */
|
||||
extern int live; /* true if we are examining a live system */
|
||||
#ifdef __rtems__
|
||||
extern int protopr_initialized;
|
||||
extern int do_rtent;
|
||||
extern struct radix_node_head **rt_tables;
|
||||
#endif /* __rtems__ */
|
||||
|
||||
typedef int kreadfn_t(u_long, void *, size_t);
|
||||
int fetch_stats(const char *, u_long, void *, size_t, kreadfn_t);
|
||||
int fetch_stats_ro(const char *, u_long, void *, size_t, kreadfn_t);
|
||||
|
||||
int kread(u_long addr, void *buf, size_t size);
|
||||
uint64_t kread_counter(u_long addr);
|
||||
int kread_counters(u_long addr, void *buf, size_t size);
|
||||
void kset_dpcpu(u_int);
|
||||
const char *plural(uintmax_t);
|
||||
const char *plurales(uintmax_t);
|
||||
const char *pluralies(uintmax_t);
|
||||
@@ -107,15 +107,13 @@ void icmp6_stats(u_long, const char *, int, int);
|
||||
void icmp6_ifstats(char *);
|
||||
void pim6_stats(u_long, const char *, int, int);
|
||||
void rip6_stats(u_long, const char *, int, int);
|
||||
void mroute6pr(u_long, u_long);
|
||||
void mrt6_stats(u_long);
|
||||
void mroute6pr(void);
|
||||
void mrt6_stats(void);
|
||||
|
||||
struct sockaddr_in6;
|
||||
struct in6_addr;
|
||||
void in6_fillscopeid(struct sockaddr_in6 *);
|
||||
char *routename6(struct sockaddr_in6 *);
|
||||
const char *netname6(struct sockaddr_in6 *, struct in6_addr *);
|
||||
void inet6print(struct in6_addr *, int, const char *, int);
|
||||
void inet6print(const char *, struct in6_addr *, int, const char *, int);
|
||||
#endif /*INET6*/
|
||||
|
||||
#ifdef IPSEC
|
||||
@@ -124,60 +122,30 @@ void pfkey_stats(u_long, const char *, int, int);
|
||||
|
||||
void mbpr(void *, u_long);
|
||||
|
||||
void netisr_stats(void *);
|
||||
void netisr_stats(void);
|
||||
|
||||
void hostpr(u_long, u_long);
|
||||
void impstats(u_long, u_long);
|
||||
|
||||
void intpr(int, u_long, void (*)(char *));
|
||||
void intpr(void (*)(char *), int);
|
||||
|
||||
void pr_rthdr(int);
|
||||
void pr_family(int);
|
||||
void rt_stats(u_long, u_long);
|
||||
char *ipx_pnet(struct sockaddr *);
|
||||
char *ipx_phost(struct sockaddr *);
|
||||
char *ns_phost(struct sockaddr *);
|
||||
void upHex(char *);
|
||||
void rt_stats(void);
|
||||
void flowtable_stats(void);
|
||||
|
||||
char *routename(in_addr_t);
|
||||
char *netname(in_addr_t, u_long);
|
||||
char *atalk_print(struct sockaddr *, int);
|
||||
char *atalk_print2(struct sockaddr *, struct sockaddr *, int);
|
||||
char *ipx_print(struct sockaddr *);
|
||||
char *ns_print(struct sockaddr *);
|
||||
void routepr(u_long);
|
||||
|
||||
void ipxprotopr(u_long, const char *, int, int);
|
||||
void spx_stats(u_long, const char *, int, int);
|
||||
void ipx_stats(u_long, const char *, int, int);
|
||||
void ipxerr_stats(u_long, const char *, int, int);
|
||||
|
||||
void nsprotopr(u_long, const char *, int, int);
|
||||
void spp_stats(u_long, const char *, int, int);
|
||||
void idp_stats(u_long, const char *, int, int);
|
||||
void nserr_stats(u_long, const char *, int, int);
|
||||
|
||||
void atalkprotopr(u_long, const char *, int, int);
|
||||
void ddp_stats(u_long, const char *, int, int);
|
||||
char *routename(struct sockaddr *, int);
|
||||
const char *netname(struct sockaddr *, struct sockaddr *);
|
||||
void routepr(int, int);
|
||||
|
||||
#ifdef NETGRAPH
|
||||
void netgraphprotopr(u_long, const char *, int, int);
|
||||
#endif
|
||||
|
||||
void unixpr(u_long, u_long, u_long, u_long, u_long);
|
||||
void unixpr(u_long, u_long, u_long, u_long, u_long, bool *);
|
||||
|
||||
void esis_stats(u_long, const char *, int, int);
|
||||
void clnp_stats(u_long, const char *, int, int);
|
||||
void cltp_stats(u_long, const char *, int, int);
|
||||
void iso_protopr(u_long, const char *, int, int);
|
||||
void iso_protopr1(u_long, int);
|
||||
void tp_protopr(u_long, const char *, int, int);
|
||||
void tp_inproto(u_long);
|
||||
void tp_stats(caddr_t, caddr_t);
|
||||
|
||||
void mroutepr(u_long, u_long, u_long);
|
||||
void mrt_stats(u_long);
|
||||
void mroutepr(void);
|
||||
void mrt_stats(void);
|
||||
void bpf_stats(char *);
|
||||
#ifdef __rtems__
|
||||
void rtems_bsd_netstat_inet_init(void);
|
||||
#include <nlist.h> /* necessary for global "nl" variable */
|
||||
#endif /* __rtems__ */
|
||||
|
58
freebsd/usr.bin/netstat/nl_defs.h
Normal file
58
freebsd/usr.bin/netstat/nl_defs.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <nlist.h>
|
||||
#ifndef __rtems__
|
||||
extern const struct nlist nl[];
|
||||
#else /* __rtems__ */
|
||||
extern struct nlist nl[];
|
||||
#endif /* __rtems__ */
|
||||
#define N_AHSTAT 0
|
||||
#define N_ARPSTAT 1
|
||||
#define N_CARPSTATS 2
|
||||
#define N_DIVCBINFO 3
|
||||
#define N_ESPSTAT 4
|
||||
#define N_ICMP6STAT 5
|
||||
#define N_ICMPSTAT 6
|
||||
#define N_IGMPSTAT 7
|
||||
#define N_IP6STAT 8
|
||||
#define N_IPCOMPSTAT 9
|
||||
#define N_IPSEC4STAT 10
|
||||
#define N_IPSEC6STAT 11
|
||||
#define N_IPSTAT 12
|
||||
#define N_MF6CTABLE 13
|
||||
#define N_MFCHASHTBL 14
|
||||
#define N_MFCTABLESIZE 15
|
||||
#define N_MIF6TABLE 16
|
||||
#define N_MRT6STAT 17
|
||||
#define N_MRTSTAT 18
|
||||
#define N_NETISR_BINDTHREADS 19
|
||||
#define N_NETISR_DEFAULTQLIMIT 20
|
||||
#define N_NETISR_DISPATCH_POLICY 21
|
||||
#define N_NETISR_MAXPROT 22
|
||||
#define N_NETISR_MAXQLIMIT 23
|
||||
#define N_NETISR_MAXTHREADS 24
|
||||
#define N_NETISR_PROTO 25
|
||||
#define N_NGSOCKLIST 26
|
||||
#define N_NWS 27
|
||||
#define N_NWS_ARRAY 28
|
||||
#define N_NWS_COUNT 29
|
||||
#define N_PFKEYSTAT 30
|
||||
#define N_PFSYNCSTATS 31
|
||||
#define N_PIM6STAT 32
|
||||
#define N_PIMSTAT 33
|
||||
#define N_RIP6STAT 34
|
||||
#define N_RIPCBINFO 35
|
||||
#define N_RTREE 36
|
||||
#define N_RTSTAT 37
|
||||
#define N_RTTRASH 38
|
||||
#define N_SCTPSTAT 39
|
||||
#define N_SFSTAT 40
|
||||
#define N_TCBINFO 41
|
||||
#define N_TCPSTAT 42
|
||||
#define N_TCPS_STATES 43
|
||||
#define N_UDBINFO 44
|
||||
#define N_UDPSTAT 45
|
||||
#define N_UNP_COUNT 46
|
||||
#define N_UNP_DHEAD 47
|
||||
#define N_UNP_GENCNT 48
|
||||
#define N_UNP_SHEAD 49
|
||||
#define N_UNP_SPHEAD 50
|
||||
#define N_VIFTABLE 51
|
75
freebsd/usr.bin/netstat/nl_symbols.c
Normal file
75
freebsd/usr.bin/netstat/nl_symbols.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <nlist.h>
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-nl_symbols-data.h"
|
||||
#endif /* __rtems__ */
|
||||
#ifndef __rtems__
|
||||
const struct nlist nl[] = {
|
||||
#else /* __rtems__ */
|
||||
/* This is not as constant as it seems. The call to kresolve_list(..) in main.c
|
||||
* might change something. */
|
||||
struct nlist nl[] = {
|
||||
#endif /* __rtems__ */
|
||||
{ .n_name = "_ahstat" },
|
||||
{ .n_name = "_arpstat" },
|
||||
{ .n_name = "_carpstats" },
|
||||
{ .n_name = "_divcbinfo" },
|
||||
{ .n_name = "_espstat" },
|
||||
{ .n_name = "_icmp6stat" },
|
||||
{ .n_name = "_icmpstat" },
|
||||
{ .n_name = "_igmpstat" },
|
||||
{ .n_name = "_ip6stat" },
|
||||
{ .n_name = "_ipcompstat" },
|
||||
{ .n_name = "_ipsec4stat" },
|
||||
{ .n_name = "_ipsec6stat" },
|
||||
{ .n_name = "_ipstat" },
|
||||
{ .n_name = "_mf6ctable" },
|
||||
{ .n_name = "_mfchashtbl" },
|
||||
{ .n_name = "_mfctablesize" },
|
||||
{ .n_name = "_mif6table" },
|
||||
{ .n_name = "_mrt6stat" },
|
||||
{ .n_name = "_mrtstat" },
|
||||
{ .n_name = "_netisr_bindthreads" },
|
||||
{ .n_name = "_netisr_defaultqlimit" },
|
||||
{ .n_name = "_netisr_dispatch_policy" },
|
||||
{ .n_name = "_netisr_maxprot" },
|
||||
{ .n_name = "_netisr_maxqlimit" },
|
||||
{ .n_name = "_netisr_maxthreads" },
|
||||
{ .n_name = "_netisr_proto" },
|
||||
{ .n_name = "_ngsocklist" },
|
||||
{ .n_name = "_nws" },
|
||||
{ .n_name = "_nws_array" },
|
||||
{ .n_name = "_nws_count" },
|
||||
{ .n_name = "_pfkeystat" },
|
||||
{ .n_name = "_pfsyncstats" },
|
||||
{ .n_name = "_pim6stat" },
|
||||
{ .n_name = "_pimstat" },
|
||||
{ .n_name = "_rip6stat" },
|
||||
{ .n_name = "_ripcbinfo" },
|
||||
{ .n_name = "_rtree" },
|
||||
{ .n_name = "_rtstat" },
|
||||
{ .n_name = "_rttrash" },
|
||||
{ .n_name = "_sctpstat" },
|
||||
{ .n_name = "_sfstat" },
|
||||
{ .n_name = "_tcbinfo" },
|
||||
{ .n_name = "_tcpstat" },
|
||||
{ .n_name = "_tcps_states" },
|
||||
{ .n_name = "_udbinfo" },
|
||||
{ .n_name = "_udpstat" },
|
||||
{ .n_name = "_unp_count" },
|
||||
{ .n_name = "_unp_dhead" },
|
||||
{ .n_name = "_unp_gencnt" },
|
||||
{ .n_name = "_unp_shead" },
|
||||
{ .n_name = "_unp_sphead" },
|
||||
{ .n_name = "_viftable" },
|
||||
{ .n_name = NULL },
|
||||
};
|
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/* $NetBSD: inet.c,v 1.35.2.1 1999/04/29 14:57:08 perry Exp $ */
|
||||
/* $KAME: ipsec.c,v 1.25 2001/03/12 09:04:39 itojun Exp $ */
|
||||
/*-
|
||||
@@ -65,6 +69,9 @@ static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -83,7 +90,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
#include <libxo/xo.h>
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-pfkey-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef IPSEC
|
||||
|
||||
@@ -101,8 +113,7 @@ static const char *pfkey_msgtype_names (int);
|
||||
static const char *
|
||||
pfkey_msgtype_names(int x)
|
||||
{
|
||||
const int max =
|
||||
sizeof(pfkey_msgtypenames)/sizeof(pfkey_msgtypenames[0]);
|
||||
const int max = nitems(pfkey_msgtypenames);
|
||||
static char buf[20];
|
||||
|
||||
if (x < max && pfkey_msgtypenames[x])
|
||||
@@ -120,59 +131,89 @@ pfkey_stats(u_long off, const char *name, int family __unused,
|
||||
|
||||
if (off == 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&pfkeystat, sizeof(pfkeystat));
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
xo_open_container(name);
|
||||
kread_counters(off, (char *)&pfkeystat, sizeof(pfkeystat));
|
||||
|
||||
#define p(f, m) if (pfkeystat.f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f))
|
||||
xo_emit(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f))
|
||||
|
||||
/* userland -> kernel */
|
||||
p(out_total, "\t%ju request%s sent from userland\n");
|
||||
p(out_bytes, "\t%ju byte%s sent from userland\n");
|
||||
p(out_total, "\t{:sent-requests/%ju} "
|
||||
"{N:/request%s sent from userland}\n");
|
||||
p(out_bytes, "\t{:sent-bytes/%ju} "
|
||||
"{N:/byte%s sent from userland}\n");
|
||||
for (first = 1, type = 0;
|
||||
type < sizeof(pfkeystat.out_msgtype)/sizeof(pfkeystat.out_msgtype[0]);
|
||||
type++) {
|
||||
type<sizeof(pfkeystat.out_msgtype)/sizeof(pfkeystat.out_msgtype[0]);
|
||||
type++) {
|
||||
if (pfkeystat.out_msgtype[type] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\thistogram by message type:\n");
|
||||
xo_open_list("output-histogram");
|
||||
xo_emit("\t{T:histogram by message type}:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %ju\n", pfkey_msgtype_names(type),
|
||||
(uintmax_t)pfkeystat.out_msgtype[type]);
|
||||
xo_open_instance("output-histogram");
|
||||
xo_emit("\t\t{k::type/%s}: {:count/%ju}\n",
|
||||
pfkey_msgtype_names(type),
|
||||
(uintmax_t)pfkeystat.out_msgtype[type]);
|
||||
xo_close_instance("output-histogram");
|
||||
}
|
||||
p(out_invlen, "\t%ju message%s with invalid length field\n");
|
||||
p(out_invver, "\t%ju message%s with invalid version field\n");
|
||||
p(out_invmsgtype, "\t%ju message%s with invalid message type field\n");
|
||||
p(out_tooshort, "\t%ju message%s too short\n");
|
||||
p(out_nomem, "\t%ju message%s with memory allocation failure\n");
|
||||
p(out_dupext, "\t%ju message%s with duplicate extension\n");
|
||||
p(out_invexttype, "\t%ju message%s with invalid extension type\n");
|
||||
p(out_invsatype, "\t%ju message%s with invalid sa type\n");
|
||||
p(out_invaddr, "\t%ju message%s with invalid address extension\n");
|
||||
if (!first)
|
||||
xo_close_list("output-histogram");
|
||||
|
||||
p(out_invlen, "\t{:dropped-bad-length/%ju} "
|
||||
"{N:/message%s with invalid length field}\n");
|
||||
p(out_invver, "\t{:dropped-bad-version/%ju} "
|
||||
"{N:/message%s with invalid version field}\n");
|
||||
p(out_invmsgtype, "\t{:dropped-bad-type/%ju} "
|
||||
"{N:/message%s with invalid message type field}\n");
|
||||
p(out_tooshort, "\t{:dropped-too-short/%ju} "
|
||||
"{N:/message%s too short}\n");
|
||||
p(out_nomem, "\t{:dropped-no-memory/%ju} "
|
||||
"{N:/message%s with memory allocation failure}\n");
|
||||
p(out_dupext, "\t{:dropped-duplicate-extension/%ju} "
|
||||
"{N:/message%s with duplicate extension}\n");
|
||||
p(out_invexttype, "\t{:dropped-bad-extension/%ju} "
|
||||
"{N:/message%s with invalid extension type}\n");
|
||||
p(out_invsatype, "\t{:dropped-bad-sa-type/%ju} "
|
||||
"{N:/message%s with invalid sa type}\n");
|
||||
p(out_invaddr, "\t{:dropped-bad-address-extension/%ju} "
|
||||
"{N:/message%s with invalid address extension}\n");
|
||||
|
||||
/* kernel -> userland */
|
||||
p(in_total, "\t%ju request%s sent to userland\n");
|
||||
p(in_bytes, "\t%ju byte%s sent to userland\n");
|
||||
p(in_total, "\t{:received-requests/%ju} "
|
||||
"{N:/request%s sent to userland}\n");
|
||||
p(in_bytes, "\t{:received-bytes/%ju} "
|
||||
"{N:/byte%s sent to userland}\n");
|
||||
for (first = 1, type = 0;
|
||||
type < sizeof(pfkeystat.in_msgtype)/sizeof(pfkeystat.in_msgtype[0]);
|
||||
type++) {
|
||||
type < sizeof(pfkeystat.in_msgtype)/sizeof(pfkeystat.in_msgtype[0]);
|
||||
type++) {
|
||||
if (pfkeystat.in_msgtype[type] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\thistogram by message type:\n");
|
||||
xo_open_list("input-histogram");
|
||||
xo_emit("\t{T:histogram by message type}:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %ju\n", pfkey_msgtype_names(type),
|
||||
(uintmax_t)pfkeystat.in_msgtype[type]);
|
||||
xo_open_instance("input-histogram");
|
||||
xo_emit("\t\t{k:type/%s}: {:count/%ju}\n",
|
||||
pfkey_msgtype_names(type),
|
||||
(uintmax_t)pfkeystat.in_msgtype[type]);
|
||||
xo_close_instance("input-histogram");
|
||||
}
|
||||
p(in_msgtarget[KEY_SENDUP_ONE],
|
||||
"\t%ju message%s toward single socket\n");
|
||||
p(in_msgtarget[KEY_SENDUP_ALL],
|
||||
"\t%ju message%s toward all sockets\n");
|
||||
if (!first)
|
||||
xo_close_list("input-histogram");
|
||||
p(in_msgtarget[KEY_SENDUP_ONE], "\t{:received-one-socket/%ju} "
|
||||
"{N:/message%s toward single socket}\n");
|
||||
p(in_msgtarget[KEY_SENDUP_ALL], "\t{:received-all-sockets/%ju} "
|
||||
"{N:/message%s toward all sockets}\n");
|
||||
p(in_msgtarget[KEY_SENDUP_REGISTERED],
|
||||
"\t%ju message%s toward registered sockets\n");
|
||||
p(in_nomem, "\t%ju message%s with memory allocation failure\n");
|
||||
"\t{:received-registered-sockets/%ju} "
|
||||
"{N:/message%s toward registered sockets}\n");
|
||||
p(in_nomem, "\t{:discarded-no-memory/%ju} "
|
||||
"{N:/message%s with memory allocation failure}\n");
|
||||
#undef p
|
||||
xo_close_container(name);
|
||||
}
|
||||
#endif /* IPSEC */
|
||||
|
File diff suppressed because it is too large
Load Diff
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-bpf-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-bpf-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* bpf.c */
|
41
freebsd/usr.bin/netstat/rtems-bsd-netstat-data.h
Normal file
41
freebsd/usr.bin/netstat/rtems-bsd-netstat-data.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
/* bpf.c */
|
||||
/* flowtable.c */
|
||||
/* if.c */
|
||||
/* inet6.c */
|
||||
/* inet.c */
|
||||
/* ipsec.c */
|
||||
/* main.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int Aflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int aflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int bflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int dflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int gflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int hflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int iflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int Lflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int mflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int noutputs);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int numeric_addr);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int numeric_port);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int rflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int Rflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int sflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int Wflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int Tflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int xflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int zflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int interval);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern char *interface);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int unit);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern int live);
|
||||
/* mbuf.c */
|
||||
/* mroute6.c */
|
||||
/* mroute.c */
|
||||
/* nl_symbols.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, extern struct nlist nl[53]);
|
||||
/* pfkey.c */
|
||||
/* route.c */
|
||||
/* sctp.c */
|
||||
/* unix.c */
|
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* flowtable.c */
|
5
freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h
Normal file
5
freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* if.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static sig_atomic_t signalled);
|
8
freebsd/usr.bin/netstat/rtems-bsd-netstat-inet-data.h
Normal file
8
freebsd/usr.bin/netstat/rtems-bsd-netstat-inet-data.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* inet.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int udp_done);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int tcp_done);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int sdp_done);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int protopr_first);
|
8
freebsd/usr.bin/netstat/rtems-bsd-netstat-inet6-data.h
Normal file
8
freebsd/usr.bin/netstat/rtems-bsd-netstat-inet6-data.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* inet6.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char ntop_buf[]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char const *ip6nh[]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char const *srcrule_str[]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char const *icmp6names[]);
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-ipsec-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-ipsec-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* ipsec.c */
|
10
freebsd/usr.bin/netstat/rtems-bsd-netstat-main-data.h
Normal file
10
freebsd/usr.bin/netstat/rtems-bsd-netstat-main-data.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* main.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static kvm_t *kvmd);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char *nlistf);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static char *memf);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int Bflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int pflag);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int af);
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mbuf-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mbuf-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* mbuf.c */
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mroute-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mroute-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* mroute.c */
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mroute6-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-mroute6-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* mroute6.c */
|
83
freebsd/usr.bin/netstat/rtems-bsd-netstat-namespace.h
Normal file
83
freebsd/usr.bin/netstat/rtems-bsd-netstat-namespace.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
/* bpf.c */
|
||||
#define bpf_stats _bsd_netstat_bpf_stats
|
||||
/* flowtable.c */
|
||||
#define flowtable_stats _bsd_netstat_flowtable_stats
|
||||
/* if.c */
|
||||
#define intpr _bsd_netstat_intpr
|
||||
/* inet6.c */
|
||||
#define inet6name _bsd_netstat_inet6name
|
||||
#define inet6print _bsd_netstat_inet6print
|
||||
#define rip6_stats _bsd_netstat_rip6_stats
|
||||
#define pim6_stats _bsd_netstat_pim6_stats
|
||||
#define icmp6_ifstats _bsd_netstat_icmp6_ifstats
|
||||
#define icmp6_stats _bsd_netstat_icmp6_stats
|
||||
#define ip6_ifstats _bsd_netstat_ip6_ifstats
|
||||
#define ip6_stats _bsd_netstat_ip6_stats
|
||||
/* inet.c */
|
||||
#define inetname _bsd_netstat_inetname
|
||||
#define inetprint _bsd_netstat_inetprint
|
||||
#define pim_stats _bsd_netstat_pim_stats
|
||||
#define igmp_stats _bsd_netstat_igmp_stats
|
||||
#define icmp_stats _bsd_netstat_icmp_stats
|
||||
#define arp_stats _bsd_netstat_arp_stats
|
||||
#define ip_stats _bsd_netstat_ip_stats
|
||||
#define carp_stats _bsd_netstat_carp_stats
|
||||
#define udp_stats _bsd_netstat_udp_stats
|
||||
#define tcp_stats _bsd_netstat_tcp_stats
|
||||
#define protopr _bsd_netstat_protopr
|
||||
#define sotoxsocket _bsd_netstat_sotoxsocket
|
||||
/* ipsec.c */
|
||||
/* main.c */
|
||||
#define Aflag _bsd_netstat_Aflag
|
||||
#define aflag _bsd_netstat_aflag
|
||||
#define bflag _bsd_netstat_bflag
|
||||
#define dflag _bsd_netstat_dflag
|
||||
#define gflag _bsd_netstat_gflag
|
||||
#define hflag _bsd_netstat_hflag
|
||||
#define iflag _bsd_netstat_iflag
|
||||
#define Lflag _bsd_netstat_Lflag
|
||||
#define mflag _bsd_netstat_mflag
|
||||
#define noutputs _bsd_netstat_noutputs
|
||||
#define numeric_addr _bsd_netstat_numeric_addr
|
||||
#define numeric_port _bsd_netstat_numeric_port
|
||||
#define rflag _bsd_netstat_rflag
|
||||
#define Rflag _bsd_netstat_Rflag
|
||||
#define sflag _bsd_netstat_sflag
|
||||
#define Wflag _bsd_netstat_Wflag
|
||||
#define Tflag _bsd_netstat_Tflag
|
||||
#define xflag _bsd_netstat_xflag
|
||||
#define zflag _bsd_netstat_zflag
|
||||
#define interval _bsd_netstat_interval
|
||||
#define interface _bsd_netstat_interface
|
||||
#define unit _bsd_netstat_unit
|
||||
#define live _bsd_netstat_live
|
||||
#define pluralies _bsd_netstat_pluralies
|
||||
#define plurales _bsd_netstat_plurales
|
||||
#define plural _bsd_netstat_plural
|
||||
#define kread_counters _bsd_netstat_kread_counters
|
||||
#define kread_counter _bsd_netstat_kread_counter
|
||||
#define kread _bsd_netstat_kread
|
||||
#define kset_dpcpu _bsd_netstat_kset_dpcpu
|
||||
#define fetch_stats_ro _bsd_netstat_fetch_stats_ro
|
||||
#define fetch_stats _bsd_netstat_fetch_stats
|
||||
/* mbuf.c */
|
||||
#define mbpr _bsd_netstat_mbpr
|
||||
/* mroute6.c */
|
||||
#define mrt6_stats _bsd_netstat_mrt6_stats
|
||||
#define mroute6pr _bsd_netstat_mroute6pr
|
||||
/* mroute.c */
|
||||
#define mrt_stats _bsd_netstat_mrt_stats
|
||||
#define mroutepr _bsd_netstat_mroutepr
|
||||
/* nl_symbols.c */
|
||||
#define nl _bsd_netstat_nl
|
||||
/* pfkey.c */
|
||||
/* route.c */
|
||||
#define rt_stats _bsd_netstat_rt_stats
|
||||
#define in6_fillscopeid _bsd_netstat_in6_fillscopeid
|
||||
#define netname _bsd_netstat_netname
|
||||
#define routename _bsd_netstat_routename
|
||||
#define pr_family _bsd_netstat_pr_family
|
||||
#define routepr _bsd_netstat_routepr
|
||||
/* sctp.c */
|
||||
/* unix.c */
|
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* nl_symbols.c */
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-pfkey-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-pfkey-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* pfkey.c */
|
15
freebsd/usr.bin/netstat/rtems-bsd-netstat-route-data.h
Normal file
15
freebsd/usr.bin/netstat/rtems-bsd-netstat-route-data.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* route.c */
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static struct ifmap_entry *ifmap);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int ifmap_size);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static struct timespec uptime);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_dst);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_gw);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_flags);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_pksent);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_mtu);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_if);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int wid_expire);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static int masktolen[]);
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-sctp-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-sctp-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* sctp.c */
|
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-unix-data.h
Normal file
4
freebsd/usr.bin/netstat/rtems-bsd-netstat-unix-data.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/* generated by userspace-header-gen.py */
|
||||
#include <rtems/linkersets.h>
|
||||
#include "rtems-bsd-netstat-data.h"
|
||||
/* unix.c */
|
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001-2007, by Weongyo Jeong. All rights reserved.
|
||||
* Copyright (c) 2011, by Michael Tuexen. All rights reserved.
|
||||
@@ -37,6 +41,9 @@ static char sccsid[] = "@(#)sctp.c 0.1 (Berkeley) 4/18/2007";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -60,9 +67,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "netstat.h"
|
||||
#include <libxo/xo.h>
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-sctp-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#ifdef SCTP
|
||||
|
||||
@@ -79,7 +91,7 @@ static void sctp_statesprint(uint32_t state);
|
||||
#define NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT 0x8
|
||||
#define NETSTAT_SCTP_STATES_SHUTDOWN_PENDING 0x9
|
||||
|
||||
char *sctpstates[] = {
|
||||
static const char *sctpstates[] = {
|
||||
"CLOSED",
|
||||
"BOUND",
|
||||
"LISTEN",
|
||||
@@ -92,114 +104,39 @@ char *sctpstates[] = {
|
||||
"SHUTDOWN_PENDING"
|
||||
};
|
||||
|
||||
LIST_HEAD(xladdr_list, xladdr_entry) xladdr_head;
|
||||
static LIST_HEAD(xladdr_list, xladdr_entry) xladdr_head;
|
||||
struct xladdr_entry {
|
||||
struct xsctp_laddr *xladdr;
|
||||
LIST_ENTRY(xladdr_entry) xladdr_entries;
|
||||
};
|
||||
|
||||
LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head;
|
||||
static LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head;
|
||||
struct xraddr_entry {
|
||||
struct xsctp_raddr *xraddr;
|
||||
LIST_ENTRY(xraddr_entry) xraddr_entries;
|
||||
struct xsctp_raddr *xraddr;
|
||||
LIST_ENTRY(xraddr_entry) xraddr_entries;
|
||||
};
|
||||
|
||||
/*
|
||||
* Construct an Internet address representation.
|
||||
* If numeric_addr has been supplied, give
|
||||
* numeric value, otherwise try for symbolic name.
|
||||
*/
|
||||
#ifdef INET
|
||||
static char *
|
||||
inetname(struct in_addr *inp)
|
||||
{
|
||||
char *cp;
|
||||
static char line[MAXHOSTNAMELEN];
|
||||
struct hostent *hp;
|
||||
struct netent *np;
|
||||
|
||||
cp = 0;
|
||||
if (!numeric_addr && inp->s_addr != INADDR_ANY) {
|
||||
int net = inet_netof(*inp);
|
||||
int lna = inet_lnaof(*inp);
|
||||
|
||||
if (lna == INADDR_ANY) {
|
||||
np = getnetbyaddr(net, AF_INET);
|
||||
if (np)
|
||||
cp = np->n_name;
|
||||
}
|
||||
if (cp == 0) {
|
||||
hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
|
||||
if (hp) {
|
||||
cp = hp->h_name;
|
||||
trimdomain(cp, strlen(cp));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inp->s_addr == INADDR_ANY)
|
||||
strcpy(line, "*");
|
||||
else if (cp) {
|
||||
strlcpy(line, cp, sizeof(line));
|
||||
} else {
|
||||
inp->s_addr = ntohl(inp->s_addr);
|
||||
#define C(x) ((u_int)((x) & 0xff))
|
||||
sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24),
|
||||
C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr));
|
||||
inp->s_addr = htonl(inp->s_addr);
|
||||
}
|
||||
return (line);
|
||||
}
|
||||
char *
|
||||
inetname(struct in_addr *inp);
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
static char ntop_buf[INET6_ADDRSTRLEN];
|
||||
|
||||
static char *
|
||||
inet6name(struct in6_addr *in6p)
|
||||
{
|
||||
char *cp;
|
||||
static char line[50];
|
||||
struct hostent *hp;
|
||||
static char domain[MAXHOSTNAMELEN];
|
||||
static int first = 1;
|
||||
|
||||
if (first && !numeric_addr) {
|
||||
first = 0;
|
||||
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
|
||||
(cp = index(domain, '.')))
|
||||
(void) strcpy(domain, cp + 1);
|
||||
else
|
||||
domain[0] = 0;
|
||||
}
|
||||
cp = 0;
|
||||
if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
|
||||
hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6);
|
||||
if (hp) {
|
||||
if ((cp = index(hp->h_name, '.')) &&
|
||||
!strcmp(cp + 1, domain))
|
||||
*cp = 0;
|
||||
cp = hp->h_name;
|
||||
}
|
||||
}
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(in6p))
|
||||
strcpy(line, "*");
|
||||
else if (cp)
|
||||
strcpy(line, cp);
|
||||
else
|
||||
sprintf(line, "%s",
|
||||
inet_ntop(AF_INET6, (void *)in6p, ntop_buf,
|
||||
sizeof(ntop_buf)));
|
||||
return (line);
|
||||
}
|
||||
char *
|
||||
inet6name(struct in6_addr *in6p);
|
||||
#endif
|
||||
|
||||
static void
|
||||
sctp_print_address(union sctp_sockstore *address, int port, int num_port)
|
||||
sctp_print_address(const char *container, union sctp_sockstore *address,
|
||||
int port, int num_port)
|
||||
{
|
||||
struct servent *sp = 0;
|
||||
char line[80], *cp;
|
||||
int width;
|
||||
|
||||
if (container)
|
||||
xo_open_container(container);
|
||||
|
||||
switch (address->sa.sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
@@ -215,7 +152,7 @@ sctp_print_address(union sctp_sockstore *address, int port, int num_port)
|
||||
sprintf(line, "%.*s.", Wflag ? 39 : 16, "");
|
||||
break;
|
||||
}
|
||||
cp = index(line, '\0');
|
||||
cp = strchr(line, '\0');
|
||||
if (!num_port && port)
|
||||
sp = getservbyport((int)port, "sctp");
|
||||
if (sp || port == 0)
|
||||
@@ -223,7 +160,14 @@ sctp_print_address(union sctp_sockstore *address, int port, int num_port)
|
||||
else
|
||||
sprintf(cp, "%d ", ntohs((u_short)port));
|
||||
width = Wflag ? 45 : 22;
|
||||
printf("%-*.*s ", width, width, line);
|
||||
xo_emit("{d:target/%-*.*s} ", width, width, line);
|
||||
|
||||
int alen = cp - line - 1, plen = strlen(cp) - 1;
|
||||
xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen,
|
||||
plen, cp);
|
||||
|
||||
if (container)
|
||||
xo_close_container(container);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -299,7 +243,7 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
|
||||
prev_xl = xl;
|
||||
xl = malloc(sizeof(struct xladdr_entry));
|
||||
if (xl == NULL) {
|
||||
warnx("malloc %lu bytes",
|
||||
xo_warnx("malloc %lu bytes",
|
||||
(u_long)sizeof(struct xladdr_entry));
|
||||
goto out;
|
||||
}
|
||||
@@ -320,7 +264,7 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
|
||||
prev_xr = xr;
|
||||
xr = malloc(sizeof(struct xraddr_entry));
|
||||
if (xr == NULL) {
|
||||
warnx("malloc %lu bytes",
|
||||
xo_warnx("malloc %lu bytes",
|
||||
(u_long)sizeof(struct xraddr_entry));
|
||||
goto out;
|
||||
}
|
||||
@@ -335,26 +279,29 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
|
||||
/*
|
||||
* Let's print the address infos.
|
||||
*/
|
||||
xo_open_list("address");
|
||||
xl = LIST_FIRST(&xladdr_head);
|
||||
xr = LIST_FIRST(&xraddr_head);
|
||||
x_max = (xl_total > xr_total) ? xl_total : xr_total;
|
||||
x_max = MAX(xl_total, xr_total);
|
||||
for (i = 0; i < x_max; i++) {
|
||||
xo_open_instance("address");
|
||||
|
||||
if (((*indent == 0) && i > 0) || *indent > 0)
|
||||
printf("%-12s ", " ");
|
||||
xo_emit("{P:/%-12s} ", " ");
|
||||
|
||||
if (xl != NULL) {
|
||||
sctp_print_address(&(xl->xladdr->address),
|
||||
sctp_print_address("local", &(xl->xladdr->address),
|
||||
htons(xstcb->local_port), numeric_port);
|
||||
} else {
|
||||
if (Wflag) {
|
||||
printf("%-45s ", " ");
|
||||
xo_emit("{P:/%-45s} ", " ");
|
||||
} else {
|
||||
printf("%-22s ", " ");
|
||||
xo_emit("{P:/%-22s} ", " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (xr != NULL && !Lflag) {
|
||||
sctp_print_address(&(xr->xraddr->address),
|
||||
sctp_print_address("remote", &(xr->xraddr->address),
|
||||
htons(xstcb->remote_port), numeric_port);
|
||||
}
|
||||
|
||||
@@ -367,7 +314,8 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
|
||||
sctp_statesprint(xstcb->state);
|
||||
|
||||
if (i < x_max)
|
||||
putchar('\n');
|
||||
xo_emit("\n");
|
||||
xo_close_instance("address");
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -395,7 +343,7 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
|
||||
{
|
||||
int indent = 0, xladdr_total = 0, is_listening = 0;
|
||||
static int first = 1;
|
||||
char *tname, *pname;
|
||||
const char *tname, *pname;
|
||||
struct xsctp_tcb *xstcb;
|
||||
struct xsctp_laddr *xladdr;
|
||||
size_t offset_laddr;
|
||||
@@ -406,30 +354,34 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
|
||||
|
||||
if (first) {
|
||||
if (!Lflag) {
|
||||
printf("Active SCTP associations");
|
||||
xo_emit("Active SCTP associations");
|
||||
if (aflag)
|
||||
printf(" (including servers)");
|
||||
xo_emit(" (including servers)");
|
||||
} else
|
||||
printf("Current listen queue sizes (qlen/maxqlen)");
|
||||
putchar('\n');
|
||||
xo_emit("Current listen queue sizes (qlen/maxqlen)");
|
||||
xo_emit("\n");
|
||||
if (Lflag)
|
||||
printf("%-6.6s %-5.5s %-8.8s %-22.22s\n",
|
||||
xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-8.8s} "
|
||||
"{T:/%-22.22s}\n",
|
||||
"Proto", "Type", "Listen", "Local Address");
|
||||
else
|
||||
if (Wflag)
|
||||
printf("%-6.6s %-5.5s %-45.45s %-45.45s %s\n",
|
||||
xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-45.45s} "
|
||||
"{T:/%-45.45s} {T:/%s}\n",
|
||||
"Proto", "Type",
|
||||
"Local Address", "Foreign Address",
|
||||
"(state)");
|
||||
else
|
||||
printf("%-6.6s %-5.5s %-22.22s %-22.22s %s\n",
|
||||
xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-22.22s} "
|
||||
"{T:/%-22.22s} {T:/%s}\n",
|
||||
"Proto", "Type",
|
||||
"Local Address", "Foreign Address",
|
||||
"(state)");
|
||||
first = 0;
|
||||
}
|
||||
xladdr = (struct xsctp_laddr *)(buf + *offset);
|
||||
if (Lflag && !is_listening) {
|
||||
if ((!aflag && is_listening) ||
|
||||
(Lflag && !is_listening)) {
|
||||
sctp_skip_xinpcb_ifneed(buf, buflen, offset);
|
||||
return;
|
||||
}
|
||||
@@ -449,30 +401,42 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
|
||||
tname = "????";
|
||||
|
||||
if (Lflag) {
|
||||
char buf1[9];
|
||||
char buf1[22];
|
||||
|
||||
snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen);
|
||||
printf("%-6.6s %-5.5s ", pname, tname);
|
||||
printf("%-8.8s ", buf1);
|
||||
snprintf(buf1, sizeof buf1, "%u/%u",
|
||||
xinpcb->qlen, xinpcb->maxqlen);
|
||||
xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
|
||||
pname, tname);
|
||||
xo_emit("{d:queues/%-8.8s}{e:queue-len/%hu}"
|
||||
"{e:max-queue-len/%hu} ",
|
||||
buf1, xinpcb->qlen, xinpcb->maxqlen);
|
||||
}
|
||||
|
||||
offset_laddr = *offset;
|
||||
process_closed = 0;
|
||||
|
||||
xo_open_list("local-address");
|
||||
retry:
|
||||
while (*offset < buflen) {
|
||||
xladdr = (struct xsctp_laddr *)(buf + *offset);
|
||||
*offset += sizeof(struct xsctp_laddr);
|
||||
if (xladdr->last) {
|
||||
if (aflag && !Lflag && (xladdr_total == 0) && process_closed) {
|
||||
printf("%-6.6s %-5.5s ", pname, tname);
|
||||
xo_open_instance("local-address");
|
||||
|
||||
xo_emit("{:protocol/%-6.6s/%s} "
|
||||
"{:type/%-5.5s/%s} ", pname, tname);
|
||||
if (Wflag) {
|
||||
printf("%-91.91s CLOSED", " ");
|
||||
xo_emit("{P:/%-91.91s/%s} "
|
||||
"{:state/CLOSED}", " ");
|
||||
} else {
|
||||
printf("%-45.45s CLOSED", " ");
|
||||
xo_emit("{P:/%-45.45s/%s} "
|
||||
"{:state/CLOSED}", " ");
|
||||
}
|
||||
xo_close_instance("local-address");
|
||||
}
|
||||
if (process_closed || is_listening) {
|
||||
putchar('\n');
|
||||
xo_emit("\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -480,31 +444,41 @@ retry:
|
||||
if (!Lflag && !is_listening && !process_closed)
|
||||
continue;
|
||||
|
||||
xo_open_instance("local-address");
|
||||
|
||||
if (xladdr_total == 0) {
|
||||
printf("%-6.6s %-5.5s ", pname, tname);
|
||||
if (!Lflag) {
|
||||
xo_emit("{:protocol/%-6.6s/%s} "
|
||||
"{:type/%-5.5s/%s} ", pname, tname);
|
||||
}
|
||||
} else {
|
||||
putchar('\n');
|
||||
printf((Lflag) ?
|
||||
"%-21.21s " : "%-12.12s ", " ");
|
||||
xo_emit("\n");
|
||||
xo_emit(Lflag ? "{P:/%-21.21s} " : "{P:/%-12.12s} ",
|
||||
" ");
|
||||
}
|
||||
sctp_print_address(&(xladdr->address),
|
||||
sctp_print_address("local", &(xladdr->address),
|
||||
htons(xinpcb->local_port), numeric_port);
|
||||
if (aflag && !Lflag && xladdr_total == 0) {
|
||||
if (Wflag) {
|
||||
if (process_closed) {
|
||||
printf("%-45.45s CLOSED", " ");
|
||||
xo_emit("{P:/%-45.45s} "
|
||||
"{:state/CLOSED}", " ");
|
||||
} else {
|
||||
printf("%-45.45s LISTEN", " ");
|
||||
xo_emit("{P:/%-45.45s} "
|
||||
"{:state/LISTEN}", " ");
|
||||
}
|
||||
} else {
|
||||
if (process_closed) {
|
||||
printf("%-22.22s CLOSED", " ");
|
||||
xo_emit("{P:/%-22.22s} "
|
||||
"{:state/CLOSED}", " ");
|
||||
} else {
|
||||
printf("%-22.22s LISTEN", " ");
|
||||
xo_emit("{P:/%-22.22s} "
|
||||
"{:state/LISTEN}", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
xladdr_total++;
|
||||
xo_close_instance("local-address");
|
||||
}
|
||||
|
||||
xstcb = (struct xsctp_tcb *)(buf + *offset);
|
||||
@@ -515,12 +489,15 @@ retry:
|
||||
goto retry;
|
||||
}
|
||||
while (xstcb->last == 0 && *offset < buflen) {
|
||||
printf("%-6.6s %-5.5s ", pname, tname);
|
||||
xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
|
||||
pname, tname);
|
||||
sctp_process_tcb(xstcb, buf, buflen, offset, &indent);
|
||||
indent++;
|
||||
xstcb = (struct xsctp_tcb *)(buf + *offset);
|
||||
*offset += sizeof(struct xsctp_tcb);
|
||||
}
|
||||
|
||||
xo_close_list("local-address");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -529,7 +506,7 @@ retry:
|
||||
*/
|
||||
void
|
||||
sctp_protopr(u_long off __unused,
|
||||
const char *name, int af1, int proto)
|
||||
const char *name __unused, int af1 __unused, int proto)
|
||||
{
|
||||
char *buf;
|
||||
const char *mibvar = "net.inet.sctp.assoclist";
|
||||
@@ -542,15 +519,15 @@ sctp_protopr(u_long off __unused,
|
||||
|
||||
if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
|
||||
if (errno != ENOENT)
|
||||
warn("sysctl: %s", mibvar);
|
||||
xo_warn("sysctl: %s", mibvar);
|
||||
return;
|
||||
}
|
||||
if ((buf = malloc(len)) == 0) {
|
||||
warnx("malloc %lu bytes", (u_long)len);
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
xo_warnx("malloc %lu bytes", (u_long)len);
|
||||
return;
|
||||
}
|
||||
if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
|
||||
warn("sysctl: %s", mibvar);
|
||||
xo_warn("sysctl: %s", mibvar);
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
@@ -574,33 +551,42 @@ sctp_statesprint(uint32_t state)
|
||||
int idx;
|
||||
|
||||
switch (state) {
|
||||
case SCTP_STATE_COOKIE_WAIT:
|
||||
case SCTP_CLOSED:
|
||||
idx = NETSTAT_SCTP_STATES_CLOSED;
|
||||
break;
|
||||
case SCTP_BOUND:
|
||||
idx = NETSTAT_SCTP_STATES_BOUND;
|
||||
break;
|
||||
case SCTP_LISTEN:
|
||||
idx = NETSTAT_SCTP_STATES_LISTEN;
|
||||
break;
|
||||
case SCTP_COOKIE_WAIT:
|
||||
idx = NETSTAT_SCTP_STATES_COOKIE_WAIT;
|
||||
break;
|
||||
case SCTP_STATE_COOKIE_ECHOED:
|
||||
case SCTP_COOKIE_ECHOED:
|
||||
idx = NETSTAT_SCTP_STATES_COOKIE_ECHOED;
|
||||
break;
|
||||
case SCTP_STATE_OPEN:
|
||||
case SCTP_ESTABLISHED:
|
||||
idx = NETSTAT_SCTP_STATES_ESTABLISHED;
|
||||
break;
|
||||
case SCTP_STATE_SHUTDOWN_SENT:
|
||||
case SCTP_SHUTDOWN_SENT:
|
||||
idx = NETSTAT_SCTP_STATES_SHUTDOWN_SENT;
|
||||
break;
|
||||
case SCTP_STATE_SHUTDOWN_RECEIVED:
|
||||
case SCTP_SHUTDOWN_RECEIVED:
|
||||
idx = NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED;
|
||||
break;
|
||||
case SCTP_STATE_SHUTDOWN_ACK_SENT:
|
||||
case SCTP_SHUTDOWN_ACK_SENT:
|
||||
idx = NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT;
|
||||
break;
|
||||
case SCTP_STATE_SHUTDOWN_PENDING:
|
||||
case SCTP_SHUTDOWN_PENDING:
|
||||
idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING;
|
||||
break;
|
||||
default:
|
||||
printf("UNKNOWN 0x%08x", state);
|
||||
xo_emit("UNKNOWN {:state/0x%08x}", state);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s", sctpstates[idx]);
|
||||
xo_emit("{:state/%s}", sctpstates[idx]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -609,105 +595,160 @@ sctp_statesprint(uint32_t state)
|
||||
void
|
||||
sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
{
|
||||
struct sctpstat sctpstat, zerostat;
|
||||
size_t len = sizeof(sctpstat);
|
||||
struct sctpstat sctpstat;
|
||||
|
||||
if (live) {
|
||||
if (zflag)
|
||||
memset(&zerostat, 0, len);
|
||||
if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
|
||||
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
|
||||
if (errno != ENOENT)
|
||||
warn("sysctl: net.inet.sctp.stats");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
kread(off, &sctpstat, len);
|
||||
if (fetch_stats("net.inet.sctp.stats", off, &sctpstat,
|
||||
sizeof(sctpstat), kread) != 0)
|
||||
return;
|
||||
|
||||
printf ("%s:\n", name);
|
||||
xo_open_container(name);
|
||||
xo_emit("{T:/%s}:\n", name);
|
||||
|
||||
#define p(f, m) if (sctpstat.f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
|
||||
xo_emit(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
|
||||
#define p1a(f, m) if (sctpstat.f || sflag <= 1) \
|
||||
printf(m, (uintmax_t)sctpstat.f)
|
||||
xo_emit(m, (uintmax_t)sctpstat.f)
|
||||
|
||||
/*
|
||||
* input statistics
|
||||
*/
|
||||
p(sctps_recvpackets, "\t%ju input packet%s\n");
|
||||
p(sctps_recvdatagrams, "\t\t%ju datagram%s\n");
|
||||
p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n");
|
||||
p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n");
|
||||
p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n");
|
||||
p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n");
|
||||
p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n");
|
||||
p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n");
|
||||
p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n");
|
||||
p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n");
|
||||
p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n");
|
||||
p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n");
|
||||
p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n");
|
||||
p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n");
|
||||
p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n");
|
||||
p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n");
|
||||
p(sctps_recvpackets, "\t{:received-packets/%ju} "
|
||||
"{N:/input packet%s}\n");
|
||||
p(sctps_recvdatagrams, "\t\t{:received-datagrams/%ju} "
|
||||
"{N:/datagram%s}\n");
|
||||
p(sctps_recvpktwithdata, "\t\t{:received-with-data/%ju} "
|
||||
"{N:/packet%s that had data}\n");
|
||||
p(sctps_recvsacks, "\t\t{:received-sack-chunks/%ju} "
|
||||
"{N:/input SACK chunk%s}\n");
|
||||
p(sctps_recvdata, "\t\t{:received-data-chunks/%ju} "
|
||||
"{N:/input DATA chunk%s}\n");
|
||||
p(sctps_recvdupdata, "\t\t{:received-duplicate-data-chunks/%ju} "
|
||||
"{N:/duplicate DATA chunk%s}\n");
|
||||
p(sctps_recvheartbeat, "\t\t{:received-hb-chunks/%ju} "
|
||||
"{N:/input HB chunk%s}\n");
|
||||
p(sctps_recvheartbeatack, "\t\t{:received-hb-ack-chunks/%ju} "
|
||||
"{N:/HB-ACK chunk%s}\n");
|
||||
p(sctps_recvecne, "\t\t{:received-ecne-chunks/%ju} "
|
||||
"{N:/input ECNE chunk%s}\n");
|
||||
p(sctps_recvauth, "\t\t{:received-auth-chunks/%ju} "
|
||||
"{N:/input AUTH chunk%s}\n");
|
||||
p(sctps_recvauthmissing, "\t\t{:dropped-missing-auth/%ju} "
|
||||
"{N:/chunk%s missing AUTH}\n");
|
||||
p(sctps_recvivalhmacid, "\t\t{:dropped-invalid-hmac/%ju} "
|
||||
"{N:/invalid HMAC id%s received}\n");
|
||||
p(sctps_recvivalkeyid, "\t\t{:dropped-invalid-secret/%ju} "
|
||||
"{N:/invalid secret id%s received}\n");
|
||||
p1a(sctps_recvauthfailed, "\t\t{:dropped-auth-failed/%ju} "
|
||||
"{N:/auth failed}\n");
|
||||
p1a(sctps_recvexpress, "\t\t{:received-fast-path/%ju} "
|
||||
"{N:/fast path receives all one chunk}\n");
|
||||
p1a(sctps_recvexpressm, "\t\t{:receives-fast-path-multipart/%ju} "
|
||||
"{N:/fast path multi-part data}\n");
|
||||
|
||||
/*
|
||||
* output statistics
|
||||
*/
|
||||
p(sctps_sendpackets, "\t%ju output packet%s\n");
|
||||
p(sctps_sendsacks, "\t\t%ju output SACK%s\n");
|
||||
p(sctps_senddata, "\t\t%ju output DATA chunk%s\n");
|
||||
p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n");
|
||||
p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n");
|
||||
p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more "
|
||||
"than once to same chunk\n");
|
||||
p(sctps_sendheartbeat, "\t\t%ju output HB chunk%s\n");
|
||||
p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n");
|
||||
p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n");
|
||||
p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n");
|
||||
p(sctps_sendpackets, "\t{:sent-packets/%ju} "
|
||||
"{N:/output packet%s}\n");
|
||||
p(sctps_sendsacks, "\t\t{:sent-sacks/%ju} "
|
||||
"{N:/output SACK%s}\n");
|
||||
p(sctps_senddata, "\t\t{:sent-data-chunks/%ju} "
|
||||
"{N:/output DATA chunk%s}\n");
|
||||
p(sctps_sendretransdata, "\t\t{:sent-retransmitted-data-chunks/%ju} "
|
||||
"{N:/retransmitted DATA chunk%s}\n");
|
||||
p(sctps_sendfastretrans, "\t\t"
|
||||
"{:sent-fast-retransmitted-data-chunks/%ju} "
|
||||
"{N:/fast retransmitted DATA chunk%s}\n");
|
||||
p(sctps_sendmultfastretrans, "\t\t"
|
||||
"{:sent-fast-retransmitted-data-chunk-multiple-times/%ju} "
|
||||
"{N:/FR'%s that happened more than once to same chunk}\n");
|
||||
p(sctps_sendheartbeat, "\t\t{:sent-hb-chunks/%ju} "
|
||||
"{N:/output HB chunk%s}\n");
|
||||
p(sctps_sendecne, "\t\t{:sent-ecne-chunks/%ju} "
|
||||
"{N:/output ECNE chunk%s}\n");
|
||||
p(sctps_sendauth, "\t\t{:sent-auth-chunks/%ju} "
|
||||
"{N:/output AUTH chunk%s}\n");
|
||||
p1a(sctps_senderrors, "\t\t{:send-errors/%ju} "
|
||||
"{N:/ip_output error counter}\n");
|
||||
|
||||
/*
|
||||
* PCKDROPREP statistics
|
||||
*/
|
||||
printf("\tPacket drop statistics:\n");
|
||||
p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n");
|
||||
p1a(sctps_pdrpfehos, "\t\t%ju from end host\n");
|
||||
p1a(sctps_pdrpmbda, "\t\t%ju with data\n");
|
||||
p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n");
|
||||
p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n");
|
||||
p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n");
|
||||
p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n");
|
||||
p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n");
|
||||
p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n");
|
||||
p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n");
|
||||
p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n");
|
||||
p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n");
|
||||
p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n");
|
||||
p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n");
|
||||
xo_emit("\t{T:Packet drop statistics}:\n");
|
||||
xo_open_container("drop-statistics");
|
||||
p1a(sctps_pdrpfmbox, "\t\t{:middle-box/%ju} "
|
||||
"{N:/from middle box}\n");
|
||||
p1a(sctps_pdrpfehos, "\t\t{:end-host/%ju} "
|
||||
"{N:/from end host}\n");
|
||||
p1a(sctps_pdrpmbda, "\t\t{:with-data/%ju} "
|
||||
"{N:/with data}\n");
|
||||
p1a(sctps_pdrpmbct, "\t\t{:non-data/%ju} "
|
||||
"{N:/non-data, non-endhost}\n");
|
||||
p1a(sctps_pdrpbwrpt, "\t\t{:non-endhost/%ju} "
|
||||
"{N:/non-endhost, bandwidth rep only}\n");
|
||||
p1a(sctps_pdrpcrupt, "\t\t{:short-header/%ju} "
|
||||
"{N:/not enough for chunk header}\n");
|
||||
p1a(sctps_pdrpnedat, "\t\t{:short-data/%ju} "
|
||||
"{N:/not enough data to confirm}\n");
|
||||
p1a(sctps_pdrppdbrk, "\t\t{:chunk-break/%ju} "
|
||||
"{N:/where process_chunk_drop said break}\n");
|
||||
p1a(sctps_pdrptsnnf, "\t\t{:tsn-not-found/%ju} "
|
||||
"{N:/failed to find TSN}\n");
|
||||
p1a(sctps_pdrpdnfnd, "\t\t{:reverse-tsn/%ju} "
|
||||
"{N:/attempt reverse TSN lookup}\n");
|
||||
p1a(sctps_pdrpdiwnp, "\t\t{:confirmed-zero-window/%ju} "
|
||||
"{N:/e-host confirms zero-rwnd}\n");
|
||||
p1a(sctps_pdrpdizrw, "\t\t{:middle-box-no-space/%ju} "
|
||||
"{N:/midbox confirms no space}\n");
|
||||
p1a(sctps_pdrpbadd, "\t\t{:bad-data/%ju} "
|
||||
"{N:/data did not match TSN}\n");
|
||||
p(sctps_pdrpmark, "\t\t{:tsn-marked-fast-retransmission/%ju} "
|
||||
"{N:/TSN'%s marked for Fast Retran}\n");
|
||||
xo_close_container("drop-statistics");
|
||||
|
||||
/*
|
||||
* Timeouts
|
||||
*/
|
||||
printf("\tTimeouts:\n");
|
||||
p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n");
|
||||
p(sctps_timodata, "\t\t%ju T3 data time out%s\n");
|
||||
p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n");
|
||||
p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n");
|
||||
p(sctps_timosack, "\t\t%ju sack timer%s fired\n");
|
||||
p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n");
|
||||
p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n");
|
||||
p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n");
|
||||
p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie"
|
||||
xo_emit("\t{T:Timeouts}:\n");
|
||||
xo_open_container("timeouts");
|
||||
p(sctps_timoiterator, "\t\t{:iterator/%ju} "
|
||||
"{N:/iterator timer%s fired}\n");
|
||||
p(sctps_timodata, "\t\t{:t3-data/%ju} "
|
||||
"{N:/T3 data time out%s}\n");
|
||||
p(sctps_timowindowprobe, "\t\t{:window-probe/%ju} "
|
||||
"{N:/window probe (T3) timer%s fired}\n");
|
||||
p(sctps_timoinit, "\t\t{:init-timer/%ju} "
|
||||
"{N:/INIT timer%s fired}\n");
|
||||
p(sctps_timosack, "\t\t{:sack-timer/%ju} "
|
||||
"{N:/sack timer%s fired}\n");
|
||||
p(sctps_timoshutdown, "\t\t{:shutdown-timer/%ju} "
|
||||
"{N:/shutdown timer%s fired}\n");
|
||||
p(sctps_timoheartbeat, "\t\t{:heartbeat-timer/%ju} "
|
||||
"{N:/heartbeat timer%s fired}\n");
|
||||
p1a(sctps_timocookie, "\t\t{:cookie-timer/%ju} "
|
||||
"{N:/a cookie timeout fired}\n");
|
||||
p1a(sctps_timosecret, "\t\t{:endpoint-changed-cookie/%ju} "
|
||||
"{N:/an endpoint changed its cook}ie"
|
||||
"secret\n");
|
||||
p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n");
|
||||
p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n");
|
||||
p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n");
|
||||
p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n");
|
||||
p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n");
|
||||
p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n");
|
||||
p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n");
|
||||
p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n");
|
||||
p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n");
|
||||
p(sctps_timopathmtu, "\t\t{:pmtu-timer/%ju} "
|
||||
"{N:/PMTU timer%s fired}\n");
|
||||
p(sctps_timoshutdownack, "\t\t{:shutdown-timer/%ju} "
|
||||
"{N:/shutdown ack timer%s fired}\n");
|
||||
p(sctps_timoshutdownguard, "\t\t{:shutdown-guard-timer/%ju} "
|
||||
"{N:/shutdown guard timer%s fired}\n");
|
||||
p(sctps_timostrmrst, "\t\t{:stream-reset-timer/%ju} "
|
||||
"{N:/stream reset timer%s fired}\n");
|
||||
p(sctps_timoearlyfr, "\t\t{:early-fast-retransmission-timer/%ju} "
|
||||
"{N:/early FR timer%s fired}\n");
|
||||
p1a(sctps_timoasconf, "\t\t{:asconf-timer/%ju} "
|
||||
"{N:/an asconf timer fired}\n");
|
||||
p1a(sctps_timoautoclose, "\t\t{:auto-close-timer/%ju} "
|
||||
"{N:/auto close timer fired}\n");
|
||||
p(sctps_timoassockill, "\t\t{:asoc-free-timer/%ju} "
|
||||
"{N:/asoc free timer%s expired}\n");
|
||||
p(sctps_timoinpkill, "\t\t{:input-free-timer/%ju} "
|
||||
"{N:/inp free timer%s expired}\n");
|
||||
xo_close_container("timeouts");
|
||||
|
||||
#if 0
|
||||
/*
|
||||
@@ -729,60 +770,86 @@ sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
/*
|
||||
* Others
|
||||
*/
|
||||
p1a(sctps_hdrops, "\t%ju packet shorter than header\n");
|
||||
p1a(sctps_badsum, "\t%ju checksum error\n");
|
||||
p1a(sctps_noport, "\t%ju no endpoint for port\n");
|
||||
p1a(sctps_badvtag, "\t%ju bad v-tag\n");
|
||||
p1a(sctps_badsid, "\t%ju bad SID\n");
|
||||
p1a(sctps_nomem, "\t%ju no memory\n");
|
||||
p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT "
|
||||
"window\n");
|
||||
p1a(sctps_hdrops, "\t{:dropped-too-short/%ju} "
|
||||
"{N:/packet shorter than header}\n");
|
||||
p1a(sctps_badsum, "\t{:dropped-bad-checksum/%ju} "
|
||||
"{N:/checksum error}\n");
|
||||
p1a(sctps_noport, "\t{:dropped-no-endpoint/%ju} "
|
||||
"{N:/no endpoint for port}\n");
|
||||
p1a(sctps_badvtag, "\t{:dropped-bad-v-tag/%ju} "
|
||||
"{N:/bad v-tag}\n");
|
||||
p1a(sctps_badsid, "\t{:dropped-bad-sid/%ju} "
|
||||
"{N:/bad SID}\n");
|
||||
p1a(sctps_nomem, "\t{:dropped-no-memory/%ju} "
|
||||
"{N:/no memory}\n");
|
||||
p1a(sctps_fastretransinrtt, "\t{:multiple-fast-retransmits-in-rtt/%ju} "
|
||||
"{N:/number of multiple FR in a RT}T window\n");
|
||||
#if 0
|
||||
p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n");
|
||||
#endif
|
||||
p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n");
|
||||
p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n");
|
||||
p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n");
|
||||
p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in "
|
||||
"interface\n");
|
||||
p(sctps_windowprobed, "\t%ju number%s of window probes sent\n");
|
||||
p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp "
|
||||
"down on next user send\n");
|
||||
p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were "
|
||||
"caused from a user\n");
|
||||
p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to "
|
||||
"chunk limit reached\n");
|
||||
p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd "
|
||||
"limit reached\n");
|
||||
p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced "
|
||||
"the cwnd\n");
|
||||
p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n");
|
||||
p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n");
|
||||
p(sctps_primary_randry, "\t%ju time%s the sender ran dry "
|
||||
"of user data on primary\n");
|
||||
p1a(sctps_cmt_randry, "\t%ju same for above\n");
|
||||
p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n");
|
||||
p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n");
|
||||
p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n");
|
||||
p(sctps_sends_with_unord, "\t%ju unordered send%s\n");
|
||||
p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n");
|
||||
p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n");
|
||||
p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n");
|
||||
p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol "
|
||||
"drain\n");
|
||||
p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n");
|
||||
p(sctps_cached_chk, "\t%ju cached chunk%s used\n");
|
||||
p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n");
|
||||
p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n");
|
||||
p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already "
|
||||
"max burst inflight to net\n");
|
||||
p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already "
|
||||
"max burst inflight to net\n");
|
||||
p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via "
|
||||
"fwd-tsn's\n");
|
||||
p1a(sctps_naglesent, "\t{:rfc813-sent/%ju} "
|
||||
"{N:/RFC813 allowed sending}\n");
|
||||
p1a(sctps_naglequeued, "\t{:rfc813-queued/%ju} "
|
||||
"{N:/RFC813 does not allow sending}\n");
|
||||
p1a(sctps_maxburstqueued, "\t{:max-burst-queued/%ju} "
|
||||
"{N:/times max burst prohibited sending}\n");
|
||||
p1a(sctps_ifnomemqueued, "\t{:no-memory-in-interface/%ju} "
|
||||
"{N:/look ahead tells us no memory in interface}\n");
|
||||
p(sctps_windowprobed, "\t{:sent-window-probes/%ju} "
|
||||
"{N:/number%s of window probes sent}\n");
|
||||
p(sctps_lowlevelerr, "\t{:low-level-err/%ju} "
|
||||
"{N:/time%s an output error to clamp down on next user send}\n");
|
||||
p(sctps_lowlevelerrusr, "\t{:low-level-user-error/%ju} "
|
||||
"{N:/time%s sctp_senderrors were caused from a user}\n");
|
||||
p(sctps_datadropchklmt, "\t{:dropped-chunk-limit/%ju} "
|
||||
"{N:/number of in data drop%s due to chunk limit reached}\n");
|
||||
p(sctps_datadroprwnd, "\t{:dropped-rwnd-limit/%ju} "
|
||||
"{N:/number of in data drop%s due to rwnd limit reached}\n");
|
||||
p(sctps_ecnereducedcwnd, "\t{:ecn-reduced-cwnd/%ju} "
|
||||
"{N:/time%s a ECN reduced the cwnd}\n");
|
||||
p1a(sctps_vtagexpress, "\t{:v-tag-express-lookup/%ju} "
|
||||
"{N:/used express lookup via vtag}\n");
|
||||
p1a(sctps_vtagbogus, "\t{:v-tag-collision/%ju} "
|
||||
"{N:/collision in express lookup}\n");
|
||||
p(sctps_primary_randry, "\t{:sender-ran-dry/%ju} "
|
||||
"{N:/time%s the sender ran dry of user data on primary}\n");
|
||||
p1a(sctps_cmt_randry, "\t{:cmt-ran-dry/%ju} "
|
||||
"{N:/same for above}\n");
|
||||
p(sctps_slowpath_sack, "\t{:slow-path-sack/%ju} "
|
||||
"{N:/sack%s the slow way}\n");
|
||||
p(sctps_wu_sacks_sent, "\t{:sent-window-update-only-sack/%ju} "
|
||||
"{N:/window update only sack%s sent}\n");
|
||||
p(sctps_sends_with_flags, "\t{:sent-with-sinfo/%ju} "
|
||||
"{N:/send%s with sinfo_flags !=0}\n");
|
||||
p(sctps_sends_with_unord, "\t{:sent-with-unordered/%ju} "
|
||||
"{N:/unordered send%s}\n");
|
||||
p(sctps_sends_with_eof, "\t{:sent-with-eof/%ju} "
|
||||
"{N:/send%s with EOF flag set}\n");
|
||||
p(sctps_sends_with_abort, "\t{:sent-with-abort/%ju} "
|
||||
"{N:/send%s with ABORT flag set}\n");
|
||||
p(sctps_protocol_drain_calls, "\t{:protocol-drain-called/%ju} "
|
||||
"{N:/time%s protocol drain called}\n");
|
||||
p(sctps_protocol_drains_done, "\t{:protocol-drain/%ju} "
|
||||
"{N:/time%s we did a protocol drain}\n");
|
||||
p(sctps_read_peeks, "\t{:read-with-peek/%ju} "
|
||||
"{N:/time%s recv was called with peek}\n");
|
||||
p(sctps_cached_chk, "\t{:cached-chunks/%ju} "
|
||||
"{N:/cached chunk%s used}\n");
|
||||
p1a(sctps_cached_strmoq, "\t{:cached-output-queue-used/%ju} "
|
||||
"{N:/cached stream oq's used}\n");
|
||||
p(sctps_left_abandon, "\t{:messages-abandoned/%ju} "
|
||||
"{N:/unread message%s abandonded by close}\n");
|
||||
p1a(sctps_send_burst_avoid, "\t{:send-burst-avoidance/%ju} "
|
||||
"{N:/send burst avoidance, already max burst inflight to net}\n");
|
||||
p1a(sctps_send_cwnd_avoid, "\t{:send-cwnd-avoidance/%ju} "
|
||||
"{N:/send cwnd full avoidance, already max burst inflight "
|
||||
"to net}\n");
|
||||
p(sctps_fwdtsn_map_over, "\t{:tsn-map-overruns/%ju} "
|
||||
"{N:/number of map array over-run%s via fwd-tsn's}\n");
|
||||
|
||||
#undef p
|
||||
#undef p1a
|
||||
xo_close_container(name);
|
||||
}
|
||||
|
||||
#endif /* SCTP */
|
||||
|
@@ -1,5 +1,9 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-namespace.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@@ -35,6 +39,9 @@ static char sccsid[] = "@(#)unix.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#ifdef __rtems__
|
||||
#include <machine/rtems-bsd-program.h>
|
||||
#endif /* __rtems__ */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@@ -59,9 +66,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <strings.h>
|
||||
#include <kvm.h>
|
||||
#include <libxo/xo.h>
|
||||
#include "netstat.h"
|
||||
#ifdef __rtems__
|
||||
#include "rtems-bsd-netstat-unix-data.h"
|
||||
#endif /* __rtems__ */
|
||||
|
||||
static void unixdomainpr(struct xunpcb *, struct xsocket *);
|
||||
|
||||
@@ -80,15 +92,15 @@ pcblist_sysctl(int type, char **bufp)
|
||||
len = 0;
|
||||
if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
|
||||
if (errno != ENOENT)
|
||||
warn("sysctl: %s", mibvar);
|
||||
xo_warn("sysctl: %s", mibvar);
|
||||
return (-1);
|
||||
}
|
||||
if ((buf = malloc(len)) == 0) {
|
||||
warnx("malloc %lu bytes", (u_long)len);
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
xo_warnx("malloc %lu bytes", (u_long)len);
|
||||
return (-2);
|
||||
}
|
||||
if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
|
||||
warn("sysctl: %s", mibvar);
|
||||
xo_warn("sysctl: %s", mibvar);
|
||||
free(buf);
|
||||
return (-2);
|
||||
}
|
||||
@@ -117,15 +129,15 @@ pcblist_kvm(u_long count_off, u_long gencnt_off, u_long head_off, char **bufp)
|
||||
return (-1);
|
||||
kread(count_off, &unp_count, sizeof(unp_count));
|
||||
len = 2 * sizeof(xug) + (unp_count + unp_count / 8) * sizeof(xu);
|
||||
if ((buf = malloc(len)) == 0) {
|
||||
warnx("malloc %lu bytes", (u_long)len);
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
xo_warnx("malloc %lu bytes", (u_long)len);
|
||||
return (-2);
|
||||
}
|
||||
p = buf;
|
||||
|
||||
#define COPYOUT(obj, size) do { \
|
||||
if (len < (size)) { \
|
||||
warnx("buffer size exceeded"); \
|
||||
xo_warnx("buffer size exceeded"); \
|
||||
goto fail; \
|
||||
} \
|
||||
bcopy((obj), p, (size)); \
|
||||
@@ -195,7 +207,7 @@ fail:
|
||||
#ifndef __rtems__
|
||||
void
|
||||
unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
|
||||
u_long sphead_off)
|
||||
u_long sphead_off, bool *first)
|
||||
{
|
||||
char *buf;
|
||||
int ret, type;
|
||||
@@ -204,6 +216,7 @@ unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
|
||||
struct xunpcb *xunp;
|
||||
u_long head_off;
|
||||
|
||||
buf = NULL;
|
||||
for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
|
||||
if (live)
|
||||
ret = pcblist_sysctl(type, &buf);
|
||||
@@ -232,26 +245,35 @@ unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
|
||||
|
||||
oxug = xug = (struct xunpgen *)buf;
|
||||
for (xug = (struct xunpgen *)((char *)xug + xug->xug_len);
|
||||
xug->xug_len > sizeof(struct xunpgen);
|
||||
xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
|
||||
xug->xug_len > sizeof(struct xunpgen);
|
||||
xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
|
||||
xunp = (struct xunpcb *)xug;
|
||||
so = &xunp->xu_socket;
|
||||
|
||||
/* Ignore PCBs which were freed during copyout. */
|
||||
if (xunp->xu_unp.unp_gencnt > oxug->xug_gen)
|
||||
continue;
|
||||
if (*first) {
|
||||
xo_open_list("socket");
|
||||
*first = false;
|
||||
}
|
||||
xo_open_instance("socket");
|
||||
unixdomainpr(xunp, so);
|
||||
xo_close_instance("socket");
|
||||
}
|
||||
if (xug != oxug && xug->xug_gen != oxug->xug_gen) {
|
||||
if (oxug->xug_count > xug->xug_count) {
|
||||
printf("Some %s sockets may have been deleted.\n",
|
||||
socktype[type]);
|
||||
xo_emit("Some {:type/%s} sockets may have "
|
||||
"been {:action/deleted}.\n",
|
||||
socktype[type]);
|
||||
} else if (oxug->xug_count < xug->xug_count) {
|
||||
printf("Some %s sockets may have been created.\n",
|
||||
socktype[type]);
|
||||
xo_emit("Some {:type/%s} sockets may have "
|
||||
"been {:action/created}.\n",
|
||||
socktype[type]);
|
||||
} else {
|
||||
printf("Some %s sockets may have been created or deleted",
|
||||
socktype[type]);
|
||||
xo_emit("Some {:type/%s} sockets may have "
|
||||
"been {:action/created or deleted}",
|
||||
socktype[type]);
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
@@ -266,7 +288,26 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
|
||||
struct unpcb *unp;
|
||||
struct sockaddr_un *sa;
|
||||
static int first = 1;
|
||||
char buf1[15];
|
||||
char buf1[33];
|
||||
static const char *titles[2] = {
|
||||
"{T:/%-8.8s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%8.8s} "
|
||||
"{T:/%8.8s} {T:/%8.8s} {T:/%8.8s} {T:Addr}\n",
|
||||
"{T:/%-16.16s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%16.16s} "
|
||||
"{T:/%16.16s} {T:/%16.16s} {T:/%16.16s} {T:Addr}\n"
|
||||
};
|
||||
static const char *format[2] = {
|
||||
"{q:address/%8lx} {t:type/%-6.6s} "
|
||||
"{:receive-bytes-waiting/%6u} "
|
||||
"{:send-bytes-waiting/%6u} "
|
||||
"{q:vnode/%8lx} {q:connection/%8lx} "
|
||||
"{q:first-reference/%8lx} {q:next-reference/%8lx}",
|
||||
"{q:address/%16lx} {t:type/%-6.6s} "
|
||||
"{:receive-bytes-waiting/%6u} "
|
||||
"{:send-bytes-waiting/%6u} "
|
||||
"{q:vnode/%16lx} {q:connection/%16lx} "
|
||||
"{q:first-reference/%16lx} {q:next-reference/%16lx}"
|
||||
};
|
||||
int fmt = (sizeof(void *) == 8) ? 1 : 0;
|
||||
|
||||
unp = &xunp->xu_unp;
|
||||
if (unp->unp_addr)
|
||||
@@ -275,9 +316,8 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
|
||||
sa = (struct sockaddr_un *)0;
|
||||
|
||||
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",
|
||||
xo_emit("{T:Active UNIX domain sockets}\n");
|
||||
xo_emit(titles[fmt],
|
||||
"Address", "Type", "Recv-Q", "Send-Q",
|
||||
"Inode", "Conn", "Refs", "Nextref");
|
||||
first = 0;
|
||||
@@ -287,20 +327,23 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
|
||||
return;
|
||||
|
||||
if (Lflag) {
|
||||
snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
|
||||
snprintf(buf1, sizeof buf1, "%u/%u/%u", so->so_qlen,
|
||||
so->so_incqlen, so->so_qlimit);
|
||||
printf("unix %-14.14s", buf1);
|
||||
xo_emit("unix {d:socket/%-32.32s}{e:queue-length/%u}"
|
||||
"{e:incomplete-queue-length/%u}{e:queue-limit/%u}",
|
||||
buf1, so->so_qlen, so->so_incqlen, so->so_qlimit);
|
||||
} else {
|
||||
printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
|
||||
xo_emit(format[fmt],
|
||||
(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,
|
||||
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",
|
||||
xo_emit(" {:path/%.*s}",
|
||||
(int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
|
||||
sa->sun_path);
|
||||
putchar('\n');
|
||||
xo_emit("\n");
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
|
Reference in New Issue
Block a user