The _modulus_ attribute will be reused as _until_, as it's similar to
other expressions with value limits (ex. hash).
Renaming is possible according to the kernel module ntf_numgen that has
not been released yet.
Signed-off-by: Laura Garcia Liebana
---
Changes in v2:
- Separate changes with incremental counter offset value.
Changes in v3:
- Update repo before submitting the patch.
include/buffer.h| 1 -
include/libnftnl/expr.h | 2 +-
include/linux/netfilter/nf_tables.h | 4 +--
src/expr/numgen.c | 52 ++---
tests/nft-expr_numgen-test.c| 8 +++---
5 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/include/buffer.h b/include/buffer.h
index 8cfe377..a753c78 100644
--- a/include/buffer.h
+++ b/include/buffer.h
@@ -82,7 +82,6 @@ int nftnl_buf_reg(struct nftnl_buf *b, int type, union
nftnl_data_reg *reg,
#define TOTAL "total"
#define TYPE "type"
#define UNIT "unit"
-#define UNTIL "until"
#define USE"use"
#define XOR"xor"
#define ADD"add"
diff --git a/include/libnftnl/expr.h b/include/libnftnl/expr.h
index 8815154..94ce529 100644
--- a/include/libnftnl/expr.h
+++ b/include/libnftnl/expr.h
@@ -52,7 +52,7 @@ enum {
enum {
NFTNL_EXPR_NG_DREG = NFTNL_EXPR_BASE,
- NFTNL_EXPR_NG_UNTIL,
+ NFTNL_EXPR_NG_MODULUS,
NFTNL_EXPR_NG_TYPE,
};
diff --git a/include/linux/netfilter/nf_tables.h
b/include/linux/netfilter/nf_tables.h
index 8a63f22..dd8b746 100644
--- a/include/linux/netfilter/nf_tables.h
+++ b/include/linux/netfilter/nf_tables.h
@@ -1126,13 +1126,13 @@ enum nft_trace_types {
* enum nft_ng_attributes - nf_tables number generator expression netlink
attributes
*
* @NFTA_NG_DREG: destination register (NLA_U32)
- * @NFTA_NG_UNTIL: source value to increment the counter until reset (NLA_U32)
+ * @NFTA_NG_MODULUS: maximum value to be returned (NLA_U32)
* @NFTA_NG_TYPE: operation type (NLA_U32)
*/
enum nft_ng_attributes {
NFTA_NG_UNSPEC,
NFTA_NG_DREG,
- NFTA_NG_UNTIL,
+ NFTA_NG_MODULUS,
NFTA_NG_TYPE,
__NFTA_NG_MAX
};
diff --git a/src/expr/numgen.c b/src/expr/numgen.c
index 7f2b425..dad41c2 100644
--- a/src/expr/numgen.c
+++ b/src/expr/numgen.c
@@ -22,7 +22,7 @@
struct nftnl_expr_ng {
enum nft_registers dreg;
- unsigned intuntil;
+ unsigned intmodulus;
enum nft_ng_types type;
};
@@ -36,8 +36,8 @@ nftnl_expr_ng_set(struct nftnl_expr *e, uint16_t type,
case NFTNL_EXPR_NG_DREG:
ng->dreg = *((uint32_t *)data);
break;
- case NFTNL_EXPR_NG_UNTIL:
- ng->until = *((uint32_t *)data);
+ case NFTNL_EXPR_NG_MODULUS:
+ ng->modulus = *((uint32_t *)data);
break;
case NFTNL_EXPR_NG_TYPE:
ng->type = *((uint32_t *)data);
@@ -58,9 +58,9 @@ nftnl_expr_ng_get(const struct nftnl_expr *e, uint16_t type,
case NFTNL_EXPR_NG_DREG:
*data_len = sizeof(ng->dreg);
return &ng->dreg;
- case NFTNL_EXPR_NG_UNTIL:
- *data_len = sizeof(ng->until);
- return &ng->until;
+ case NFTNL_EXPR_NG_MODULUS:
+ *data_len = sizeof(ng->modulus);
+ return &ng->modulus;
case NFTNL_EXPR_NG_TYPE:
*data_len = sizeof(ng->type);
return &ng->type;
@@ -78,7 +78,7 @@ static int nftnl_expr_ng_cb(const struct nlattr *attr, void
*data)
switch (type) {
case NFTA_NG_DREG:
- case NFTA_NG_UNTIL:
+ case NFTA_NG_MODULUS:
case NFTA_NG_TYPE:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0)
abi_breakage();
@@ -96,8 +96,8 @@ nftnl_expr_ng_build(struct nlmsghdr *nlh, const struct
nftnl_expr *e)
if (e->flags & (1 << NFTNL_EXPR_NG_DREG))
mnl_attr_put_u32(nlh, NFTA_NG_DREG, htonl(ng->dreg));
- if (e->flags & (1 << NFTNL_EXPR_NG_UNTIL))
- mnl_attr_put_u32(nlh, NFTA_NG_UNTIL, htonl(ng->until));
+ if (e->flags & (1 << NFTNL_EXPR_NG_MODULUS))
+ mnl_attr_put_u32(nlh, NFTA_NG_MODULUS, htonl(ng->modulus));
if (e->flags & (1 << NFTNL_EXPR_NG_TYPE))
mnl_attr_put_u32(nlh, NFTA_NG_TYPE, htonl(ng->type));
}
@@ -116,9 +116,9 @@ nftnl_expr_ng_parse(struct nftnl_expr *e, struct nlattr
*attr)
ng->dreg = ntohl(mnl_attr_get_u32(tb[NFTA_NG_DREG]));
e->flags |= (1 << NFTNL_EXPR_NG_DREG);
}
- if (tb[NFTA_NG_UNTIL]) {
- ng->until = ntohl(mnl_attr_get_u32(tb[NFTA_NG_UNTIL]));
- e->flags |= (1 << NFTNL_EXPR_NG_UNTIL);
+ if (tb[NFTA_NG_MODULUS]) {
+ ng->modulus = ntohl(mnl_attr_get