summaryrefslogtreecommitdiffstats
path: root/include/regs.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2022-05-01 17:40:01 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2022-05-04 11:58:01 +0200
commitb9e00458b9f357f6c9b301f95b276fd019da0692 (patch)
tree7bda5c1f1b684da25e864b42feb28d2f76a86a78 /include/regs.h
parente2514c0eff4da7e8e0aabd410f7b7d0b7564c880 (diff)
src: add dynamic register allocation infrastructure
Starting Linux kernel 5.18-rc, operations on registers that already contain the expected data are turned into noop. Track operation on registers to use the same register through nftnl_reg_get(). This patch introduces an LRU eviction strategy when all the registers are in used. nftnl_reg_get_scratch() is used to allocate a register as scratchpad area: no tracking is performed in this case, although register eviction might occur. Acked-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/regs.h')
-rw-r--r--include/regs.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/regs.h b/include/regs.h
new file mode 100644
index 0000000..5312f60
--- /dev/null
+++ b/include/regs.h
@@ -0,0 +1,32 @@
+#ifndef _LIBNFTNL_REGS_INTERNAL_H_
+#define _LIBNFTNL_REGS_INTERNAL_H_
+
+enum nftnl_expr_type {
+ NFT_EXPR_UNSPEC = 0,
+ NFT_EXPR_PAYLOAD,
+ NFT_EXPR_META,
+};
+
+struct nftnl_reg {
+ enum nftnl_expr_type type;
+ uint32_t len;
+ uint64_t genid;
+ uint8_t word;
+ union {
+ struct {
+ enum nft_meta_keys key;
+ } meta;
+ struct {
+ enum nft_payload_bases base;
+ uint32_t offset;
+ } payload;
+ };
+};
+
+struct nftnl_regs {
+ uint32_t num_regs;
+ struct nftnl_reg *reg;
+ uint64_t genid;
+};
+
+#endif