[PATCH] fix iptables on systems with discontiguous processor ids

Herbert Xu herbert at gondor.apana.org.au
Thu Oct 13 10:46:06 CEST 2005


David S. Miller <davem at davemloft.net> wrote:
> 
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index b15826f..36c46a7 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -392,4 +392,18 @@ extern cpumask_t cpu_present_map;
> #define for_each_online_cpu(cpu)  for_each_cpu_mask((cpu), cpu_online_map)
> #define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
> 
> +/* Find the highest possible smp_processor_id() */
> +static inline unsigned int highest_possible_processor_id(void)
> +{
> +       unsigned int cpu, highest = 0;
> +
> +       for_each_cpu_mask(cpu, cpu_possible_map) {
> +               if (cpu > highest)
> +                       highest = cpu;
> +       }
> +
> +       return highest;
> +}

This is a cue for someone to do find_last_bit for 2.6.15 :)

In the mean time we can at least kill the (cpu > highest) check since
cpu is monotonically increasing.

> @@ -893,11 +895,8 @@ static void get_counters(struct ebt_coun
>        int i, cpu;
>        struct ebt_counter *counter_base;
> 
> -       /* counters of cpu 0 */
> -       memcpy(counters, oldcounters,
> -          sizeof(struct ebt_counter) * nentries);
>        /* add other counters to those of cpu 0 */
> -       for (cpu = 1; cpu < num_possible_cpus(); cpu++) {
> +       for_each_cpu(cpu) {
>                counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
>                for (i = 0; i < nentries; i++) {
>                        counters[i].pcnt += counter_base[i].pcnt;

I'm not sure about this.  Counters hasn't been zeroed yet, has it?

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



More information about the netfilter-devel mailing list