diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2010-04-27 10:05:28 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-04-27 10:33:08 +0200 |
commit | 863c3ad87b10617464fc52c21fc7e31987910559 (patch) | |
tree | 51ef7c1adf6f6e22bc4a86a5443318cc76df536e | |
parent | 17928ff706858bf492fe0c8661c40415479158fe (diff) | |
download | lwn-863c3ad87b10617464fc52c21fc7e31987910559.tar.gz lwn-863c3ad87b10617464fc52c21fc7e31987910559.zip |
net: Fix iptables get_counters()
The preempt-rt changes to iptables get_counters() left the counters
array uninitialized which results in random packet statistic numbers.
Reported-by: prd.gtt@operamail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | net/ipv4/netfilter/ip_tables.c | 9 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6_tables.c | 10 |
2 files changed, 10 insertions, 9 deletions
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index afeadce13a55..401ada700bd2 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -907,7 +907,7 @@ get_counters(const struct xt_table_info *t, { unsigned int cpu; unsigned int i; - unsigned int curcpu = NR_CPUS; + unsigned int curcpu; /* Instead of clearing (by a previous call to memset()) * the counters and using adds, we set the counters @@ -917,16 +917,17 @@ get_counters(const struct xt_table_info *t, * if new softirq were to run and call ipt_do_table */ local_bh_disable(); -#ifndef CONFIG_PREEMPT_RT - curcpu = smp_processor_id(); + curcpu = raw_smp_processor_id(); i = 0; + xt_info_wrlock(curcpu); IPT_ENTRY_ITERATE(t->entries[curcpu], t->size, set_entry_to_counter, counters, &i); -#endif + xt_info_wrunlock(curcpu); + for_each_possible_cpu(cpu) { if (cpu == curcpu) continue; diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 9238a5a7e75e..9091de88a702 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -939,7 +939,7 @@ get_counters(const struct xt_table_info *t, { unsigned int cpu; unsigned int i; - unsigned int curcpu = NR_CPUS; + unsigned int curcpu; /* Instead of clearing (by a previous call to memset()) * the counters and using adds, we set the counters @@ -949,17 +949,17 @@ get_counters(const struct xt_table_info *t, * if new softirq were to run and call ipt_do_table */ local_bh_disable(); - -#ifndef CONFIG_PREEMPT_RT - curcpu = smp_processor_id(); + curcpu = raw_smp_processor_id(); i = 0; + xt_info_wrlock(curcpu); IP6T_ENTRY_ITERATE(t->entries[curcpu], t->size, set_entry_to_counter, counters, &i); -#endif + xt_info_wrunlock(curcpu); + for_each_possible_cpu(cpu) { if (cpu == curcpu) continue; |