diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-03-22 08:27:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-03-22 22:36:17 -0400 |
commit | 523f610e1be2a4afca605962e137064378883c5f (patch) | |
tree | 82923297355fccb70a03c5d2108bc5a6030212a2 /net | |
parent | 5d5440a835710d09f0ef18da5000541ec98b537a (diff) |
netfilter: remove forward module param confusion.
It used to be an int, and it got changed to a bool parameter at least
7 years ago. It happens that NF_ACCEPT and NF_DROP are 0 and 1, so
this works, but it's unclear, and the check that it's in range is not
required.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/iptable_filter.c | 9 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6table_filter.c | 9 |
2 files changed, 4 insertions, 14 deletions
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c index 0e58f09e59fb..851acec852d2 100644 --- a/net/ipv4/netfilter/iptable_filter.c +++ b/net/ipv4/netfilter/iptable_filter.c | |||
@@ -52,7 +52,7 @@ iptable_filter_hook(unsigned int hook, struct sk_buff *skb, | |||
52 | static struct nf_hook_ops *filter_ops __read_mostly; | 52 | static struct nf_hook_ops *filter_ops __read_mostly; |
53 | 53 | ||
54 | /* Default to forward because I got too much mail already. */ | 54 | /* Default to forward because I got too much mail already. */ |
55 | static bool forward = NF_ACCEPT; | 55 | static bool forward = true; |
56 | module_param(forward, bool, 0000); | 56 | module_param(forward, bool, 0000); |
57 | 57 | ||
58 | static int __net_init iptable_filter_net_init(struct net *net) | 58 | static int __net_init iptable_filter_net_init(struct net *net) |
@@ -64,7 +64,7 @@ static int __net_init iptable_filter_net_init(struct net *net) | |||
64 | return -ENOMEM; | 64 | return -ENOMEM; |
65 | /* Entry 1 is the FORWARD hook */ | 65 | /* Entry 1 is the FORWARD hook */ |
66 | ((struct ipt_standard *)repl->entries)[1].target.verdict = | 66 | ((struct ipt_standard *)repl->entries)[1].target.verdict = |
67 | -forward - 1; | 67 | forward ? -NF_ACCEPT - 1 : -NF_DROP - 1; |
68 | 68 | ||
69 | net->ipv4.iptable_filter = | 69 | net->ipv4.iptable_filter = |
70 | ipt_register_table(net, &packet_filter, repl); | 70 | ipt_register_table(net, &packet_filter, repl); |
@@ -88,11 +88,6 @@ static int __init iptable_filter_init(void) | |||
88 | { | 88 | { |
89 | int ret; | 89 | int ret; |
90 | 90 | ||
91 | if (forward < 0 || forward > NF_MAX_VERDICT) { | ||
92 | pr_err("iptables forward must be 0 or 1\n"); | ||
93 | return -EINVAL; | ||
94 | } | ||
95 | |||
96 | ret = register_pernet_subsys(&iptable_filter_net_ops); | 91 | ret = register_pernet_subsys(&iptable_filter_net_ops); |
97 | if (ret < 0) | 92 | if (ret < 0) |
98 | return ret; | 93 | return ret; |
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c index a8f6da97e3b2..325e59a0224f 100644 --- a/net/ipv6/netfilter/ip6table_filter.c +++ b/net/ipv6/netfilter/ip6table_filter.c | |||
@@ -44,7 +44,7 @@ ip6table_filter_hook(unsigned int hook, struct sk_buff *skb, | |||
44 | static struct nf_hook_ops *filter_ops __read_mostly; | 44 | static struct nf_hook_ops *filter_ops __read_mostly; |
45 | 45 | ||
46 | /* Default to forward because I got too much mail already. */ | 46 | /* Default to forward because I got too much mail already. */ |
47 | static bool forward = NF_ACCEPT; | 47 | static bool forward = true; |
48 | module_param(forward, bool, 0000); | 48 | module_param(forward, bool, 0000); |
49 | 49 | ||
50 | static int __net_init ip6table_filter_net_init(struct net *net) | 50 | static int __net_init ip6table_filter_net_init(struct net *net) |
@@ -56,7 +56,7 @@ static int __net_init ip6table_filter_net_init(struct net *net) | |||
56 | return -ENOMEM; | 56 | return -ENOMEM; |
57 | /* Entry 1 is the FORWARD hook */ | 57 | /* Entry 1 is the FORWARD hook */ |
58 | ((struct ip6t_standard *)repl->entries)[1].target.verdict = | 58 | ((struct ip6t_standard *)repl->entries)[1].target.verdict = |
59 | -forward - 1; | 59 | forward ? -NF_ACCEPT - 1 : -NF_DROP - 1; |
60 | 60 | ||
61 | net->ipv6.ip6table_filter = | 61 | net->ipv6.ip6table_filter = |
62 | ip6t_register_table(net, &packet_filter, repl); | 62 | ip6t_register_table(net, &packet_filter, repl); |
@@ -80,11 +80,6 @@ static int __init ip6table_filter_init(void) | |||
80 | { | 80 | { |
81 | int ret; | 81 | int ret; |
82 | 82 | ||
83 | if (forward < 0 || forward > NF_MAX_VERDICT) { | ||
84 | pr_err("iptables forward must be 0 or 1\n"); | ||
85 | return -EINVAL; | ||
86 | } | ||
87 | |||
88 | ret = register_pernet_subsys(&ip6table_filter_net_ops); | 83 | ret = register_pernet_subsys(&ip6table_filter_net_ops); |
89 | if (ret < 0) | 84 | if (ret < 0) |
90 | return ret; | 85 | return ret; |