@@ -1230,7 +1230,7 @@ static int _conntrack3_mt_xlate(struct xt_xlate *xl,
if ((sinfo->state_mask & XT_CONNTRACK_STATE_SNAT) ||
(sinfo->state_mask & XT_CONNTRACK_STATE_DNAT)) {
xt_xlate_add(xl, "%sct status %s%s", space,
- sinfo->invert_flags & XT_CONNTRACK_STATUS ? "!=" : "",
+ sinfo->invert_flags & XT_CONNTRACK_STATE ? "!= " : "",
sinfo->state_mask & XT_CONNTRACK_STATE_SNAT ? "snat" : "dnat");
space = " ";
} else {
@@ -55,6 +55,12 @@ nft 'add rule ip filter INPUT ct direction original ct original protocol 6 ct st
iptables-translate -t filter -A INPUT -m conntrack --ctstate SNAT -j ACCEPT
nft 'add rule ip filter INPUT ct status snat counter accept'
+iptables-translate -t filter -A INPUT -m conntrack ! --ctstate SNAT -j ACCEPT
+nft 'add rule ip filter INPUT ct status != snat counter accept'
+
iptables-translate -t filter -A INPUT -m conntrack --ctstate DNAT -j ACCEPT
nft 'add rule ip filter INPUT ct status dnat counter accept'
+iptables-translate -t filter -A INPUT -m conntrack ! --ctstate DNAT -j ACCEPT
+nft 'add rule ip filter INPUT ct status != dnat counter accept'
+
Special casing for SNAT/DNAT conntrack states was broken with inverted matches: - Wrong bit in invert_flags checked (typo?) - Missing space after operator (cosmetics!) Reported-by: Balazs Gulacsi <m2gulbal@gmail.com> Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1826 Signed-off-by: Phil Sutter <phil@nwl.cc> --- extensions/libxt_conntrack.c | 2 +- extensions/libxt_conntrack.txlate | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)