diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2006-11-30 22:28:25 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:32:04 -0500 |
commit | df07a81e939a0176b125bc83cf22dbb5e380ae9f (patch) | |
tree | 5e92edf21bbb4198fcf2ada60a323d056107e4ea /net | |
parent | 1bc2326cbe24766d9cb236e63c091cbaecfa2f29 (diff) |
[EBTABLES]: Clean ebt_register_table() up.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/bridge/netfilter/ebtables.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index f0d9ffd4c916..00a89705c1c4 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
@@ -1156,38 +1156,47 @@ int ebt_register_table(struct ebt_table *table) | |||
1156 | { | 1156 | { |
1157 | struct ebt_table_info *newinfo; | 1157 | struct ebt_table_info *newinfo; |
1158 | struct ebt_table *t; | 1158 | struct ebt_table *t; |
1159 | struct ebt_replace *repl; | ||
1159 | int ret, i, countersize; | 1160 | int ret, i, countersize; |
1161 | void *p; | ||
1160 | 1162 | ||
1161 | if (!table || !table->table ||!table->table->entries || | 1163 | if (!table || !(repl = table->table) || !repl->entries || |
1162 | table->table->entries_size == 0 || | 1164 | repl->entries_size == 0 || |
1163 | table->table->counters || table->private) { | 1165 | repl->counters || table->private) { |
1164 | BUGPRINT("Bad table data for ebt_register_table!!!\n"); | 1166 | BUGPRINT("Bad table data for ebt_register_table!!!\n"); |
1165 | return -EINVAL; | 1167 | return -EINVAL; |
1166 | } | 1168 | } |
1167 | 1169 | ||
1168 | countersize = COUNTER_OFFSET(table->table->nentries) * | 1170 | countersize = COUNTER_OFFSET(repl->nentries) * |
1169 | (highest_possible_processor_id()+1); | 1171 | (highest_possible_processor_id()+1); |
1170 | newinfo = vmalloc(sizeof(*newinfo) + countersize); | 1172 | newinfo = vmalloc(sizeof(*newinfo) + countersize); |
1171 | ret = -ENOMEM; | 1173 | ret = -ENOMEM; |
1172 | if (!newinfo) | 1174 | if (!newinfo) |
1173 | return -ENOMEM; | 1175 | return -ENOMEM; |
1174 | 1176 | ||
1175 | newinfo->entries = vmalloc(table->table->entries_size); | 1177 | p = vmalloc(repl->entries_size); |
1176 | if (!(newinfo->entries)) | 1178 | if (!p) |
1177 | goto free_newinfo; | 1179 | goto free_newinfo; |
1178 | 1180 | ||
1179 | memcpy(newinfo->entries, table->table->entries, | 1181 | memcpy(p, repl->entries, repl->entries_size); |
1180 | table->table->entries_size); | 1182 | newinfo->entries = p; |
1183 | |||
1184 | newinfo->entries_size = repl->entries_size; | ||
1185 | newinfo->nentries = repl->nentries; | ||
1181 | 1186 | ||
1182 | if (countersize) | 1187 | if (countersize) |
1183 | memset(newinfo->counters, 0, countersize); | 1188 | memset(newinfo->counters, 0, countersize); |
1184 | 1189 | ||
1185 | /* fill in newinfo and parse the entries */ | 1190 | /* fill in newinfo and parse the entries */ |
1186 | newinfo->chainstack = NULL; | 1191 | newinfo->chainstack = NULL; |
1187 | ret = ebt_verify_pointers(table->table, newinfo); | 1192 | for (i = 0; i < NF_BR_NUMHOOKS; i++) { |
1188 | if (ret != 0) | 1193 | if ((repl->valid_hooks & (1 << i)) == 0) |
1189 | goto free_chainstack; | 1194 | newinfo->hook_entry[i] = NULL; |
1190 | ret = translate_table(table->table->name, newinfo); | 1195 | else |
1196 | newinfo->hook_entry[i] = p + | ||
1197 | ((char *)repl->hook_entry[i] - repl->entries); | ||
1198 | } | ||
1199 | ret = translate_table(repl->name, newinfo); | ||
1191 | if (ret != 0) { | 1200 | if (ret != 0) { |
1192 | BUGPRINT("Translate_table failed\n"); | 1201 | BUGPRINT("Translate_table failed\n"); |
1193 | goto free_chainstack; | 1202 | goto free_chainstack; |