diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-12-08 20:26:30 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-12-09 19:12:20 +0100 |
commit | 0451b82aaaf0b0bf67e7dcf38ffa4f7cef5e3066 (patch) | |
tree | 949ecaabd5ec69ef9bb465e08ba734cf28d46947 /include/expression.h | |
parent | 82e0a693110be85b6ebc023b4dbf5e798ac60bdc (diff) |
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 <pablo@netfilter.org>
Diffstat (limited to 'include/expression.h')
-rw-r--r-- | include/expression.h | 16 |
1 files changed, 14 insertions, 2 deletions
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); } /** |