@@ -21,7 +21,7 @@ static DEFINE_PER_CPU(struct rnd_state, nft_numgen_prandom_state);
21
21
22
22
struct nft_ng_inc {
23
23
enum nft_registers dreg :8 ;
24
- u32 until ;
24
+ u32 modulus ;
25
25
atomic_t counter ;
26
26
};
27
27
@@ -34,15 +34,15 @@ static void nft_ng_inc_eval(const struct nft_expr *expr,
34
34
35
35
do {
36
36
oval = atomic_read (& priv -> counter );
37
- nval = (oval + 1 < priv -> until ) ? oval + 1 : 0 ;
37
+ nval = (oval + 1 < priv -> modulus ) ? oval + 1 : 0 ;
38
38
} while (atomic_cmpxchg (& priv -> counter , oval , nval ) != oval );
39
39
40
40
memcpy (& regs -> data [priv -> dreg ], & priv -> counter , sizeof (u32 ));
41
41
}
42
42
43
43
static const struct nla_policy nft_ng_policy [NFTA_NG_MAX + 1 ] = {
44
44
[NFTA_NG_DREG ] = { .type = NLA_U32 },
45
- [NFTA_NG_UNTIL ] = { .type = NLA_U32 },
45
+ [NFTA_NG_MODULUS ] = { .type = NLA_U32 },
46
46
[NFTA_NG_TYPE ] = { .type = NLA_U32 },
47
47
};
48
48
@@ -52,8 +52,8 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
52
52
{
53
53
struct nft_ng_inc * priv = nft_expr_priv (expr );
54
54
55
- priv -> until = ntohl (nla_get_be32 (tb [NFTA_NG_UNTIL ]));
56
- if (priv -> until == 0 )
55
+ priv -> modulus = ntohl (nla_get_be32 (tb [NFTA_NG_MODULUS ]));
56
+ if (priv -> modulus == 0 )
57
57
return - ERANGE ;
58
58
59
59
priv -> dreg = nft_parse_register (tb [NFTA_NG_DREG ]);
@@ -64,11 +64,11 @@ static int nft_ng_inc_init(const struct nft_ctx *ctx,
64
64
}
65
65
66
66
static int nft_ng_dump (struct sk_buff * skb , enum nft_registers dreg ,
67
- u32 until , enum nft_ng_types type )
67
+ u32 modulus , enum nft_ng_types type )
68
68
{
69
69
if (nft_dump_register (skb , NFTA_NG_DREG , dreg ))
70
70
goto nla_put_failure ;
71
- if (nla_put_be32 (skb , NFTA_NG_UNTIL , htonl (until )))
71
+ if (nla_put_be32 (skb , NFTA_NG_MODULUS , htonl (modulus )))
72
72
goto nla_put_failure ;
73
73
if (nla_put_be32 (skb , NFTA_NG_TYPE , htonl (type )))
74
74
goto nla_put_failure ;
@@ -83,12 +83,12 @@ static int nft_ng_inc_dump(struct sk_buff *skb, const struct nft_expr *expr)
83
83
{
84
84
const struct nft_ng_inc * priv = nft_expr_priv (expr );
85
85
86
- return nft_ng_dump (skb , priv -> dreg , priv -> until , NFT_NG_INCREMENTAL );
86
+ return nft_ng_dump (skb , priv -> dreg , priv -> modulus , NFT_NG_INCREMENTAL );
87
87
}
88
88
89
89
struct nft_ng_random {
90
90
enum nft_registers dreg :8 ;
91
- u32 until ;
91
+ u32 modulus ;
92
92
};
93
93
94
94
static void nft_ng_random_eval (const struct nft_expr * expr ,
@@ -99,7 +99,7 @@ static void nft_ng_random_eval(const struct nft_expr *expr,
99
99
struct rnd_state * state = this_cpu_ptr (& nft_numgen_prandom_state );
100
100
101
101
regs -> data [priv -> dreg ] = reciprocal_scale (prandom_u32_state (state ),
102
- priv -> until );
102
+ priv -> modulus );
103
103
}
104
104
105
105
static int nft_ng_random_init (const struct nft_ctx * ctx ,
@@ -108,8 +108,8 @@ static int nft_ng_random_init(const struct nft_ctx *ctx,
108
108
{
109
109
struct nft_ng_random * priv = nft_expr_priv (expr );
110
110
111
- priv -> until = ntohl (nla_get_be32 (tb [NFTA_NG_UNTIL ]));
112
- if (priv -> until == 0 )
111
+ priv -> modulus = ntohl (nla_get_be32 (tb [NFTA_NG_MODULUS ]));
112
+ if (priv -> modulus == 0 )
113
113
return - ERANGE ;
114
114
115
115
prandom_init_once (& nft_numgen_prandom_state );
@@ -124,7 +124,7 @@ static int nft_ng_random_dump(struct sk_buff *skb, const struct nft_expr *expr)
124
124
{
125
125
const struct nft_ng_random * priv = nft_expr_priv (expr );
126
126
127
- return nft_ng_dump (skb , priv -> dreg , priv -> until , NFT_NG_RANDOM );
127
+ return nft_ng_dump (skb , priv -> dreg , priv -> modulus , NFT_NG_RANDOM );
128
128
}
129
129
130
130
static struct nft_expr_type nft_ng_type ;
@@ -149,8 +149,8 @@ nft_ng_select_ops(const struct nft_ctx *ctx, const struct nlattr * const tb[])
149
149
{
150
150
u32 type ;
151
151
152
- if (!tb [NFTA_NG_DREG ] ||
153
- !tb [NFTA_NG_UNTIL ] ||
152
+ if (!tb [NFTA_NG_DREG ] ||
153
+ !tb [NFTA_NG_MODULUS ] ||
154
154
!tb [NFTA_NG_TYPE ])
155
155
return ERR_PTR (- EINVAL );
156
156
0 commit comments