summaryrefslogtreecommitdiffstats
path: root/freebsd/usr.bin
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-04-04 09:36:57 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-04-04 14:46:23 +0200
commitde8a76da2f374792594ce03a203b3f30e4889f6f (patch)
tree12b5e1e59358005c3c522955c08aee4795e4829c /freebsd/usr.bin
parentEnable bridging by default (diff)
downloadrtems-libbsd-de8a76da2f374792594ce03a203b3f30e4889f6f.tar.bz2
Update to FreeBSD head 2017-04-04
Git mirror commit 642b174daddbd0efd9bb5f242c43f4ab4db6869f.
Diffstat (limited to 'freebsd/usr.bin')
-rw-r--r--freebsd/usr.bin/netstat/flowtable.c2
-rw-r--r--freebsd/usr.bin/netstat/if.c2
-rw-r--r--freebsd/usr.bin/netstat/inet.c192
-rw-r--r--freebsd/usr.bin/netstat/inet6.c2
-rw-r--r--freebsd/usr.bin/netstat/ipsec.c2
-rw-r--r--freebsd/usr.bin/netstat/main.c2
-rw-r--r--freebsd/usr.bin/netstat/netstat.h2
-rw-r--r--freebsd/usr.bin/netstat/pfkey.c2
-rw-r--r--freebsd/usr.bin/netstat/route.c2
-rw-r--r--freebsd/usr.bin/netstat/unix.c2
-rw-r--r--freebsd/usr.bin/vmstat/vmstat.c10
11 files changed, 52 insertions, 168 deletions
diff --git a/freebsd/usr.bin/netstat/flowtable.c b/freebsd/usr.bin/netstat/flowtable.c
index fda45657..890ac22b 100644
--- a/freebsd/usr.bin/netstat/flowtable.c
+++ b/freebsd/usr.bin/netstat/flowtable.c
@@ -15,7 +15,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/if.c b/freebsd/usr.bin/netstat/if.c
index 007067e4..ebdcd85a 100644
--- a/freebsd/usr.bin/netstat/if.c
+++ b/freebsd/usr.bin/netstat/if.c
@@ -17,7 +17,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/inet.c b/freebsd/usr.bin/netstat/inet.c
index b3023070..30965229 100644
--- a/freebsd/usr.bin/netstat/inet.c
+++ b/freebsd/usr.bin/netstat/inet.c
@@ -16,7 +16,7 @@
* 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
+ * 3. 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.
*
@@ -103,7 +103,7 @@ static int udp_done, tcp_done, sdp_done;
#endif /* INET6 */
static int
-pcblist_sysctl(int proto, const char *name, char **bufp, int istcp __unused)
+pcblist_sysctl(int proto, const char *name, char **bufp)
{
const char *mibvar;
char *buf;
@@ -193,123 +193,6 @@ sotoxsocket(struct socket *so, struct xsocket *xso)
return (0);
}
-static int
-pcblist_kvm(u_long off, char **bufp, int istcp)
-{
- struct inpcbinfo pcbinfo;
- struct inpcbhead listhead;
- struct inpcb *inp;
- struct xinpcb xi;
- struct xinpgen xig;
- struct xtcpcb xt;
- struct socket so;
- struct xsocket *xso;
- char *buf, *p;
- size_t len;
-
- if (off == 0)
- return (0);
- kread(off, &pcbinfo, sizeof(pcbinfo));
- if (istcp)
- len = 2 * sizeof(xig) +
- (pcbinfo.ipi_count + pcbinfo.ipi_count / 8) *
- sizeof(struct xtcpcb);
- else
- len = 2 * sizeof(xig) +
- (pcbinfo.ipi_count + pcbinfo.ipi_count / 8) *
- sizeof(struct xinpcb);
- if ((buf = malloc(len)) == NULL) {
- xo_warnx("malloc %lu bytes", (u_long)len);
- return (0);
- }
- p = buf;
-
-#define COPYOUT(obj, size) do { \
- if (len < (size)) { \
- xo_warnx("buffer size exceeded"); \
- goto fail; \
- } \
- bcopy((obj), p, (size)); \
- len -= (size); \
- p += (size); \
-} while (0)
-
-#define KREAD(off, buf, len) do { \
- if (kread((uintptr_t)(off), (buf), (len)) != 0) \
- goto fail; \
-} while (0)
-
- /* Write out header. */
- xig.xig_len = sizeof xig;
- xig.xig_count = pcbinfo.ipi_count;
- xig.xig_gen = pcbinfo.ipi_gencnt;
- xig.xig_sogen = 0;
- COPYOUT(&xig, sizeof xig);
-
- /* Walk the PCB list. */
- xt.xt_len = sizeof xt;
- xi.xi_len = sizeof xi;
- if (istcp)
- xso = &xt.xt_socket;
- else
- xso = &xi.xi_socket;
- KREAD(pcbinfo.ipi_listhead, &listhead, sizeof(listhead));
- LIST_FOREACH(inp, &listhead, inp_list) {
- if (istcp) {
- KREAD(inp, &xt.xt_inp, sizeof(*inp));
- inp = &xt.xt_inp;
- } else {
- KREAD(inp, &xi.xi_inp, sizeof(*inp));
- inp = &xi.xi_inp;
- }
-
- if (inp->inp_gencnt > pcbinfo.ipi_gencnt)
- continue;
-
- if (istcp) {
- if (inp->inp_ppcb == NULL)
- bzero(&xt.xt_tp, sizeof xt.xt_tp);
- else if (inp->inp_flags & INP_TIMEWAIT) {
- bzero(&xt.xt_tp, sizeof xt.xt_tp);
- xt.xt_tp.t_state = TCPS_TIME_WAIT;
- } else
- KREAD(inp->inp_ppcb, &xt.xt_tp,
- sizeof xt.xt_tp);
- }
- if (inp->inp_socket) {
- KREAD(inp->inp_socket, &so, sizeof(so));
- if (sotoxsocket(&so, xso) != 0)
- goto fail;
- } else {
- bzero(xso, sizeof(*xso));
- if (istcp)
- xso->xso_protocol = IPPROTO_TCP;
- }
- if (istcp)
- COPYOUT(&xt, sizeof xt);
- else
- COPYOUT(&xi, sizeof xi);
- }
-
- /* Reread the pcbinfo and write out the footer. */
- kread(off, &pcbinfo, sizeof(pcbinfo));
- xig.xig_count = pcbinfo.ipi_count;
- xig.xig_gen = pcbinfo.ipi_gencnt;
- COPYOUT(&xig, sizeof xig);
-
- *bufp = buf;
- return (1);
-
-fail:
- free(buf);
- return (0);
-#undef COPYOUT
-#undef KREAD
-}
-
-#ifdef __rtems__
-static int protopr_first = 1;
-#endif /* __rtems__ */
/*
* Print a summary of connections related to an Internet
* protocol. For TCP, also give state of connection.
@@ -319,17 +202,16 @@ static int protopr_first = 1;
void
protopr(u_long off, const char *name, int af1, int proto)
{
- int istcp;
#ifndef __rtems__
static int first = 1;
#endif /* __rtems__ */
+ int istcp;
char *buf;
const char *vchar;
- struct tcpcb *tp = NULL;
- struct inpcb *inp;
+ struct xtcpcb *tp;
+ struct xinpcb *inp;
struct xinpgen *xig, *oxig;
struct xsocket *so;
- struct xtcp_timer *timer;
istcp = 0;
switch (proto) {
@@ -358,28 +240,21 @@ protopr(u_long off, const char *name, int af1, int proto)
#endif
break;
}
- if (live) {
- if (!pcblist_sysctl(proto, name, &buf, istcp))
- return;
- } else {
- if (!pcblist_kvm(off, &buf, istcp))
- return;
- }
+
+ if (!pcblist_sysctl(proto, name, &buf))
+ return;
oxig = xig = (struct xinpgen *)buf;
for (xig = (struct xinpgen *)((char *)xig + xig->xig_len);
xig->xig_len > sizeof(struct xinpgen);
xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
if (istcp) {
- timer = &((struct xtcpcb *)xig)->xt_timer;
- tp = &((struct xtcpcb *)xig)->xt_tp;
- inp = &((struct xtcpcb *)xig)->xt_inp;
- so = &((struct xtcpcb *)xig)->xt_socket;
+ tp = (struct xtcpcb *)xig;
+ inp = &tp->xt_inp;
} else {
- inp = &((struct xinpcb *)xig)->xi_inp;
- so = &((struct xinpcb *)xig)->xi_socket;
- timer = NULL;
+ inp = (struct xinpcb *)xig;
}
+ so = &inp->xi_socket;
/* Ignore sockets for protocols other than the desired one. */
if (so->xso_protocol != proto)
@@ -494,7 +369,7 @@ protopr(u_long off, const char *name, int af1, int proto)
2 * (int)sizeof(void *),
(u_long)inp->inp_ppcb);
else
- xo_emit("{q:adddress/%*lx} ",
+ xo_emit("{q:address/%*lx} ",
2 * (int)sizeof(void *),
(u_long)so->so_pcb);
}
@@ -599,25 +474,25 @@ protopr(u_long off, const char *name, int af1, int proto)
so->so_rcv.sb_lowat, so->so_snd.sb_lowat,
so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt,
so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax);
- if (timer != NULL)
+ if (istcp)
xo_emit(" {:retransmit-timer/%4d.%02d} "
"{:persist-timer/%4d.%02d} "
"{:keepalive-timer/%4d.%02d} "
"{:msl2-timer/%4d.%02d} "
"{:delay-ack-timer/%4d.%02d} "
"{:inactivity-timer/%4d.%02d}",
- timer->tt_rexmt / 1000,
- (timer->tt_rexmt % 1000) / 10,
- timer->tt_persist / 1000,
- (timer->tt_persist % 1000) / 10,
- timer->tt_keep / 1000,
- (timer->tt_keep % 1000) / 10,
- timer->tt_2msl / 1000,
- (timer->tt_2msl % 1000) / 10,
- timer->tt_delack / 1000,
- (timer->tt_delack % 1000) / 10,
- timer->t_rcvtime / 1000,
- (timer->t_rcvtime % 1000) / 10);
+ tp->tt_rexmt / 1000,
+ (tp->tt_rexmt % 1000) / 10,
+ tp->tt_persist / 1000,
+ (tp->tt_persist % 1000) / 10,
+ tp->tt_keep / 1000,
+ (tp->tt_keep % 1000) / 10,
+ tp->tt_2msl / 1000,
+ (tp->tt_2msl % 1000) / 10,
+ tp->tt_delack / 1000,
+ (tp->tt_delack % 1000) / 10,
+ tp->t_rcvtime / 1000,
+ (tp->t_rcvtime % 1000) / 10);
}
if (istcp && !Lflag && !xflag && !Tflag && !Rflag) {
if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
@@ -883,12 +758,25 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
"{N:/successful ECN handshake%s}\n");
p(tcps_ecn_rcwnd, "\t{:congestion-reductions/%ju} "
"{N:/time%s ECN reduced the congestion window}\n");
+
+ xo_close_container("ecn");
+ xo_open_container("tcp-signature");
+ p(tcps_sig_rcvgoodsig, "\t{:received-good-signature/%ju} "
+ "{N:/packet%s with matching signature received}\n");
+ p(tcps_sig_rcvbadsig, "\t{:received-bad-signature/%ju} "
+ "{N:/packet%s with bad signature received}\n");
+ p(tcps_sig_err_buildsig, "\t{:failed-make-signature/%ju} "
+ "{N:/time%s failed to make signature due to no SA}\n");
+ p(tcps_sig_err_sigopt, "\t{:no-signature-expected/%ju} "
+ "{N:/time%s unexpected signature received}\n");
+ p(tcps_sig_err_nosigopt, "\t{:no-signature-provided/%ju} "
+ "{N:/time%s no signature provided by segment}\n");
#undef p
#undef p1a
#undef p2
#undef p2a
#undef p3
- xo_close_container("ecn");
+ xo_close_container("tcp-signature");
xo_open_container("TCP connection count by state");
xo_emit("{T:/TCP connection count by state}:\n");
diff --git a/freebsd/usr.bin/netstat/inet6.c b/freebsd/usr.bin/netstat/inet6.c
index 285565bf..21572711 100644
--- a/freebsd/usr.bin/netstat/inet6.c
+++ b/freebsd/usr.bin/netstat/inet6.c
@@ -17,7 +17,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/ipsec.c b/freebsd/usr.bin/netstat/ipsec.c
index 5b7c185b..78aa8680 100644
--- a/freebsd/usr.bin/netstat/ipsec.c
+++ b/freebsd/usr.bin/netstat/ipsec.c
@@ -71,7 +71,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/main.c b/freebsd/usr.bin/netstat/main.c
index 53b4d9bc..2ac9ed7c 100644
--- a/freebsd/usr.bin/netstat/main.c
+++ b/freebsd/usr.bin/netstat/main.c
@@ -16,7 +16,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/netstat.h b/freebsd/usr.bin/netstat/netstat.h
index cdd0ccbd..776c09e7 100644
--- a/freebsd/usr.bin/netstat/netstat.h
+++ b/freebsd/usr.bin/netstat/netstat.h
@@ -10,7 +10,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/pfkey.c b/freebsd/usr.bin/netstat/pfkey.c
index 8feb91e9..e76dddb2 100644
--- a/freebsd/usr.bin/netstat/pfkey.c
+++ b/freebsd/usr.bin/netstat/pfkey.c
@@ -46,7 +46,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/route.c b/freebsd/usr.bin/netstat/route.c
index 0c3f6184..8e163dbb 100644
--- a/freebsd/usr.bin/netstat/route.c
+++ b/freebsd/usr.bin/netstat/route.c
@@ -16,7 +16,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/netstat/unix.c b/freebsd/usr.bin/netstat/unix.c
index 313be435..e9532c74 100644
--- a/freebsd/usr.bin/netstat/unix.c
+++ b/freebsd/usr.bin/netstat/unix.c
@@ -16,7 +16,7 @@
* 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
+ * 3. 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.
*
diff --git a/freebsd/usr.bin/vmstat/vmstat.c b/freebsd/usr.bin/vmstat/vmstat.c
index 8f9daa9a..558c3f48 100644
--- a/freebsd/usr.bin/vmstat/vmstat.c
+++ b/freebsd/usr.bin/vmstat/vmstat.c
@@ -12,7 +12,7 @@
* 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
+ * 3. 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.
*
@@ -338,17 +338,13 @@ retry_nlist:
namelist[X_SUM].n_name = "_cnt";
goto retry_nlist;
}
- for (c = 0;
- c < (int)(sizeof(namelist)/sizeof(namelist[0]));
- c++)
+ for (c = 0; c < (int)(nitems(namelist)); c++)
if (namelist[c].n_type == 0)
bufsize += strlen(namelist[c].n_name) + 1;
bufsize += len + 1;
buf = bp = alloca(bufsize);
- for (c = 0;
- c < (int)(sizeof(namelist)/sizeof(namelist[0]));
- c++)
+ for (c = 0; c < (int)(nitems(namelist)); c++)
if (namelist[c].n_type == 0) {
xo_error(" %s",
namelist[c].n_name);