]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
payload: disable payload merge if offsets are not on byte boundary.
authorFlorian Westphal <fw@strlen.de>
Tue, 4 Aug 2015 10:29:50 +0000 (12:29 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 17 Sep 2015 22:05:05 +0000 (00:05 +0200)
... because it doesn't work, we attempt to merge it into wrong
place, we would have to merge the second value at a specific location.

F.e. vlan hdr 4094 gives us

0xfe0f

Merging in the CFI should yield 0xfe1f, but the constant merging
doesn't know how to achive that; at the moment 'vlan id 4094'
and 'vlan id 4094 vlan cfi 1' give same result -- 0xfe0f.

For now just turn off the optimization step unless everything is
byte divisible (the common case).

Signed-off-by: Florian Westphal <fw@strlen.de>
src/payload.c

index 62f1d56da68215af638cd2d2ace64952db0baba3..880b5d0d0b9708eded6c0cb9073366e8f5b5d15a 100644 (file)
@@ -357,6 +357,10 @@ raw:
  */
 bool payload_is_adjacent(const struct expr *e1, const struct expr *e2)
 {
+       if (e1->payload.offset % BITS_PER_BYTE || e1->len % BITS_PER_BYTE ||
+           e2->payload.offset % BITS_PER_BYTE || e2->len % BITS_PER_BYTE)
+               return false;
+
        if (e1->payload.base             == e2->payload.base &&
            e1->payload.offset + e1->len == e2->payload.offset)
                return true;