Date: Fri, 22 Jul 2005 23:32:34 GMT From: soc-anders <soc-anders@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 80814 for review Message-ID: <200507222332.j6MNWYwP049240@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=80814 Change 80814 by soc-anders@soc-anders_gimli on 2005/07/22 23:32:21 netstat compiles without kvm, however, the following parts are disabled: * IPX * AppleTalk * Netgraph * Multicast routing * IPSec6 stats Affected files ... .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/Makefile#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/atalk.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/inet6.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/ipsec.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/ipx.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/main.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mbuf.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mroute.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mroute6.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/netgraph.c#2 edit .. //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/unix.c#2 edit Differences ... ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/Makefile#2 (text+ko) ==== @@ -16,6 +16,8 @@ BINGRP= kmem BINMODE=2555 DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL} -LDADD= -lkvm -lipx -lnetgraph -lutil - +LDADD= -lipx -lnetgraph -lutil +.if defined(IFCLEANUP) +LDADD+= -lkvm +.endif .include <bsd.prog.mk> ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/atalk.c#2 (text+ko) ==== @@ -218,6 +218,7 @@ void atalkprotopr(u_long off __unused, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct ddpcb *this, *next; if (off == 0) @@ -256,6 +257,7 @@ (struct sockaddr *)&ddpcb.ddp_fsat,7)); putchar('\n'); } +#endif /* IFCLEANUP */ } #define ANY(x,y,z) if (x || sflag <= 1) \ @@ -267,6 +269,7 @@ void ddp_stats(u_long off __unused, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct ddpstat ddpstat; if (off == 0) @@ -283,4 +286,5 @@ ANY(ddpstat.ddps_encap, "packet", " encapsulated "); ANY(ddpstat.ddps_cantforward, "packet", " rcvd for unreachable dest "); ANY(ddpstat.ddps_nosockspace, "packet", " dropped due to no socket space "); +#endif /* IFCLEANUP */ } ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/inet6.c#2 (text+ko) ==== @@ -44,7 +44,6 @@ #ifdef INET6 #include <sys/param.h> #include <sys/socket.h> -#include <sys/socketvar.h> #include <sys/ioctl.h> #include <sys/mbuf.h> #include <sys/protosw.h> @@ -52,15 +51,11 @@ #include <net/route.h> #include <net/if.h> -#include <net/if_var.h> #include <netinet/in.h> #include <netinet/ip6.h> #include <netinet/icmp6.h> #include <netinet/in_systm.h> -#include <netinet6/in6_pcb.h> -#include <netinet6/in6_var.h> -#include <netinet6/ip6_var.h> -#include <netinet6/pim6_var.h> +#include <netinet6/pim6.h> #include <netinet6/raw_ip6.h> #include <arpa/inet.h> @@ -71,8 +66,6 @@ #include <unistd.h> #include "netstat.h" -struct socket sockb; - char *inet6name(struct in6_addr *); const char *pluralies(int); @@ -994,11 +987,12 @@ pim6_stats(u_long off __unused, const char *name, int af1 __unused) { struct pim6stat pim6stat; + size_t len = sizeof(pim6stat); - if (off == 0) + if (sysctlbyname("net.inet6.pim6.stats", &pim6stat, &len, + NULL, 0) < 0) return; - if (kread(off, (char *)&pim6stat, sizeof(pim6stat))) - return; + printf("%s:\n", name); #define p(f, m) if (pim6stat.f || sflag <= 1) \ ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/ipsec.c#2 (text+ko) ==== @@ -75,6 +75,7 @@ #include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> +#include <sys/sysctl.h> #include <netinet/in.h> @@ -86,6 +87,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <err.h> #include "netstat.h" #ifdef IPSEC @@ -235,11 +237,21 @@ void ipsec_stats(u_long off __unused, const char *name, int af1 __unused) { - if (off == 0) - return; + size_t len; + printf ("%s:\n", name); - kread(off, (char *)&ipsecstat, sizeof (ipsecstat)); + if (strcmp(name, "ipsec") == 0) { + len = sizeof(ipsecstat); + if (sysctlbyname("net.inet.ipsec.stats", &ipsecstat, &len, + NULL, 0) < 0) { + warn("sysctl: net.inet.ipsec.stats"); + return; + } + } else { + /* IFCLEANUP: Not yet available */ + return; + } print_ipsecstats(); } @@ -260,12 +272,16 @@ pfkey_stats(u_long off __unused, const char *name, int af1 __unused) { struct pfkeystat pfkeystat; + size_t len; unsigned first, type; - if (off == 0) + printf ("%s:\n", name); + len = sizeof(pfkeystat); + if (sysctlbyname("net.key.pfkeystat", &pfkeystat, &len, + NULL, 0) < 0) { + warn("sysctl: net.key.pfkeystat"); return; - printf ("%s:\n", name); - kread(off, (char *)&pfkeystat, sizeof(pfkeystat)); + } #define p(f, m) if (pfkeystat.f || sflag <= 1) \ printf(m, (unsigned long long)pfkeystat.f, plural(pfkeystat.f)) ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/ipx.c#2 (text+ko) ==== @@ -83,6 +83,7 @@ void ipxprotopr(u_long off, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct ipxpcbhead cb; struct ipxpcb *ipxp; struct ipxpcb ipxpcb; @@ -143,6 +144,7 @@ } putchar('\n'); } +#endif /* IFCLEANUP */ } #define ANY(x,y,z) \ @@ -156,6 +158,7 @@ void spx_stats(u_long off, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct spx_istat spx_istat; #define spxstat spx_istat.newstats @@ -224,6 +227,7 @@ ANYl(spxstat.spxs_rcvackpack, "rcvd ack packet", ""); ANYl(spxstat.spxs_rcvackbyte, "byte", " acked by rcvd acks"); ANYl(spxstat.spxs_rcvwinupd, "rcvd window update packet", ""); +#endif /* CLEANUP */ } /* @@ -232,6 +236,7 @@ void ipx_stats(u_long off, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct ipxstat ipxstat; if (off == 0) @@ -249,6 +254,7 @@ ANYl(ipxstat.ipxs_odropped, "packet", " dropped due to no bufs, etc."); ANYl(ipxstat.ipxs_noroute, "packet", " discarded due to no route"); ANYl(ipxstat.ipxs_mtutoosmall, "packet", " too big"); +#endif /* IFCLEANUP */ } #ifdef IPXERRORMSGS @@ -275,6 +281,7 @@ void ipxerr_stats(u_long off, const char *name, int af __unused) { +#ifdef IFCLEANUP struct ipx_errstat ipx_errstat; int j; int histoprint = 1; @@ -310,6 +317,7 @@ } ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); } +#endif /* IFCLEANUP */ } static void ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/main.c#2 (text+ko) ==== @@ -166,15 +166,15 @@ { -1, -1, 1, protopr, igmp_stats, NULL, "igmp", IPPROTO_IGMP }, #ifdef IPSEC - { -1, N_IPSECSTAT, 1, NULL, - ipsec_stats, NULL, "ipsec", 0}, + { -1, -1, 1, NULL, + ipsec_stats, NULL, "ipsec", 1}, #endif { -1, -1, 1, NULL, bdg_stats, NULL, "bdg", 1 /* bridging... */ }, { -1, -1, 1, protopr, pim_stats, NULL, "pim", IPPROTO_PIM }, { -1, N_CARPSTAT, 1, 0, - carp_stats, NULL, "carp", 0}, + carp_stats, NULL, "carp", 1}, { -1, -1, 0, NULL, NULL, NULL, NULL, 0 } }; @@ -185,20 +185,20 @@ tcp_stats, NULL, "tcp", IPPROTO_TCP }, { -1, -1, 1, protopr, udp_stats, NULL, "udp", IPPROTO_UDP }, - { -1, N_IP6STAT, 1, protopr, + { -1, -1, 1, protopr, ip6_stats, ip6_ifstats, "ip6", IPPROTO_RAW }, - { -1, N_ICMP6STAT, 1, protopr, + { -1, -1, 1, protopr, icmp6_stats, icmp6_ifstats, "icmp6",IPPROTO_ICMPV6 }, #ifdef IPSEC - { -1, N_IPSEC6STAT, 1, NULL, - ipsec_stats, NULL, "ipsec6",0 }, + { -1, -1, 1, NULL, + ipsec_stats, NULL, "ipsec6",1 }, #endif #ifdef notyet - { -1, N_PIM6STAT, 1, NULL, - pim6_stats, NULL, "pim6", 0 }, + { -1, -1, 1, NULL, + pim6_stats, NULL, "pim6", 1 }, #endif { -1, -1, 1, NULL, - rip6_stats, NULL, "rip6", 0 }, + rip6_stats, NULL, "rip6", 1 }, { -1, -1, 1, NULL, bdg_stats, NULL, "bdg", 1 /* bridging... */ }, { -1, -1, 0, NULL, @@ -209,7 +209,7 @@ #ifdef IPSEC struct protox pfkeyprotox[] = { { -1, N_PFKEYSTAT, 1, NULL, - pfkey_stats, NULL, "pfkey", 0 }, + pfkey_stats, NULL, "pfkey", 1 }, { -1, -1, 0, NULL, NULL, NULL, NULL, 0 } }; @@ -428,6 +428,7 @@ setgid(getgid()); if (mflag) { +#ifdef IFCLEANUP if (memf != NULL) { if (kread(0, 0, 0) == 0) mbpr(nl[N_MBSTAT].n_value, @@ -442,6 +443,7 @@ nl[N_PAGESZ].n_value, nl[N_MBPSTAT].n_value); } else +#endif /* IFCLEANUP */ mbpr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); exit(0); } @@ -460,12 +462,10 @@ */ #endif if (iflag && !sflag) { - kread(0, 0, 0); intpr(interval, nl[N_IFNET].n_value, NULL); exit(0); } if (rflag) { - kread(0, 0, 0); if (sflag) rt_stats(nl[N_RTSTAT].n_value, nl[N_RTTRASH].n_value); else @@ -473,7 +473,6 @@ exit(0); } if (gflag) { - kread(0, 0, 0); if (sflag) { if (af == AF_INET || af == AF_UNSPEC) mrt_stats(nl[N_MRTSTAT].n_value); @@ -495,7 +494,6 @@ exit(0); } - kread(0, 0, 0); if (tp) { printproto(tp, tp->pr_name); exit(0); @@ -514,7 +512,6 @@ printproto(tp, tp->pr_name); #endif /*IPSEC*/ if (af == AF_IPX || af == AF_UNSPEC) { - kread(0, 0, 0); for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); } @@ -580,6 +577,7 @@ /* * Read kernel memory, return 0 on success. */ +#ifdef IFCLEANUP int kread(u_long addr, char *buf, int size) { @@ -617,7 +615,7 @@ } return (0); } - +#endif /* IFCLEANUP */ const char * plural(int n) { ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mbuf.c#2 (text+ko) ==== @@ -115,24 +115,16 @@ goto err; } - if (mbaddr) { - if (kread(mbaddr, (char *)mbstat, sizeof mbstat)) - goto err; - if (kread(nmbcaddr, (char *)&nmbclusters, sizeof(int))) - goto err; - } else { - mlen = sizeof *mbstat; - if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0) - < 0) { - warn("sysctl: retrieving mbstat"); - goto err; - } - mlen = sizeof(int); - if (sysctlbyname("kern.ipc.nmbclusters", &nmbclusters, &mlen, - NULL, 0) < 0) { - warn("sysctl: retrieving nmbclusters"); - goto err; - } + if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0) + < 0) { + warn("sysctl: retrieving mbstat"); + goto err; + } + mlen = sizeof(int); + if (sysctlbyname("kern.ipc.nmbclusters", &nmbclusters, &mlen, + NULL, 0) < 0) { + warn("sysctl: retrieving nmbclusters"); + goto err; } if (mbstat->m_mbufs < 0) mbstat->m_mbufs = 0; /* XXX */ if (mbstat->m_mclusts < 0) mbstat->m_mclusts = 0; /* XXX */ ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mroute.c#2 (text+ko) ==== @@ -71,6 +71,7 @@ void mroutepr(u_long mfcaddr, u_long vifaddr) { +#ifdef IFCLEANUP struct mfc *mfctable[MFCTBLSIZ]; struct vif viftable[MAXVIFS]; struct mfc mfc, *m; @@ -82,28 +83,14 @@ vifi_t maxvif = 0; size_t len; - len = sizeof(mfctable); - if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL, 0) < 0) { - warn("sysctl: net.inet.ip.mfctable"); - /* Compatability with older kernels - candidate for removal */ - if (mfcaddr == 0) { - printf("No IPv4 multicast routing compiled into this system.\n"); - return; - } - - kread(mfcaddr, (char *)mfctable, sizeof(mfctable)); - } - len = sizeof(viftable); if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL, 0) < 0) { - warn("sysctl: net.inet.ip.viftable"); - /* Compatability with older kernels - candidate for removal */ - if (vifaddr == 0) { - printf("No IPv4 multicast routing compiled into this system.\n"); - return; - } + printf("No IPv4 multicast routing compiled into this system.\n"); + } - kread(vifaddr, (char *)viftable, sizeof(viftable)); + len = sizeof(mfctable); + if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL, 0) < 0) { + printf("No IPv4 multicast routing compiled into this system.\n"); } saved_numeric_addr = numeric_addr; @@ -185,6 +172,7 @@ printf("\n"); numeric_addr = saved_numeric_addr; +#endif /* IFCLEANUP */ } static void @@ -267,14 +255,9 @@ if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL, 0) < 0) { - warn("sysctl: net.inet.ip.mrtstat"); /* Compatability with older kernels - candidate for removal */ - if (mstaddr == 0) { - printf("No IPv4 multicast routing compiled into this system.\n"); - return; - } - - kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat)); + printf("No IPv4 multicast routing compiled into this system.\n"); + return; } printf("IPv4 multicast forwarding:\n"); ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/mroute6.c#2 (text+ko) ==== @@ -96,6 +96,7 @@ void mroute6pr(u_long mfcaddr, u_long mifaddr) { +#ifdef IFCLEANUP struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp; struct mif6 mif6table[MAXMIFS]; struct mf6c mfc; @@ -192,11 +193,13 @@ printf("\n"); numeric_addr = saved_numeric_addr; +#endif /* IFCLEANUP */ } void mrt6_stats(u_long mstaddr) { +#ifdef IFCLEANUP struct mrt6stat mrtstat; if (mstaddr == 0) { @@ -231,5 +234,6 @@ #undef p2 #undef p +#endif /* IFCLEANUP */ } #endif /*INET6*/ ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/netgraph.c#2 (text+ko) ==== @@ -63,6 +63,7 @@ void netgraphprotopr(u_long off, const char *name, int af1 __unused) { +#ifdef IFCLEANUP struct ngpcb *this, *next; struct ngpcb ngpcb; struct ngsock info; @@ -180,5 +181,6 @@ finish: putchar('\n'); } +#endif /* IFCLEANUP */ } ==== //depot/projects/soc2005/ifcleanup/src/src/usr.bin/netstat/unix.c#2 (text+ko) ====
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507222332.j6MNWYwP049240>