diff options
author | Phil Sutter <phil@nwl.cc> | 2019-09-20 11:19:15 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2019-09-23 22:13:20 +0200 |
commit | 7c64eaf4b1b97ff69a7d9c5c13d4e9eff97d2cd1 (patch) | |
tree | 5e2274d40d1ec704fdbddc54fcb7235cf87ae519 /iptables/nft-shared.h | |
parent | 5a0294901db1df0d8b1f22c2f64e3b967562ad2e (diff) |
nft: Fix add_bitwise_u16() on Big Endian
Type used for 'mask' and 'xor' parameters was wrong, 'int' is four bytes
on 32 or 64 bit architectures. After casting a uint16_t to int, on Big
Endian the first two bytes of data are (the leading) zero which libnftnl
then copies instead of the actual value.
This problem was noticed when using '--fragment' option:
| # iptables-nft -A FORWARD --fragment -j ACCEPT
| # nft list ruleset | grep frag-off
| ip frag-off & 0 != 0 counter packets 0 bytes 0 accept
With this fix in place, the resulting nft rule is correct:
| ip frag-off & 8191 != 0 counter packets 0 bytes 0 accept
Fixes: 2f1fbab671576 ("iptables: nft: add -f support")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/nft-shared.h')
-rw-r--r-- | iptables/nft-shared.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h index de889ead..9d629134 100644 --- a/iptables/nft-shared.h +++ b/iptables/nft-shared.h @@ -111,7 +111,7 @@ struct nft_family_ops { void add_meta(struct nftnl_rule *r, uint32_t key); void add_payload(struct nftnl_rule *r, int offset, int len, uint32_t base); void add_bitwise(struct nftnl_rule *r, uint8_t *mask, size_t len); -void add_bitwise_u16(struct nftnl_rule *r, int mask, int xor); +void add_bitwise_u16(struct nftnl_rule *r, uint16_t mask, uint16_t xor); void add_cmp_ptr(struct nftnl_rule *r, uint32_t op, void *data, size_t len); void add_cmp_u8(struct nftnl_rule *r, uint8_t val, uint32_t op); void add_cmp_u16(struct nftnl_rule *r, uint16_t val, uint32_t op); |