diff mbox

[nf] netfilter: nft_dynset: fix element timeout for HZ != 1000

Message ID 1476020942.992.20.camel@cohaesio.com
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Anders K. Pedersen | Cohaesio Oct. 9, 2016, 1:49 p.m. UTC
From: Anders K. Pedersen <akp@cohaesio.com>


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: 22fe54d5fefc ("netfilter: nf_tables: add support for dynamic set updates")
Signed-off-by: Anders K. Pedersen <akp@cohaesio.com>

---

Comments

Pablo Neira Ayuso Oct. 17, 2016, 3:29 p.m. UTC | #1
On Sun, Oct 09, 2016 at 01:49:02PM +0000, Anders K. Pedersen | Cohaesio wrote:
> From: Anders K. Pedersen <akp@cohaesio.com>
> 
> 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.

Applied, thanks Anders.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/net/netfilter/nft_dynset.c	2016-10-03 01:24:33.000000000 +0200
+++ b/net/netfilter/nft_dynset.c	2016-10-09 14:39:48.519488167 +0200
@@ -143,7 +143,8 @@  static int nft_dynset_init(const struct
 	if (tb[NFTA_DYNSET_TIMEOUT] != NULL) {
 		if (!(set->flags & NFT_SET_TIMEOUT))
 			return -EINVAL;
-		timeout = be64_to_cpu(nla_get_be64(tb[NFTA_DYNSET_TIMEOUT]));
+		timeout = msecs_to_jiffies(be64_to_cpu(nla_get_be64(
+						tb[NFTA_DYNSET_TIMEOUT])));
 	}
 
 	priv->sreg_key = nft_parse_register(tb[NFTA_DYNSET_SREG_KEY]);
@@ -230,7 +231,8 @@  static int nft_dynset_dump(struct sk_buf
 		goto nla_put_failure;
 	if (nla_put_string(skb, NFTA_DYNSET_SET_NAME, priv->set->name))
 		goto nla_put_failure;
-	if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT, cpu_to_be64(priv->timeout),
+	if (nla_put_be64(skb, NFTA_DYNSET_TIMEOUT,
+			 cpu_to_be64(jiffies_to_msecs(priv->timeout)),
 			 NFTA_DYNSET_PAD))
 		goto nla_put_failure;
 	if (priv->expr && nft_expr_dump(skb, NFTA_DYNSET_EXPR, priv->expr))