diff options
author | Patrick McHardy <kaber@trash.net> | 2015-04-12 21:10:41 +0100 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2015-06-02 13:03:58 +0200 |
commit | 9c286f2d689bbc19889d2f3b69923ad68831b3e7 (patch) | |
tree | f75756901e6f53ca160c82f3af2efe91df554974 /include/netlink.h | |
parent | 59221eacafbae721c0e46b75c688f1cd0f251afc (diff) |
netlink_linearize: use NFT_REG32 values internally
Prepare netlink_linearize for 32 bit register usage:
Switch to use 16 data registers of 32 bit each. A helper function takes
care of mapping the registers to the NFT_REG32 values and, if the
register refers to the beginning of an 128 bit area, the old NFT_REG_1-4
values for compatibility.
New register reservation and release helper function take the size into
account and reserve the required amount of registers.
The reservation and release functions will so far still always allocate
128 bit. If no other expression in a rule uses a 32 bit register directly,
these will be mapped to the old register values, meaning everything
continues to work with old kernel versions.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/netlink.h')
-rw-r--r-- | include/netlink.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/netlink.h b/include/netlink.h index 9f24ea5e..9b42fdbd 100644 --- a/include/netlink.h +++ b/include/netlink.h @@ -53,6 +53,11 @@ struct nft_data_delinearize { int verdict; }; +static inline unsigned int netlink_register_space(unsigned int size) +{ + return div_round_up(size, NFT_REG32_SIZE * BITS_PER_BYTE); +} + extern void netlink_gen_data(const struct expr *expr, struct nft_data_linearize *data); extern void netlink_gen_raw_data(const mpz_t value, enum byteorder byteorder, |