nf_nat_used_tuple(9)
π nf_nat_used_tuple(9) π
okay so bestie, welcome to the kernel API manual β¨ this one's a function from the Kernel API Manual, and it's lowkey one of those tiny functions that does SO much heavy lifting. let's get into it π«Ά
πΈ NAME πΈ
nf_nat_used_tuple β literally checks if your proposed nat tuple is gonna clash with an existing entry π
β¨ SYNOPSIS β¨
int nf_nat_used_tuple (const struct nf_conntrack_tuple *tuple , const struct nf_conn *ignored_conntrack );
that's it. two args, one int back. she's simple, she's iconic π
π ARGUMENTS π
tupleβ the proposed NAT binding, aka the thing we're tryna see if it's valid. main character of the question ngl πignored_conntrackβ our own (unconfirmed) conntrack entry. yeah she's tagged "ignored" but she still matters, don't do her dirty π
π¦ DESCRIPTION π¦
so here's the vibe check: a conntrack entry can only be inserted into the connection tracking table if there's no existing entry with an identical tuple in either direction. either direction, bestie. both ways. no cap π¨
that's the whole thing. that's the function. she checks, you decide. periodt.
π₯ EXAMPLE π₯
here's the scenario, and honestly it's giving "this is why we can't have nice things" π
INITIATOR -> NAT/PAT -> RESPONDER
so INITIATOR passes through NAT/PAT (that's "us", hi π) and SNAT is done (saddr rewrite). then, later, NAT/PAT itself also connects to RESPONDER.
and this will not work if the SNAT done earlier has the same IP:PORT source pair π
the conntrack table has:
ORIGINAL: $IP_INITIATOR:$SPORT -> $IP_RESPONDER:$DPORT
REPLY: $IP_RESPONDER:$DPORT -> $IP_NAT:$SPORT
and the new locally originating connection wants:
ORIGINAL: $IP_NAT:$SPORT -> $IP_RESPONDER:$DPORT
REPLY: $IP_RESPONDER:$DPORT -> $IP_NAT:$SPORT
β¦ which would mean incoming packets can't be distinguished between the existing entry and the newly added one, because they'd have an identical IP_CT_DIR_REPLY tuple ππ identical!! the packets would be out here matching two entries and nobody would know which is which. chaos. mess. disaster. prevent it. π«Ά
β RETURN β
returns true if the proposed NAT mapping collides with an existing entry. that's your red flag bestie, listen to it π©
π SEE ALSO π
- Kernel file
./net/netfilter/nf_nat_core.c nf_nat_used_tuple_new(9)
and that's the tea! π this page came from ./net/netfilter, dated October 2026 β so go forth and check those tuples, queen. you got this πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms