diff options
author | Jan Engelhardt <jengelh@inai.de> | 2013-01-10 07:30:05 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-01-13 06:54:12 -0500 |
commit | 5b76c4948fe6977bead2359c2054f3e6a2dcf3d0 (patch) | |
tree | 84ddb40fd0bc96f882ecca646b4966b2b717c377 /net | |
parent | 1e47ee8367babe6a5e8adf44a714c7086657b87e (diff) |
netfilter: x_tables: print correct hook names for ARP
arptables 0.0.4 (released on 10th Jan 2013) supports calling the
CLASSIFY target, but on adding a rule to the wrong chain, the
diagnostic is as follows:
# arptables -A INPUT -j CLASSIFY --set-class 0:0
arptables: Invalid argument
# dmesg | tail -n1
x_tables: arp_tables: CLASSIFY target: used from hooks
PREROUTING, but only usable from INPUT/FORWARD
This is incorrect, since xt_CLASSIFY.c does specify
(1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD).
This patch corrects the x_tables diagnostic message to print the
proper hook names for the NFPROTO_ARP case.
Affects all kernels down to and including v2.6.31.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/x_tables.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 8d987c3573fd..7b3a9e5999c0 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -345,19 +345,27 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target, | |||
345 | } | 345 | } |
346 | EXPORT_SYMBOL_GPL(xt_find_revision); | 346 | EXPORT_SYMBOL_GPL(xt_find_revision); |
347 | 347 | ||
348 | static char *textify_hooks(char *buf, size_t size, unsigned int mask) | 348 | static char * |
349 | textify_hooks(char *buf, size_t size, unsigned int mask, uint8_t nfproto) | ||
349 | { | 350 | { |
350 | static const char *const names[] = { | 351 | static const char *const inetbr_names[] = { |
351 | "PREROUTING", "INPUT", "FORWARD", | 352 | "PREROUTING", "INPUT", "FORWARD", |
352 | "OUTPUT", "POSTROUTING", "BROUTING", | 353 | "OUTPUT", "POSTROUTING", "BROUTING", |
353 | }; | 354 | }; |
354 | unsigned int i; | 355 | static const char *const arp_names[] = { |
356 | "INPUT", "FORWARD", "OUTPUT", | ||
357 | }; | ||
358 | const char *const *names; | ||
359 | unsigned int i, max; | ||
355 | char *p = buf; | 360 | char *p = buf; |
356 | bool np = false; | 361 | bool np = false; |
357 | int res; | 362 | int res; |
358 | 363 | ||
364 | names = (nfproto == NFPROTO_ARP) ? arp_names : inetbr_names; | ||
365 | max = (nfproto == NFPROTO_ARP) ? ARRAY_SIZE(arp_names) : | ||
366 | ARRAY_SIZE(inetbr_names); | ||
359 | *p = '\0'; | 367 | *p = '\0'; |
360 | for (i = 0; i < ARRAY_SIZE(names); ++i) { | 368 | for (i = 0; i < max; ++i) { |
361 | if (!(mask & (1 << i))) | 369 | if (!(mask & (1 << i))) |
362 | continue; | 370 | continue; |
363 | res = snprintf(p, size, "%s%s", np ? "/" : "", names[i]); | 371 | res = snprintf(p, size, "%s%s", np ? "/" : "", names[i]); |
@@ -402,8 +410,10 @@ int xt_check_match(struct xt_mtchk_param *par, | |||
402 | pr_err("%s_tables: %s match: used from hooks %s, but only " | 410 | pr_err("%s_tables: %s match: used from hooks %s, but only " |
403 | "valid from %s\n", | 411 | "valid from %s\n", |
404 | xt_prefix[par->family], par->match->name, | 412 | xt_prefix[par->family], par->match->name, |
405 | textify_hooks(used, sizeof(used), par->hook_mask), | 413 | textify_hooks(used, sizeof(used), par->hook_mask, |
406 | textify_hooks(allow, sizeof(allow), par->match->hooks)); | 414 | par->family), |
415 | textify_hooks(allow, sizeof(allow), par->match->hooks, | ||
416 | par->family)); | ||
407 | return -EINVAL; | 417 | return -EINVAL; |
408 | } | 418 | } |
409 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { | 419 | if (par->match->proto && (par->match->proto != proto || inv_proto)) { |
@@ -575,8 +585,10 @@ int xt_check_target(struct xt_tgchk_param *par, | |||
575 | pr_err("%s_tables: %s target: used from hooks %s, but only " | 585 | pr_err("%s_tables: %s target: used from hooks %s, but only " |
576 | "usable from %s\n", | 586 | "usable from %s\n", |
577 | xt_prefix[par->family], par->target->name, | 587 | xt_prefix[par->family], par->target->name, |
578 | textify_hooks(used, sizeof(used), par->hook_mask), | 588 | textify_hooks(used, sizeof(used), par->hook_mask, |
579 | textify_hooks(allow, sizeof(allow), par->target->hooks)); | 589 | par->family), |
590 | textify_hooks(allow, sizeof(allow), par->target->hooks, | ||
591 | par->family)); | ||
580 | return -EINVAL; | 592 | return -EINVAL; |
581 | } | 593 | } |
582 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { | 594 | if (par->target->proto && (par->target->proto != proto || inv_proto)) { |