Skip to contentSkip to conversation

expr: numgen: Rename until attribute by modulus

PATCH Applied Laura Garcia Liebana 2 participants 2 messages Sep 7, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 expr: numgen: Rename until attribute by modulus

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.

---
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(-)
include/buffer.h +0 -1
index 8cfe377..a753c78 100644
@@ -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"
include/libnftnl/expr.h +1 -1
index 8815154..94ce529 100644
@@ -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,
 };
 
include/linux/netfilter/nf_tables.h +2 -2
index 8a63f22..dd8b746 100644
@@ -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
 };
src/expr/numgen.c +26 -26

133 lines not on this page · raw message

tests/nft-expr_numgen-test.c +4 -4
index b78ee76..7092c8d 100644
@@ -33,9 +33,9 @@ static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
 	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_DREG) !=
 	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_DREG))
 		print_err("Expr NFTNL_EXPR_NG_DREG mismatches");
-	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_UNTIL) !=
-	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_UNTIL))
-		print_err("Expr NFTNL_EXPR_NG_UNTIL mismatches");
+	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_MODULUS) !=
+	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_MODULUS))
+		print_err("Expr NFTNL_EXPR_NG_MODULUS mismatches");
 	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_TYPE) !=
 	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_TYPE))
 		print_err("Expr NFTNL_EXPR_NG_TYPE mismatches");
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
 		print_err("OOM");
 
 	nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_DREG, 0x1234568);
-	nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_UNTIL, 0x78123456);
+	nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_MODULUS, 0x78123456);
 	nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_TYPE, NFT_NG_INCREMENTAL);
 
 	nftnl_rule_add_expr(a, ex);
Signature · 1 line
2.8.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Laura Garcia Liebana

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.

Applied, thanks Laura.