Skip to content

Commit 073bfd5

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

11 files changed

Lines changed: 25 additions & 30 deletions

File tree

‎include/net/netfilter/nf_tables.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ struct nft_pktinfo {
2626
static inline void nft_set_pktinfo(struct nft_pktinfo *pkt,
2727
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
{
3231
pkt->skb = skb;
33-
pkt->in = pkt->xt.in = in;
34-
pkt->out = pkt->xt.out = out;
32+
pkt->in = pkt->xt.in = state->in;
33+
pkt->out = pkt->xt.out = state->out;
3534
pkt->ops = ops;
3635
pkt->xt.hooknum = ops->hooknum;
3736
pkt->xt.family = ops->pf;

‎include/net/netfilter/nf_tables_ipv4.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ static inline void
88
nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt,
99
const struct nf_hook_ops *ops,
1010
struct sk_buff *skb,
11-
const struct net_device *in,
12-
const struct net_device *out)
11+
const struct nf_hook_state *state)
1312
{
1413
struct iphdr *ip;
1514

16-
nft_set_pktinfo(pkt, ops, skb, in, out);
15+
nft_set_pktinfo(pkt, ops, skb, state);
1716

1817
ip = ip_hdr(pkt->skb);
1918
pkt->tprot = ip->protocol;

‎include/net/netfilter/nf_tables_ipv6.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ static inline int
88
nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
99
const struct nf_hook_ops *ops,
1010
struct sk_buff *skb,
11-
const struct net_device *in,
12-
const struct net_device *out)
11+
const struct nf_hook_state *state)
1312
{
1413
int protohdr, thoff = 0;
1514
unsigned short frag_off;
1615

17-
nft_set_pktinfo(pkt, ops, skb, in, out);
16+
nft_set_pktinfo(pkt, ops, skb, state);
1817

1918
protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL);
2019
/* If malformed, drop it */

‎net/bridge/netfilter/nf_tables_bridge.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,25 @@ EXPORT_SYMBOL_GPL(nft_bridge_ip6hdr_validate);
6767
static inline void nft_bridge_set_pktinfo_ipv4(struct nft_pktinfo *pkt,
6868
const struct nf_hook_ops *ops,
6969
struct sk_buff *skb,
70-
const struct net_device *in,
71-
const struct net_device *out)
70+
const struct nf_hook_state *state)
7271
{
7372
if (nft_bridge_iphdr_validate(skb))
74-
nft_set_pktinfo_ipv4(pkt, ops, skb, in, out);
73+
nft_set_pktinfo_ipv4(pkt, ops, skb, state);
7574
else
76-
nft_set_pktinfo(pkt, ops, skb, in, out);
75+
nft_set_pktinfo(pkt, ops, skb, state);
7776
}
7877

7978
static inline void nft_bridge_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
80-
const struct nf_hook_ops *ops,
81-
struct sk_buff *skb,
82-
const struct net_device *in,
83-
const struct net_device *out)
79+
const struct nf_hook_ops *ops,
80+
struct sk_buff *skb,
81+
const struct nf_hook_state *state)
8482
{
8583
#if IS_ENABLED(CONFIG_IPV6)
8684
if (nft_bridge_ip6hdr_validate(skb) &&
87-
nft_set_pktinfo_ipv6(pkt, ops, skb, in, out) == 0)
85+
nft_set_pktinfo_ipv6(pkt, ops, skb, state) == 0)
8886
return;
8987
#endif
90-
nft_set_pktinfo(pkt, ops, skb, in, out);
88+
nft_set_pktinfo(pkt, ops, skb, state);
9189
}
9290

9391
static unsigned int
@@ -99,13 +97,13 @@ nft_do_chain_bridge(const struct nf_hook_ops *ops,
9997

10098
switch (eth_hdr(skb)->h_proto) {
10199
case htons(ETH_P_IP):
102-
nft_bridge_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
100+
nft_bridge_set_pktinfo_ipv4(&pkt, ops, skb, state);
103101
break;
104102
case htons(ETH_P_IPV6):
105-
nft_bridge_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out);
103+
nft_bridge_set_pktinfo_ipv6(&pkt, ops, skb, state);
106104
break;
107105
default:
108-
nft_set_pktinfo(&pkt, ops, skb, state->in, state->out);
106+
nft_set_pktinfo(&pkt, ops, skb, state);
109107
break;
110108
}
111109

‎net/ipv4/netfilter/nf_tables_arp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ nft_do_chain_arp(const struct nf_hook_ops *ops,
2121
{
2222
struct nft_pktinfo pkt;
2323

24-
nft_set_pktinfo(&pkt, ops, skb, state->in, state->out);
24+
nft_set_pktinfo(&pkt, ops, skb, state);
2525

2626
return nft_do_chain(&pkt, ops);
2727
}

‎net/ipv4/netfilter/nf_tables_ipv4.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static unsigned int nft_do_chain_ipv4(const struct nf_hook_ops *ops,
2424
{
2525
struct nft_pktinfo pkt;
2626

27-
nft_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
27+
nft_set_pktinfo_ipv4(&pkt, ops, skb, state);
2828

2929
return nft_do_chain(&pkt, ops);
3030
}

‎net/ipv4/netfilter/nft_chain_nat_ipv4.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static unsigned int nft_nat_do_chain(const struct nf_hook_ops *ops,
3333
{
3434
struct nft_pktinfo pkt;
3535

36-
nft_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
36+
nft_set_pktinfo_ipv4(&pkt, ops, skb, state);
3737

3838
return nft_do_chain(&pkt, ops);
3939
}

‎net/ipv4/netfilter/nft_chain_route_ipv4.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
3737
ip_hdrlen(skb) < sizeof(struct iphdr))
3838
return NF_ACCEPT;
3939

40-
nft_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
40+
nft_set_pktinfo_ipv4(&pkt, ops, skb, state);
4141

4242
mark = skb->mark;
4343
iph = ip_hdr(skb);

‎net/ipv6/netfilter/nf_tables_ipv6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static unsigned int nft_do_chain_ipv6(const struct nf_hook_ops *ops,
2323
struct nft_pktinfo pkt;
2424

2525
/* malformed packet, drop it */
26-
if (nft_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out) < 0)
26+
if (nft_set_pktinfo_ipv6(&pkt, ops, skb, state) < 0)
2727
return NF_DROP;
2828

2929
return nft_do_chain(&pkt, ops);

‎net/ipv6/netfilter/nft_chain_nat_ipv6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static unsigned int nft_nat_do_chain(const struct nf_hook_ops *ops,
3131
{
3232
struct nft_pktinfo pkt;
3333

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

3636
return nft_do_chain(&pkt, ops);
3737
}

0 commit comments

Comments
 (0)