]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
ct: display bit number instead of raw value
authorFlorian Westphal <fw@strlen.de>
Sun, 21 Aug 2016 22:27:48 +0000 (00:27 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 22 Aug 2016 16:36:43 +0000 (18:36 +0200)
... and add test cases for ct label.
Currently this dumped 'label 0x2', now 'label 1' would be shown.

This makes add/list behave the same.

Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/ct.c
tests/py/any/ct.t
tests/py/any/ct.t.payload

index 018ca0b94b5ebcb5ae8c84b99c50f74c2e783a28..a68293896ed6dba41fee416f085ad06804910546 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -113,7 +113,7 @@ static void ct_label_type_print(const struct expr *expr)
                return;
        }
        /* can happen when connlabel.conf is altered after rules were added */
-       gmp_printf("0x%Zx", expr->value);
+       printf("%ld\n", (long)mpz_scan1(expr->value, 0));
 }
 
 static struct error_record *ct_label_type_parse(const struct expr *sym,
index 4d13213d07fee6ea57925e23434d5b8a76324b61..7fd4f2cbdc9a1eed5661ca1a8bdc1d44e7fccddb 100644 (file)
@@ -92,3 +92,7 @@ ct saddr 1.2.3.4;fail
 ct original mark 42;fail
 # swapped key and direction
 ct mark original;fail
+
+ct label 127;ok
+ct label set 127;ok
+ct label 128;fail
index e64ce2ff8429d3ffeccc703be4700cf3ea69be9f..97f292ea235904054325dcd4d8c1b58e65b05e91 100644 (file)
@@ -332,3 +332,14 @@ ip test-ip4 output
   [ bitwise reg 1 = (reg=1 & 0x00000020 ) ^ 0x00000000 ]
   [ cmp neq reg 1 0x00000000 ]
 
+# ct label 127
+ip test-ip4 output
+  [ ct load label => reg 1 ]
+  [ bitwise reg 1 = (reg=1 & 0x00000000 0x00000000 0x00000000 0x80000000 ) ^ 0x00000000 0x00000000 0x00000000 0x00000000 ]
+  [ cmp neq reg 1 0x00000000 0x00000000 0x00000000 0x00000000 ]
+
+# ct label set 127
+ip test-ip4 output
+  [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x80000000 ]
+  [ ct set label with reg 1 ]
+