Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Added per-addr input/output statistics. Currently just ...
details: https://anonhg.NetBSD.org/src/rev/5a7bc98cc7e8
branches: trunk
changeset: 467664:5a7bc98cc7e8
user: aidan <aidan%NetBSD.org@localhost>
date: Sat Mar 27 01:24:49 1999 +0000
description:
Added per-addr input/output statistics. Currently just support netatalk
and netinet, currently only tested under netinet.
Disabled by default, enabled by compiling the kernel with option
IFA_STATS. Enabling this feature seems to make the ip_output function
take 13% longer than before, which should be OK for people that need
this feature.
diffstat:
sys/net/if.h | 12 +++++++++++-
sys/netatalk/ddp_input.c | 6 +++++-
sys/netatalk/ddp_output.c | 6 +++++-
sys/netinet/ip_input.c | 5 ++++-
sys/netinet/ip_output.c | 18 +++++++++++++++++-
5 files changed, 42 insertions(+), 5 deletions(-)
diffs (131 lines):
diff -r c715ccde01b1 -r 5a7bc98cc7e8 sys/net/if.h
--- a/sys/net/if.h Sat Mar 27 01:22:36 1999 +0000
+++ b/sys/net/if.h Sat Mar 27 01:24:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.34 1999/03/10 21:05:08 thorpej Exp $ */
+/* $NetBSD: if.h,v 1.35 1999/03/27 01:24:49 aidan Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -228,6 +228,15 @@
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
/*
+ * Structure defining statistics and other data kept regarding an address
+ * on a network interface.
+ */
+struct ifaddr_data {
+ int64_t ifad_inbytes;
+ int64_t ifad_outbytes;
+};
+
+/*
* The ifaddr structure contains information about one address
* of an interface. They are maintained by the different address families,
* are allocated and attached when an address is set, and are linked
@@ -240,6 +249,7 @@
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct ifnet *ifa_ifp; /* back-pointer to interface */
TAILQ_ENTRY(ifaddr) ifa_list; /* list of addresses for interface */
+ struct ifaddr_data ifa_data; /* statistics on the address */
void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
__P((int, struct rtentry *, struct sockaddr *));
u_short ifa_flags; /* mostly rt_flags for cloning */
diff -r c715ccde01b1 -r 5a7bc98cc7e8 sys/netatalk/ddp_input.c
--- a/sys/netatalk/ddp_input.c Sat Mar 27 01:22:36 1999 +0000
+++ b/sys/netatalk/ddp_input.c Sat Mar 27 01:24:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ddp_input.c,v 1.3 1998/06/10 00:43:58 wrstuden Exp $ */
+/* $NetBSD: ddp_input.c,v 1.4 1999/03/27 01:24:50 aidan Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@@ -326,6 +326,10 @@
m_freem(m);
return;
}
+#if IFA_STATS
+ if (aa)
+ aa->aa_ifa.ifa_data.ifad_inbytes += dlen;
+#endif
sorwakeup(ddp->ddp_socket);
}
diff -r c715ccde01b1 -r 5a7bc98cc7e8 sys/netatalk/ddp_output.c
--- a/sys/netatalk/ddp_output.c Sat Mar 27 01:22:36 1999 +0000
+++ b/sys/netatalk/ddp_output.c Sat Mar 27 01:24:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ddp_output.c,v 1.1 1997/04/02 21:31:10 christos Exp $ */
+/* $NetBSD: ddp_output.c,v 1.2 1999/03/27 01:24:50 aidan Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -200,6 +200,10 @@
}
ro->ro_rt->rt_use++;
+#if IFA_STATS
+ aa->aa_ifa.ifa_data.ifad_outbytes += m->m_pkthdr.len;
+#endif
+
/* XXX */
return ((*ifp->if_output) (ifp, m, (struct sockaddr *) &gate, NULL));
}
diff -r c715ccde01b1 -r 5a7bc98cc7e8 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c Sat Mar 27 01:22:36 1999 +0000
+++ b/sys/netinet/ip_input.c Sat Mar 27 01:24:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_input.c,v 1.81 1999/03/26 08:51:36 proff Exp $ */
+/* $NetBSD: ip_input.c,v 1.82 1999/03/27 01:24:49 aidan Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -588,6 +588,9 @@
/*
* Switch out to protocol's input routine.
*/
+#if IFA_STATS
+ ia->ia_ifa.ifa_data.ifad_inbytes += ip->ip_len;
+#endif
ipstat.ips_delivered++;
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
goto next;
diff -r c715ccde01b1 -r 5a7bc98cc7e8 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c Sat Mar 27 01:22:36 1999 +0000
+++ b/sys/netinet/ip_output.c Sat Mar 27 01:24:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_output.c,v 1.57 1999/03/12 22:42:31 perry Exp $ */
+/* $NetBSD: ip_output.c,v 1.58 1999/03/27 01:24:50 aidan Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -127,6 +127,9 @@
int len, off, error = 0;
struct route iproute;
struct sockaddr_in *dst;
+#if IFA_STATS
+ struct sockaddr_in src;
+#endif
struct in_ifaddr *ia;
struct mbuf *opt;
struct route *ro;
@@ -482,6 +485,19 @@
RTFREE(ro->ro_rt);
ro->ro_rt = 0;
}
+#if IFA_STATS
+ if (error == 0) {
+ /* search for the source address structure to maintain output
+ * statistics. */
+ bzero((caddr_t*) &src, sizeof(src));
+ src.sin_family = AF_INET;
+ src.sin_addr.s_addr = ip->ip_src.s_addr;
+ src.sin_len = sizeof(src);
+ ia = ifatoia(ifa_ifwithladdr(sintosa(&src)));
+ if (ia)
+ ia->ia_ifa.ifa_data.ifad_outbytes += ntohs(ip->ip_len);
+ }
+#endif
return (error);
bad:
m_freem(m);
Home |
Main Index |
Thread Index |
Old Index