xref: /freebsd/usr.bin/systat/ip.c (revision fb9aaba000a429421e31d9e40e98f6f035409a10)
12938fb78SGarrett Wollman /*-
22938fb78SGarrett Wollman  * Copyright (c) 1980, 1992, 1993
32938fb78SGarrett Wollman  *	The Regents of the University of California.  All rights reserved.
42938fb78SGarrett Wollman  *
52938fb78SGarrett Wollman  * Redistribution and use in source and binary forms, with or without
62938fb78SGarrett Wollman  * modification, are permitted provided that the following conditions
72938fb78SGarrett Wollman  * are met:
82938fb78SGarrett Wollman  * 1. Redistributions of source code must retain the above copyright
92938fb78SGarrett Wollman  *    notice, this list of conditions and the following disclaimer.
102938fb78SGarrett Wollman  * 2. Redistributions in binary form must reproduce the above copyright
112938fb78SGarrett Wollman  *    notice, this list of conditions and the following disclaimer in the
122938fb78SGarrett Wollman  *    documentation and/or other materials provided with the distribution.
132938fb78SGarrett Wollman  * 3. All advertising materials mentioning features or use of this software
142938fb78SGarrett Wollman  *    must display the following acknowledgement:
152938fb78SGarrett Wollman  *	This product includes software developed by the University of
162938fb78SGarrett Wollman  *	California, Berkeley and its contributors.
172938fb78SGarrett Wollman  * 4. Neither the name of the University nor the names of its contributors
182938fb78SGarrett Wollman  *    may be used to endorse or promote products derived from this software
192938fb78SGarrett Wollman  *    without specific prior written permission.
202938fb78SGarrett Wollman  *
212938fb78SGarrett Wollman  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
222938fb78SGarrett Wollman  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232938fb78SGarrett Wollman  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242938fb78SGarrett Wollman  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
252938fb78SGarrett Wollman  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
262938fb78SGarrett Wollman  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
272938fb78SGarrett Wollman  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
282938fb78SGarrett Wollman  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
292938fb78SGarrett Wollman  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302938fb78SGarrett Wollman  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312938fb78SGarrett Wollman  * SUCH DAMAGE.
322938fb78SGarrett Wollman  */
332938fb78SGarrett Wollman 
342938fb78SGarrett Wollman #ifndef lint
352938fb78SGarrett Wollman /* From:
362938fb78SGarrett Wollman static char sccsid[] = "@(#)mbufs.c	8.1 (Berkeley) 6/6/93";
372938fb78SGarrett Wollman static const char rcsid[] =
382938fb78SGarrett Wollman 	"Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp";
392938fb78SGarrett Wollman */
402938fb78SGarrett Wollman static const char rcsid[] =
41c3aac50fSPeter Wemm   "$FreeBSD$";
422938fb78SGarrett Wollman #endif /* not lint */
432938fb78SGarrett Wollman 
442938fb78SGarrett Wollman #include <sys/param.h>
452938fb78SGarrett Wollman #include <sys/types.h>
462938fb78SGarrett Wollman #include <sys/socket.h>
472938fb78SGarrett Wollman #include <sys/sysctl.h>
482938fb78SGarrett Wollman 
492938fb78SGarrett Wollman #include <netinet/in.h>
502938fb78SGarrett Wollman #include <netinet/in_systm.h>
512938fb78SGarrett Wollman #include <netinet/ip.h>
522938fb78SGarrett Wollman #include <netinet/ip_var.h>
532938fb78SGarrett Wollman #include <netinet/udp.h>
542938fb78SGarrett Wollman #include <netinet/udp_var.h>
552938fb78SGarrett Wollman 
562938fb78SGarrett Wollman #include <stdlib.h>
572938fb78SGarrett Wollman #include <string.h>
582938fb78SGarrett Wollman #include <paths.h>
592938fb78SGarrett Wollman #include "systat.h"
602938fb78SGarrett Wollman #include "extern.h"
612938fb78SGarrett Wollman #include "mode.h"
622938fb78SGarrett Wollman 
632938fb78SGarrett Wollman struct stat {
642938fb78SGarrett Wollman 	struct ipstat i;
652938fb78SGarrett Wollman 	struct udpstat u;
662938fb78SGarrett Wollman };
672938fb78SGarrett Wollman 
682938fb78SGarrett Wollman static struct stat curstat, initstat, oldstat;
692938fb78SGarrett Wollman 
702938fb78SGarrett Wollman /*-
712938fb78SGarrett Wollman --0         1         2         3         4         5         6         7
722938fb78SGarrett Wollman --0123456789012345678901234567890123456789012345678901234567890123456789012345
732938fb78SGarrett Wollman 01          IP Input                           IP Output
742938fb78SGarrett Wollman 02999999999 total packets received   999999999 total packets sent
752938fb78SGarrett Wollman 03999999999 - with bad checksums     999999999 - generated locally
762938fb78SGarrett Wollman 04999999999 - too short for header   999999999 - output drops
772938fb78SGarrett Wollman 05999999999 - too short for data     999999999 output fragments generated
782938fb78SGarrett Wollman 06999999999 - with invalid hlen      999999999 - fragmentation failed
792938fb78SGarrett Wollman 07999999999 - with invalid length    999999999 destinations unreachable
802938fb78SGarrett Wollman 08999999999 - with invalid version   999999999 packets output via raw IP
812938fb78SGarrett Wollman 09999999999 - jumbograms
822938fb78SGarrett Wollman 10999999999 total fragments received           UDP Statistics
832938fb78SGarrett Wollman 11999999999 - fragments dropped      999999999 total input packets
842938fb78SGarrett Wollman 12999999999 - fragments timed out    999999999 - too short for header
852938fb78SGarrett Wollman 13999999999 - packets reassembled ok 999999999 - invalid checksum
86fb9aaba0SRuslan Ermilov 14999999999 packets forwarded        999999999 - no checksum
87fb9aaba0SRuslan Ermilov 15999999999 - unreachable dests      999999999 - invalid length
88fb9aaba0SRuslan Ermilov 16999999999 - redirects generated    999999999 - no socket for dest port
89fb9aaba0SRuslan Ermilov 17999999999 option errors            999999999 - no socket for broadcast
90fb9aaba0SRuslan Ermilov 18999999999 unwanted multicasts      999999999 - socket buffer full
91fb9aaba0SRuslan Ermilov 19999999999 delivered to upper layer 999999999 total output packets
922938fb78SGarrett Wollman --0123456789012345678901234567890123456789012345678901234567890123456789012345
932938fb78SGarrett Wollman --0         1         2         3         4         5         6         7
942938fb78SGarrett Wollman */
952938fb78SGarrett Wollman 
962938fb78SGarrett Wollman WINDOW *
972938fb78SGarrett Wollman openip(void)
982938fb78SGarrett Wollman {
99fb9aaba0SRuslan Ermilov 	return (subwin(stdscr, LINES-4-1, 0, 4, 0));
1002938fb78SGarrett Wollman }
1012938fb78SGarrett Wollman 
1022938fb78SGarrett Wollman void
1032938fb78SGarrett Wollman closeip(w)
1042938fb78SGarrett Wollman 	WINDOW *w;
1052938fb78SGarrett Wollman {
1062938fb78SGarrett Wollman 	if (w == NULL)
1072938fb78SGarrett Wollman 		return;
1082938fb78SGarrett Wollman 	wclear(w);
1092938fb78SGarrett Wollman 	wrefresh(w);
1102938fb78SGarrett Wollman 	delwin(w);
1112938fb78SGarrett Wollman }
1122938fb78SGarrett Wollman 
1132938fb78SGarrett Wollman void
1142938fb78SGarrett Wollman labelip(void)
1152938fb78SGarrett Wollman {
1162938fb78SGarrett Wollman 	wmove(wnd, 0, 0); wclrtoeol(wnd);
1172938fb78SGarrett Wollman #define L(row, str) mvwprintw(wnd, row, 10, str)
1182938fb78SGarrett Wollman #define R(row, str) mvwprintw(wnd, row, 45, str);
1192938fb78SGarrett Wollman 	L(1, "IP Input");			R(1, "IP Output");
1202938fb78SGarrett Wollman 	L(2, "total packets received");		R(2, "total packets sent");
1212938fb78SGarrett Wollman 	L(3, "- with bad checksums");		R(3, "- generated locally");
1222938fb78SGarrett Wollman 	L(4, "- too short for header");		R(4, "- output drops");
1232938fb78SGarrett Wollman 	L(5, "- too short for data");	R(5, "output fragments generated");
1242938fb78SGarrett Wollman 	L(6, "- with invalid hlen");	R(6, "- fragmentation failed");
1252938fb78SGarrett Wollman 	L(7, "- with invalid length");	R(7, "destinations unreachable");
1262938fb78SGarrett Wollman 	L(8, "- with invalid version");	R(8, "packets output via raw IP");
1272938fb78SGarrett Wollman 	L(9, "- jumbograms");
1282938fb78SGarrett Wollman 	L(10, "total fragments received");	R(10, "UDP Statistics");
1292938fb78SGarrett Wollman 	L(11, "- fragments dropped");	R(11, "total input packets");
1302938fb78SGarrett Wollman 	L(12, "- fragments timed out");	R(12, "- too short for header");
1312938fb78SGarrett Wollman 	L(13, "- packets reassembled ok");	R(13, "- invalid checksum");
132fb9aaba0SRuslan Ermilov 	L(14, "packets forwarded");	R(14, "- no checksum");
133fb9aaba0SRuslan Ermilov 	L(15, "- unreachable dests");	R(15, "- invalid length");
134fb9aaba0SRuslan Ermilov 	L(16, "- redirects generated");	R(16, "- no socket for dest port");
135fb9aaba0SRuslan Ermilov 	L(17, "option errors");		R(17, "- no socket for broadcast");
136fb9aaba0SRuslan Ermilov 	L(18, "unwanted multicasts");	R(18, "- socket buffer full");
137fb9aaba0SRuslan Ermilov 	L(19, "delivered to upper layer");	R(19, "total output packets");
1382938fb78SGarrett Wollman #undef L
1392938fb78SGarrett Wollman #undef R
1402938fb78SGarrett Wollman }
1412938fb78SGarrett Wollman 
1422938fb78SGarrett Wollman static void
1432938fb78SGarrett Wollman domode(struct stat *ret)
1442938fb78SGarrett Wollman {
1452938fb78SGarrett Wollman 	const struct stat *sub;
146d22889b8SDavid E. O'Brien 	int divisor = 1;
1472938fb78SGarrett Wollman 
1482938fb78SGarrett Wollman 	switch(currentmode) {
1492938fb78SGarrett Wollman 	case display_RATE:
1502938fb78SGarrett Wollman 		sub = &oldstat;
1512938fb78SGarrett Wollman 		divisor = naptime;
1522938fb78SGarrett Wollman 		break;
1532938fb78SGarrett Wollman 	case display_DELTA:
1542938fb78SGarrett Wollman 		sub = &oldstat;
1552938fb78SGarrett Wollman 		break;
1562938fb78SGarrett Wollman 	case display_SINCE:
1572938fb78SGarrett Wollman 		sub = &initstat;
1582938fb78SGarrett Wollman 		break;
1592938fb78SGarrett Wollman 	default:
1602938fb78SGarrett Wollman 		*ret = curstat;
1612938fb78SGarrett Wollman 		return;
1622938fb78SGarrett Wollman 	}
1632938fb78SGarrett Wollman #define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor
1642938fb78SGarrett Wollman 	DO(i.ips_total);
1652938fb78SGarrett Wollman 	DO(i.ips_badsum);
1662938fb78SGarrett Wollman 	DO(i.ips_tooshort);
1672938fb78SGarrett Wollman 	DO(i.ips_toosmall);
1682938fb78SGarrett Wollman 	DO(i.ips_badhlen);
1692938fb78SGarrett Wollman 	DO(i.ips_badlen);
1702938fb78SGarrett Wollman 	DO(i.ips_fragments);
1712938fb78SGarrett Wollman 	DO(i.ips_fragdropped);
1722938fb78SGarrett Wollman 	DO(i.ips_fragtimeout);
1732938fb78SGarrett Wollman 	DO(i.ips_forward);
1742938fb78SGarrett Wollman 	DO(i.ips_cantforward);
1752938fb78SGarrett Wollman 	DO(i.ips_redirectsent);
1762938fb78SGarrett Wollman 	DO(i.ips_noproto);
1772938fb78SGarrett Wollman 	DO(i.ips_delivered);
1782938fb78SGarrett Wollman 	DO(i.ips_localout);
1792938fb78SGarrett Wollman 	DO(i.ips_odropped);
1802938fb78SGarrett Wollman 	DO(i.ips_reassembled);
1812938fb78SGarrett Wollman 	DO(i.ips_fragmented);
1822938fb78SGarrett Wollman 	DO(i.ips_ofragments);
1832938fb78SGarrett Wollman 	DO(i.ips_cantfrag);
1842938fb78SGarrett Wollman 	DO(i.ips_badoptions);
1852938fb78SGarrett Wollman 	DO(i.ips_noroute);
1862938fb78SGarrett Wollman 	DO(i.ips_badvers);
1872938fb78SGarrett Wollman 	DO(i.ips_rawout);
1882938fb78SGarrett Wollman 	DO(i.ips_toolong);
1892938fb78SGarrett Wollman 	DO(i.ips_notmember);
1902938fb78SGarrett Wollman 	DO(u.udps_ipackets);
1912938fb78SGarrett Wollman 	DO(u.udps_hdrops);
1922938fb78SGarrett Wollman 	DO(u.udps_badsum);
193fb9aaba0SRuslan Ermilov 	DO(u.udps_nosum);
1942938fb78SGarrett Wollman 	DO(u.udps_badlen);
1952938fb78SGarrett Wollman 	DO(u.udps_noport);
1962938fb78SGarrett Wollman 	DO(u.udps_noportbcast);
1972938fb78SGarrett Wollman 	DO(u.udps_fullsock);
1982938fb78SGarrett Wollman 	DO(u.udps_opackets);
1992938fb78SGarrett Wollman #undef DO
2002938fb78SGarrett Wollman }
2012938fb78SGarrett Wollman 
2022938fb78SGarrett Wollman void
2032938fb78SGarrett Wollman showip(void)
2042938fb78SGarrett Wollman {
2052938fb78SGarrett Wollman 	struct stat stats;
2062938fb78SGarrett Wollman 	u_long totalout;
2072938fb78SGarrett Wollman 
2082938fb78SGarrett Wollman 	domode(&stats);
2092938fb78SGarrett Wollman 	totalout = stats.i.ips_forward + stats.i.ips_localout;
2102938fb78SGarrett Wollman 
2112938fb78SGarrett Wollman #define DO(stat, row, col) \
2122938fb78SGarrett Wollman 	mvwprintw(wnd, row, col, "%9lu", stats.stat)
2132938fb78SGarrett Wollman 
2142938fb78SGarrett Wollman 	DO(i.ips_total, 2, 0);
2152938fb78SGarrett Wollman 	mvwprintw(wnd, 2, 35, "%9lu", totalout);
2162938fb78SGarrett Wollman 	DO(i.ips_badsum, 3, 0);
2172938fb78SGarrett Wollman 	DO(i.ips_localout, 3, 35);
2182938fb78SGarrett Wollman 	DO(i.ips_tooshort, 4, 0);
2192938fb78SGarrett Wollman 	DO(i.ips_odropped, 4, 35);
2202938fb78SGarrett Wollman 	DO(i.ips_toosmall, 5, 0);
2212938fb78SGarrett Wollman 	DO(i.ips_ofragments, 5, 35);
2222938fb78SGarrett Wollman 	DO(i.ips_badhlen, 6, 0);
2232938fb78SGarrett Wollman 	DO(i.ips_cantfrag, 6, 35);
2242938fb78SGarrett Wollman 	DO(i.ips_badlen, 7, 0);
2252938fb78SGarrett Wollman 	DO(i.ips_noroute, 7, 35);
2262938fb78SGarrett Wollman 	DO(i.ips_badvers, 8, 0);
2272938fb78SGarrett Wollman 	DO(i.ips_rawout, 8, 35);
2282938fb78SGarrett Wollman 	DO(i.ips_toolong, 9, 0);
2292938fb78SGarrett Wollman 	DO(i.ips_fragments, 10, 0);
2302938fb78SGarrett Wollman 	DO(i.ips_fragdropped, 11, 0);
2312938fb78SGarrett Wollman 	DO(u.udps_ipackets, 11, 35);
2322938fb78SGarrett Wollman 	DO(i.ips_fragtimeout, 12, 0);
2332938fb78SGarrett Wollman 	DO(u.udps_hdrops, 12, 35);
2342938fb78SGarrett Wollman 	DO(i.ips_reassembled, 13, 0);
2352938fb78SGarrett Wollman 	DO(u.udps_badsum, 13, 35);
2362938fb78SGarrett Wollman 	DO(i.ips_forward, 14, 0);
237fb9aaba0SRuslan Ermilov 	DO(u.udps_nosum, 14, 35);
2382938fb78SGarrett Wollman 	DO(i.ips_cantforward, 15, 0);
239fb9aaba0SRuslan Ermilov 	DO(u.udps_badlen, 15, 35);
2402938fb78SGarrett Wollman 	DO(i.ips_redirectsent, 16, 0);
241fb9aaba0SRuslan Ermilov 	DO(u.udps_noport, 16, 35);
2422938fb78SGarrett Wollman 	DO(i.ips_badoptions, 17, 0);
243fb9aaba0SRuslan Ermilov 	DO(u.udps_noportbcast, 17, 35);
2442938fb78SGarrett Wollman 	DO(i.ips_notmember, 18, 0);
245fb9aaba0SRuslan Ermilov 	DO(u.udps_fullsock, 18, 35);
2462938fb78SGarrett Wollman 	DO(i.ips_delivered, 19, 0);
247fb9aaba0SRuslan Ermilov 	DO(u.udps_opackets, 19, 35);
2482938fb78SGarrett Wollman #undef DO
2492938fb78SGarrett Wollman }
2502938fb78SGarrett Wollman 
2512938fb78SGarrett Wollman int
2522938fb78SGarrett Wollman initip(void)
2532938fb78SGarrett Wollman {
2542938fb78SGarrett Wollman 	size_t len;
2552938fb78SGarrett Wollman 	int name[4];
2562938fb78SGarrett Wollman 
2572938fb78SGarrett Wollman 	name[0] = CTL_NET;
2582938fb78SGarrett Wollman 	name[1] = PF_INET;
2592938fb78SGarrett Wollman 	name[2] = IPPROTO_IP;
2602938fb78SGarrett Wollman 	name[3] = IPCTL_STATS;
2612938fb78SGarrett Wollman 
2622938fb78SGarrett Wollman 	len = 0;
2632938fb78SGarrett Wollman 	if (sysctl(name, 4, 0, &len, 0, 0) < 0) {
2642938fb78SGarrett Wollman 		error("sysctl getting ipstat size failed");
2652938fb78SGarrett Wollman 		return 0;
2662938fb78SGarrett Wollman 	}
2672938fb78SGarrett Wollman 	if (len > sizeof curstat.i) {
2682938fb78SGarrett Wollman 		error("ipstat structure has grown--recompile systat!");
2692938fb78SGarrett Wollman 		return 0;
2702938fb78SGarrett Wollman 	}
2712938fb78SGarrett Wollman 	if (sysctl(name, 4, &initstat.i, &len, 0, 0) < 0) {
2722938fb78SGarrett Wollman 		error("sysctl getting ipstat failed");
2732938fb78SGarrett Wollman 		return 0;
2742938fb78SGarrett Wollman 	}
2752938fb78SGarrett Wollman 	name[2] = IPPROTO_UDP;
2762938fb78SGarrett Wollman 	name[3] = UDPCTL_STATS;
2772938fb78SGarrett Wollman 
2782938fb78SGarrett Wollman 	len = 0;
2792938fb78SGarrett Wollman 	if (sysctl(name, 4, 0, &len, 0, 0) < 0) {
2802938fb78SGarrett Wollman 		error("sysctl getting udpstat size failed");
2812938fb78SGarrett Wollman 		return 0;
2822938fb78SGarrett Wollman 	}
2832938fb78SGarrett Wollman 	if (len > sizeof curstat.u) {
2842938fb78SGarrett Wollman 		error("ipstat structure has grown--recompile systat!");
2852938fb78SGarrett Wollman 		return 0;
2862938fb78SGarrett Wollman 	}
2872938fb78SGarrett Wollman 	if (sysctl(name, 4, &initstat.u, &len, 0, 0) < 0) {
2882938fb78SGarrett Wollman 		error("sysctl getting udpstat failed");
2892938fb78SGarrett Wollman 		return 0;
2902938fb78SGarrett Wollman 	}
2912938fb78SGarrett Wollman 	oldstat = initstat;
2922938fb78SGarrett Wollman 	return 1;
2932938fb78SGarrett Wollman }
2942938fb78SGarrett Wollman 
2952938fb78SGarrett Wollman void
2962938fb78SGarrett Wollman resetip(void)
2972938fb78SGarrett Wollman {
2982938fb78SGarrett Wollman 	size_t len;
2992938fb78SGarrett Wollman 	int name[4];
3002938fb78SGarrett Wollman 
3012938fb78SGarrett Wollman 	name[0] = CTL_NET;
3022938fb78SGarrett Wollman 	name[1] = PF_INET;
3032938fb78SGarrett Wollman 	name[2] = IPPROTO_IP;
3042938fb78SGarrett Wollman 	name[3] = IPCTL_STATS;
3052938fb78SGarrett Wollman 
3062938fb78SGarrett Wollman 	len = sizeof initstat.i;
3072938fb78SGarrett Wollman 	if (sysctl(name, 4, &initstat.i, &len, 0, 0) < 0) {
3082938fb78SGarrett Wollman 		error("sysctl getting ipstat failed");
3092938fb78SGarrett Wollman 	}
3102938fb78SGarrett Wollman 	name[2] = IPPROTO_UDP;
3112938fb78SGarrett Wollman 	name[3] = UDPCTL_STATS;
3122938fb78SGarrett Wollman 
3132938fb78SGarrett Wollman 	len = sizeof initstat.u;
3142938fb78SGarrett Wollman 	if (sysctl(name, 4, &initstat.u, &len, 0, 0) < 0) {
3152938fb78SGarrett Wollman 		error("sysctl getting udpstat failed");
3162938fb78SGarrett Wollman 	}
3172938fb78SGarrett Wollman 	oldstat = initstat;
3182938fb78SGarrett Wollman }
3192938fb78SGarrett Wollman 
3202938fb78SGarrett Wollman void
3212938fb78SGarrett Wollman fetchip(void)
3222938fb78SGarrett Wollman {
3232938fb78SGarrett Wollman 	int name[4];
3242938fb78SGarrett Wollman 	size_t len;
3252938fb78SGarrett Wollman 
3262938fb78SGarrett Wollman 	oldstat = curstat;
3272938fb78SGarrett Wollman 	name[0] = CTL_NET;
3282938fb78SGarrett Wollman 	name[1] = PF_INET;
3292938fb78SGarrett Wollman 	name[2] = IPPROTO_IP;
3302938fb78SGarrett Wollman 	name[3] = IPCTL_STATS;
3312938fb78SGarrett Wollman 	len = sizeof curstat.i;
3322938fb78SGarrett Wollman 
3332938fb78SGarrett Wollman 	if (sysctl(name, 4, &curstat.i, &len, 0, 0) < 0)
3342938fb78SGarrett Wollman 		return;
3352938fb78SGarrett Wollman 	name[2] = IPPROTO_UDP;
3362938fb78SGarrett Wollman 	name[3] = UDPCTL_STATS;
3372938fb78SGarrett Wollman 	len = sizeof curstat.u;
3382938fb78SGarrett Wollman 
3392938fb78SGarrett Wollman 	if (sysctl(name, 4, &curstat.u, &len, 0, 0) < 0)
3402938fb78SGarrett Wollman 		return;
3412938fb78SGarrett Wollman }
3422938fb78SGarrett Wollman 
343