From 0451b82aaaf0b0bf67e7dcf38ffa4f7cef5e3066 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 8 Dec 2014 20:26:30 +0100 Subject: src: generate set members using integer_type in the appropriate byteorder Rules with header fields that rely on the generic integer datatype from sets are not matching, eg. nft add rule filter input udp length { 9 } counter This set member is an integer represented in host byte order, which obviously doesn't match the header field (in network byte order). Since the integer datatype has no specific byteorder, we have to rely on the expression byteorder instead when configuring the context, before we evaluate the list of set members. Signed-off-by: Pablo Neira Ayuso --- include/expression.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include/expression.h') diff --git a/include/expression.h b/include/expression.h index 59fa5f3d..4b968796 100644 --- a/include/expression.h +++ b/include/expression.h @@ -96,19 +96,31 @@ enum symbol_types { * struct expr_ctx - type context for symbol parsing during evaluation * * @dtype: expected datatype + * @byteorder: expected byteorder * @len: expected len */ struct expr_ctx { const struct datatype *dtype; + enum byteorder byteorder; unsigned int len; }; +static inline void __expr_set_context(struct expr_ctx *ctx, + const struct datatype *dtype, + enum byteorder byteorder, + unsigned int len) +{ + ctx->dtype = dtype; + ctx->byteorder = byteorder; + ctx->len = len; +} + static inline void expr_set_context(struct expr_ctx *ctx, const struct datatype *dtype, unsigned int len) { - ctx->dtype = dtype; - ctx->len = len; + __expr_set_context(ctx, dtype, + dtype ? dtype->byteorder : BYTEORDER_INVALID, len); } /** -- cgit v1.2.3