Skip to content

Commit 90869f4

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: make nf_conntrack_id callable without a module dependency
While nf_conntrack_id() doesn't need any functionaliy from conntrack, it does reside in nf_conntrack_core.c -- callers add a module dependency on conntrack. Followup patch will need to compute the conntrack id from nf_tables_trace.c to include it in nf_trace messages emitted to userspace via netlink. I don't want to introduce a module dependency between nf_tables and conntrack for this. Since trace is slowpath, the added indirection is ok. One alternative is to move nf_conntrack_id to the netfilter/core.c, but I don't see a compelling reason so far. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent f37ad91 commit 90869f4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/linux/netfilter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ struct nf_ct_hook {
470470
void (*attach)(struct sk_buff *nskb, const struct sk_buff *skb);
471471
void (*set_closing)(struct nf_conntrack *nfct);
472472
int (*confirm)(struct sk_buff *skb);
473+
u32 (*get_id)(const struct nf_conntrack *nfct);
473474
};
474475
extern const struct nf_ct_hook __rcu *nf_ct_hook;
475476

net/netfilter/nf_conntrack_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ u32 nf_ct_get_id(const struct nf_conn *ct)
505505
}
506506
EXPORT_SYMBOL_GPL(nf_ct_get_id);
507507

508+
static u32 nf_conntrack_get_id(const struct nf_conntrack *nfct)
509+
{
510+
return nf_ct_get_id(nf_ct_to_nf_conn(nfct));
511+
}
512+
508513
static void
509514
clean_from_lists(struct nf_conn *ct)
510515
{
@@ -2710,6 +2715,7 @@ static const struct nf_ct_hook nf_conntrack_hook = {
27102715
.attach = nf_conntrack_attach,
27112716
.set_closing = nf_conntrack_set_closing,
27122717
.confirm = __nf_conntrack_confirm,
2718+
.get_id = nf_conntrack_get_id,
27132719
};
27142720

27152721
void nf_conntrack_init_end(void)

0 commit comments

Comments
 (0)