Skip to content

Commit 8fe2238

Browse files
committed
netfilter: Pass nf_hook_state through nf_nat_ipv6_{in,out,fn,local_fn}().
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1c491ba commit 8fe2238

4 files changed

Lines changed: 35 additions & 52 deletions

File tree

‎include/net/netfilter/nf_nat_l3proto.h‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,40 +77,32 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
7777
unsigned int hooknum, unsigned int hdrlen);
7878

7979
unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
80-
const struct net_device *in,
81-
const struct net_device *out,
80+
const struct nf_hook_state *state,
8281
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
8382
struct sk_buff *skb,
84-
const struct net_device *in,
85-
const struct net_device *out,
83+
const struct nf_hook_state *state,
8684
struct nf_conn *ct));
8785

8886
unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
89-
const struct net_device *in,
90-
const struct net_device *out,
87+
const struct nf_hook_state *state,
9188
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
9289
struct sk_buff *skb,
93-
const struct net_device *in,
94-
const struct net_device *out,
90+
const struct nf_hook_state *state,
9591
struct nf_conn *ct));
9692

9793
unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
9894
struct sk_buff *skb,
99-
const struct net_device *in,
100-
const struct net_device *out,
95+
const struct nf_hook_state *state,
10196
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
10297
struct sk_buff *skb,
103-
const struct net_device *in,
104-
const struct net_device *out,
98+
const struct nf_hook_state *state,
10599
struct nf_conn *ct));
106100

107101
unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
108-
const struct net_device *in,
109-
const struct net_device *out,
102+
const struct nf_hook_state *state,
110103
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
111104
struct sk_buff *skb,
112-
const struct net_device *in,
113-
const struct net_device *out,
105+
const struct nf_hook_state *state,
114106
struct nf_conn *ct));
115107

116108
#endif /* _NF_NAT_L3PROTO_H */

‎net/ipv6/netfilter/ip6table_nat.c‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,41 @@ static const struct xt_table nf_nat_ipv6_table = {
3232

3333
static unsigned int ip6table_nat_do_chain(const struct nf_hook_ops *ops,
3434
struct sk_buff *skb,
35-
const struct net_device *in,
36-
const struct net_device *out,
35+
const struct nf_hook_state *state,
3736
struct nf_conn *ct)
3837
{
3938
struct net *net = nf_ct_net(ct);
4039

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

4444
static unsigned int ip6table_nat_fn(const struct nf_hook_ops *ops,
4545
struct sk_buff *skb,
4646
const struct nf_hook_state *state)
4747
{
48-
return nf_nat_ipv6_fn(ops, skb, state->in, state->out,
49-
ip6table_nat_do_chain);
48+
return nf_nat_ipv6_fn(ops, skb, state, ip6table_nat_do_chain);
5049
}
5150

5251
static unsigned int ip6table_nat_in(const struct nf_hook_ops *ops,
5352
struct sk_buff *skb,
5453
const struct nf_hook_state *state)
5554
{
56-
return nf_nat_ipv6_in(ops, skb, state->in, state->out,
57-
ip6table_nat_do_chain);
55+
return nf_nat_ipv6_in(ops, skb, state, ip6table_nat_do_chain);
5856
}
5957

6058
static unsigned int ip6table_nat_out(const struct nf_hook_ops *ops,
6159
struct sk_buff *skb,
6260
const struct nf_hook_state *state)
6361
{
64-
return nf_nat_ipv6_out(ops, skb, state->in, state->out,
65-
ip6table_nat_do_chain);
62+
return nf_nat_ipv6_out(ops, skb, state, ip6table_nat_do_chain);
6663
}
6764

6865
static unsigned int ip6table_nat_local_fn(const struct nf_hook_ops *ops,
6966
struct sk_buff *skb,
7067
const struct nf_hook_state *state)
7168
{
72-
return nf_nat_ipv6_local_fn(ops, skb, state->in, state->out,
73-
ip6table_nat_do_chain);
69+
return nf_nat_ipv6_local_fn(ops, skb, state, ip6table_nat_do_chain);
7470
}
7571

7672
static struct nf_hook_ops nf_nat_ipv6_ops[] __read_mostly = {

‎net/ipv6/netfilter/nf_nat_l3proto_ipv6.c‎

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,10 @@ EXPORT_SYMBOL_GPL(nf_nat_icmpv6_reply_translation);
263263

264264
unsigned int
265265
nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
266-
const struct net_device *in, const struct net_device *out,
266+
const struct nf_hook_state *state,
267267
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
268268
struct sk_buff *skb,
269-
const struct net_device *in,
270-
const struct net_device *out,
269+
const struct nf_hook_state *state,
271270
struct nf_conn *ct))
272271
{
273272
struct nf_conn *ct;
@@ -318,7 +317,7 @@ nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
318317
if (!nf_nat_initialized(ct, maniptype)) {
319318
unsigned int ret;
320319

321-
ret = do_chain(ops, skb, in, out, ct);
320+
ret = do_chain(ops, skb, state, ct);
322321
if (ret != NF_ACCEPT)
323322
return ret;
324323

@@ -332,7 +331,7 @@ nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
332331
pr_debug("Already setup manip %s for ct %p\n",
333332
maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST",
334333
ct);
335-
if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, out))
334+
if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, state->out))
336335
goto oif_changed;
337336
}
338337
break;
@@ -341,7 +340,7 @@ nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
341340
/* ESTABLISHED */
342341
NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
343342
ctinfo == IP_CT_ESTABLISHED_REPLY);
344-
if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, out))
343+
if (nf_nat_oif_changed(ops->hooknum, ctinfo, nat, state->out))
345344
goto oif_changed;
346345
}
347346

@@ -355,17 +354,16 @@ EXPORT_SYMBOL_GPL(nf_nat_ipv6_fn);
355354

356355
unsigned int
357356
nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
358-
const struct net_device *in, const struct net_device *out,
357+
const struct nf_hook_state *state,
359358
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
360359
struct sk_buff *skb,
361-
const struct net_device *in,
362-
const struct net_device *out,
360+
const struct nf_hook_state *state,
363361
struct nf_conn *ct))
364362
{
365363
unsigned int ret;
366364
struct in6_addr daddr = ipv6_hdr(skb)->daddr;
367365

368-
ret = nf_nat_ipv6_fn(ops, skb, in, out, do_chain);
366+
ret = nf_nat_ipv6_fn(ops, skb, state, do_chain);
369367
if (ret != NF_DROP && ret != NF_STOLEN &&
370368
ipv6_addr_cmp(&daddr, &ipv6_hdr(skb)->daddr))
371369
skb_dst_drop(skb);
@@ -376,11 +374,10 @@ EXPORT_SYMBOL_GPL(nf_nat_ipv6_in);
376374

377375
unsigned int
378376
nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
379-
const struct net_device *in, const struct net_device *out,
377+
const struct nf_hook_state *state,
380378
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
381379
struct sk_buff *skb,
382-
const struct net_device *in,
383-
const struct net_device *out,
380+
const struct nf_hook_state *state,
384381
struct nf_conn *ct))
385382
{
386383
#ifdef CONFIG_XFRM
@@ -394,7 +391,7 @@ nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
394391
if (skb->len < sizeof(struct ipv6hdr))
395392
return NF_ACCEPT;
396393

397-
ret = nf_nat_ipv6_fn(ops, skb, in, out, do_chain);
394+
ret = nf_nat_ipv6_fn(ops, skb, state, do_chain);
398395
#ifdef CONFIG_XFRM
399396
if (ret != NF_DROP && ret != NF_STOLEN &&
400397
!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
@@ -418,11 +415,10 @@ EXPORT_SYMBOL_GPL(nf_nat_ipv6_out);
418415

419416
unsigned int
420417
nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
421-
const struct net_device *in, const struct net_device *out,
418+
const struct nf_hook_state *state,
422419
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
423420
struct sk_buff *skb,
424-
const struct net_device *in,
425-
const struct net_device *out,
421+
const struct nf_hook_state *state,
426422
struct nf_conn *ct))
427423
{
428424
const struct nf_conn *ct;
@@ -434,7 +430,7 @@ nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
434430
if (skb->len < sizeof(struct ipv6hdr))
435431
return NF_ACCEPT;
436432

437-
ret = nf_nat_ipv6_fn(ops, skb, in, out, do_chain);
433+
ret = nf_nat_ipv6_fn(ops, skb, state, do_chain);
438434
if (ret != NF_DROP && ret != NF_STOLEN &&
439435
(ct = nf_ct_get(skb, &ctinfo)) != NULL) {
440436
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);

‎net/ipv6/netfilter/nft_chain_nat_ipv6.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626

2727
static unsigned int nft_nat_do_chain(const struct nf_hook_ops *ops,
2828
struct sk_buff *skb,
29-
const struct net_device *in,
30-
const struct net_device *out,
29+
const struct nf_hook_state *state,
3130
struct nf_conn *ct)
3231
{
3332
struct nft_pktinfo pkt;
3433

35-
nft_set_pktinfo_ipv6(&pkt, ops, skb, in, out);
34+
nft_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out);
3635

3736
return nft_do_chain(&pkt, ops);
3837
}
@@ -41,28 +40,28 @@ static unsigned int nft_nat_ipv6_fn(const struct nf_hook_ops *ops,
4140
struct sk_buff *skb,
4241
const struct nf_hook_state *state)
4342
{
44-
return nf_nat_ipv6_fn(ops, skb, state->in, state->out, nft_nat_do_chain);
43+
return nf_nat_ipv6_fn(ops, skb, state, nft_nat_do_chain);
4544
}
4645

4746
static unsigned int nft_nat_ipv6_in(const struct nf_hook_ops *ops,
4847
struct sk_buff *skb,
4948
const struct nf_hook_state *state)
5049
{
51-
return nf_nat_ipv6_in(ops, skb, state->in, state->out, nft_nat_do_chain);
50+
return nf_nat_ipv6_in(ops, skb, state, nft_nat_do_chain);
5251
}
5352

5453
static unsigned int nft_nat_ipv6_out(const struct nf_hook_ops *ops,
5554
struct sk_buff *skb,
5655
const struct nf_hook_state *state)
5756
{
58-
return nf_nat_ipv6_out(ops, skb, state->in, state->out, nft_nat_do_chain);
57+
return nf_nat_ipv6_out(ops, skb, state, nft_nat_do_chain);
5958
}
6059

6160
static unsigned int nft_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
6261
struct sk_buff *skb,
6362
const struct nf_hook_state *state)
6463
{
65-
return nf_nat_ipv6_local_fn(ops, skb, state->in, state->out, nft_nat_do_chain);
64+
return nf_nat_ipv6_local_fn(ops, skb, state, nft_nat_do_chain);
6665
}
6766

6867
static const struct nf_chain_type nft_chain_nat_ipv6 = {

0 commit comments

Comments
 (0)