summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux/netfilter/ip_set_timeout.h
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-24 21:42:48 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-24 21:42:48 +0200
commit0d32c5c070f817229110f92d7b31df9a3e4eeec5 (patch)
tree5ee04a9e03de32d2029ad0d708811e382ca922d1 /kernel/include/linux/netfilter/ip_set_timeout.h
parent62a3d29539aa109fed1c8a20d63ef95948b13842 (diff)
Fixes, cleanups, commentsv5.0-pre8
- More comments added to the code - ICMP and ICMPv6 support added to the hash:ip,port, hash:ip,port,ip and hash:ip,port,net types - hash:net and hash:ip,port,net types are reworked - hash:net,port type added - Wrong direction parameters fixed in hash:ip,port - Helps and manpage are updated - More tests added - Ugly macros are rewritten to functions in parse.c (Holger Eitzenberger) - resize related bug in hash types fixed (Holger Eitzenberger) - autoreconf patches by Jan Engelhardt applied - netlink patch minimalized: dumping can be initialized by a second parsing of the message (thanks to David and Patrick for the suggestion) - IPv4/IPv6 address attributes are introduced in order to fix the context (suggested by David)
Diffstat (limited to 'kernel/include/linux/netfilter/ip_set_timeout.h')
-rw-r--r--kernel/include/linux/netfilter/ip_set_timeout.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/kernel/include/linux/netfilter/ip_set_timeout.h b/kernel/include/linux/netfilter/ip_set_timeout.h
index bf1cbf6..b917480 100644
--- a/kernel/include/linux/netfilter/ip_set_timeout.h
+++ b/kernel/include/linux/netfilter/ip_set_timeout.h
@@ -17,7 +17,7 @@
#define IPSET_GC_PERIOD(timeout) \
((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1)
-/* Set is defined without timeout support */
+/* Set is defined without timeout support: timeout value may be 0 */
#define IPSET_NO_TIMEOUT UINT_MAX
#define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT)
@@ -27,11 +27,14 @@ ip_set_timeout_uget(struct nlattr *tb)
{
unsigned int timeout = ip_set_get_h32(tb);
+ /* Userspace supplied TIMEOUT parameter: adjust crazy size */
return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 : timeout;
}
#ifdef IP_SET_BITMAP_TIMEOUT
+/* Bitmap specific timeout constants and macros for the entries */
+
/* Bitmap entry is unset */
#define IPSET_ELEM_UNSET 0
/* Bitmap entry is set with no timeout value */
@@ -63,6 +66,7 @@ ip_set_timeout_set(u32 timeout)
t = timeout * HZ + jiffies;
if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT)
+ /* Bingo! */
t++;
return t;
@@ -76,19 +80,23 @@ ip_set_timeout_get(unsigned long timeout)
#else
+/* Hash specific timeout constants and macros for the entries */
+
/* Hash entry is set with no timeout value */
-#define IPSET_ELEM_UNSET 0
+#define IPSET_ELEM_PERMANENT 0
static inline bool
ip_set_timeout_test(unsigned long timeout)
{
- return timeout == IPSET_ELEM_UNSET || time_after(timeout, jiffies);
+ return timeout == IPSET_ELEM_PERMANENT
+ || time_after(timeout, jiffies);
}
static inline bool
ip_set_timeout_expired(unsigned long timeout)
{
- return timeout != IPSET_ELEM_UNSET && time_before(timeout, jiffies);
+ return timeout != IPSET_ELEM_PERMANENT
+ && time_before(timeout, jiffies);
}
static inline unsigned long
@@ -97,10 +105,11 @@ ip_set_timeout_set(u32 timeout)
unsigned long t;
if (!timeout)
- return IPSET_ELEM_UNSET;
+ return IPSET_ELEM_PERMANENT;
t = timeout * HZ + jiffies;
- if (t == IPSET_ELEM_UNSET)
+ if (t == IPSET_ELEM_PERMANENT)
+ /* Bingo! :-) */
t++;
return t;
@@ -109,10 +118,10 @@ ip_set_timeout_set(u32 timeout)
static inline u32
ip_set_timeout_get(unsigned long timeout)
{
- return timeout == IPSET_ELEM_UNSET ? 0 : (timeout - jiffies)/HZ;
+ return timeout == IPSET_ELEM_PERMANENT ? 0 : (timeout - jiffies)/HZ;
}
-#endif /* IP_SET_BITMAP_TIMEOUT */
+#endif /* ! IP_SET_BITMAP_TIMEOUT */
#endif /* __KERNEL__ */
-#endif /*_IP_SET_TIMEOUT_H */
+#endif /* _IP_SET_TIMEOUT_H */