summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-04-06 22:12:18 +0000
committerglebius <glebius@FreeBSD.org>2015-04-06 22:12:18 +0000
commit8ea08edd44b2a5073cc4b52e69f2b75dcf9c665f (patch)
tree1c781eb21846c125dc7da4c159419dd667ff0e64 /usr.bin/netstat
parent9435c121fa6dba0bbeae6c40cf3df7623095bf5e (diff)
downloadFreeBSD-src-8ea08edd44b2a5073cc4b52e69f2b75dcf9c665f.zip
FreeBSD-src-8ea08edd44b2a5073cc4b52e69f2b75dcf9c665f.tar.gz
o Make net.inet6.ip6.mif6table return special API structure, that doesn't
contain kernel pointers, and instead has interface index. Bump __FreeBSD_version for that change. o Now, netstat/mroute6.c no longer needs to kvm_read(3) struct ifnet, and no longer needs to include if_var.h Note that this change is far from being a complete move of IPv6 multicast routing to a proper API. Other structures are still dumped into their sysctls as is, requiring userland application to #define _KERNEL when including ip6_mroute.h and then call kvm_read(3) to gather all bits and pieces. But fixing this is out of scope of the opaque ifnet project. Sponsored by: Nginx, Inc. Sponsored by: Netflix
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/mroute6.c81
-rw-r--r--usr.bin/netstat/netstat.14
2 files changed, 19 insertions, 66 deletions
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index f00b119..d9c127a 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -79,13 +79,11 @@ __FBSDID("$FreeBSD$");
#include <sys/time.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/route.h>
#include <netinet/in.h>
#include <err.h>
-#include <nlist.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -98,20 +96,6 @@ __FBSDID("$FreeBSD$");
#include "netstat.h"
-/*
- * kvm(3) bindings for every needed symbol
- */
-static struct nlist mrl[] = {
-#define N_MF6CTABLE 0
- { .n_name = "_mf6ctable" },
-#define N_MIF6TABLE 1
- { .n_name = "_mif6table" },
-#define N_MRT6STAT 2
- { .n_name = "_mrt6stat" },
- { .n_name = NULL },
-};
-
-
#define WID_ORG (Wflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */
#define WID_GRP (Wflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */
@@ -119,11 +103,10 @@ void
mroute6pr()
{
struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
- struct mif6 mif6table[MAXMIFS];
+ struct mif6_sctl mif6table[MAXMIFS];
struct mf6c mfc;
struct rtdetq rte, *rtep;
- struct mif6 *mifp;
- u_long mfcaddr, mifaddr;
+ struct mif6_sctl *mifp;
mifi_t mifi;
int i;
int banner_printed;
@@ -132,39 +115,26 @@ mroute6pr()
long int waitings;
size_t len;
- kresolve_list(mrl);
- mfcaddr = mrl[N_MF6CTABLE].n_value;
- mifaddr = mrl[N_MIF6TABLE].n_value;
-
- if (mfcaddr == 0 || mifaddr == 0) {
- fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
+ if (live == 0)
return;
- }
len = sizeof(mif6table);
- if (live) {
- if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
- NULL, 0) < 0) {
- xo_warn("sysctl: net.inet6.ip6.mif6table");
- return;
- }
- } else
- kread(mifaddr, (char *)mif6table, sizeof(mif6table));
+ if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len, NULL, 0) <
+ 0) {
+ xo_warn("sysctl: net.inet6.ip6.mif6table");
+ return;
+ }
saved_numeric_addr = numeric_addr;
numeric_addr = 1;
banner_printed = 0;
for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
- struct ifnet ifnet;
char ifname[IFNAMSIZ];
- if (mifp->m6_ifp == NULL)
+ if (mifp->m6_ifp == 0)
continue;
- /* XXX KVM */
- kread((u_long)mifp->m6_ifp, (char *)&ifnet, sizeof(ifnet));
-
maxmif = mifi;
if (!banner_printed) {
xo_open_list("multicast-interface");
@@ -177,7 +147,7 @@ mroute6pr()
xo_emit(" {:mif/%2u} {:rate-limit/%4d}",
mifi, mifp->m6_rate_limit);
xo_emit(" {:ifname/%5s}", (mifp->m6_flags & MIFF_REGISTER) ?
- "reg0" : if_indextoname(ifnet.if_index, ifname));
+ "reg0" : if_indextoname(mifp->m6_ifp, ifname));
xo_emit(" {:received-packets/%9ju} {:sent-packets/%9ju}\n",
(uintmax_t)mifp->m6_pkt_in,
@@ -190,14 +160,11 @@ mroute6pr()
xo_emit("\n{T:IPv6 Multicast Interface Table is empty}\n");
len = sizeof(mf6ctable);
- if (live) {
- if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
- NULL, 0) < 0) {
- xo_warn("sysctl: net.inet6.ip6.mf6ctable");
- return;
- }
- } else
- kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
+ if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len, NULL, 0) <
+ 0) {
+ xo_warn("sysctl: net.inet6.ip6.mf6ctable");
+ return;
+ }
banner_printed = 0;
@@ -262,26 +229,14 @@ void
mrt6_stats()
{
struct mrt6stat mrtstat;
- u_long mstaddr;
size_t len = sizeof mrtstat;
- kresolve_list(mrl);
- mstaddr = mrl[N_MRT6STAT].n_value;
-
- if (mstaddr == 0) {
- fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
+ if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len, NULL, 0) <
+ 0) {
+ xo_warn("sysctl: net.inet6.ip6.mrt6stat");
return;
}
- if (live) {
- if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
- NULL, 0) < 0) {
- xo_warn("sysctl: net.inet6.ip6.mrt6stat");
- return;
- }
- } else
- kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
-
xo_open_container("multicast-statistics");
xo_emit("{T:IPv6 multicast forwarding}:\n");
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 1b67b1a..69dd25b 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -28,7 +28,7 @@
.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd February 21, 2015
+.Dd April 7, 2015
.Dt NETSTAT 1
.Os
.Sh NAME
@@ -92,8 +92,6 @@
.Op Fl -libxo
.Op Fl 46W
.Op Fl f Ar address_family
-.Op Fl M Ar core
-.Op Fl N Ar system
.It Nm Fl gs
.Op Fl -libxo
.Op Fl 46s
OpenPOWER on IntegriCloud