Skip to content

Commit 1ba7faf

Browse files
cohakpgregkh
authored andcommitted
netfilter: nft_dynset: fix element timeout for HZ != 1000
commit a8b1e36d0d1d6f51490e7adce35367ed6adb10e7 upstream. With HZ=100 element timeout in dynamic sets (i.e. flow tables) is 10 times higher than configured. Add proper conversion to/from jiffies, when interacting with userspace. I tested this on Linux 4.8.1, and it applies cleanly to current nf and nf-next trees. Fixes: 22fe54d ("netfilter: nf_tables: add support for dynamic set updates") Signed-off-by: Anders K. Pedersen <akp@cohaesio.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 698a8dd commit 1ba7faf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/netfilter/nft_dynset.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
140140
if (tb[NFTA_DYNSET_TIMEOUT] != NULL) {
141141
if (!(set->flags & NFT_SET_TIMEOUT))
142142
return -EINVAL;
143-
timeout = be64_to_cpu(nla_get_be64(tb[NFTA_DYNSET_TIMEOUT]));
143+
timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
144+
tb[NFTA_DYNSET_TIMEOUT])));
144145
}
145146

146147
priv->sreg_key = nft_parse_register(tb[NFTA_DYNSET_SREG_KEY]);
@@ -227,7 +228,8 @@ static int nft_dynset_dump(struct sk_buff *skb, const struct nft_expr *expr)
227228
goto nla_put_failure;
228229
if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name))
229230
goto nla_put_failure;
230-
if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout)))
231+
if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT,
232+
cpu_to_be64(jiffies_to_msecs(priv->timeout))))
231233
goto nla_put_failure;
232234
if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr))
233235
goto nla_put_failure;

0 commit comments

Comments
 (0)