Skip to content

Commit

Permalink
netfilter: ipset: List timing out entries with "timeout 1" instead of…
Browse files Browse the repository at this point in the history
… zero

When listing sets with timeout support, there's a probability that
just timing out entries with "0" timeout value is listed/saved.
However when restoring the saved list, the zero timeout value means
permanent elelements.

The new behaviour is that timing out entries are listed with "timeout 1"
instead of zero.

Fixes netfilter bugzilla #1258.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
  • Loading branch information
Jozsef Kadlecsik committed Jun 6, 2018
1 parent 9dcceb1 commit bd975e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/linux/netfilter/ipset/ip_set_timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
static inline u32
ip_set_timeout_get(const unsigned long *timeout)
{
return *timeout == IPSET_ELEM_PERMANENT ? 0 :
jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
u32 t;

if (*timeout == IPSET_ELEM_PERMANENT)
return 0;

t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
/* Zero value in userspace means no timeout */
return t == 0 ? 1 : t;
}

#endif /* __KERNEL__ */
Expand Down

0 comments on commit bd975e6

Please sign in to comment.