netfilter: core: move ip_ct_attach indirection to struct nf_ct_hook

ip_ct_attach predates struct nf_ct_hook, we can place it there and
remove the exported symbol.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Florian Westphal 2022-01-07 05:03:23 +01:00 committed by Pablo Neira Ayuso
parent 7197743776
commit 3fce16493d
3 changed files with 10 additions and 15 deletions

View File

@ -440,7 +440,6 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
#if IS_ENABLED(CONFIG_NF_CONNTRACK) #if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <linux/netfilter/nf_conntrack_zones_common.h> #include <linux/netfilter/nf_conntrack_zones_common.h>
extern void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *) __rcu;
void nf_ct_attach(struct sk_buff *, const struct sk_buff *); void nf_ct_attach(struct sk_buff *, const struct sk_buff *);
struct nf_conntrack_tuple; struct nf_conntrack_tuple;
bool nf_ct_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple, bool nf_ct_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple,
@ -463,6 +462,7 @@ struct nf_ct_hook {
void (*destroy)(struct nf_conntrack *); void (*destroy)(struct nf_conntrack *);
bool (*get_tuple_skb)(struct nf_conntrack_tuple *, bool (*get_tuple_skb)(struct nf_conntrack_tuple *,
const struct sk_buff *); const struct sk_buff *);
void (*attach)(struct sk_buff *nskb, const struct sk_buff *skb);
}; };
extern struct nf_ct_hook __rcu *nf_ct_hook; extern struct nf_ct_hook __rcu *nf_ct_hook;

View File

@ -673,25 +673,22 @@ struct nf_ct_hook __rcu *nf_ct_hook __read_mostly;
EXPORT_SYMBOL_GPL(nf_ct_hook); EXPORT_SYMBOL_GPL(nf_ct_hook);
#if IS_ENABLED(CONFIG_NF_CONNTRACK) #if IS_ENABLED(CONFIG_NF_CONNTRACK)
/* This does not belong here, but locally generated errors need it if connection
tracking in use: without this, connection may not be in hash table, and hence
manufactured ICMP or RST packets will not be associated with it. */
void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *)
__rcu __read_mostly;
EXPORT_SYMBOL(ip_ct_attach);
struct nf_nat_hook __rcu *nf_nat_hook __read_mostly; struct nf_nat_hook __rcu *nf_nat_hook __read_mostly;
EXPORT_SYMBOL_GPL(nf_nat_hook); EXPORT_SYMBOL_GPL(nf_nat_hook);
/* This does not belong here, but locally generated errors need it if connection
* tracking in use: without this, connection may not be in hash table, and hence
* manufactured ICMP or RST packets will not be associated with it.
*/
void nf_ct_attach(struct sk_buff *new, const struct sk_buff *skb) void nf_ct_attach(struct sk_buff *new, const struct sk_buff *skb)
{ {
void (*attach)(struct sk_buff *, const struct sk_buff *); const struct nf_ct_hook *ct_hook;
if (skb->_nfct) { if (skb->_nfct) {
rcu_read_lock(); rcu_read_lock();
attach = rcu_dereference(ip_ct_attach); ct_hook = rcu_dereference(nf_ct_hook);
if (attach) if (ct_hook)
attach(new, skb); ct_hook->attach(new, skb);
rcu_read_unlock(); rcu_read_unlock();
} }
} }

View File

@ -2455,7 +2455,6 @@ static int kill_all(struct nf_conn *i, void *data)
void nf_conntrack_cleanup_start(void) void nf_conntrack_cleanup_start(void)
{ {
conntrack_gc_work.exiting = true; conntrack_gc_work.exiting = true;
RCU_INIT_POINTER(ip_ct_attach, NULL);
} }
void nf_conntrack_cleanup_end(void) void nf_conntrack_cleanup_end(void)
@ -2774,12 +2773,11 @@ static struct nf_ct_hook nf_conntrack_hook = {
.update = nf_conntrack_update, .update = nf_conntrack_update,
.destroy = destroy_conntrack, .destroy = destroy_conntrack,
.get_tuple_skb = nf_conntrack_get_tuple_skb, .get_tuple_skb = nf_conntrack_get_tuple_skb,
.attach = nf_conntrack_attach,
}; };
void nf_conntrack_init_end(void) void nf_conntrack_init_end(void)
{ {
/* For use by REJECT target */
RCU_INIT_POINTER(ip_ct_attach, nf_conntrack_attach);
RCU_INIT_POINTER(nf_ct_hook, &nf_conntrack_hook); RCU_INIT_POINTER(nf_ct_hook, &nf_conntrack_hook);
} }