path: root/src/ct.c
diff options
authorFlorian Westphal <>2017-02-28 00:59:02 +0100
committerPablo Neira Ayuso <>2017-02-28 00:59:02 +0100
commit450653a4f0822f170cb412013aa4cf9d6ef6ce3a (patch)
tree85b29132b134e68616efd7e5692ac872ba693fda /src/ct.c
parente6ca6739cc136d05ec3d13dbf82cdee247bee1d9 (diff)
src: add conntrack zone support
This enables zone get/set support. As the zone can be optionally tied to a direction as well we need a new token for this (unless we turn reply/original into tokens in which case we could handle zone via STRING). There was some discussion on how zone set support should be handled, especially 'zone set 1'. There are several issues to consider: 1. its not possible to change a zone 'later on', any given conntrack flow has exactly one zone for its entire lifetime. 2. to create conntracks in a given zone, the zone therefore has to be assigned *before* the packet gets picked up by conntrack (so that lookup finds the correct existing flow or the flow is created with the desired zone id). In iptables, this is enforced because zones are assigned with CT target and this is restricted to the 'raw' table in iptables, which runs after defragmentation but before connection tracking. 3. Thus, in nftables the 'ct zone set' rule needs to hook before conntrack too, e.g. via table raw { chain pre { type filter hook prerouting priority -300; iif eth3 ct zone set 23 } chain out { type filter hook output priority -300; oif eth3 ct zone set 23 } } ... but this is not enforced. There were two alternatives to better document this. One was to use an explicit 'template' keyword: nft ... template zone set 23 ... but 'connection tracking templates' are a kernel detail that users should not and need not know about. The other one was to use the meta keyword instead since we're (from a practical point of view) assigning the zone to the packet, not the conntrack: nft ... meta zone set 23 However, next patch also supports 'directional' zones, and nft ... meta original zone 23 makes no sense because 'direction' refers to a direction as understood by the connection tracker. Signed-off-by: Florian Westphal <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'src/ct.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/src/ct.c b/src/ct.c
index 31c7a4b1..99f450a7 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -234,6 +234,8 @@ static const struct ct_template ct_templates[] = {
[NFT_CT_AVGPKT] = CT_TEMPLATE("avgpkt", &integer_type,
+ [NFT_CT_ZONE] = CT_TEMPLATE("zone", &integer_type,
static void ct_expr_print(const struct expr *expr)