From patchwork Sun Oct 9 13:49:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Anders K. Pedersen | Cohaesio" X-Patchwork-Id: 680050 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ssPkw6jh0z9sBR for ; Mon, 10 Oct 2016 00:49:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751441AbcJINtm (ORCPT ); Sun, 9 Oct 2016 09:49:42 -0400 Received: from bender.cohaesio.com ([212.97.128.130]:33383 "EHLO mail.cohaesio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751130AbcJINtl (ORCPT ); Sun, 9 Oct 2016 09:49:41 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.cohaesio.com (Postfix) with ESMTP id 1439C78834D9; Sun, 9 Oct 2016 15:49:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at cohaesio.com Received: from mail.cohaesio.com ([127.0.0.1]) by localhost (bender.cohaesio.com [127.0.0.1]) (amavisd-new, port 10028) with LMTP id vnipKjGSWmtl; Sun, 9 Oct 2016 15:49:03 +0200 (CEST) Received: from cohexch01.cohaesio.com (cohexch01.cohaesio.com [212.97.128.231]) by mail.cohaesio.com (Postfix) with ESMTP id D9CC678000BD; Sun, 9 Oct 2016 15:49:03 +0200 (CEST) Received: from cohexch02.cohaesio.com (212.97.128.232) by cohexch01.cohaesio.com (212.97.128.231) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Sun, 9 Oct 2016 15:49:03 +0200 Received: from cohexch02.cohaesio.com ([212.97.128.232]) by cohexch02.cohaesio.com ([212.97.128.232]) with mapi id 15.00.1104.000; Sun, 9 Oct 2016 15:49:02 +0200 From: "Anders K. Pedersen | Cohaesio" To: "netfilter-devel@vger.kernel.org" , "pablo@netfilter.org" CC: "kaber@trash.net" Subject: [PATCH nf] netfilter: nft_dynset: fix element timeout for HZ != 1000 Thread-Topic: [PATCH nf] netfilter: nft_dynset: fix element timeout for HZ != 1000 Thread-Index: AQHSIjPkCAfuq6kXoUia0PgzH4b9Vw== Date: Sun, 9 Oct 2016 13:49:02 +0000 Message-ID: <1476020942.992.20.camel@cohaesio.com> Accept-Language: en-US, da-DK Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Evolution 3.20.5 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [85.204.120.79] Content-ID: MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Anders K. Pedersen 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 --- 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))