Revert "misc: uidstat: Adding uid stat driver to collect network statistics."
authorAmit Pundir <amit.pundir@linaro.org>
Mon, 25 Apr 2016 11:38:15 +0000 (17:08 +0530)
committerAmit Pundir <amit.pundir@linaro.org>
Thu, 19 May 2016 07:02:41 +0000 (12:32 +0530)
This reverts commit 6b6d5fbf9ae567aefb58099a30bbb6d25fa8925b.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/uid_stat.c [deleted file]
include/linux/uid_stat.h [deleted file]
net/ipv4/tcp.c

index 2dcafd0ba17f6c4d434a998f2db49e6bcf1e72c6..ca7463544c72f3852af580574eb0a1b6ee5ed996 100644 (file)
@@ -412,10 +412,6 @@ config TI_DAC7512
          This driver can also be built as a module. If so, the module
          will be called ti_dac7512.
 
-config UID_STAT
-       bool "UID based statistics tracking exported to /proc/uid_stat"
-       default n
-
 config VMWARE_BALLOON
        tristate "VMware Balloon Driver"
        depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST
index 24483a6caa6b2dce5e02d33166b27394aba9a7f8..e5142b836aee8a0d907453d4e9ee1bf541fd3518 100644 (file)
@@ -35,7 +35,6 @@ obj-$(CONFIG_ISL29020)                += isl29020.o
 obj-$(CONFIG_SENSORS_TSL2550)  += tsl2550.o
 obj-$(CONFIG_DS1682)           += ds1682.o
 obj-$(CONFIG_TI_DAC7512)       += ti_dac7512.o
-obj-$(CONFIG_UID_STAT)         += uid_stat.o
 obj-$(CONFIG_C2PORT)           += c2port/
 obj-$(CONFIG_HMC6352)          += hmc6352.o
 obj-y                          += eeprom/
diff --git a/drivers/misc/uid_stat.c b/drivers/misc/uid_stat.c
deleted file mode 100644 (file)
index e6760b5..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* drivers/misc/uid_stat.c
- *
- * Copyright (C) 2008 - 2009 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <asm/atomic.h>
-
-#include <linux/err.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/stat.h>
-#include <linux/uid_stat.h>
-
-static DEFINE_SPINLOCK(uid_lock);
-static LIST_HEAD(uid_list);
-static struct proc_dir_entry *parent;
-
-struct uid_stat {
-       struct list_head link;
-       uid_t uid;
-       atomic_t tcp_rcv;
-       atomic_t tcp_snd;
-};
-
-static struct uid_stat *find_uid_stat(uid_t uid) {
-       unsigned long flags;
-       struct uid_stat *entry;
-
-       spin_lock_irqsave(&uid_lock, flags);
-       list_for_each_entry(entry, &uid_list, link) {
-               if (entry->uid == uid) {
-                       spin_unlock_irqrestore(&uid_lock, flags);
-                       return entry;
-               }
-       }
-       spin_unlock_irqrestore(&uid_lock, flags);
-       return NULL;
-}
-
-static int tcp_snd_read_proc(char *page, char **start, off_t off,
-                               int count, int *eof, void *data)
-{
-       int len;
-       unsigned int bytes;
-       char *p = page;
-       struct uid_stat *uid_entry = (struct uid_stat *) data;
-       if (!data)
-               return 0;
-
-       bytes = (unsigned int) (atomic_read(&uid_entry->tcp_snd) + INT_MIN);
-       p += sprintf(p, "%u\n", bytes);
-       len = (p - page) - off;
-       *eof = (len <= count) ? 1 : 0;
-       *start = page + off;
-       return len;
-}
-
-static int tcp_rcv_read_proc(char *page, char **start, off_t off,
-                               int count, int *eof, void *data)
-{
-       int len;
-       unsigned int bytes;
-       char *p = page;
-       struct uid_stat *uid_entry = (struct uid_stat *) data;
-       if (!data)
-               return 0;
-
-       bytes = (unsigned int) (atomic_read(&uid_entry->tcp_rcv) + INT_MIN);
-       p += sprintf(p, "%u\n", bytes);
-       len = (p - page) - off;
-       *eof = (len <= count) ? 1 : 0;
-       *start = page + off;
-       return len;
-}
-
-/* Create a new entry for tracking the specified uid. */
-static struct uid_stat *create_stat(uid_t uid) {
-       unsigned long flags;
-       char uid_s[32];
-       struct uid_stat *new_uid;
-       struct proc_dir_entry *entry;
-
-       /* Create the uid stat struct and append it to the list. */
-       if ((new_uid = kmalloc(sizeof(struct uid_stat), GFP_KERNEL)) == NULL)
-               return NULL;
-
-       new_uid->uid = uid;
-       /* Counters start at INT_MIN, so we can track 4GB of network traffic. */
-       atomic_set(&new_uid->tcp_rcv, INT_MIN);
-       atomic_set(&new_uid->tcp_snd, INT_MIN);
-
-       spin_lock_irqsave(&uid_lock, flags);
-       list_add_tail(&new_uid->link, &uid_list);
-       spin_unlock_irqrestore(&uid_lock, flags);
-
-       sprintf(uid_s, "%d", uid);
-       entry = proc_mkdir(uid_s, parent);
-
-       /* Keep reference to uid_stat so we know what uid to read stats from. */
-       create_proc_read_entry("tcp_snd", S_IRUGO, entry , tcp_snd_read_proc,
-               (void *) new_uid);
-
-       create_proc_read_entry("tcp_rcv", S_IRUGO, entry, tcp_rcv_read_proc,
-               (void *) new_uid);
-
-       return new_uid;
-}
-
-int uid_stat_tcp_snd(uid_t uid, int size) {
-       struct uid_stat *entry;
-       if ((entry = find_uid_stat(uid)) == NULL &&
-               ((entry = create_stat(uid)) == NULL)) {
-                       return -1;
-       }
-       atomic_add(size, &entry->tcp_snd);
-       return 0;
-}
-
-int uid_stat_tcp_rcv(uid_t uid, int size) {
-       struct uid_stat *entry;
-       if ((entry = find_uid_stat(uid)) == NULL &&
-               ((entry = create_stat(uid)) == NULL)) {
-                       return -1;
-       }
-       atomic_add(size, &entry->tcp_rcv);
-       return 0;
-}
-
-static int __init uid_stat_init(void)
-{
-       parent = proc_mkdir("uid_stat", NULL);
-       if (!parent) {
-               pr_err("uid_stat: failed to create proc entry\n");
-               return -1;
-       }
-       return 0;
-}
-
-__initcall(uid_stat_init);
diff --git a/include/linux/uid_stat.h b/include/linux/uid_stat.h
deleted file mode 100644 (file)
index 6bd6c4e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* include/linux/uid_stat.h
- *
- * Copyright (C) 2008-2009 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef __uid_stat_h
-#define __uid_stat_h
-
-/* Contains definitions for resource tracking per uid. */
-
-#ifdef CONFIG_UID_STAT
-int uid_stat_tcp_snd(uid_t uid, int size);
-int uid_stat_tcp_rcv(uid_t uid, int size);
-#else
-#define uid_stat_tcp_snd(uid, size) do {} while (0);
-#define uid_stat_tcp_rcv(uid, size) do {} while (0);
-#endif
-
-#endif /* _LINUX_UID_STAT_H */
index cf2e13db0619e19ac9f4d2202b92cd153a9109e5..6ecfc9de599ccede1db44d92e51f4304b34cd09c 100644 (file)
 #include <linux/crypto.h>
 #include <linux/time.h>
 #include <linux/slab.h>
-#include <linux/uid_stat.h>
 
 #include <net/icmp.h>
 #include <net/inet_common.h>
@@ -1285,10 +1284,6 @@ out:
                tcp_push(sk, flags, mss_now, tp->nonagle, size_goal);
 out_nopush:
        release_sock(sk);
-
-       if (copied + copied_syn)
-               uid_stat_tcp_snd(from_kuid(&init_user_ns, current_uid()),
-                                copied + copied_syn);
        return copied + copied_syn;
 
 do_fault:
@@ -1563,8 +1558,6 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
        if (copied > 0) {
                tcp_recv_skb(sk, seq, &offset);
                tcp_cleanup_rbuf(sk, copied);
-               uid_stat_tcp_rcv(from_kuid(&init_user_ns, current_uid()),
-                                copied);
        }
        return copied;
 }
@@ -1898,10 +1891,6 @@ skip_copy:
        tcp_cleanup_rbuf(sk, copied);
 
        release_sock(sk);
-
-       if (copied > 0)
-               uid_stat_tcp_rcv(from_kuid(&init_user_ns, current_uid()),
-                                copied);
        return copied;
 
 out:
@@ -1910,9 +1899,6 @@ out:
 
 recv_urg:
        err = tcp_recv_urg(sk, msg, len, flags);
-       if (err > 0)
-               uid_stat_tcp_rcv(from_kuid(&init_user_ns, current_uid()),
-                                err);
        goto out;
 
 recv_sndq: