diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-05-01 17:40:01 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-05-04 11:58:01 +0200 |
commit | b9e00458b9f357f6c9b301f95b276fd019da0692 (patch) | |
tree | 7bda5c1f1b684da25e864b42feb28d2f76a86a78 /include/expr_ops.h | |
parent | e2514c0eff4da7e8e0aabd410f7b7d0b7564c880 (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/expr_ops.h')
-rw-r--r-- | include/expr_ops.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/expr_ops.h b/include/expr_ops.h index 7a6aa23..01f6fef 100644 --- a/include/expr_ops.h +++ b/include/expr_ops.h @@ -7,6 +7,7 @@ struct nlattr; struct nlmsghdr; struct nftnl_expr; +struct nftnl_reg; struct expr_ops { const char *name; @@ -19,6 +20,11 @@ struct expr_ops { int (*parse)(struct nftnl_expr *e, struct nlattr *attr); void (*build)(struct nlmsghdr *nlh, const struct nftnl_expr *e); int (*snprintf)(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e); + struct { + int (*len)(const struct nftnl_expr *e); + bool (*cmp)(const struct nftnl_reg *reg, const struct nftnl_expr *e); + void (*update)(struct nftnl_reg *reg, const struct nftnl_expr *e); + } reg; }; struct expr_ops *nftnl_expr_ops_lookup(const char *name); |