]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
meta: iif/oifname should be host byte order
authorFlorian Westphal <fw@strlen.de>
Fri, 20 Sep 2013 14:01:33 +0000 (16:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Sep 2013 18:27:04 +0000 (20:27 +0200)
src/nft add rule filter output meta oifname eth0

doesn't work on x86.  Problem is that nft declares these as
BYTEORDER_INVALID, but when converting the string mpz_import_data
treats INVALID like BIG_ENDIAN.

[ cmp eq reg 1 0x00000000 0x00000000 0x65000000 0x00306874 ]

as kernel nft_cmp_eval basically boils down to

memcmp(reg, skb->dev->name, sizeof(reg) comparision fails.

with patch:
[ cmp eq reg 1 0x30687465 0x00000000 0x00000000 0x00000000 ]

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/ct.c
src/datatype.c
src/meta.c

index 1baefed877ad56627c4578a2ac895c22b7226e59..e5ca593ccfc72dbce9ed3d35ec8538220d175f1d 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -110,7 +110,7 @@ static const struct ct_template ct_templates[] = {
                                              BYTEORDER_HOST_ENDIAN,
                                              4 * BITS_PER_BYTE),
        [NFT_CT_HELPER]         = CT_TEMPLATE("helper",     &string_type,
-                                             BYTEORDER_INVALID, 0),
+                                             BYTEORDER_HOST_ENDIAN, 0),
        [NFT_CT_L3PROTOCOL]     = CT_TEMPLATE("l3proto",    &invalid_type,
                                              BYTEORDER_INVALID,
                                              BITS_PER_BYTE),
index c4fc131ded5ed93c720687f2335d7c61a3e57bdc..4c5a70f2e9161ebadbc7d794b57ccbfe924e3b07 100644 (file)
@@ -258,7 +258,7 @@ static void string_type_print(const struct expr *expr)
        unsigned int len = div_round_up(expr->len, BITS_PER_BYTE);
        char data[len];
 
-       mpz_export_data(data, expr->value, BYTEORDER_BIG_ENDIAN, len);
+       mpz_export_data(data, expr->value, BYTEORDER_HOST_ENDIAN, len);
        printf("\"%s\"", data);
 }
 
@@ -266,7 +266,7 @@ static struct error_record *string_type_parse(const struct expr *sym,
                                              struct expr **res)
 {
        *res = constant_expr_alloc(&sym->location, &string_type,
-                                  BYTEORDER_INVALID,
+                                  BYTEORDER_HOST_ENDIAN,
                                   (strlen(sym->identifier) + 1) * BITS_PER_BYTE,
                                   sym->identifier);
        return NULL;
index 17322afd25f814c2b83a7c764acd15ca29b61468..9606a44ba4bd689a23c3524ad92b2f0e15e5ede7 100644 (file)
@@ -295,14 +295,14 @@ static const struct meta_template meta_templates[] = {
                                                4 * 8, BYTEORDER_HOST_ENDIAN),
        [NFT_META_IIFNAME]      = META_TEMPLATE("iifname",   &string_type,
                                                IFNAMSIZ * BITS_PER_BYTE,
-                                               BYTEORDER_INVALID),
+                                               BYTEORDER_HOST_ENDIAN),
        [NFT_META_IIFTYPE]      = META_TEMPLATE("iiftype",   &arphrd_type,
                                                2 * 8, BYTEORDER_HOST_ENDIAN),
        [NFT_META_OIF]          = META_TEMPLATE("oif",       &ifindex_type,
                                                4 * 8, BYTEORDER_HOST_ENDIAN),
        [NFT_META_OIFNAME]      = META_TEMPLATE("oifname",   &string_type,
                                                IFNAMSIZ * BITS_PER_BYTE,
-                                               BYTEORDER_INVALID),
+                                               BYTEORDER_HOST_ENDIAN),
        [NFT_META_OIFTYPE]      = META_TEMPLATE("oiftype",   &arphrd_type,
                                                2 * 8, BYTEORDER_HOST_ENDIAN),
        [NFT_META_SKUID]        = META_TEMPLATE("skuid",     &uid_type,