summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2013-10-15 11:37:57 +0000
committerglebius <glebius@FreeBSD.org>2013-10-15 11:37:57 +0000
commit790225cfbce40af294b0962bcba0febee9125487 (patch)
treec8e33cc195b6a05b074a56d713bbf025af1bbdc4 /sys/netinet/ip_input.c
parentbc71d67cbbd8f45860c1763eb82f7de40d07538c (diff)
downloadFreeBSD-src-790225cfbce40af294b0962bcba0febee9125487.zip
FreeBSD-src-790225cfbce40af294b0962bcba0febee9125487.tar.gz
- Utilize counter(9) to accumulate statistics on interface addresses. Add
four counters to struct ifaddr. This kills '+=' on a variables shared between processors for every packet. - Nuke struct if_data from struct ifaddr. - In ip_input() do not put a reference on ifaddr, instead update statistics right now in place and do IN_IFADDR_RUNLOCK(). These removes atomic(9) for every packet. [1] - To properly support NET_RT_IFLISTL sysctl used by getifaddrs(3), in rtsock.c fill if_data fields using counter_u64_fetch(). - Accidentially fix bug in COMPAT_32 version of NET_RT_IFLISTL, which took if_data not from the ifaddr, but from ifaddr's ifnet. [2] Submitted by: melifaro [1], pluknet[2] Sponsored by: Netflix Sponsored by: Nginx, Inc.
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index c265d02..4fe52d5 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -603,7 +603,9 @@ passin:
*/
if (IA_SIN(ia)->sin_addr.s_addr == ip->ip_dst.s_addr &&
(!checkif || ia->ia_ifp == ifp)) {
- ifa_ref(&ia->ia_ifa);
+ counter_u64_add(ia->ia_ifa.ifa_ipackets, 1);
+ counter_u64_add(ia->ia_ifa.ifa_ibytes,
+ m->m_pkthdr.len);
/* IN_IFADDR_RUNLOCK(); */
goto ours;
}
@@ -626,13 +628,17 @@ passin:
ia = ifatoia(ifa);
if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr ==
ip->ip_dst.s_addr) {
- ifa_ref(ifa);
+ counter_u64_add(ia->ia_ifa.ifa_ipackets, 1);
+ counter_u64_add(ia->ia_ifa.ifa_ibytes,
+ m->m_pkthdr.len);
IF_ADDR_RUNLOCK(ifp);
goto ours;
}
#ifdef BOOTP_COMPAT
if (IA_SIN(ia)->sin_addr.s_addr == INADDR_ANY) {
- ifa_ref(ifa);
+ counter_u64_add(ia->ia_ifa.ifa_ipackets, 1);
+ counter_u64_add(ia->ia_ifa.ifa_ibytes,
+ m->m_pkthdr.len);
IF_ADDR_RUNLOCK(ifp);
goto ours;
}
@@ -717,20 +723,10 @@ ours:
* IPSTEALTH: Process non-routing options only
* if the packet is destined for us.
*/
- if (V_ipstealth && hlen > sizeof (struct ip) && ip_dooptions(m, 1)) {
- if (ia != NULL)
- ifa_free(&ia->ia_ifa);
+ if (V_ipstealth && hlen > sizeof (struct ip) && ip_dooptions(m, 1))
return;
- }
#endif /* IPSTEALTH */
- /* Count the packet in the ip address stats */
- if (ia != NULL) {
- ia->ia_ifa.if_ipackets++;
- ia->ia_ifa.if_ibytes += m->m_pkthdr.len;
- ifa_free(&ia->ia_ifa);
- }
-
/*
* Attempt reassembly; if it succeeds, proceed.
* ip_reass() will return a different mbuf.
OpenPOWER on IntegriCloud