Skip to content

Commit

Permalink
netfilter: conntrack: tag conntracks picked up in local out hook
Browse files Browse the repository at this point in the history
This allows to identify flows that originate from local machine
in a followup patch.

It would be possible to make this a ->status bit instead.
For now I did not do that yet because I don't have a use-case for
exposing this info to userspace.

If one comes up the toggle can be replaced with a status bit.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Dec 23, 2021
1 parent 023223d commit 4a6fbdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/netfilter/nf_conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ struct nf_conn {
unsigned long status;

u16 cpu;
u16 local_origin:1;
possible_net_t ct_net;

#if IS_ENABLED(CONFIG_NF_NAT)
Expand Down
3 changes: 3 additions & 0 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,9 @@ resolve_normal_ct(struct nf_conn *tmpl,
return 0;
if (IS_ERR(h))
return PTR_ERR(h);

ct = nf_ct_tuplehash_to_ctrack(h);
ct->local_origin = state->hook == NF_INET_LOCAL_OUT;
}
ct = nf_ct_tuplehash_to_ctrack(h);

Expand Down

0 comments on commit 4a6fbdd

Please sign in to comment.