Commit 249ddc79 authored by Jozsef Kadlecsik's avatar Jozsef Kadlecsik Committed by Pablo Neira Ayuso

netfilter: ipset: Use proper timeout value to jiffies conversion

Signed-off-by: default avatarJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 71338aa7
...@@ -45,7 +45,7 @@ ip_set_timeout_test(unsigned long timeout) ...@@ -45,7 +45,7 @@ ip_set_timeout_test(unsigned long timeout)
{ {
return timeout != IPSET_ELEM_UNSET && return timeout != IPSET_ELEM_UNSET &&
(timeout == IPSET_ELEM_PERMANENT || (timeout == IPSET_ELEM_PERMANENT ||
time_after(timeout, jiffies)); time_is_after_jiffies(timeout));
} }
static inline bool static inline bool
...@@ -53,7 +53,7 @@ ip_set_timeout_expired(unsigned long timeout) ...@@ -53,7 +53,7 @@ ip_set_timeout_expired(unsigned long timeout)
{ {
return timeout != IPSET_ELEM_UNSET && return timeout != IPSET_ELEM_UNSET &&
timeout != IPSET_ELEM_PERMANENT && timeout != IPSET_ELEM_PERMANENT &&
time_before(timeout, jiffies); time_is_before_jiffies(timeout);
} }
static inline unsigned long static inline unsigned long
...@@ -64,7 +64,7 @@ ip_set_timeout_set(u32 timeout) ...@@ -64,7 +64,7 @@ ip_set_timeout_set(u32 timeout)
if (!timeout) if (!timeout)
return IPSET_ELEM_PERMANENT; return IPSET_ELEM_PERMANENT;
t = timeout * HZ + jiffies; t = msecs_to_jiffies(timeout * 1000) + jiffies;
if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT) if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT)
/* Bingo! */ /* Bingo! */
t++; t++;
...@@ -75,7 +75,8 @@ ip_set_timeout_set(u32 timeout) ...@@ -75,7 +75,8 @@ ip_set_timeout_set(u32 timeout)
static inline u32 static inline u32
ip_set_timeout_get(unsigned long timeout) ip_set_timeout_get(unsigned long timeout)
{ {
return timeout == IPSET_ELEM_PERMANENT ? 0 : (timeout - jiffies)/HZ; return timeout == IPSET_ELEM_PERMANENT ? 0 :
jiffies_to_msecs(timeout - jiffies)/1000;
} }
#else #else
...@@ -89,14 +90,14 @@ static inline bool ...@@ -89,14 +90,14 @@ static inline bool
ip_set_timeout_test(unsigned long timeout) ip_set_timeout_test(unsigned long timeout)
{ {
return timeout == IPSET_ELEM_PERMANENT || return timeout == IPSET_ELEM_PERMANENT ||
time_after(timeout, jiffies); time_is_after_jiffies(timeout);
} }
static inline bool static inline bool
ip_set_timeout_expired(unsigned long timeout) ip_set_timeout_expired(unsigned long timeout)
{ {
return timeout != IPSET_ELEM_PERMANENT && return timeout != IPSET_ELEM_PERMANENT &&
time_before(timeout, jiffies); time_is_before_jiffies(timeout);
} }
static inline unsigned long static inline unsigned long
...@@ -107,7 +108,7 @@ ip_set_timeout_set(u32 timeout) ...@@ -107,7 +108,7 @@ ip_set_timeout_set(u32 timeout)
if (!timeout) if (!timeout)
return IPSET_ELEM_PERMANENT; return IPSET_ELEM_PERMANENT;
t = timeout * HZ + jiffies; t = msecs_to_jiffies(timeout * 1000) + jiffies;
if (t == IPSET_ELEM_PERMANENT) if (t == IPSET_ELEM_PERMANENT)
/* Bingo! :-) */ /* Bingo! :-) */
t++; t++;
...@@ -118,7 +119,8 @@ ip_set_timeout_set(u32 timeout) ...@@ -118,7 +119,8 @@ ip_set_timeout_set(u32 timeout)
static inline u32 static inline u32
ip_set_timeout_get(unsigned long timeout) ip_set_timeout_get(unsigned long timeout)
{ {
return timeout == IPSET_ELEM_PERMANENT ? 0 : (timeout - jiffies)/HZ; return timeout == IPSET_ELEM_PERMANENT ? 0 :
jiffies_to_msecs(timeout - jiffies)/1000;
} }
#endif /* ! IP_SET_BITMAP_TIMEOUT */ #endif /* ! IP_SET_BITMAP_TIMEOUT */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment