diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-04-05 04:43:09 -0400 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2009-05-08 04:30:50 -0400 |
commit | 451853645f3cb804b523227eca054701e4cbc589 (patch) | |
tree | ed1b501977dd361292ab20c47c5f12e422446d70 | |
parent | bb70dfa5f8ab4a0f1c699ddb3ef0276d91219b7c (diff) |
netfilter: xtables: print hook name instead of mask
Users cannot make anything of these numbers. Let's just tell them
directly.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r-- | net/netfilter/x_tables.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 150e5cf62f85..46dba5f043d5 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -329,6 +329,32 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target, | |||
329 | } | 329 | } |
330 | EXPORT_SYMBOL_GPL(xt_find_revision); | 330 | EXPORT_SYMBOL_GPL(xt_find_revision); |
331 | 331 | ||
332 | static char *textify_hooks(char *buf, size_t size, unsigned int mask) | ||
333 | { | ||
334 | static const char *const names[] = { | ||
335 | "PREROUTING", "INPUT", "FORWARD", | ||
336 | "OUTPUT", "POSTROUTING", "BROUTING", | ||
337 | }; | ||
338 | unsigned int i; | ||
339 | char *p = buf; | ||
340 | bool np = false; | ||
341 | int res; | ||
342 | |||
343 | *p = '\0'; | ||
344 | for (i = 0; i < ARRAY_SIZE(names); ++i) { | ||
345 | if (!(mask & (1 << i))) | ||
346 | continue; | ||
347 | res = snprintf(p, size, "%s%s", np ? "/" : "", names[i]); | ||
348 | if (res > 0) { | ||
349 | size -= res; | ||
350 | p += res; | ||
351 | } | ||
352 | np = true; | ||
353 | } | ||
354 | |||
355 | return buf; | ||
356 | } | ||
357 | |||
332 | int xt_check_match(struct xt_mtchk_param *par, | 358 | int xt_check_match(struct xt_mtchk_param *par, |
333 | unsigned int size, u_int8_t proto, bool inv_proto) | 359 | unsigned int size, u_int8_t proto, bool inv_proto) |
334 | { | 360 | { |
@@ -351,9 +377,13 @@ int xt_check_match(struct xt_mtchk_param *par, | |||
351 | return -EINVAL; | 377 | return -EINVAL; |
352 | } | 378 | } |
353 | if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { | 379 | if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { |
354 | printk("%s_tables: %s match: bad hook_mask %#x/%#x\n", | 380 | char used[64], allow[64]; |
381 | |||
382 | printk("%s_tables: %s match: used from hooks %s, but only " | ||
383 | "valid from %s\n", | ||
355 | xt_prefix[par->family], par->match->name, | 384 | xt_prefix[par->family], par->match->name, |
356 | par->hook_mask, par->match->hooks); | 385 | textify_hooks(used, sizeof(used), par->hook_mask), |
386 | textify_hooks(allow, sizeof(allow), par->match->hooks)); | ||
357 | return -EINVAL; | 387 | return -EINVAL; |
358 | } | 388 | } |
359 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { | 389 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { |
@@ -497,9 +527,13 @@ int xt_check_target(struct xt_tgchk_param *par, | |||
497 | return -EINVAL; | 527 | return -EINVAL; |
498 | } | 528 | } |
499 | if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { | 529 | if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { |
500 | printk("%s_tables: %s target: bad hook_mask %#x/%#x\n", | 530 | char used[64], allow[64]; |
531 | |||
532 | printk("%s_tables: %s target: used from hooks %s, but only " | ||
533 | "usable from %s\n", | ||
501 | xt_prefix[par->family], par->target->name, | 534 | xt_prefix[par->family], par->target->name, |
502 | par->hook_mask, par->target->hooks); | 535 | textify_hooks(used, sizeof(used), par->hook_mask), |
536 | textify_hooks(allow, sizeof(allow), par->target->hooks)); | ||
503 | return -EINVAL; | 537 | return -EINVAL; |
504 | } | 538 | } |
505 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { | 539 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { |