Skip to content

Commit

Permalink
netfilter: remove forward module param confusion.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
rustyrussell authored and davem330 committed Mar 23, 2012
1 parent 5d5440a commit 523f610
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
9 changes: 2 additions & 7 deletions net/ipv4/netfilter/iptable_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ iptable_filter_hook(unsigned int hook, struct sk_buff *skb,
static struct nf_hook_ops *filter_ops __read_mostly;

/* Default to forward because I got too much mail already. */
static bool forward = NF_ACCEPT;
static bool forward = true;
module_param(forward, bool, 0000);

static int __net_init iptable_filter_net_init(struct net *net)
Expand All @@ -64,7 +64,7 @@ static int __net_init iptable_filter_net_init(struct net *net)
return -ENOMEM;
/* Entry 1 is the FORWARD hook */
((struct ipt_standard *)repl->entries)[1].target.verdict =
-forward - 1;
forward ? -NF_ACCEPT - 1 : -NF_DROP - 1;

net->ipv4.iptable_filter =
ipt_register_table(net, &packet_filter, repl);
Expand All @@ -88,11 +88,6 @@ static int __init iptable_filter_init(void)
{
int ret;

if (forward < 0 || forward > NF_MAX_VERDICT) {
pr_err("iptables forward must be 0 or 1\n");
return -EINVAL;
}

ret = register_pernet_subsys(&iptable_filter_net_ops);
if (ret < 0)
return ret;
Expand Down
9 changes: 2 additions & 7 deletions net/ipv6/netfilter/ip6table_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ip6table_filter_hook(unsigned int hook, struct sk_buff *skb,
static struct nf_hook_ops *filter_ops __read_mostly;

/* Default to forward because I got too much mail already. */
static bool forward = NF_ACCEPT;
static bool forward = true;
module_param(forward, bool, 0000);

static int __net_init ip6table_filter_net_init(struct net *net)
Expand All @@ -56,7 +56,7 @@ static int __net_init ip6table_filter_net_init(struct net *net)
return -ENOMEM;
/* Entry 1 is the FORWARD hook */
((struct ip6t_standard *)repl->entries)[1].target.verdict =
-forward - 1;
forward ? -NF_ACCEPT - 1 : -NF_DROP - 1;

net->ipv6.ip6table_filter =
ip6t_register_table(net, &packet_filter, repl);
Expand All @@ -80,11 +80,6 @@ static int __init ip6table_filter_init(void)
{
int ret;

if (forward < 0 || forward > NF_MAX_VERDICT) {
pr_err("iptables forward must be 0 or 1\n");
return -EINVAL;
}

ret = register_pernet_subsys(&ip6table_filter_net_ops);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 523f610

Please sign in to comment.