Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=27e2c26b85b6b234411d94127201436c1ec9c002
Commit:     27e2c26b85b6b234411d94127201436c1ec9c002
Parent:     fb5b6095f320bd5a615049aa5fe8827ae9d1bf80
Author:     Patrick McHardy <[EMAIL PROTECTED]>
AuthorDate: Mon Dec 17 21:56:48 2007 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 14:58:47 2008 -0800

    [NETFILTER]: arp_tables: move counter allocation to seperate function
    
    More resyncing with ip_tables.c as preparation for compat support.
    
    Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/ipv4/netfilter/arp_tables.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index b0f4331..eaca06e 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -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
@@ -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) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to