aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAshish Sharma <ashishsharma@google.com>2011-03-14 18:56:50 -0700
committerJonas ABERG <jonas.aberg@stericsson.com>2011-04-01 13:31:03 +0200
commit8daf3c865e02cc40a579700425f38ba8e480688c (patch)
treed3c79d16193883373ab66fb0e02cfe782be0ebf6 /net
parentb0071d59dfe203a7d7364588b4fcf109167efb0f (diff)
net: New iface_stat module to monitor persistent network stats
Adding a new module that tracks the number of bytes/packets transfered by a network interface, even after the interface has been removed. This is relevant to track the total data usage in mobile devices whose interfaces are added and removed quite frequently (WiFi, Bluetooth, 3G,..). Monitoring is done only for devices that are configured with a valid IP address (check to exclude virtual/loopback/tunnel interfaces). Change-Id: I8ac642af1990433ebd0784e8dbd72bf0714b5bf6 Signed-off-by: Ashish Sharma <ashishsharma@google.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/19516 Tested-by: Piotr TOMASZEWSKI <piotr.tomaszewski@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c4
-rw-r--r--net/ipv4/devinet.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 95cc4861804..85064004a12 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -131,6 +131,7 @@
#include <linux/random.h>
#include <trace/events/napi.h>
#include <linux/pci.h>
+#include <linux/iface_stat.h>
#include "net-sysfs.h"
@@ -4803,6 +4804,9 @@ static void rollback_registered_many(struct list_head *head)
synchronize_net();
list_for_each_entry(dev, head, unreg_list) {
+ /* Store stats for this device in persistent iface_stat */
+ iface_stat_update(dev);
+
/* Shutdown queueing discipline. */
dev_shutdown(dev);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8b7dfaf3b6e..39b876b7b72 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -55,6 +55,7 @@
#include <linux/sysctl.h>
#endif
#include <linux/kmod.h>
+#include <linux/iface_stat.h>
#include <net/arp.h>
#include <net/ip.h>
@@ -375,6 +376,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh,
rtmsg_ifa(RTM_NEWADDR, ifa, nlh, pid);
blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);
+ /* Start persistent interface stat monitoring. Ignores if loopback. */
+ create_iface_stat(in_dev);
+
return 0;
}