Permalink
Browse files

OpenBSD 3.0

  • Loading branch information...
1 parent 5559202 commit 7c0920f1d1dde08a95c96b7b5d2772a66ed9869a itojun committed Nov 29, 2001
View
6 openbsd/sbin/ifconfig/ifconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ifconfig.8,v 1.51 2001/05/02 06:44:23 itojun Exp $
+.\" $OpenBSD: ifconfig.8,v 1.52 2001/09/15 18:06:56 mickey Exp $
.\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $
.\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $
.\"
@@ -266,6 +266,10 @@ Refer to the interfaces' driver specific man page for a complete
list of available options.
.It Fl mediaopt Ar opts
Disable the specified media options on the interface.
+.It Cm mtu Ar value
+Set the MTU for this device to the given
+.Ar value .
+Cloned routes will inherit this value as a default.
.It Cm instance Ar minst
Set the media instance to
.Ar minst .
View
29 openbsd/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.48 2001/05/07 13:53:26 markus Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.52 2001/08/19 01:51:34 itojun Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -81,7 +81,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.48 2001/05/07 13:53:26 markus Exp $";
+static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.52 2001/08/19 01:51:34 itojun Exp $";
#endif
#endif /* not lint */
@@ -195,6 +195,7 @@ void unsetvlandev __P((char *, int));
void vlan_status ();
void fixnsel __P((struct sockaddr_iso *));
int main __P((int, char *[]));
+int prefix __P((void *val, int));
/*
* Media stuff. Whenever a media command is first performed, the
@@ -371,7 +372,7 @@ main(argc, argv)
int argc;
char *argv[];
{
- register const struct afswtch *rafp;
+ register const struct afswtch *rafp = NULL;
int aflag = 0;
int ifaliases = 0;
int i;
@@ -1941,7 +1942,8 @@ in_getprefix(plen, which)
memset((void *)&sin->sin_addr, 0x00, sizeof(sin->sin_addr));
for (cp = (u_char *)&sin->sin_addr; len > 7; len -= 8)
*cp++ = 0xff;
- *cp = 0xff << (8 - len);
+ if (len)
+ *cp = 0xff << (8 - len);
}
/*
@@ -2046,7 +2048,8 @@ in6_getprefix(plen, which)
memset((void *)&sin->sin6_addr, 0x00, sizeof(sin->sin6_addr));
for (cp = (u_char *)&sin->sin6_addr; len > 7; len -= 8)
*cp++ = 0xff;
- *cp = 0xff << (8 - len);
+ if (len)
+ *cp = 0xff << (8 - len);
}
int
@@ -2369,6 +2372,7 @@ sec2str(total)
int first = 1;
char *p = result;
char *end = &result[sizeof(result)];
+ int n;
if (0) { /*XXX*/
days = total / 3600 / 24;
@@ -2378,15 +2382,24 @@ sec2str(total)
if (days) {
first = 0;
- p += snprintf(p, end - p, "%dd", days);
+ n = snprintf(p, end - p, "%dd", days);
+ if (n < 0 || n >= end - p)
+ return(result);
+ p += n;
}
if (!first || hours) {
first = 0;
- p += snprintf(p, end - p, "%dh", hours);
+ n = snprintf(p, end - p, "%dh", hours);
+ if (n < 0 || n >= end - p)
+ return(result);
+ p += n;
}
if (!first || mins) {
first = 0;
- p += snprintf(p, end - p, "%dm", mins);
+ n = snprintf(p, end - p, "%dm", mins);
+ if (n < 0 || n >= end - p)
+ return(result);
+ p += n;
}
snprintf(p, end - p, "%ds", secs);
} else
View
13 openbsd/sbin/sysctl/Makefile
@@ -1,12 +1,11 @@
-# $OpenBSD: Makefile,v 1.7 2000/04/14 02:40:01 itojun Exp $
+# $OpenBSD: Makefile,v 1.8 2001/06/27 06:16:46 art Exp $
-PROG= ifconfig
-MAN= ifconfig.8
+PROG= sysctl
+MAN= sysctl.8
-CPPFLAGS+=-DINET6
-CPPFLAGS+=-DHAVE_IFADDRS_H
+CPPFLAGS+= -DINET6
-# kame scopeid hack
-CPPFLAGS+=-DKAME_SCOPEID
+afterinstall:
+ (cd ${DESTDIR}/usr/sbin; ln -sf ../../sbin/sysctl .)
.include <bsd.prog.mk>
View
8 openbsd/sbin/sysctl/pathconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathconf.c,v 1.4 2001/01/28 22:45:20 niklas Exp $ */
+/* $OpenBSD: pathconf.c,v 1.5 2001/06/04 14:59:50 mickey Exp $ */
/* $NetBSD: pathconf.c,v 1.2 1995/09/30 07:12:47 thorpej Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)pathconf.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: pathconf.c,v 1.4 2001/01/28 22:45:20 niklas Exp $";
+static char rcsid[] = "$OpenBSD: pathconf.c,v 1.5 2001/06/04 14:59:50 mickey Exp $";
#endif
#endif /* not lint */
@@ -120,13 +120,13 @@ main(argc, argv)
argc--;
if (Aflag || aflag) {
listall(path, &pclist);
- exit(0);
+ return (0);
}
if (argc == 0)
usage();
while (argc-- > 0)
parse(path, *argv, 1);
- exit(0);
+ return (0);
}
/*
View
76 openbsd/sbin/sysctl/sysctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sysctl.8,v 1.61 2001/02/07 11:43:49 itojun Exp $
+.\" $OpenBSD: sysctl.8,v 1.68 2001/08/18 03:32:16 art Exp $
.\" $NetBSD: sysctl.8,v 1.4 1995/09/30 07:12:49 thorpej Exp $
.\"
.\" Copyright (c) 1993
@@ -53,42 +53,39 @@
.Fl aA
.Sh DESCRIPTION
The
-.Nm sysctl
+.Nm
utility retrieves kernel state and allows processes with
appropriate privilege to set kernel state.
The state to be retrieved or set is described using a
``Management Information Base'' (``MIB'') style name,
described as a dotted set of components.
-The
-.Fl a
-flag can be used to list all the currently available string or integer values.
-The
-.Fl A
-flag will list all the known MIB names including tables.
+
+The options are as follows:
+.Bl -tag -width xxx
+.It Fl a
+list all the currently available string or integer values.
+.It Fl A
+list all the known MIB names including tables.
Those with string or integer values will be printed as with the
.Fl a
-flag; for the table values,
-the name of the utility to retrieve them is given.
-.Pp
-The
-.Fl n
-flag specifies that the printing of the field name should be
-suppressed and that only its value should be output.
-This flag is useful for setting shell variables.
-For example, to save the pagesize in variable psize, use:
+flag; for the table values, the name of the utility to retrieve them is given.
+.It Fl n
+suppress printing of the field name, only output the field value.
+Useful for setting shell variables.
+For example:
.Bd -literal -offset indent -compact
set psize=`sysctl -n hw.pagesize`
.Ed
.Pp
If just a MIB style name is given,
the corresponding value is retrieved.
-If a value is to be set, the
-.Fl w
-flag must be specified and the MIB name followed
-by an equal sign and the new value to be used.
+.It Fl w
+required to set a variable. The MIB name should be followed
+by an equal sign and the new value.
+.El
.Pp
The information available from
-.Nm sysctl
+.Nm
consists of integers, strings, and tables.
The tabular information can only be retrieved by special
purpose programs such as
@@ -123,15 +120,11 @@ privilege can change the value.
.It kern.ngroups integer no
.It kern.job_control integer no
.It kern.saved_ids integer no
-.It kern.link_max integer no
-.It kern.max_canon integer no
-.It kern.max_input integer no
-.It kern.name_max integer no
-.It kern.path_max integer no
-.It kern.pipe_buf integer no
-.It kern.chown_restricted integer no
-.It kern.no_trunc integer no
.It kern.boottime struct no
+.It kern.ntptime struct no
+.It kern.cp_time struct no
+.It kern.nchstats struct no
+.It kern.forkstat struct no
.It kern.somaxconn integer yes
.It kern.sominconn integer yes
.It kern.usermount integer yes
@@ -142,13 +135,27 @@ privilege can change the value.
.It kern.sysvsem integer no
.It kern.sysvshm integer no
.It kern.arandom u_int no
+.It kern.msgbufsize integer no
+.It kern.nselcoll integer no
.It kern.malloc.buckets string no
.It kern.malloc.bucket.<sz> string no
+.It kern.malloc.kmemnames string no
+.It kern.malloc.kmemstat.<name> string no
+.It kern.tty.tk_nin int64_t no
+.It kern.tty.tk_nout int64_t no
+.It kern.tty.tk_rawcc int64_t no
+.It kern.tty.tk_cancc int64_t no
+.It kern.fscale int no
+.It kern.ccpu u_int no
+.It kern.nprocs int no
+.It kern.stackgap_random int yes
.It vm.loadavg struct no
.It vm.psstrings struct no
.It vm.swapencrypt.enable integer yes
.It vm.swapencrypt.keyscreated integer no
.It vm.swapencrypt.keysdeleted integer no
+.It vm.uvmexp struct no
+.It vm.vmmeter struct no
.It fs.posix.setuid integer yes
.It net.inet.ip.forwarding integer yes
.It net.inet.ip.redirect integer yes
@@ -173,6 +180,7 @@ privilege can change the value.
.It net.inet.ip.ipsec-firstuse integer yes
.It net.inet.ip.ipsec-enc-alg string yes
.It net.inet.ip.ipsec-auth-alg string yes
+.It net.inet.ip.ipsec-comp-alg string yes
.It net.inet.ip.ipsec-expire-acquire integer yes
.It net.inet.ip.ipsec-invalid-life integer yes
.It net.inet.ip.mtudisc integer yes
@@ -199,6 +207,7 @@ privilege can change the value.
.It net.inet.udp.sendspace integer yes
.It net.inet.esp.enable integer yes
.It net.inet.ah.enable integer yes
+.It net.inet.ipcomp.enable integer yes
.It net.inet.gre.allow integer yes
.It net.inet.mobileip.allow integer yes
.It net.inet6.ip6.forwarding integer yes
@@ -247,6 +256,9 @@ privilege can change the value.
.It hw.physmem integer no
.It hw.usermem integer no
.It hw.pagesize integer no
+.It hw.diskstats struct no
+.It hw.disknames string no
+.It hw.diskcount integer no
.It machdep.console_device dev_t no
.It machdep.apmwarn integer yes (i386 only)
.It machdep.apmhalt integer yes (i386 only)
@@ -289,15 +301,15 @@ privilege can change the value.
.El
.Pp
The
-.Nm sysctl
+.Nm
program can get or set debugging variables
that have been identified for its display.
This information can be obtained by using the command:
.Bd -literal -offset indent
sysctl debug
.Ed
In addition,
-.Nm sysctl
+.Nm
can extract information about the filesystems that have been compiled
into the running system.
This information can be obtained by using the command:
View
397 openbsd/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.60 2001/02/23 16:46:36 mickey Exp $ */
+/* $OpenBSD: sysctl.c,v 1.76 2001/08/02 11:09:39 art Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95";
#else
-static char *rcsid = "$OpenBSD: sysctl.c,v 1.60 2001/02/23 16:46:36 mickey Exp $";
+static char *rcsid = "$OpenBSD: sysctl.c,v 1.76 2001/08/02 11:09:39 art Exp $";
#endif
#endif /* not lint */
@@ -56,6 +56,9 @@ static char *rcsid = "$OpenBSD: sysctl.c,v 1.60 2001/02/23 16:46:36 mickey Exp $
#include <sys/socket.h>
#include <sys/malloc.h>
#include <sys/dkstat.h>
+#include <sys/uio.h>
+#include <sys/tty.h>
+#include <sys/namei.h>
#include <vm/vm_param.h>
#include <machine/cpu.h>
#include <net/route.h>
@@ -77,6 +80,7 @@ static char *rcsid = "$OpenBSD: sysctl.c,v 1.60 2001/02/23 16:46:36 mickey Exp $
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/ip_gre.h>
+#include <netinet/ip_ipcomp.h>
#ifdef INET6
#include <netinet/ip6.h>
@@ -85,9 +89,7 @@ static char *rcsid = "$OpenBSD: sysctl.c,v 1.60 2001/02/23 16:46:36 mickey Exp $
#include <netinet6/pim6_var.h>
#endif
-#ifdef UVM
#include <uvm/uvm_swap_encrypt.h>
-#endif
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
@@ -124,6 +126,9 @@ struct ctlname hwname[] = CTL_HW_NAMES;
struct ctlname username[] = CTL_USER_NAMES;
struct ctlname debugname[CTL_DEBUG_MAXID];
struct ctlname kernmallocname[] = CTL_KERN_MALLOC_NAMES;
+struct ctlname forkstatname[] = CTL_KERN_FORKSTAT_NAMES;
+struct ctlname nchstatsname[] = CTL_KERN_NCHSTATS_NAMES;
+struct ctlname ttyname[] = CTL_KERN_TTY_NAMES;
struct ctlname *vfsname;
#ifdef CTL_MACHDEP_NAMES
struct ctlname machdepname[] = CTL_MACHDEP_NAMES;
@@ -172,6 +177,7 @@ int Aflag, aflag, nflag, wflag;
#define UNSIGNED 0x00000200
#define KMEMBUCKETS 0x00000400
#define LONGARRAY 0x00000800
+#define KMEMSTATS 0x00001000
/* prototypes */
void debuginit __P((void));
@@ -190,6 +196,10 @@ static int sysctl_vfs __P((char *, char **, int[], int, int *));
static int sysctl_vfsgen __P((char *, char **, int[], int, int *));
int sysctl_bios __P((char *, char **, int *, int, int *));
int sysctl_swpenc __P((char *, char **, int *, int, int *));
+int sysctl_forkstat __P((char *, char **, int *, int, int *));
+int sysctl_tty __P((char *, char **, int *, int, int *));
+int sysctl_nchstats __P((char *, char **, int *, int, int *));
+int sysctl_malloc __P((char *, char **, int *, int, int *));
void vfsinit __P((void));
int
@@ -230,13 +240,13 @@ main(argc, argv)
vfsinit();
for (lvl1 = 1; lvl1 < CTL_MAXID; lvl1++)
listall(topname[lvl1].ctl_name, &secondlevel[lvl1]);
- exit(0);
+ return (0);
}
if (argc == 0)
usage();
for (; *argv != NULL; ++argv)
parse(*argv, 1);
- exit(0);
+ return (0);
}
/*
@@ -247,18 +257,21 @@ listall(prefix, lp)
char *prefix;
struct list *lp;
{
- int lvl2;
char *cp, name[BUFSIZ];
+ int lvl2, len;
if (lp->list == NULL)
return;
- (void)strlcpy(name, prefix, BUFSIZ);
- cp = &name[strlen(name)];
+ if ((len = strlcpy(name, prefix, sizeof(name))) >= sizeof(name))
+ warn("%s: name too long", prefix);
+ cp = name + len++;
*cp++ = '.';
for (lvl2 = 0; lvl2 < lp->size; lvl2++) {
if (lp->list[lvl2].ctl_name == NULL)
continue;
- (void)strcpy(cp, lp->list[lvl2].ctl_name);
+ if (strlcpy(cp, lp->list[lvl2].ctl_name,
+ sizeof(name) - len) >= sizeof(name) - len)
+ warn("%s: name too long", lp->list[lvl2].ctl_name);
parse(name, Aflag);
}
}
@@ -277,7 +290,7 @@ parse(string, flags)
size_t size, newsize = 0;
int lal = 0, special = 0;
void *newval = 0;
- quad_t quadval;
+ int64_t quadval;
struct list *lp;
int mib[CTL_MAXNAME];
char *cp, *bufp, buf[BUFSIZ];
@@ -334,14 +347,33 @@ parse(string, flags)
(void)printf("%s = %s\n", string,
state == GMON_PROF_OFF ? "off" : "running");
return;
+ case KERN_FORKSTAT:
+ sysctl_forkstat(string, &bufp, mib, flags, &type);
+ return;
+ case KERN_TTY:
+ len = sysctl_tty(string, &bufp, mib, flags, &type);
+ if (len < 0)
+ return;
+ newsize = 0;
+ break;
+ case KERN_NCHSTATS:
+ sysctl_nchstats(string, &bufp, mib, flags, &type);
+ return;
case KERN_MALLOCSTATS:
len = sysctl_malloc(string, &bufp, mib, flags, &type);
if (len < 0)
return;
if (mib[2] == KERN_MALLOC_BUCKET)
special |= KMEMBUCKETS;
+ if (mib[2] == KERN_MALLOC_KMEMSTATS)
+ special |= KMEMSTATS;
newsize = 0;
break;
+ case KERN_MSGBUF:
+ if (flags == 0)
+ return;
+ warnx("use dmesg to view %s", string);
+ return;
case KERN_VNODE:
case KERN_FILE:
if (flags == 0)
@@ -379,6 +411,17 @@ parse(string, flags)
break;
case CTL_HW:
+ switch (mib[1]) {
+ case HW_DISKSTATS:
+ /*
+ * Only complain if someone asks explicitly for this,
+ * otherwise "fail" silently.
+ */
+ if (flags)
+ warnx("use vmstat to view %s information",
+ string);
+ return;
+ }
break;
case CTL_VM:
@@ -407,16 +450,15 @@ parse(string, flags)
(void)printf("%s = ", string);
(void)printf("%p\n", _ps.val);
return;
- }
-#ifdef UVM
- else if (mib[1] == VM_SWAPENCRYPT) {
+ } else if (mib[1] == VM_SWAPENCRYPT) {
len = sysctl_swpenc(string, &bufp, mib, flags, &type);
if (len < 0)
return;
break;
+ } else if (mib[1] == VM_NKMEMPAGES) {
+ break;
}
-#endif
if (flags == 0)
return;
warnx("use vmstat or systat to view %s information", string);
@@ -567,7 +609,8 @@ parse(string, flags)
break;
case CTLTYPE_QUAD:
- (void)sscanf(newval, "%qd", &quadval);
+ /* XXX - assumes sizeof(long long) == sizeof(quad_t) */
+ (void)sscanf(newval, "%lld", (long long *)&quadval);
newval = &quadval;
newsize = sizeof(quadval);
break;
@@ -599,7 +642,35 @@ parse(string, flags)
struct kmembuckets *kb = (struct kmembuckets *)buf;
if (!nflag)
(void)printf("%s = ", string);
- (void)printf("calls = %qu, total_allocated = %qu, total_free = %qu, elements = %qu, high_watermark = %qu, could_free = %qu\n", kb->kb_calls, kb->kb_total, kb->kb_totalfree, kb->kb_elmpercl, kb->kb_highwat, kb->kb_couldfree);
+ printf("(");
+ printf("calls = %llu ", (long long)kb->kb_calls);
+ printf("total_allocated = %llu ", (long long)kb->kb_total);
+ printf("total_free = %lld ", (long long)kb->kb_totalfree);
+ printf("elements = %lld ", (long long)kb->kb_elmpercl);
+ printf("high watermark = %lld ", (long long)kb->kb_highwat);
+ printf("could_free = %lld", (long long)kb->kb_couldfree);
+ printf(")\n");
+ return;
+ }
+ if (special & KMEMSTATS) {
+ struct kmemstats *km = (struct kmemstats *)buf;
+ int j, first = 1;
+
+ if (!nflag)
+ (void)printf("%s = ", string);
+ (void)printf("(inuse = %ld, calls = %ld, memuse = %ldK, limblocks = %d, mapblocks = %d, maxused = %ldK, limit = %ldK, spare = %ld, sizes = (", km->ks_inuse, km->ks_calls, (km->ks_memuse + 1023) / 1024, km->ks_limblocks, km->ks_mapblocks, (km->ks_maxused + 1023) / 1024, (km->ks_limit + 1023) / 1024, km->ks_spare);
+ for (j = 1 << MINBUCKET; j < 1 << (MINBUCKET + 16); j <<= 1) {
+ if ((km->ks_size & j ) == 0)
+ continue;
+ if (first)
+ (void)printf("%d", j);
+ else
+ (void)printf(",%d", j);
+ first = 0;
+ }
+ if (first)
+ (void)printf("none");
+ (void)printf("))\n");
return;
}
if (special & CLOCK) {
@@ -651,8 +722,8 @@ parse(string, flags)
(void)printf("%s = ", string);
(void)printf("bootdev = 0x%x, "
"cylinders = %u, heads = %u, sectors = %u\n",
- pdi->bsd_dev, pdi->bios_cylinders, pdi->bios_heads,
- pdi->bios_sectors);
+ pdi->bsd_dev, pdi->bios_cylinders,
+ pdi->bios_heads, pdi->bios_sectors);
return;
}
if (special & BIOSDEV) {
@@ -684,25 +755,29 @@ parse(string, flags)
if (!nflag)
(void)printf("%s = ", string);
(void)printf(
- "%qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu %qu",
- rndstats->rnd_total,
- rndstats->rnd_used, rndstats->rnd_reads,
- rndstats->arc4_reads, rndstats->arc4_nstirs,
- rndstats->arc4_stirs,
- rndstats->rnd_pad[0],
- rndstats->rnd_pad[1],
- rndstats->rnd_pad[2],
- rndstats->rnd_pad[3],
- rndstats->rnd_pad[4],
- rndstats->rnd_waits,
- rndstats->rnd_enqs, rndstats->rnd_deqs,
- rndstats->rnd_drops, rndstats->rnd_drople);
+ "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
+ (unsigned long long)rndstats->rnd_total,
+ (unsigned long long)rndstats->rnd_used,
+ (unsigned long long)rndstats->rnd_reads,
+ (unsigned long long)rndstats->arc4_reads,
+ (unsigned long long)rndstats->arc4_nstirs,
+ (unsigned long long)rndstats->arc4_stirs,
+ (unsigned long long)rndstats->rnd_pad[0],
+ (unsigned long long)rndstats->rnd_pad[1],
+ (unsigned long long)rndstats->rnd_pad[2],
+ (unsigned long long)rndstats->rnd_pad[3],
+ (unsigned long long)rndstats->rnd_pad[4],
+ (unsigned long long)rndstats->rnd_waits,
+ (unsigned long long)rndstats->rnd_enqs,
+ (unsigned long long)rndstats->rnd_deqs,
+ (unsigned long long)rndstats->rnd_drops,
+ (unsigned long long)rndstats->rnd_drople);
for (i = 0; i < sizeof(rndstats->rnd_ed)/sizeof(rndstats->rnd_ed[0]); i++)
- (void)printf(" %qu", rndstats->rnd_ed[i]);
+ (void)printf(" %llu", (unsigned long long)rndstats->rnd_ed[i]);
for (i = 0; i < sizeof(rndstats->rnd_sc)/sizeof(rndstats->rnd_sc[0]); i++)
- (void)printf(" %qu", rndstats->rnd_sc[i]);
+ (void)printf(" %llu", (unsigned long long)rndstats->rnd_sc[i]);
for (i = 0; i < sizeof(rndstats->rnd_sb)/sizeof(rndstats->rnd_sb[0]); i++)
- (void)printf(" %qu", rndstats->rnd_sb[i]);
+ (void)printf(" %llu", (unsigned long long)rndstats->rnd_sb[i]);
printf("\n");
return;
}
@@ -738,7 +813,7 @@ parse(string, flags)
if (special & LONGARRAY) {
long *la = (long *)buf;
if (!nflag)
- printf("%s = ", string, lal);
+ printf("%s = ", string);
while (lal--)
printf("%ld%s", *la++, lal? ",":"");
putchar('\n');
@@ -772,14 +847,18 @@ parse(string, flags)
case CTLTYPE_QUAD:
if (newsize == 0) {
+ long long tmp = *(quad_t *)buf;
+
if (!nflag)
(void)printf("%s = ", string);
- (void)printf("%qd\n", *(quad_t *)buf);
+ (void)printf("%lld\n", tmp);
} else {
+ long long tmp = *(quad_t *)buf;
+
if (!nflag)
- (void)printf("%s: %qd -> ", string,
- *(quad_t *)buf);
- (void)printf("%qd\n", *(quad_t *)newval);
+ (void)printf("%s: %lld -> ", string, tmp);
+ tmp = *(quad_t *)newval;
+ (void)printf("%qd\n", tmp);
}
return;
@@ -1099,7 +1178,6 @@ sysctl_bios(string, bufpp, mib, flags, typep)
}
#endif
-#ifdef UVM
struct ctlname swpencname[] = CTL_SWPENC_NAMES;
struct list swpenclist = { swpencname, SWPENC_MAXID };
@@ -1114,7 +1192,6 @@ sysctl_swpenc(string, bufpp, mib, flags, typep)
int flags;
int *typep;
{
- char *name;
int indx;
if (*bufpp == NULL) {
@@ -1127,7 +1204,6 @@ sysctl_swpenc(string, bufpp, mib, flags, typep)
*typep = swpenclist.list[indx].ctl_type;
return(3);
}
-#endif
struct ctlname inetname[] = CTL_IPPROTO_NAMES;
struct ctlname ipname[] = IPCTL_NAMES;
@@ -1140,6 +1216,7 @@ struct ctlname ahname[] = AHCTL_NAMES;
struct ctlname etheripname[] = ETHERIPCTL_NAMES;
struct ctlname grename[] = GRECTL_NAMES;
struct ctlname mobileipname[] = MOBILEIPCTL_NAMES;
+struct ctlname ipcompname[] = IPCOMPCTL_NAMES;
struct list inetlist = { inetname, IPPROTO_MAXID };
struct list inetvars[] = {
{ ipname, IPCTL_MAXID }, /* ip */
@@ -1240,9 +1317,176 @@ struct list inetvars[] = {
{ 0, 0 },
{ 0, 0 },
{ etheripname, ETHERIPCTL_MAXID },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { ipcompname, IPCOMPCTL_MAXID },
};
struct list kernmalloclist = { kernmallocname, KERN_MALLOC_MAXID };
+struct list forkstatlist = { forkstatname, KERN_FORKSTAT_MAXID };
+struct list nchstatslist = { nchstatsname, KERN_NCHSTATS_MAXID };
+struct list ttylist = { ttyname, KERN_TTY_MAXID };
+
+/*
+ * handle vfs namei cache statistics
+ */
+int
+sysctl_nchstats(string, bufpp, mib, flags, typep)
+ char *string;
+ char **bufpp;
+ int mib[];
+ int flags;
+ int *typep;
+{
+ static struct nchstats nch;
+ int indx;
+ size_t size;
+ static int keepvalue = 0;
+
+ if (*bufpp == NULL) {
+ bzero(&nch, sizeof(struct nchstats));
+ listall(string, &nchstatslist);
+ return(-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &nchstatslist)) == -1)
+ return(-1);
+ mib[2] = indx;
+ if (*bufpp != NULL) {
+ warnx("fourth level name in %s is invalid", string);
+ return(-1);
+ }
+ if (keepvalue == 0) {
+ size = sizeof(struct nchstats);
+ if (sysctl(mib, 2, &nch, &size, NULL, 0) < 0)
+ return(-1);
+ keepvalue = 1;
+ }
+ if (!nflag)
+ (void)printf("%s = ", string);
+ switch (indx) {
+ case KERN_NCHSTATS_GOODHITS:
+ (void)printf("%ld\n", nch.ncs_goodhits);
+ break;
+ case KERN_NCHSTATS_NEGHITS:
+ (void)printf("%ld\n", nch.ncs_neghits);
+ break;
+ case KERN_NCHSTATS_BADHITS:
+ (void)printf("%ld\n", nch.ncs_badhits);
+ break;
+ case KERN_NCHSTATS_FALSEHITS:
+ (void)printf("%ld\n", nch.ncs_falsehits);
+ break;
+ case KERN_NCHSTATS_MISS:
+ (void)printf("%ld\n", nch.ncs_miss);
+ break;
+ case KERN_NCHSTATS_LONG:
+ (void)printf("%ld\n", nch.ncs_long);
+ break;
+ case KERN_NCHSTATS_PASS2:
+ (void)printf("%ld\n", nch.ncs_pass2);
+ break;
+ case KERN_NCHSTATS_2PASSES:
+ (void)printf("%ld\n", nch.ncs_2passes);
+ break;
+ }
+ return(-1);
+}
+
+/*
+ * handle tty statistics
+ */
+int
+sysctl_tty(string, bufpp, mib, flags, typep)
+ char *string;
+ char **bufpp;
+ int mib[];
+ int flags;
+ int *typep;
+{
+ int indx;
+
+ if (*bufpp == NULL) {
+ listall(string, &ttylist);
+ return(-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &ttylist)) == -1)
+ return(-1);
+ mib[2] = indx;
+ *typep = CTLTYPE_QUAD;
+ return(3);
+}
+
+/*
+ * handle fork statistics
+ */
+int
+sysctl_forkstat(string, bufpp, mib, flags, typep)
+ char *string;
+ char **bufpp;
+ int mib[];
+ int flags;
+ int *typep;
+{
+ static struct forkstat fks;
+ static int keepvalue = 0;
+ int indx;
+ size_t size;
+
+ if (*bufpp == NULL) {
+ bzero(&fks, sizeof(struct forkstat));
+ listall(string, &forkstatlist);
+ return(-1);
+ }
+ if ((indx = findname(string, "third", bufpp, &forkstatlist)) == -1)
+ return(-1);
+ if (*bufpp != NULL) {
+ warnx("fourth level name in %s is invalid", string);
+ return(-1);
+ }
+ if (keepvalue == 0) {
+ size = sizeof(struct forkstat);
+ if (sysctl(mib, 2, &fks, &size, NULL, 0) < 0)
+ return(-1);
+ keepvalue = 1;
+ }
+ if (!nflag)
+ (void)printf("%s = ", string);
+ switch (indx) {
+ case KERN_FORKSTAT_FORK:
+ (void)printf("%d\n", fks.cntfork);
+ break;
+ case KERN_FORKSTAT_VFORK:
+ (void)printf("%d\n", fks.cntvfork);
+ break;
+ case KERN_FORKSTAT_RFORK:
+ (void)printf("%d\n", fks.cntrfork);
+ break;
+ case KERN_FORKSTAT_KTHREAD:
+ (void)printf("%d\n", fks.cntkthread);
+ break;
+ case KERN_FORKSTAT_SIZFORK:
+ (void)printf("%d\n", fks.sizfork);
+ break;
+ case KERN_FORKSTAT_SIZVFORK:
+ (void)printf("%d\n", fks.sizvfork);
+ break;
+ case KERN_FORKSTAT_SIZRFORK:
+ (void)printf("%d\n", fks.sizrfork);
+ break;
+ case KERN_FORKSTAT_SIZKTHREAD:
+ (void)printf("%d\n", fks.sizkthread);
+ break;
+ }
+ return(-1);
+}
/*
* handle malloc statistics
@@ -1255,16 +1499,17 @@ sysctl_malloc(string, bufpp, mib, flags, typep)
int flags;
int *typep;
{
- int indx, size, stor, i;
- char *name, bufp[BUFSIZ], *buf;
+ int indx, stor, i;
+ char *name, bufp[BUFSIZ], *buf, *ptr;
struct list lp;
+ size_t size;
if (*bufpp == NULL) {
listall(string, &kernmalloclist);
return(-1);
}
if ((indx = findname(string, "third", bufpp, &kernmalloclist)) == -1)
- return (-1);
+ return(-1);
mib[2] = indx;
if (mib[2] == KERN_MALLOC_BUCKET) {
if ((name = strsep(bufpp, ".")) == NULL) {
@@ -1283,8 +1528,8 @@ sysctl_malloc(string, bufpp, mib, flags, typep)
return(-1);
lp.size = stor + 2;
for (i = 1;
- (lp.list[i].ctl_name = strsep(&buf, ",")) != NULL;
- i++) {
+ (lp.list[i].ctl_name = strsep(&buf, ",")) != NULL;
+ i++) {
lp.list[i].ctl_type = CTLTYPE_STRUCT;
}
lp.list[i].ctl_name = buf;
@@ -1295,10 +1540,64 @@ sysctl_malloc(string, bufpp, mib, flags, typep)
}
mib[3] = atoi(name);
return(4);
- } else {
+ } else if (mib[2] == KERN_MALLOC_BUCKETS) {
+ *typep = CTLTYPE_STRING;
+ return(3);
+ } else if (mib[2] == KERN_MALLOC_KMEMSTATS) {
+ size = BUFSIZ;
+ stor = mib[2];
+ mib[2] = KERN_MALLOC_KMEMNAMES;
+ buf = bufp;
+ if (sysctl(mib, 3, buf, &size, NULL, 0) < 0)
+ return(-1);
+ mib[2] = stor;
+ if ((name = strsep(bufpp, ".")) == NULL) {
+ for (stor = 0, i = 0; i < size; i++)
+ if (buf[i] == ',')
+ stor++;
+ lp.list = calloc(stor + 2, sizeof(struct ctlname));
+ if (lp.list == NULL)
+ return(-1);
+ lp.size = stor + 2;
+ for (i = 1; (lp.list[i].ctl_name = strsep(&buf, ",")) != NULL; i++) {
+ if (lp.list[i].ctl_name[0] == '\0') {
+ i--;
+ continue;
+ }
+ lp.list[i].ctl_type = CTLTYPE_STRUCT;
+ }
+ lp.list[i].ctl_name = buf;
+ lp.list[i].ctl_type = CTLTYPE_STRUCT;
+ listall(string, &lp);
+ free(lp.list);
+ return(-1);
+ }
+ ptr = strstr(buf, name);
+ tryagain:
+ if (ptr == NULL) {
+ warnx("fourth level name %s in %s is invalid", name,
+ string);
+ return(-1);
+ }
+ if ((*(ptr + strlen(name)) != ',') &&
+ (*(ptr + strlen(name)) != '\0')) {
+ ptr = strstr(ptr + 1, name); /* retry */
+ goto tryagain;
+ }
+ if ((ptr != buf) && (*(ptr - 1) != ',')) {
+ ptr = strstr(ptr + 1, name); /* retry */
+ goto tryagain;
+ }
+ for (i = 0, stor = 0; buf + i < ptr; i++)
+ if (buf[i] == ',')
+ stor++;
+ mib[3] = stor;
+ return(4);
+ } else if (mib[2] == KERN_MALLOC_KMEMNAMES) {
*typep = CTLTYPE_STRING;
return(3);
}
+ return(-1);
}
/*
View
6 openbsd/usr.bin/netstat/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.9 2000/06/14 01:05:04 itojun Exp $
+# $OpenBSD: Makefile,v 1.10 2001/07/30 11:42:09 hugh Exp $
PROG= netstat
-SRCS= if.c inet.c ipx.c iso.c main.c mbuf.c mroute.c ns.c route.c \
- tp_astring.c unix.c atalk.c inet6.c mroute6.c
+SRCS= if.c inet.c inet6.c ipx.c iso.c main.c mbuf.c mroute.c ns.c route.c \
+ tp_astring.c unix.c atalk.c mroute6.c
.PATH: ${.CURDIR}/../../sys/netiso
BINGRP= kmem
BINMODE=2555
View
12 openbsd/usr.bin/netstat/atalk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atalk.c,v 1.3 2001/01/29 01:58:13 niklas Exp $ */
+/* $OpenBSD: atalk.c,v 1.4 2001/08/18 22:14:03 brian Exp $ */
/* $NetBSD: atalk.c,v 1.2 1997/05/22 17:21:26 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from @(#)atalk.c 1.1 (Whistle) 6/6/96";
#else
-static char rcsid[] = "$OpenBSD: atalk.c,v 1.3 2001/01/29 01:58:13 niklas Exp $";
+static char rcsid[] = "$OpenBSD: atalk.c,v 1.4 2001/08/18 22:14:03 brian Exp $";
#endif
#endif /* not lint */
@@ -235,21 +235,25 @@ atalk_print2(sa, mask, what)
n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8)));
if (n >= sizeof(buf))
n = sizeof(buf) - 1;
+ else if (n == -1)
+ n = 0; /* What else can be done ? */
if (sat2->sat_addr.s_net != 0xFFFF) {
thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net |
~sat2->sat_addr.s_net;
l = snprintf(buf + n, sizeof(buf) - n,
"-%s", atalk_print(sa2, 1 | (what & 8)));
if (l >= sizeof(buf) - n)
l = sizeof(buf) - n - 1;
- n += l;
+ if (l > 0)
+ n += l;
}
if (what & 2) {
l = snprintf(buf + n, sizeof(buf) - n, ".%s",
atalk_print(sa, what & (~1)));
if (l >= sizeof(buf) - n)
l = sizeof(buf) - n - 1;
- n += l;
+ if (l > 0)
+ n += l;
}
return (buf);
}
View
48 openbsd/usr.bin/netstat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.23 2001/02/06 05:24:10 fgsch Exp $ */
+/* $OpenBSD: if.c,v 1.26 2001/09/04 23:35:59 millert Exp $ */
/* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-static char *rcsid = "$OpenBSD: if.c,v 1.23 2001/02/06 05:24:10 fgsch Exp $";
+static char *rcsid = "$OpenBSD: if.c,v 1.26 2001/09/04 23:35:59 millert Exp $";
#endif
#endif /* not lint */
@@ -95,11 +95,11 @@ intpr(interval, ifnetaddr)
struct ipx_ifaddr ipx;
struct iso_ifaddr iso;
} ifaddr;
+ u_long total;
u_long ifaddraddr;
struct sockaddr *sa;
struct ifnet_head ifhead; /* TAILQ_HEAD */
char name[IFNAMSIZ];
- int n;
if (ifnetaddr == 0) {
printf("ifnet: symbol not defined\n");
@@ -154,6 +154,22 @@ intpr(interval, ifnetaddr)
*cp = '\0';
ifaddraddr = (u_long)ifnet.if_addrlist.tqh_first;
}
+
+ if (qflag) {
+ total = ifnet.if_ibytes + ifnet.if_obytes +
+ ifnet.if_ipackets + ifnet.if_ierrors +
+ ifnet.if_opackets + ifnet.if_oerrors +
+ ifnet.if_collisions;
+ if (tflag)
+ total += ifnet.if_timer;
+ if (dflag)
+ total += ifnet.if_snd.ifq_drops;
+ if (total == 0) {
+ ifaddraddr = 0;
+ continue;
+ }
+ }
+
printf("%-7.7s %-5ld ", name, ifnet.if_mtu);
if (ifaddraddr == 0) {
printf("%-11.11s ", "none");
@@ -360,7 +376,7 @@ struct iftot {
int ift_dr; /* drops */
} iftot[MAXIF];
-u_char signalled; /* set if alarm goes off "early" */
+volatile sig_atomic_t signalled; /* set if alarm goes off "early" */
/*
* Print a running summary of interface statistics.
@@ -379,7 +395,7 @@ sidewaysintpr(interval, off)
register int line;
struct iftot *lastif, *sum, *interesting;
struct ifnet_head ifhead; /* TAILQ_HEAD */
- int oldmask;
+ sigset_t emptyset;
/*
* Find the pointer to the first ifnet structure. Replace
@@ -520,27 +536,25 @@ sidewaysintpr(interval, off)
if (lastif - iftot > 0) {
if (bflag)
printf(" %10lu %8.8s %10lu %5.5s",
- sum->ift_ib - total->ift_ib, " ",
- sum->ift_ob - total->ift_ob, " ");
+ (unsigned long)sum->ift_ib - total->ift_ib, " ",
+ (unsigned long)sum->ift_ob - total->ift_ob, " ");
else
printf(" %8lu %5lu %8lu %5lu %5lu",
- sum->ift_ip - total->ift_ip,
- sum->ift_ie - total->ift_ie,
- sum->ift_op - total->ift_op,
- sum->ift_oe - total->ift_oe,
- sum->ift_co - total->ift_co);
+ (unsigned long)sum->ift_ip - total->ift_ip,
+ (unsigned long)sum->ift_ie - total->ift_ie,
+ (unsigned long)sum->ift_op - total->ift_op,
+ (unsigned long)sum->ift_oe - total->ift_oe,
+ (unsigned long)sum->ift_co - total->ift_co);
if (dflag)
printf(" %5d", sum->ift_dr - total->ift_dr);
}
*total = *sum;
putchar('\n');
fflush(stdout);
line++;
- oldmask = sigblock(sigmask(SIGALRM));
- if (! signalled) {
- sigpause(0);
- }
- sigsetmask(oldmask);
+ sigemptyset(&emptyset);
+ if (!signalled)
+ sigsuspend(&emptyset);
signalled = NO;
(void)alarm(interval);
if (line == 21)
View
61 openbsd/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.49 2001/03/03 01:00:20 itojun Exp $ */
+/* $OpenBSD: inet.c,v 1.53 2001/08/26 09:42:04 brian Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-static char *rcsid = "$OpenBSD: inet.c,v 1.49 2001/03/03 01:00:20 itojun Exp $";
+static char *rcsid = "$OpenBSD: inet.c,v 1.53 2001/08/26 09:42:04 brian Exp $";
#endif
#endif /* not lint */
@@ -72,6 +72,7 @@ static char *rcsid = "$OpenBSD: inet.c,v 1.49 2001/03/03 01:00:20 itojun Exp $";
#include <netinet/ip_ah.h>
#include <netinet/ip_esp.h>
#include <netinet/ip_ipip.h>
+#include <netinet/ip_ipcomp.h>
#include <netinet/ip_ether.h>
#include <arpa/inet.h>
@@ -272,6 +273,7 @@ tcp_stats(off, name)
p(tcps_sndprobe, "\t\t%u window probe packet%s\n");
p(tcps_sndwinup, "\t\t%u window update packet%s\n");
p(tcps_sndctrl, "\t\t%u control packet%s\n");
+ p(tcps_outhwcsum, "\t\t%u packet%s hardware-checksummed\n");
p(tcps_rcvtotal, "\t%u packet%s received\n");
p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%u ack%s (for %qd byte%s)\n");
p(tcps_rcvdupack, "\t\t%u duplicate ack%s\n");
@@ -294,6 +296,7 @@ tcp_stats(off, name)
p(tcps_rcvbadoff, "\t\t%u discarded for bad header offset field%s\n");
p1(tcps_rcvshort, "\t\t%u discarded because packet too short\n");
p1(tcps_rcvnosec, "\t\t%u discarded for missing IPSec protection\n");
+ p(tcps_inhwcsum, "\t\t%u packet%s hardware-checksummed\n");
p(tcps_connattempt, "\t%u connection request%s\n");
p(tcps_accepts, "\t%u connection accept%s\n");
p(tcps_connects, "\t%u connection%s established (including accepts)\n");
@@ -343,6 +346,8 @@ udp_stats(off, name)
p1(udps_badlen, "\t%lu with bad data length field\n");
p1(udps_badsum, "\t%lu with bad checksum\n");
p1(udps_nosum, "\t%lu with no checksum\n");
+ p(udps_inhwcsum, "\t%lu input packet%s hardware-checksummed\n");
+ p(udps_outhwcsum, "\t%lu output packet%s hardware-checksummed\n");
p1(udps_noport, "\t%lu dropped due to no socket\n");
p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n");
p1(udps_nosec, "\t%lu dropped due to missing IPSec protection\n");
@@ -411,6 +416,8 @@ ip_stats(off, name)
p(ips_toolong, "\t%lu packet%s with ip length > max ip packet size\n");
p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
p(ips_badaddr, "\t%lu datagram%s with bad address in header\n");
+ p(ips_inhwcsum, "\t%lu input datagram%s checksum-processed by hardware\n");
+ p(ips_outhwcsum, "\t%lu output datagram%s checksum-processed by hardware\n");
#undef p
#undef p1
}
@@ -743,13 +750,13 @@ etherip_stats(off, name)
printf(m, etheripstat.f, plural(etheripstat.f))
- p(etherip_hdrops, "\t%u packet%s shorter than header shows\n");
- p(etherip_qfull, "\t%u packet%s were dropped due to full output queue\n");
+ p(etherip_hdrops, "\t%u packet%s shorter than header shows\n");
+ p(etherip_qfull, "\t%u packet%s were dropped due to full output queue\n");
p(etherip_noifdrops, "\t%u packet%s were dropped because of no interface/bridge information\n");
- p(etherip_pdrops, "\t%u packet%s dropped due to policy\n");
- p(etherip_adrops, "\t%u packet%s dropped for other reasons\n");
- p(etherip_ipackets, "\t%u input ethernet-in-IP packets\n");
- p(etherip_opackets, "\t%u output ethernet-in-IP packets\n");
+ p(etherip_pdrops, "\t%u packet%s dropped due to policy\n");
+ p(etherip_adrops, "\t%u packet%s dropped for other reasons\n");
+ p(etherip_ipackets, "\t%u input ethernet-in-IP packet%s\n");
+ p(etherip_opackets, "\t%u output ethernet-in-IP packet%s\n");
p(etherip_ibytes, "\t%qu input byte%s\n");
p(etherip_obytes, "\t%qu output byte%s\n");
#undef p
@@ -827,3 +834,41 @@ ipip_stats(off, name)
p(ipips_unspec, "\t%u attempts to use tunnel with unspecified endpoint(s)\n");
#undef p
}
+
+/*
+ * Dump IPCOMP statistics structure.
+ */
+void
+ipcomp_stats(off, name)
+ u_long off;
+ char *name;
+{
+ struct ipcompstat ipcompstat;
+
+
+ if (off == 0)
+ return;
+ kread(off, (char *)&ipcompstat, sizeof (ipcompstat));
+ printf("%s:\n", name);
+
+#define p(f, m) if (ipcompstat.f || sflag <= 1) \
+ printf(m, ipcompstat.f, plural(ipcompstat.f))
+
+ p(ipcomps_input, "\t%u input IPCOMP packet%s\n");
+ p(ipcomps_output, "\t%u output IPCOMP packet%s\n");
+ p(ipcomps_nopf, "\t%u packet%s from unsupported protocol families\n");
+ p(ipcomps_hdrops, "\t%u packet%s shorter than header shows\n");
+ p(ipcomps_pdrops, "\t%u packet%s dropped due to policy\n");
+ p(ipcomps_notdb, "\t%u packet%s for which no TDB was found\n");
+ p(ipcomps_badkcr, "\t%u input packet%s that failed to be processed\n");
+ p(ipcomps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n");
+ p(ipcomps_qfull, "\t%u packet%s were dropped due to full output queue\n");
+ p(ipcomps_wrap, "\t%u packet%s where counter wrapping was detected\n");
+ p(ipcomps_invalid, "\t%u packet%s attempted to use an invalid tdb\n");
+ p(ipcomps_toobig, "\t%u packet%s got larger than max IP packet size\n");
+ p(ipcomps_crypto, "\t%u packet%s that failed (de)compression processing\n");
+ p(ipcomps_ibytes, "\t%qu input byte%s\n");
+ p(ipcomps_obytes, "\t%qu output byte%s\n");
+
+#undef p
+}
View
8 openbsd/usr.bin/netstat/inet6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet6.c,v 1.14 2001/02/07 11:43:50 itojun Exp $ */
+/* $OpenBSD: inet6.c,v 1.15 2001/06/13 02:29:15 itojun Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
* Copyright (c) 1983, 1988, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-/*__RCSID("$OpenBSD: inet6.c,v 1.14 2001/02/07 11:43:50 itojun Exp $");*/
+/*__RCSID("$OpenBSD: inet6.c,v 1.15 2001/06/13 02:29:15 itojun Exp $");*/
/*__RCSID("KAME Id: inet6.c,v 1.10 2000/02/09 10:49:31 itojun Exp");*/
#endif
#endif /* not lint */
@@ -698,9 +698,9 @@ static char *icmp6names[] = {
"multicast listener report",
"multicast listener done",
"router solicitation",
- "router advertisment",
+ "router advertisement",
"neighbor solicitation",
- "neighbor advertisment",
+ "neighbor advertisement",
"redirect",
"router renumbering",
"node information request",
View
20 openbsd/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.24 2000/12/13 15:52:58 camield Exp $ */
+/* $OpenBSD: main.c,v 1.27 2001/08/26 09:42:04 brian Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
#else
-static char *rcsid = "$OpenBSD: main.c,v 1.24 2000/12/13 15:52:58 camield Exp $";
+static char *rcsid = "$OpenBSD: main.c,v 1.27 2001/08/26 09:42:04 brian Exp $";
#endif
#endif /* not lint */
@@ -171,6 +171,12 @@ struct nlist nl[] = {
{ "_mf6ctable" },
#define N_MIF6TABLE 50
{ "_mif6table" },
+#define N_MBPOOL 51
+ { "_mbpool" },
+#define N_MCLPOOL 52
+ { "_mclpool" },
+#define N_IPCOMPSTAT 53
+ { "_ipcompstat" },
{ ""},
};
@@ -200,6 +206,8 @@ struct protox {
ipip_stats, "ipencap" },
{ -1, N_ETHERIPSTAT, 1, 0,
etherip_stats,"etherip" },
+ { -1, N_IPCOMPSTAT, 1, 0,
+ ipcomp_stats, "ipcomp" },
{ -1, -1, 0, 0,
0, 0 }
};
@@ -289,7 +297,7 @@ main(argc, argv)
af = AF_UNSPEC;
- while ((ch = getopt(argc, argv, "Aabdf:gI:ilM:mN:np:rstuvw:")) != -1)
+ while ((ch = getopt(argc, argv, "Aabdf:gI:ilM:mN:np:qrstuvw:")) != -1)
switch(ch) {
case 'A':
Aflag = 1;
@@ -363,6 +371,9 @@ main(argc, argv)
}
pflag = 1;
break;
+ case 'q':
+ qflag = 1;
+ break;
case 'r':
rflag = 1;
break;
@@ -433,7 +444,8 @@ main(argc, argv)
exit(1);
}
if (mflag) {
- mbpr(nl[N_MBSTAT].n_value);
+ mbpr(nl[N_MBSTAT].n_value, nl[N_MBPOOL].n_value,
+ nl[N_MCLPOOL].n_value);
exit(0);
}
if (pflag) {
View
40 openbsd/usr.bin/netstat/mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.c,v 1.7 1999/02/27 21:22:19 deraadt Exp $ */
+/* $OpenBSD: mbuf.c,v 1.8 2001/05/18 02:41:38 provos Exp $ */
/* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */
/*
@@ -38,14 +38,17 @@
#if 0
static char sccsid[] = "from: @(#)mbuf.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: mbuf.c,v 1.7 1999/02/27 21:22:19 deraadt Exp $";
+static char *rcsid = "$OpenBSD: mbuf.c,v 1.8 2001/05/18 02:41:38 provos Exp $";
#endif
#endif /* not lint */
+#define __POOL_EXPOSE
+
#include <sys/param.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
+#include <sys/pool.h>
#include <limits.h>
#include <stdio.h>
@@ -55,6 +58,8 @@ static char *rcsid = "$OpenBSD: mbuf.c,v 1.7 1999/02/27 21:22:19 deraadt Exp $";
typedef int bool;
struct mbstat mbstat;
+struct pool mbpool, mclpool;
+
static struct mbtypes {
int mt_type;
@@ -64,16 +69,9 @@ static struct mbtypes {
{ MT_OOBDATA, "oob data" },
{ MT_CONTROL, "ancillary data" },
{ MT_HEADER, "packet headers" },
- { MT_SOCKET, "socket structures" }, /* XXX */
- { MT_PCB, "protocol control blocks" }, /* XXX */
- { MT_RTABLE, "routing table entries" }, /* XXX */
- { MT_HTABLE, "IMP host table entries" }, /* XXX */
- { MT_ATABLE, "address resolution tables" },
{ MT_FTABLE, "fragment reassembly queue headers" }, /* XXX */
{ MT_SONAME, "socket names and addresses" },
{ MT_SOOPTS, "socket options" },
- { MT_RIGHTS, "access rights" },
- { MT_IFADDR, "interface addresses" }, /* XXX */
{ 0, 0 }
};
@@ -84,10 +82,11 @@ bool seen[256]; /* "have we seen this type yet?" */
* Print mbuf statistics.
*/
void
-mbpr(mbaddr)
+mbpr(mbaddr, mbpooladdr, mclpooladdr)
u_long mbaddr;
+ u_long mbpooladdr, mclpooladdr;
{
- register int totmem, totfree, totmbufs;
+ register int totmem, totused, totmbufs, totpct;
register int i;
register struct mbtypes *mp;
@@ -104,6 +103,12 @@ mbpr(mbaddr)
}
if (kread(mbaddr, (char *)&mbstat, sizeof (mbstat)))
return;
+ if (kread(mbpooladdr, (char *)&mbpool, sizeof (mbpool)))
+ return;
+
+ if (kread(mclpooladdr, (char *)&mclpool, sizeof (mclpool)))
+ return;
+
totmbufs = 0;
for (mp = mbtypes; mp->mt_name; mp++)
totmbufs += mbstat.m_mtypes[mp->mt_type];
@@ -124,12 +129,15 @@ mbpr(mbaddr)
plural((int)mbstat.m_mtypes[i]), i);
}
printf("%lu/%lu mapped pages in use\n",
- mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
- totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES;
- totfree = mbstat.m_clfree * MCLBYTES;
+ (u_long)(mclpool.pr_nget - mclpool.pr_nput),
+ ((u_long)mclpool.pr_npages * mclpool.pr_itemsperpage));
+ totmem = (mbpool.pr_npages << mbpool.pr_pageshift) +
+ (mclpool.pr_npages << mclpool.pr_pageshift);
+ totused = (mbpool.pr_nget - mbpool.pr_nput) * mbpool.pr_size +
+ (mclpool.pr_nget - mclpool.pr_nput) * mclpool.pr_size;
+ totpct = (totmem == 0)? 0 : ((totused * 100)/totmem);
printf("%u Kbytes allocated to network (%d%% in use)\n",
- totmem / 1024,
- totmem ? (totmem - totfree) * 100 / totmem : 100);
+ totmem / 1024, totpct);
printf("%lu requests for memory denied\n", mbstat.m_drops);
printf("%lu requests for memory delayed\n", mbstat.m_wait);
printf("%lu calls to protocol drain routines\n", mbstat.m_drain);
View
15 openbsd/usr.bin/netstat/netstat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: netstat.1,v 1.24 2000/12/13 15:52:58 camield Exp $
+.\" $OpenBSD: netstat.1,v 1.26 2001/08/26 09:42:04 brian Exp $
.\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $
.\"
.\" Copyright (c) 1983, 1990, 1992, 1993
@@ -47,7 +47,7 @@
.Op Fl M Ar core
.Op Fl N Ar system
.Nm netstat
-.Op Fl bdgimnrs
+.Op Fl bdgimnqrs
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
@@ -207,14 +207,18 @@ report.
The program will complain if
.Ar protocol
is unknown or if there is no statistics routine for it.
-.It Fl s
-Show per-protocol statistics.
-If this option is repeated, counters with a value of zero are suppressed.
+.It Fl q
+Only show interfaces that have seen packets (or bytes if
+.Fl b
+is specified)
.It Fl r
Show the routing tables.
If the
.Fl s
option is also specified, show routing statistics instead.
+.It Fl s
+Show per-protocol statistics.
+If this option is repeated, counters with a value of zero are suppressed.
.It Fl v
Be verbose.
Avoids truncation of long addresses.
@@ -280,6 +284,7 @@ The mapping between letters and flags is:
.Bl -column XXXX RTF_BLACKHOLE
1 RTF_PROTO1 Protocol specific routing flag #1.
2 RTF_PROTO2 Protocol specific routing flag #2.
+3 RTF_PROTO3 Protocol specific routing flag #3.
B RTF_BLACKHOLE Just discard pkts (during updates).
C RTF_CLONING Generate new routes on use.
D RTF_DYNAMIC Created dynamically (by redirect).
View
6 openbsd/usr.bin/netstat/netstat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.h,v 1.16 2000/12/13 15:52:58 camield Exp $ */
+/* $OpenBSD: netstat.h,v 1.19 2001/08/26 09:42:04 brian Exp $ */
/* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */
/*
@@ -51,6 +51,7 @@ int lflag; /* show routing table with use and ref */
int mflag; /* show memory stats */
int nflag; /* show addresses numerically */
int pflag; /* show given protocol */
+int qflag; /* only display non-zero values for output */
int rflag; /* show routing tables (or routing stats) */
int sflag; /* show protocol statistics */
int tflag; /* show i/f watchdog timers */
@@ -83,8 +84,9 @@ void esp_stats __P((u_long, char *));
void ipip_stats __P((u_long, char *));
void etherip_stats __P((u_long, char *));
void protopr __P((u_long, char *));
+void ipcomp_stats __P((u_long, char *));
-void mbpr(u_long);
+void mbpr(u_long, u_long, u_long);
void hostpr __P((u_long, u_long));
void impstats __P((u_long, u_long));
View
20 openbsd/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.39 2000/12/11 17:33:07 provos Exp $ */
+/* $OpenBSD: route.c,v 1.42 2001/10/09 09:21:10 brian Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: route.c,v 1.39 2000/12/11 17:33:07 provos Exp $";
+static char *rcsid = "$OpenBSD: route.c,v 1.42 2001/10/09 09:21:10 brian Exp $";
#endif
#endif /* not lint */
@@ -110,6 +110,7 @@ struct bits {
{ RTF_STATIC, 'S' },
{ RTF_PROTO1, '1' },
{ RTF_PROTO2, '2' },
+ { RTF_PROTO3, '3' },
{ 0 }
};
@@ -440,7 +441,7 @@ p_sockaddr(sa, mask, flags, width)
register struct sockaddr_in *msin = (struct sockaddr_in *)mask;
cp = (sin->sin_addr.s_addr == 0) ? "default" :
- ((flags & RTF_HOST) ?
+ ((flags & RTF_HOST) || mask == NULL ?
routename(sin->sin_addr.s_addr) :
netname(sin->sin_addr.s_addr, msin->sin_addr.s_addr));
@@ -505,10 +506,12 @@ p_sockaddr(sa, mask, flags, width)
n = snprintf(cp,
workbuf + sizeof (workbuf) - cp,
"%s%x", cplim, *lla);
+ cplim = ":";
+ if (n == -1) /* What else to do ? */
+ continue;
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
cp += n;
- cplim = ":";
}
cp = workbuf;
break;
@@ -535,20 +538,23 @@ p_sockaddr(sa, mask, flags, width)
n = snprintf(cp, cplim - cp, "(%d)", sa->sa_family);
if (n >= cplim - cp)
n = cplim - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
while (s < slim && cp < cplim) {
n = snprintf(cp, workbuf + sizeof (workbuf) - cp,
" %02x", *s++);
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
if (s < slim) {
n = snprintf(cp,
workbuf + sizeof (workbuf) - cp,
"%02x", *s++);
if (n >= workbuf + sizeof (workbuf) - cp)
n = workbuf + sizeof (workbuf) - cp - 1;
- cp += n;
+ if (n > 0)
+ cp += n;
}
}
cp = workbuf;
View
5 openbsd/usr.bin/systat/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.12 2000/09/03 18:41:20 espie Exp $
+# $OpenBSD: Makefile,v 1.13 2001/06/27 07:13:39 art Exp $
PROG= systat
@@ -16,6 +16,3 @@ CPPFLAGS+=-DINET6
.include <bsd.prog.mk>
-.if (${UVM:L} == "yes")
-CFLAGS+=-DUVM
-.endif
View
13 openbsd/usr.bin/systat/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.5 1997/06/23 22:21:45 millert Exp $ */
+/* $OpenBSD: cmds.c,v 1.6 2001/09/04 23:35:59 millert Exp $ */
/* $NetBSD: cmds.c,v 1.4 1996/05/10 23:16:32 thorpej Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
#endif
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.5 1997/06/23 22:21:45 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmds.c,v 1.6 2001/09/04 23:35:59 millert Exp $";
#endif /* not lint */
#include <stdlib.h>
@@ -55,9 +55,12 @@ command(cmd)
{
register struct cmdtab *p;
register char *cp;
- int interval, omask;
+ int interval;
+ sigset_t mask, omask;
- omask = sigblock(sigmask(SIGALRM));
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGALRM);
+ sigprocmask(SIG_BLOCK, &mask, &omask);
for (cp = cmd; *cp && !isspace(*cp); cp++)
;
if (*cp)
@@ -144,7 +147,7 @@ command(cmd)
if (curcmd->c_cmd == 0 || !(*curcmd->c_cmd)(cmd, cp))
error("%s: Unknown command.", cmd);
done:
- sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
}
struct cmdtab *
View
6 openbsd/usr.bin/systat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.11 2000/07/07 20:47:25 deraadt Exp $ */
+/* $OpenBSD: iostat.c,v 1.12 2001/08/12 12:03:03 heko Exp $ */
/* $NetBSD: iostat.c,v 1.5 1996/05/10 23:16:35 thorpej Exp $ */
/*
@@ -38,8 +38,8 @@
#if 0
static char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: iostat.c,v 1.11 2000/07/07 20:47:25 deraadt Exp $";
-#endif not lint
+static char rcsid[] = "$OpenBSD: iostat.c,v 1.12 2001/08/12 12:03:03 heko Exp $";
+#endif /* not lint */
#include <sys/param.h>
#include <sys/dkstat.h>
View
38 openbsd/usr.bin/systat/keyboard.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keyboard.c,v 1.6 2000/07/10 03:10:17 millert Exp $ */
+/* $OpenBSD: keyboard.c,v 1.7 2001/09/04 23:35:59 millert Exp $ */
/* $NetBSD: keyboard.c,v 1.2 1995/01/20 08:51:59 jtc Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: keyboard.c,v 1.6 2000/07/10 03:10:17 millert Exp $";
+static char rcsid[] = "$OpenBSD: keyboard.c,v 1.7 2001/09/04 23:35:59 millert Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -52,7 +52,7 @@ void
keyboard()
{
char ch, line[80];
- int oldmask;
+ sigset_t mask, omask;
for (;;) {
col = 0;
@@ -69,21 +69,23 @@ keyboard()
if (ch >= 'A' && ch <= 'Z')
ch += 'a' - 'A';
if (col == 0) {
-#define mask(s) (1 << ((s) - 1))
- if (ch == CTRL('l')) {
- oldmask = sigblock(mask(SIGALRM));
- wrefresh(curscr);
- sigsetmask(oldmask);
+ switch (ch) {
+ case CTRL('l'):
+ case CTRL('g'):
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGALRM);
+ sigprocmask(SIG_BLOCK, &mask, &omask);
+ if (ch == CTRL('l'))
+ wrefresh(curscr);
+ else
+ status();
+ sigprocmask(SIG_SETMASK, &omask, NULL);
continue;
- }
- if (ch == CTRL('g')) {
- oldmask = sigblock(mask(SIGALRM));
- status();
- sigsetmask(oldmask);
+ case ':':
+ break;
+ default:
continue;
}
- if (ch != ':')
- continue;
move(CMDLINE, 0);
clrtoeol();
}
@@ -124,9 +126,11 @@ keyboard()
}
} while (col == 0 || (ch != '\r' && ch != '\n'));
line[col] = '\0';
- oldmask = sigblock(mask(SIGALRM));
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGALRM);
+ sigprocmask(SIG_BLOCK, &mask, &omask);
command(line + 1);
- sigsetmask(oldmask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
}
/*NOTREACHED*/
}
View
24 openbsd/usr.bin/systat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.14 1997/11/04 12:20:19 kstailey Exp $ */
+/* $OpenBSD: main.c,v 1.16 2001/09/04 23:35:59 millert Exp $ */
/* $NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: main.c,v 1.14 1997/11/04 12:20:19 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.16 2001/09/04 23:35:59 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -96,7 +96,7 @@ main(argc, argv)
int argc;
char **argv;
{
- int ch;
+ int ch, ret;
char errbuf[_POSIX2_LINE_MAX];
while ((ch = getopt(argc, argv, "M:N:w:")) != -1)
@@ -148,10 +148,12 @@ main(argc, argv)
error("%s", errbuf);
exit(1);
}
- if (kvm_nlist(kd, namelist)) {
+
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- exit(1);
- }
+
if (namelist[X_FIRST].n_type == 0)
errx(1, "couldn't read namelist");
signal(SIGINT, die);
@@ -287,14 +289,14 @@ void
resize(signo)
int signo;
{
- int oldmask;
+ sigset_t mask, oldmask;
-#define mask(s) (1 << ((s) - 1))
- oldmask = sigblock(mask(SIGALRM));
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGALRM);
+ sigprocmask(SIG_BLOCK, &mask, &oldmask);
clearok(curscr, TRUE);
wrefresh(curscr);
- sigsetmask(oldmask);
-#undef mask
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
}
View
12 openbsd/usr.bin/systat/mbufs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $ */
+/* $OpenBSD: mbufs.c,v 1.5 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: mbufs.c,v 1.2 1995/01/20 08:52:02 jtc Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mbufs.c,v 1.5 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -145,11 +145,13 @@ static struct nlist namelist[] = {
int
initmbufs()
{
+ int ret;
+
if (namelist[X_MBSTAT].n_type == 0) {
- if (kvm_nlist(kd, namelist)) {
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[X_MBSTAT].n_type == 0) {
error("namelist on %s failed", _PATH_UNIX);
return(0);
View
21 openbsd/usr.bin/systat/netstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.c,v 1.13 2000/05/24 13:17:08 itojun Exp $ */
+/* $OpenBSD: netstat.c,v 1.16 2001/07/28 05:36:18 pvalchev Exp $ */
/* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: netstat.c,v 1.13 2000/05/24 13:17:08 itojun Exp $";
+static char rcsid[] = "$OpenBSD: netstat.c,v 1.16 2001/07/28 05:36:18 pvalchev Exp $";
#endif /* not lint */
/*
@@ -73,6 +73,7 @@ static char rcsid[] = "$OpenBSD: netstat.c,v 1.13 2000/05/24 13:17:08 itojun Exp
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
+#include <err.h>
#include <nlist.h>
#include <paths.h>
#include "systat.h"
@@ -162,10 +163,12 @@ static struct nlist namelist[] = {
int
initnetstat()
{
- if (kvm_nlist(kd, namelist)) {
+ int ret;
+
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[X_TCBTABLE].n_value == 0) {
error("No symbols in namelist");
return(0);
@@ -210,7 +213,7 @@ fetchnetstat()
while (next != head) {
KREAD(next, &inpcb, sizeof (inpcb));
if (inpcb.inp_queue.cqe_prev != prev) {
-printf("prev = %x, head = %x, next = %x, inpcb...prev = %x\n", prev, head, next, inpcb.inp_queue.cqe_prev);
+printf("prev = %p, head = %p, next = %p, inpcb...prev = %p\n", prev, head, next, inpcb.inp_queue.cqe_prev);
p = netcb.nif_forw;
for (; p != (struct netinfo *)&netcb; p = p->nif_forw)
p->nif_seen = 1;
@@ -545,11 +548,9 @@ inetname(in)
}
}
if (in.s_addr == INADDR_ANY) {
- strncpy(line, "*", sizeof line-1);
- line[sizeof line-1] = '\0';
+ strlcpy(line, "*", sizeof line);
} else if (cp) {
- strncpy(line, cp, sizeof line-1);
- line[sizeof line-1] = '\0';
+ strlcpy(line, cp, sizeof line);
} else {
in.s_addr = ntohl(in.s_addr);
#define C(x) ((x) & 0xff)
View
12 openbsd/usr.bin/systat/pigs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pigs.c,v 1.6 2000/06/18 17:59:55 niklas Exp $ */
+/* $OpenBSD: pigs.c,v 1.8 2001/07/28 05:36:18 pvalchev Exp $ */
/* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
#endif
-static char rcsid[] = "$OpenBSD: pigs.c,v 1.6 2000/06/18 17:59:55 niklas Exp $";
+static char rcsid[] = "$OpenBSD: pigs.c,v 1.8 2001/07/28 05:36:18 pvalchev Exp $";
#endif /* not lint */
/*
@@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: pigs.c,v 1.6 2000/06/18 17:59:55 niklas Exp $";
#include <math.h>
#include <nlist.h>
#include <pwd.h>
+#include <err.h>