Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78523
b: refs/heads/master
c: 27e2c26
h: refs/heads/master
i:
  78521: 3f30915
  78519: 02a74ab
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Jan 28, 2008
1 parent 727a445 commit 8ba6530
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fb5b6095f320bd5a615049aa5fe8827ae9d1bf80
refs/heads/master: 27e2c26b85b6b234411d94127201436c1ec9c002
29 changes: 21 additions & 8 deletions trunk/net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,11 @@ static void get_counters(const struct xt_table_info *t,
}
}

static int copy_entries_to_user(unsigned int total_size,
struct arpt_table *table,
void __user *userptr)
static inline struct xt_counters *alloc_counters(struct arpt_table *table)
{
unsigned int off, num, countersize;
struct arpt_entry *e;
unsigned int countersize;
struct xt_counters *counters;
struct xt_table_info *private = table->private;
int ret = 0;
void *loc_cpu_entry;

/* We need atomic snapshot of counters: rest doesn't change
* (other than comefrom, which userspace doesn't care
Expand All @@ -725,13 +720,31 @@ static int copy_entries_to_user(unsigned int total_size,
counters = vmalloc_node(countersize, numa_node_id());

if (counters == NULL)
return -ENOMEM;
return ERR_PTR(-ENOMEM);

/* First, sum counters... */
write_lock_bh(&table->lock);
get_counters(private, counters);
write_unlock_bh(&table->lock);

return counters;
}

static int copy_entries_to_user(unsigned int total_size,
struct arpt_table *table,
void __user *userptr)
{
unsigned int off, num;
struct arpt_entry *e;
struct xt_counters *counters;
struct xt_table_info *private = table->private;
int ret = 0;
void *loc_cpu_entry;

counters = alloc_counters(table);
if (IS_ERR(counters))
return PTR_ERR(counters);

loc_cpu_entry = private->entries[raw_smp_processor_id()];
/* ... then copy entire thing ... */
if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) {
Expand Down

0 comments on commit 8ba6530

Please sign in to comment.