]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
netfilter: nf_tables: fix inconsistent element expiration calculation
authorAnders K. Pedersen <akp@cohaesio.com>
Sun, 20 Nov 2016 16:38:47 +0000 (16:38 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Nov 2016 13:43:34 +0000 (14:43 +0100)
commitd3e2a1110cae6ee5eeb1f9a97addf03e974f12e6
tree81cbe225d30cc88bb084a810a1d7d98f7026ac3a
parent7223ecd4669921cb2a709193521967aaa2b06862
netfilter: nf_tables: fix inconsistent element expiration calculation

As Liping Zhang reports, after commit a8b1e36d0d1d ("netfilter: nft_dynset:
fix element timeout for HZ != 1000"), priv->timeout was stored in jiffies,
while set->timeout was stored in milliseconds. This is inconsistent and
incorrect.

Firstly, we already call msecs_to_jiffies in nft_set_elem_init, so
priv->timeout will be converted to jiffies twice.

Secondly, if the user did not specify the NFTA_DYNSET_TIMEOUT attr,
set->timeout will be used, but we forget to call msecs_to_jiffies
when do update elements.

Fix this by using jiffies internally for traditional sets and doing the
conversions to/from msec when interacting with userspace - as dynset
already does.

This is preferable to doing the conversions, when elements are inserted or
updated, because this can happen very frequently on busy dynsets.

Fixes: a8b1e36d0d1d ("netfilter: nft_dynset: fix element timeout for HZ != 1000")
Reported-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Anders K. Pedersen <akp@cohaesio.com>
Acked-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c