diff options
Diffstat (limited to 'net/bridge')
-rw-r--r-- | net/bridge/netfilter/ebtables.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index c4540144f0f4..f8ffbf6e2333 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
28 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
29 | #include <linux/cpumask.h> | ||
29 | #include <net/sock.h> | 30 | #include <net/sock.h> |
30 | /* needed for logical [in,out]-dev filtering */ | 31 | /* needed for logical [in,out]-dev filtering */ |
31 | #include "../br_private.h" | 32 | #include "../br_private.h" |
@@ -823,10 +824,11 @@ static int translate_table(struct ebt_replace *repl, | |||
823 | /* this will get free'd in do_replace()/ebt_register_table() | 824 | /* this will get free'd in do_replace()/ebt_register_table() |
824 | if an error occurs */ | 825 | if an error occurs */ |
825 | newinfo->chainstack = (struct ebt_chainstack **) | 826 | newinfo->chainstack = (struct ebt_chainstack **) |
826 | vmalloc(num_possible_cpus() * sizeof(struct ebt_chainstack)); | 827 | vmalloc((highest_possible_processor_id()+1) |
828 | * sizeof(struct ebt_chainstack)); | ||
827 | if (!newinfo->chainstack) | 829 | if (!newinfo->chainstack) |
828 | return -ENOMEM; | 830 | return -ENOMEM; |
829 | for (i = 0; i < num_possible_cpus(); i++) { | 831 | for_each_cpu(i) { |
830 | newinfo->chainstack[i] = | 832 | newinfo->chainstack[i] = |
831 | vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); | 833 | vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); |
832 | if (!newinfo->chainstack[i]) { | 834 | if (!newinfo->chainstack[i]) { |
@@ -895,9 +897,12 @@ static void get_counters(struct ebt_counter *oldcounters, | |||
895 | 897 | ||
896 | /* counters of cpu 0 */ | 898 | /* counters of cpu 0 */ |
897 | memcpy(counters, oldcounters, | 899 | memcpy(counters, oldcounters, |
898 | sizeof(struct ebt_counter) * nentries); | 900 | sizeof(struct ebt_counter) * nentries); |
901 | |||
899 | /* add other counters to those of cpu 0 */ | 902 | /* add other counters to those of cpu 0 */ |
900 | for (cpu = 1; cpu < num_possible_cpus(); cpu++) { | 903 | for_each_cpu(cpu) { |
904 | if (cpu == 0) | ||
905 | continue; | ||
901 | counter_base = COUNTER_BASE(oldcounters, nentries, cpu); | 906 | counter_base = COUNTER_BASE(oldcounters, nentries, cpu); |
902 | for (i = 0; i < nentries; i++) { | 907 | for (i = 0; i < nentries; i++) { |
903 | counters[i].pcnt += counter_base[i].pcnt; | 908 | counters[i].pcnt += counter_base[i].pcnt; |
@@ -929,7 +934,8 @@ static int do_replace(void __user *user, unsigned int len) | |||
929 | BUGPRINT("Entries_size never zero\n"); | 934 | BUGPRINT("Entries_size never zero\n"); |
930 | return -EINVAL; | 935 | return -EINVAL; |
931 | } | 936 | } |
932 | countersize = COUNTER_OFFSET(tmp.nentries) * num_possible_cpus(); | 937 | countersize = COUNTER_OFFSET(tmp.nentries) * |
938 | (highest_possible_processor_id()+1); | ||
933 | newinfo = (struct ebt_table_info *) | 939 | newinfo = (struct ebt_table_info *) |
934 | vmalloc(sizeof(struct ebt_table_info) + countersize); | 940 | vmalloc(sizeof(struct ebt_table_info) + countersize); |
935 | if (!newinfo) | 941 | if (!newinfo) |
@@ -1022,7 +1028,7 @@ static int do_replace(void __user *user, unsigned int len) | |||
1022 | 1028 | ||
1023 | vfree(table->entries); | 1029 | vfree(table->entries); |
1024 | if (table->chainstack) { | 1030 | if (table->chainstack) { |
1025 | for (i = 0; i < num_possible_cpus(); i++) | 1031 | for_each_cpu(i) |
1026 | vfree(table->chainstack[i]); | 1032 | vfree(table->chainstack[i]); |
1027 | vfree(table->chainstack); | 1033 | vfree(table->chainstack); |
1028 | } | 1034 | } |
@@ -1040,7 +1046,7 @@ free_counterstmp: | |||
1040 | vfree(counterstmp); | 1046 | vfree(counterstmp); |
1041 | /* can be initialized in translate_table() */ | 1047 | /* can be initialized in translate_table() */ |
1042 | if (newinfo->chainstack) { | 1048 | if (newinfo->chainstack) { |
1043 | for (i = 0; i < num_possible_cpus(); i++) | 1049 | for_each_cpu(i) |
1044 | vfree(newinfo->chainstack[i]); | 1050 | vfree(newinfo->chainstack[i]); |
1045 | vfree(newinfo->chainstack); | 1051 | vfree(newinfo->chainstack); |
1046 | } | 1052 | } |
@@ -1132,7 +1138,8 @@ int ebt_register_table(struct ebt_table *table) | |||
1132 | return -EINVAL; | 1138 | return -EINVAL; |
1133 | } | 1139 | } |
1134 | 1140 | ||
1135 | countersize = COUNTER_OFFSET(table->table->nentries) * num_possible_cpus(); | 1141 | countersize = COUNTER_OFFSET(table->table->nentries) * |
1142 | (highest_possible_processor_id()+1); | ||
1136 | newinfo = (struct ebt_table_info *) | 1143 | newinfo = (struct ebt_table_info *) |
1137 | vmalloc(sizeof(struct ebt_table_info) + countersize); | 1144 | vmalloc(sizeof(struct ebt_table_info) + countersize); |
1138 | ret = -ENOMEM; | 1145 | ret = -ENOMEM; |
@@ -1186,7 +1193,7 @@ free_unlock: | |||
1186 | up(&ebt_mutex); | 1193 | up(&ebt_mutex); |
1187 | free_chainstack: | 1194 | free_chainstack: |
1188 | if (newinfo->chainstack) { | 1195 | if (newinfo->chainstack) { |
1189 | for (i = 0; i < num_possible_cpus(); i++) | 1196 | for_each_cpu(i) |
1190 | vfree(newinfo->chainstack[i]); | 1197 | vfree(newinfo->chainstack[i]); |
1191 | vfree(newinfo->chainstack); | 1198 | vfree(newinfo->chainstack); |
1192 | } | 1199 | } |
@@ -1209,7 +1216,7 @@ void ebt_unregister_table(struct ebt_table *table) | |||
1209 | up(&ebt_mutex); | 1216 | up(&ebt_mutex); |
1210 | vfree(table->private->entries); | 1217 | vfree(table->private->entries); |
1211 | if (table->private->chainstack) { | 1218 | if (table->private->chainstack) { |
1212 | for (i = 0; i < num_possible_cpus(); i++) | 1219 | for_each_cpu(i) |
1213 | vfree(table->private->chainstack[i]); | 1220 | vfree(table->private->chainstack[i]); |
1214 | vfree(table->private->chainstack); | 1221 | vfree(table->private->chainstack); |
1215 | } | 1222 | } |