summaryrefslogtreecommitdiffstats
path: root/src/exthdr.c
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <alvaroneay@gmail.com>2014-09-17 09:20:28 +0200
committerPatrick McHardy <kaber@trash.net>2014-09-17 09:20:28 +0200
commitd4e06f5bb9511c6a3a00191f74a99ba0c58093a6 (patch)
tree742db55dd46f7c809b20b00fa02095a1ce078163 /src/exthdr.c
parent52f169d3938492e42112e0412e17780db7949227 (diff)
src: add specific byteorder to the struct proto_hdr_template
If we try to add a rule like: nft add rule filter input udp length {55-9999} nftable shows: BUG: invalid byte order conversion 0 => 2 nft: src/evaluate.c:153: byteorder_conversion_op: Assertion `0' failed. Some of the existing payload fields rely on BYTEORDER_INVALID. Therefore, if we try to convert it in evaluation step, we hit this bug. This patch allows to add a specific byteorder to the struct proto_hdr_template. If we create a expression with a invalid byteorder, we will use the byteorder added to the proto_hdr_template structure. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/exthdr.c')
-rw-r--r--src/exthdr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/exthdr.c b/src/exthdr.c
index a619ecce..9ed0b6ac 100644
--- a/src/exthdr.c
+++ b/src/exthdr.c
@@ -48,7 +48,7 @@ static const struct expr_ops exthdr_expr_ops = {
};
static const struct proto_hdr_template exthdr_unknown_template =
- PROTO_HDR_TEMPLATE("unknown", &invalid_type, 0, 0);
+ PROTO_HDR_TEMPLATE("unknown", &invalid_type, BYTEORDER_INVALID, 0, 0);
struct expr *exthdr_expr_alloc(const struct location *loc,
const struct exthdr_desc *desc,
@@ -102,6 +102,7 @@ void exthdr_init_raw(struct expr *expr, uint8_t type,
#define HDR_TEMPLATE(__name, __dtype, __type, __member) \
PROTO_HDR_TEMPLATE(__name, __dtype, \
+ BYTEORDER_BIG_ENDIAN, \
offsetof(__type, __member) * 8, \
field_sizeof(__type, __member) * 8)
@@ -179,10 +180,13 @@ const struct exthdr_desc exthdr_frag = {
[FRAGHDR_NEXTHDR] = FRAG_FIELD("nexthdr", ip6f_nxt, &inet_protocol_type),
[FRAGHDR_RESERVED] = FRAG_FIELD("reserved", ip6f_reserved, &integer_type),
[FRAGHDR_FRAG_OFF] = PROTO_HDR_TEMPLATE("frag-off", &integer_type,
+ BYTEORDER_BIG_ENDIAN,
16, 13),
[FRAGHDR_RESERVED2] = PROTO_HDR_TEMPLATE("reserved2", &integer_type,
+ BYTEORDER_BIG_ENDIAN,
29, 2),
[FRAGHDR_MFRAGS] = PROTO_HDR_TEMPLATE("more-fragments", &integer_type,
+ BYTEORDER_BIG_ENDIAN,
31, 1),
[FRAGHDR_ID] = FRAG_FIELD("id", ip6f_ident, &integer_type),
},