aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2013-05-13 20:42:46 -0700
committerArve Hjønnevåg <arve@android.com>2013-07-01 15:52:03 -0700
commit73570fe76d3b47e669558f06f1a18e0f02dff606 (patch)
tree418c03c26d8a5276c8216c7f2754c08b4430a44d
parent4af1c50c2b8d5cb96ee803cc8c8d969708130509 (diff)
netfilter: xt_quota2: 3.10 fixes.
- Stop using obsolete create_proc_entry api. - Use proc_set_user instead of directly accessing the private structure. Signed-off-by: Arve Hjønnevåg <arve@android.com>
-rw-r--r--net/netfilter/xt_quota2.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/net/netfilter/xt_quota2.c b/net/netfilter/xt_quota2.c
index aace7292853..44ebdcc7596 100644
--- a/net/netfilter/xt_quota2.c
+++ b/net/netfilter/xt_quota2.c
@@ -122,22 +122,23 @@ static void quota2_log(unsigned int hooknum,
}
#endif /* if+else CONFIG_NETFILTER_XT_MATCH_QUOTA2_LOG */
-static int quota_proc_read(char *page, char **start, off_t offset,
- int count, int *eof, void *data)
+static int quota_proc_read(struct file *file, char __user *buf,
+ size_t size, loff_t *ppos)
{
- struct xt_quota_counter *e = data;
- int ret;
+ struct xt_quota_counter *e = PDE_DATA(file_inode(file));
+ char tmp[24];
+ size_t tmp_size;
spin_lock_bh(&e->lock);
- ret = snprintf(page, PAGE_SIZE, "%llu\n", e->quota);
+ tmp_size = scnprintf(tmp, sizeof(tmp), "%llu\n", e->quota);
spin_unlock_bh(&e->lock);
- return ret;
+ return simple_read_from_buffer(buf, size, ppos, tmp, tmp_size);
}
static int quota_proc_write(struct file *file, const char __user *input,
- unsigned long size, void *data)
+ size_t size, loff_t *ppos)
{
- struct xt_quota_counter *e = data;
+ struct xt_quota_counter *e = PDE_DATA(file_inode(file));
char buf[sizeof("18446744073709551616")];
if (size > sizeof(buf))
@@ -152,6 +153,12 @@ static int quota_proc_write(struct file *file, const char __user *input,
return size;
}
+static const struct file_operations q2_counter_fops = {
+ .read = quota_proc_read,
+ .write = quota_proc_write,
+ .llseek = default_llseek,
+};
+
static struct xt_quota_counter *
q2_new_counter(const struct xt_quota_mtinfo2 *q, bool anon)
{
@@ -215,8 +222,8 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
spin_unlock_bh(&counter_list_lock);
/* create_proc_entry() is not spin_lock happy */
- p = e->procfs_entry = create_proc_entry(e->name, quota_list_perms,
- proc_xt_quota);
+ p = e->procfs_entry = proc_create_data(e->name, quota_list_perms,
+ proc_xt_quota, &q2_counter_fops, e);
if (IS_ERR_OR_NULL(p)) {
spin_lock_bh(&counter_list_lock);
@@ -224,11 +231,7 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
spin_unlock_bh(&counter_list_lock);
goto out;
}
- p->data = e;
- p->read_proc = quota_proc_read;
- p->write_proc = quota_proc_write;
- p->uid = quota_list_uid;
- p->gid = quota_list_gid;
+ proc_set_user(p, quota_list_uid, quota_list_gid);
return e;
out: