mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
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>
This commit is contained in:
committed by
Pablo Neira Ayuso
parent
176971b338
commit
06198b34a3
@@ -80,7 +80,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
|
||||
p->okfn = okfn;
|
||||
}
|
||||
|
||||
typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
|
||||
typedef unsigned int nf_hookfn(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void br_netfilter_enable(void);
|
||||
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
int br_validate_ipv6(struct sk_buff *skb);
|
||||
unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
|
||||
unsigned int br_nf_pre_routing_ipv6(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state);
|
||||
#else
|
||||
|
||||
@@ -43,31 +43,31 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
|
||||
enum ip_conntrack_info ctinfo,
|
||||
unsigned int hooknum);
|
||||
|
||||
unsigned int nf_nat_ipv4_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv4_in(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv4_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv4_out(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
|
||||
unsigned int nf_nat_ipv4_local_fn(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv4_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv4_fn(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
@@ -76,31 +76,31 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
|
||||
enum ip_conntrack_info ctinfo,
|
||||
unsigned int hooknum, unsigned int hdrlen);
|
||||
|
||||
unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv6_in(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv6_out(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
|
||||
unsigned int nf_nat_ipv6_local_fn(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
unsigned int nf_nat_ipv6_fn(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
|
||||
unsigned int (*do_chain)(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct));
|
||||
|
||||
@@ -816,8 +816,7 @@ int nft_register_basechain(struct nft_base_chain *basechain,
|
||||
void nft_unregister_basechain(struct nft_base_chain *basechain,
|
||||
unsigned int hook_nops);
|
||||
|
||||
unsigned int nft_do_chain(struct nft_pktinfo *pkt,
|
||||
const struct nf_hook_ops *ops);
|
||||
unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv);
|
||||
|
||||
/**
|
||||
* struct nft_table - nf_tables table
|
||||
|
||||
@@ -464,7 +464,7 @@ struct net_device *setup_pre_routing(struct sk_buff *skb)
|
||||
* receiving device) to make netfilter happy, the REDIRECT
|
||||
* target in particular. Save the original destination IP
|
||||
* address to be able to detect DNAT afterwards. */
|
||||
static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
|
||||
static unsigned int br_nf_pre_routing(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -486,7 +486,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
|
||||
return NF_ACCEPT;
|
||||
|
||||
nf_bridge_pull_encap_header_rcsum(skb);
|
||||
return br_nf_pre_routing_ipv6(ops, skb, state);
|
||||
return br_nf_pre_routing_ipv6(priv, skb, state);
|
||||
}
|
||||
|
||||
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,
|
||||
* took place when the packet entered the bridge), but we
|
||||
* register an IPv4 PRE_ROUTING 'sabotage' hook that will
|
||||
* prevent this from happening. */
|
||||
static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
|
||||
static unsigned int br_nf_local_in(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -570,7 +570,7 @@ static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff
|
||||
* but we are still able to filter on the 'real' indev/outdev
|
||||
* because of the physdev module. For ARP, indev and outdev are the
|
||||
* bridge ports. */
|
||||
static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
|
||||
static unsigned int br_nf_forward_ip(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -633,7 +633,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
|
||||
return NF_STOLEN;
|
||||
}
|
||||
|
||||
static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
|
||||
static unsigned int br_nf_forward_arp(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ static int br_nf_dev_queue_xmit(struct net *net, struct sock *sk, struct sk_buff
|
||||
}
|
||||
|
||||
/* PF_BRIDGE/POST_ROUTING ********************************************/
|
||||
static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
|
||||
static unsigned int br_nf_post_routing(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -850,7 +850,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
|
||||
/* IP/SABOTAGE *****************************************************/
|
||||
/* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING
|
||||
* for the second time. */
|
||||
static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops,
|
||||
static unsigned int ip_sabotage_in(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -218,7 +218,7 @@ static int br_nf_pre_routing_finish_ipv6(struct net *net, struct sock *sk, struc
|
||||
/* Replicate the checks that IPv6 does on packet reception and pass the packet
|
||||
* to ip6tables.
|
||||
*/
|
||||
unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
|
||||
unsigned int br_nf_pre_routing_ipv6(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -57,14 +57,14 @@ static const struct ebt_table frame_filter = {
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
ebt_in_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(skb, state, state->net->xt.frame_filter);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
ebt_out_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(skb, state, state->net->xt.frame_filter);
|
||||
|
||||
@@ -57,14 +57,14 @@ static struct ebt_table frame_nat = {
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
ebt_nat_in(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(skb, state, state->net->xt.frame_nat);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
ebt_nat_out(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return ebt_do_table(skb, state, state->net->xt.frame_nat);
|
||||
|
||||
@@ -87,7 +87,7 @@ static inline void nft_bridge_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
nft_do_chain_bridge(const struct nf_hook_ops *ops,
|
||||
nft_do_chain_bridge(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ nft_do_chain_bridge(const struct nf_hook_ops *ops,
|
||||
break;
|
||||
}
|
||||
|
||||
return nft_do_chain(&pkt, ops);
|
||||
return nft_do_chain(&pkt, priv);
|
||||
}
|
||||
|
||||
static struct nft_af_info nft_af_bridge __read_mostly = {
|
||||
|
||||
@@ -87,7 +87,7 @@ static void dnrmg_send_peer(struct sk_buff *skb)
|
||||
}
|
||||
|
||||
|
||||
static unsigned int dnrmg_hook(const struct nf_hook_ops *ops,
|
||||
static unsigned int dnrmg_hook(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ static const struct xt_table packet_filter = {
|
||||
|
||||
/* The work comes in here from netfilter.c */
|
||||
static unsigned int
|
||||
arptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
arptable_filter_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return arpt_do_table(skb, state, state->net->ipv4.arptable_filter);
|
||||
|
||||
@@ -507,7 +507,7 @@ static void arp_print(struct arp_payload *payload)
|
||||
#endif
|
||||
|
||||
static unsigned int
|
||||
arp_mangle(const struct nf_hook_ops *ops,
|
||||
arp_mangle(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -299,7 +299,7 @@ synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
|
||||
return XT_CONTINUE;
|
||||
}
|
||||
|
||||
static unsigned int ipv4_synproxy_hook(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_synproxy_hook(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *nhs)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ static const struct xt_table packet_filter = {
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
iptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
iptable_filter_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
if (state->hook == NF_INET_LOCAL_OUT &&
|
||||
|
||||
@@ -78,7 +78,7 @@ ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
|
||||
|
||||
/* The work comes in here from netfilter.c. */
|
||||
static unsigned int
|
||||
iptable_mangle_hook(const struct nf_hook_ops *ops,
|
||||
iptable_mangle_hook(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ static const struct xt_table nf_nat_ipv4_table = {
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
static unsigned int iptable_nat_do_chain(const struct nf_hook_ops *ops,
|
||||
static unsigned int iptable_nat_do_chain(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state,
|
||||
struct nf_conn *ct)
|
||||
@@ -36,32 +36,32 @@ static unsigned int iptable_nat_do_chain(const struct nf_hook_ops *ops,
|
||||
return ipt_do_table(skb, state, state->net->ipv4.nat_table);
|
||||
}
|
||||
|
||||
static unsigned int iptable_nat_ipv4_fn(const struct nf_hook_ops *ops,
|
||||
static unsigned int iptable_nat_ipv4_fn(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_nat_ipv4_fn(ops, skb, state, iptable_nat_do_chain);
|
||||
return nf_nat_ipv4_fn(priv, skb, state, iptable_nat_do_chain);
|
||||
}
|
||||
|
||||
static unsigned int iptable_nat_ipv4_in(const struct nf_hook_ops *ops,
|
||||
static unsigned int iptable_nat_ipv4_in(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_nat_ipv4_in(ops, skb, state, iptable_nat_do_chain);
|
||||
return nf_nat_ipv4_in(priv, skb, state, iptable_nat_do_chain);
|
||||
}
|
||||
|
||||
static unsigned int iptable_nat_ipv4_out(const struct nf_hook_ops *ops,
|
||||
static unsigned int iptable_nat_ipv4_out(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_nat_ipv4_out(ops, skb, state, iptable_nat_do_chain);
|
||||
return nf_nat_ipv4_out(priv, skb, state, iptable_nat_do_chain);
|
||||
}
|
||||
|
||||
static unsigned int iptable_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
|
||||
static unsigned int iptable_nat_ipv4_local_fn(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_nat_ipv4_local_fn(ops, skb, state, iptable_nat_do_chain);
|
||||
return nf_nat_ipv4_local_fn(priv, skb, state, iptable_nat_do_chain);
|
||||
}
|
||||
|
||||
static struct nf_hook_ops nf_nat_ipv4_ops[] __read_mostly = {
|
||||
|
||||
@@ -20,7 +20,7 @@ static const struct xt_table packet_raw = {
|
||||
|
||||
/* The work comes in here from netfilter.c. */
|
||||
static unsigned int
|
||||
iptable_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
iptable_raw_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
if (state->hook == NF_INET_LOCAL_OUT &&
|
||||
|
||||
@@ -37,7 +37,7 @@ static const struct xt_table security_table = {
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
iptable_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
|
||||
iptable_security_hook(void *priv, struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
if (state->hook == NF_INET_LOCAL_OUT &&
|
||||
|
||||
@@ -92,7 +92,7 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
static unsigned int ipv4_helper(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_helper(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ static unsigned int ipv4_helper(const struct nf_hook_ops *ops,
|
||||
ct, ctinfo);
|
||||
}
|
||||
|
||||
static unsigned int ipv4_confirm(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_confirm(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
@@ -143,14 +143,14 @@ out:
|
||||
return nf_conntrack_confirm(skb);
|
||||
}
|
||||
|
||||
static unsigned int ipv4_conntrack_in(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_conntrack_in(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
return nf_conntrack_in(state->net, PF_INET, state->hook, skb);
|
||||
}
|
||||
|
||||
static unsigned int ipv4_conntrack_local(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_conntrack_local(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
|
||||
return IP_DEFRAG_CONNTRACK_OUT + zone_id;
|
||||
}
|
||||
|
||||
static unsigned int ipv4_conntrack_defrag(const struct nf_hook_ops *ops,
|
||||
static unsigned int ipv4_conntrack_defrag(void *priv,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user