diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-18 00:49:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:58:34 -0500 |
commit | ed1a6f5e77441c4020b8541b3f03f03e37d638e1 (patch) | |
tree | 401faf03d55c0b1869245849fcfc4e0e3965e9aa /net/ipv6 | |
parent | 3b84e92b0d54864b0731c3ab3c20dd140bb3d7d9 (diff) |
[NETFILTER]: ip6_tables: move counter allocation to seperate function
More resyncing with ip_tables.c as preparation for compat support.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/netfilter/ip6_tables.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index d0b5fa6661f5..02be4fcb915b 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -943,17 +943,11 @@ get_counters(const struct xt_table_info *t, | |||
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | static int | 946 | static inline struct xt_counters *alloc_counters(struct xt_table *table) |
947 | copy_entries_to_user(unsigned int total_size, | ||
948 | struct xt_table *table, | ||
949 | void __user *userptr) | ||
950 | { | 947 | { |
951 | unsigned int off, num, countersize; | 948 | unsigned int countersize; |
952 | struct ip6t_entry *e; | ||
953 | struct xt_counters *counters; | 949 | struct xt_counters *counters; |
954 | struct xt_table_info *private = table->private; | 950 | struct xt_table_info *private = table->private; |
955 | int ret = 0; | ||
956 | void *loc_cpu_entry; | ||
957 | 951 | ||
958 | /* We need atomic snapshot of counters: rest doesn't change | 952 | /* We need atomic snapshot of counters: rest doesn't change |
959 | (other than comefrom, which userspace doesn't care | 953 | (other than comefrom, which userspace doesn't care |
@@ -962,13 +956,32 @@ copy_entries_to_user(unsigned int total_size, | |||
962 | counters = vmalloc_node(countersize, numa_node_id()); | 956 | counters = vmalloc_node(countersize, numa_node_id()); |
963 | 957 | ||
964 | if (counters == NULL) | 958 | if (counters == NULL) |
965 | return -ENOMEM; | 959 | return ERR_PTR(-ENOMEM); |
966 | 960 | ||
967 | /* First, sum counters... */ | 961 | /* First, sum counters... */ |
968 | write_lock_bh(&table->lock); | 962 | write_lock_bh(&table->lock); |
969 | get_counters(private, counters); | 963 | get_counters(private, counters); |
970 | write_unlock_bh(&table->lock); | 964 | write_unlock_bh(&table->lock); |
971 | 965 | ||
966 | return counters; | ||
967 | } | ||
968 | |||
969 | static int | ||
970 | copy_entries_to_user(unsigned int total_size, | ||
971 | struct xt_table *table, | ||
972 | void __user *userptr) | ||
973 | { | ||
974 | unsigned int off, num; | ||
975 | struct ip6t_entry *e; | ||
976 | struct xt_counters *counters; | ||
977 | struct xt_table_info *private = table->private; | ||
978 | int ret = 0; | ||
979 | void *loc_cpu_entry; | ||
980 | |||
981 | counters = alloc_counters(table); | ||
982 | if (IS_ERR(counters)) | ||
983 | return PTR_ERR(counters); | ||
984 | |||
972 | /* choose the copy that is on ourc node/cpu */ | 985 | /* choose the copy that is on ourc node/cpu */ |
973 | loc_cpu_entry = private->entries[raw_smp_processor_id()]; | 986 | loc_cpu_entry = private->entries[raw_smp_processor_id()]; |
974 | if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) { | 987 | if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) { |