Skip to content

Commit 8f8a371

Browse files
committed
netfilter: Pass nf_hook_state through ip6t_do_table().
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8fe2238 commit 8f8a371

7 files changed

Lines changed: 17 additions & 22 deletions

File tree

‎include/linux/netfilter_ipv6/ip6_tables.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ extern struct xt_table *ip6t_register_table(struct net *net,
3131
extern void ip6t_unregister_table(struct net *net, struct xt_table *table);
3232
extern unsigned int ip6t_do_table(struct sk_buff *skb,
3333
unsigned int hook,
34-
const struct net_device *in,
35-
const struct net_device *out,
34+
const struct nf_hook_state *state,
3635
struct xt_table *table);
3736

3837
/* Check for an extension */

‎net/ipv6/netfilter/ip6_tables.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ ip6t_next_entry(const struct ip6t_entry *entry)
317317
unsigned int
318318
ip6t_do_table(struct sk_buff *skb,
319319
unsigned int hook,
320-
const struct net_device *in,
321-
const struct net_device *out,
320+
const struct nf_hook_state *state,
322321
struct xt_table *table)
323322
{
324323
static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
@@ -333,17 +332,17 @@ ip6t_do_table(struct sk_buff *skb,
333332
unsigned int addend;
334333

335334
/* Initialization */
336-
indev = in ? in->name : nulldevname;
337-
outdev = out ? out->name : nulldevname;
335+
indev = state->in ? state->in->name : nulldevname;
336+
outdev = state->out ? state->out->name : nulldevname;
338337
/* We handle fragments by dealing with the first fragment as
339338
* if it was a normal packet. All other fragments are treated
340339
* normally, except that they will NEVER match rules that ask
341340
* things we don't know, ie. tcp syn flag or ports). If the
342341
* rule is also a fragment-specific rule, non-fragments won't
343342
* match it. */
344343
acpar.hotdrop = false;
345-
acpar.in = in;
346-
acpar.out = out;
344+
acpar.in = state->in;
345+
acpar.out = state->out;
347346
acpar.family = NFPROTO_IPV6;
348347
acpar.hooknum = hook;
349348

@@ -393,7 +392,7 @@ ip6t_do_table(struct sk_buff *skb,
393392
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
394393
/* The packet is traced: log it */
395394
if (unlikely(skb->nf_trace))
396-
trace_packet(skb, hook, in, out,
395+
trace_packet(skb, hook, state->in, state->out,
397396
table->name, private, e);
398397
#endif
399398
/* Standard target? */

‎net/ipv6/netfilter/ip6table_filter.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ ip6table_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
3737
{
3838
const struct net *net = dev_net(state->in ? state->in : state->out);
3939

40-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
41-
net->ipv6.ip6table_filter);
40+
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_filter);
4241
}
4342

4443
static struct nf_hook_ops *filter_ops __read_mostly;

‎net/ipv6/netfilter/ip6table_mangle.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static const struct xt_table packet_mangler = {
3232
};
3333

3434
static unsigned int
35-
ip6t_mangle_out(struct sk_buff *skb, const struct net_device *out)
35+
ip6t_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
3636
{
3737
unsigned int ret;
3838
struct in6_addr saddr, daddr;
@@ -57,8 +57,8 @@ ip6t_mangle_out(struct sk_buff *skb, const struct net_device *out)
5757
/* flowlabel and prio (includes version, which shouldn't change either */
5858
flowlabel = *((u_int32_t *)ipv6_hdr(skb));
5959

60-
ret = ip6t_do_table(skb, NF_INET_LOCAL_OUT, NULL, out,
61-
dev_net(out)->ipv6.ip6table_mangle);
60+
ret = ip6t_do_table(skb, NF_INET_LOCAL_OUT, state,
61+
dev_net(state->out)->ipv6.ip6table_mangle);
6262

6363
if (ret != NF_DROP && ret != NF_STOLEN &&
6464
(!ipv6_addr_equal(&ipv6_hdr(skb)->saddr, &saddr) ||
@@ -80,12 +80,12 @@ ip6table_mangle_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
8080
const struct nf_hook_state *state)
8181
{
8282
if (ops->hooknum == NF_INET_LOCAL_OUT)
83-
return ip6t_mangle_out(skb, state->out);
83+
return ip6t_mangle_out(skb, state);
8484
if (ops->hooknum == NF_INET_POST_ROUTING)
85-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
85+
return ip6t_do_table(skb, ops->hooknum, state,
8686
dev_net(state->out)->ipv6.ip6table_mangle);
8787
/* INPUT/FORWARD */
88-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
88+
return ip6t_do_table(skb, ops->hooknum, state,
8989
dev_net(state->in)->ipv6.ip6table_mangle);
9090
}
9191

‎net/ipv6/netfilter/ip6table_nat.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ static unsigned int ip6table_nat_do_chain(const struct nf_hook_ops *ops,
3737
{
3838
struct net *net = nf_ct_net(ct);
3939

40-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
41-
net->ipv6.ip6table_nat);
40+
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_nat);
4241
}
4342

4443
static unsigned int ip6table_nat_fn(const struct nf_hook_ops *ops,

‎net/ipv6/netfilter/ip6table_raw.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ ip6table_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
2424
{
2525
const struct net *net = dev_net(state->in ? state->in : state->out);
2626

27-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
28-
net->ipv6.ip6table_raw);
27+
return ip6t_do_table(skb, ops->hooknum, state, net->ipv6.ip6table_raw);
2928
}
3029

3130
static struct nf_hook_ops *rawtable_ops __read_mostly;

‎net/ipv6/netfilter/ip6table_security.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ip6table_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
4141
{
4242
const struct net *net = dev_net(state->in ? state->in : state->out);
4343

44-
return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
44+
return ip6t_do_table(skb, ops->hooknum, state,
4545
net->ipv6.ip6table_security);
4646
}
4747

0 commit comments

Comments
 (0)