summaryrefslogtreecommitdiffstats
path: root/kernel/ip_set_ipporthash.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-21 12:09:05 +0000
committer/C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu </C=EU/ST=EU/CN=Jozsef Kadlecsik/emailAddress=kadlec@blackhole.kfki.hu>2008-10-21 12:09:05 +0000
commitb8d6cfc169bf79b72faaab6ef7940798dbfe9328 (patch)
tree0bcc128ad3bcfdfca6849cea318e3de51673c6c6 /kernel/ip_set_ipporthash.c
parenta96e4fca10506462df4ee4035f0f86f09bd9dc34 (diff)
As the manpage says, zero valued set entries cannot be used with
hash type of sets. Enforce the restriction.
Diffstat (limited to 'kernel/ip_set_ipporthash.c')
-rw-r--r--kernel/ip_set_ipporthash.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/ip_set_ipporthash.c b/kernel/ip_set_ipporthash.c
index 1dd39c3..97b2323 100644
--- a/kernel/ip_set_ipporthash.c
+++ b/kernel/ip_set_ipporthash.c
@@ -39,8 +39,11 @@ ipporthash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
ip_set_ip_t *elem;
*hash_ip = pack_ip_port(map, ip, port);
+
DP("set: %s, ipport:%u.%u.%u.%u:%u, %u.%u.%u.%u",
set->name, HIPQUAD(ip), port, HIPQUAD(*hash_ip));
+ if (!*hash_ip)
+ return UINT_MAX;
for (i = 0; i < map->probes; i++) {
id = jhash_ip(map, i, *hash_ip) % map->hashsize;
@@ -113,6 +116,9 @@ ipporthash_add(struct ip_set *set, ip_set_ip_t *hash_ip,
return -ERANGE;
*hash_ip = pack_ip_port(map, ip, port);
+
+ if (!*hash_ip)
+ return -ERANGE;
return __ipporthash_add(map, hash_ip);
}