Skip to content

Commit 06198b3

Browse files
ebiedermummakynes
authored andcommitted
netfilter: Pass priv instead of nf_hook_ops to netfilter hooks
Only pass the void *priv parameter out of the nf_hook_ops. That is all any of the functions are interested now, and by limiting what is passed it becomes simpler to change implementation details. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 176971b commit 06198b3

43 files changed

Lines changed: 156 additions & 157 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/linux/netfilter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
8080
p->okfn = okfn;
8181
}
8282

83-
typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
83+
typedef unsigned int nf_hookfn(void *priv,
8484
struct sk_buff *skb,
8585
const struct nf_hook_state *state);
8686

‎include/net/netfilter/br_netfilter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void br_netfilter_enable(void);
4646

4747
#if IS_ENABLED(CONFIG_IPV6)
4848
int br_validate_ipv6(struct sk_buff *skb);
49-
unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
49+
unsigned int br_nf_pre_routing_ipv6(void *priv,
5050
struct sk_buff *skb,
5151
const struct nf_hook_state *state);
5252
#else

‎include/net/netfilter/nf_nat_l3proto.h‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,31 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
4343
enum ip_conntrack_info ctinfo,
4444
unsigned int hooknum);
4545

46-
unsigned int nf_nat_ipv4_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
46+
unsigned int nf_nat_ipv4_in(void *priv, struct sk_buff *skb,
4747
const struct nf_hook_state *state,
48-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
48+
unsigned int (*do_chain)(void *priv,
4949
struct sk_buff *skb,
5050
const struct nf_hook_state *state,
5151
struct nf_conn *ct));
5252

53-
unsigned int nf_nat_ipv4_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
53+
unsigned int nf_nat_ipv4_out(void *priv, struct sk_buff *skb,
5454
const struct nf_hook_state *state,
55-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
55+
unsigned int (*do_chain)(void *priv,
5656
struct sk_buff *skb,
5757
const struct nf_hook_state *state,
5858
struct nf_conn *ct));
5959

60-
unsigned int nf_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
60+
unsigned int nf_nat_ipv4_local_fn(void *priv,
6161
struct sk_buff *skb,
6262
const struct nf_hook_state *state,
63-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
63+
unsigned int (*do_chain)(void *priv,
6464
struct sk_buff *skb,
6565
const struct nf_hook_state *state,
6666
struct nf_conn *ct));
6767

68-
unsigned int nf_nat_ipv4_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
68+
unsigned int nf_nat_ipv4_fn(void *priv, struct sk_buff *skb,
6969
const struct nf_hook_state *state,
70-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
70+
unsigned int (*do_chain)(void *priv,
7171
struct sk_buff *skb,
7272
const struct nf_hook_state *state,
7373
struct nf_conn *ct));
@@ -76,31 +76,31 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
7676
enum ip_conntrack_info ctinfo,
7777
unsigned int hooknum, unsigned int hdrlen);
7878

79-
unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
79+
unsigned int nf_nat_ipv6_in(void *priv, struct sk_buff *skb,
8080
const struct nf_hook_state *state,
81-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
81+
unsigned int (*do_chain)(void *priv,
8282
struct sk_buff *skb,
8383
const struct nf_hook_state *state,
8484
struct nf_conn *ct));
8585

86-
unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
86+
unsigned int nf_nat_ipv6_out(void *priv, struct sk_buff *skb,
8787
const struct nf_hook_state *state,
88-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
88+
unsigned int (*do_chain)(void *priv,
8989
struct sk_buff *skb,
9090
const struct nf_hook_state *state,
9191
struct nf_conn *ct));
9292

93-
unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
93+
unsigned int nf_nat_ipv6_local_fn(void *priv,
9494
struct sk_buff *skb,
9595
const struct nf_hook_state *state,
96-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
96+
unsigned int (*do_chain)(void *priv,
9797
struct sk_buff *skb,
9898
const struct nf_hook_state *state,
9999
struct nf_conn *ct));
100100

101-
unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
101+
unsigned int nf_nat_ipv6_fn(void *priv, struct sk_buff *skb,
102102
const struct nf_hook_state *state,
103-
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
103+
unsigned int (*do_chain)(void *priv,
104104
struct sk_buff *skb,
105105
const struct nf_hook_state *state,
106106
struct nf_conn *ct));

‎include/net/netfilter/nf_tables.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ int nft_register_basechain(struct nft_base_chain *basechain,
816816
void nft_unregister_basechain(struct nft_base_chain *basechain,
817817
unsigned int hook_nops);
818818

819-
unsigned int nft_do_chain(struct nft_pktinfo *pkt,
820-
const struct nf_hook_ops *ops);
819+
unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv);
821820

822821
/**
823822
* struct nft_table - nf_tables table

‎net/bridge/br_netfilter_hooks.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ struct net_device *setup_pre_routing(struct sk_buff *skb)
464464
* receiving device) to make netfilter happy, the REDIRECT
465465
* target in particular. Save the original destination IP
466466
* address to be able to detect DNAT afterwards. */
467-
static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
467+
static unsigned int br_nf_pre_routing(void *priv,
468468
struct sk_buff *skb,
469469
const struct nf_hook_state *state)
470470
{
@@ -486,7 +486,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
486486
return NF_ACCEPT;
487487

488488
nf_bridge_pull_encap_header_rcsum(skb);
489-
return br_nf_pre_routing_ipv6(ops, skb, state);
489+
return br_nf_pre_routing_ipv6(priv, skb, state);
490490
}
491491

492492
if (!brnf_call_iptables && !br->nf_call_iptables)
@@ -526,7 +526,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
526526
* took place when the packet entered the bridge), but we
527527
* register an IPv4 PRE_ROUTING 'sabotage' hook that will
528528
* prevent this from happening. */
529-
static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
529+
static unsigned int br_nf_local_in(void *priv,
530530
struct sk_buff *skb,
531531
const struct nf_hook_state *state)
532532
{
@@ -570,7 +570,7 @@ static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff
570570
* but we are still able to filter on the 'real' indev/outdev
571571
* because of the physdev module. For ARP, indev and outdev are the
572572
* bridge ports. */
573-
static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
573+
static unsigned int br_nf_forward_ip(void *priv,
574574
struct sk_buff *skb,
575575
const struct nf_hook_state *state)
576576
{
@@ -633,7 +633,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
633633
return NF_STOLEN;
634634
}
635635

636-
static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
636+
static unsigned int br_nf_forward_arp(void *priv,
637637
struct sk_buff *skb,
638638
const struct nf_hook_state *state)
639639
{
@@ -801,7 +801,7 @@ static int br_nf_dev_queue_xmit(struct net *net, struct sock *sk, struct sk_buff
801801
}
802802

803803
/* PF_BRIDGE/POST_ROUTING ********************************************/
804-
static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
804+
static unsigned int br_nf_post_routing(void *priv,
805805
struct sk_buff *skb,
806806
const struct nf_hook_state *state)
807807
{
@@ -850,7 +850,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
850850
/* IP/SABOTAGE *****************************************************/
851851
/* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING
852852
* for the second time. */
853-
static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops,
853+
static unsigned int ip_sabotage_in(void *priv,
854854
struct sk_buff *skb,
855855
const struct nf_hook_state *state)
856856
{

‎net/bridge/br_netfilter_ipv6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struc
218218
/* Replicate the checks that IPv6 does on packet reception and pass the packet
219219
* to ip6tables.
220220
*/
221-
unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
221+
unsigned int br_nf_pre_routing_ipv6(void *priv,
222222
struct sk_buff *skb,
223223
const struct nf_hook_state *state)
224224
{

‎net/bridge/netfilter/ebtable_filter.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ static const struct ebt_table frame_filter = {
5757
};
5858

5959
static unsigned int
60-
ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
60+
ebt_in_hook(void *priv, struct sk_buff *skb,
6161
const struct nf_hook_state *state)
6262
{
6363
return ebt_do_table(skb, state, state->net->xt.frame_filter);
6464
}
6565

6666
static unsigned int
67-
ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
67+
ebt_out_hook(void *priv, struct sk_buff *skb,
6868
const struct nf_hook_state *state)
6969
{
7070
return ebt_do_table(skb, state, state->net->xt.frame_filter);

‎net/bridge/netfilter/ebtable_nat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ static struct ebt_table frame_nat = {
5757
};
5858

5959
static unsigned int
60-
ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
60+
ebt_nat_in(void *priv, struct sk_buff *skb,
6161
const struct nf_hook_state *state)
6262
{
6363
return ebt_do_table(skb, state, state->net->xt.frame_nat);
6464
}
6565

6666
static unsigned int
67-
ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
67+
ebt_nat_out(void *priv, struct sk_buff *skb,
6868
const struct nf_hook_state *state)
6969
{
7070
return ebt_do_table(skb, state, state->net->xt.frame_nat);

‎net/bridge/netfilter/nf_tables_bridge.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static inline void nft_bridge_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
8787
}
8888

8989
static unsigned int
90-
nft_do_chain_bridge(const struct nf_hook_ops *ops,
90+
nft_do_chain_bridge(void *priv,
9191
struct sk_buff *skb,
9292
const struct nf_hook_state *state)
9393
{
@@ -105,7 +105,7 @@ nft_do_chain_bridge(const struct nf_hook_ops *ops,
105105
break;
106106
}
107107

108-
return nft_do_chain(&pkt, ops);
108+
return nft_do_chain(&pkt, priv);
109109
}
110110

111111
static struct nft_af_info nft_af_bridge __read_mostly = {

‎net/decnet/netfilter/dn_rtmsg.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void dnrmg_send_peer(struct sk_buff *skb)
8787
}
8888

8989

90-
static unsigned int dnrmg_hook(const struct nf_hook_ops *ops,
90+
static unsigned int dnrmg_hook(void *priv,
9191
struct sk_buff *skb,
9292
const struct nf_hook_state *state)
9393
{

0 commit comments

Comments
 (0)