summaryrefslogtreecommitdiffstats
path: root/kernel/ip_set_ipportiphash.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/ip_set_ipportiphash.c')
-rw-r--r--kernel/ip_set_ipportiphash.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/kernel/ip_set_ipportiphash.c b/kernel/ip_set_ipportiphash.c
index 166bec4..5fe00f1 100644
--- a/kernel/ip_set_ipportiphash.c
+++ b/kernel/ip_set_ipportiphash.c
@@ -31,7 +31,7 @@ static int limit = MAX_RANGE;
jhash_2words(ipport, ip1, *(map->initval + i))
static inline __u32
-ipportiphash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
+ipportiphash_id(struct ip_set *set,
ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t ip1)
{
struct ip_set_ipportiphash *map = set->data;
@@ -39,17 +39,15 @@ ipportiphash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
u_int16_t i;
struct ipportip *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 || ip1))
+ ip = pack_ip_port(map, ip, port);
+ if (!(ip || ip1))
return UINT_MAX;
for (i = 0; i < map->probes; i++) {
- id = jhash_ip2(map, i, *hash_ip, ip1) % map->hashsize;
+ id = jhash_ip2(map, i, ip, ip1) % map->hashsize;
DP("hash key: %u", id);
elem = HARRAY_ELEM(map->members, struct ipportip *, id);
- if (elem->ip == *hash_ip && elem->ip1 == ip1)
+ if (elem->ip == ip && elem->ip1 == ip1)
return id;
/* No shortcut - there can be deleted entries. */
}
@@ -57,7 +55,7 @@ ipportiphash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
}
static inline int
-ipportiphash_test(struct ip_set *set, ip_set_ip_t *hash_ip,
+ipportiphash_test(struct ip_set *set,
ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t ip1)
{
struct ip_set_ipportiphash *map = set->data;
@@ -65,17 +63,17 @@ ipportiphash_test(struct ip_set *set, ip_set_ip_t *hash_ip,
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- return (ipportiphash_id(set, hash_ip, ip, port, ip1) != UINT_MAX);
+ return (ipportiphash_id(set, ip, port, ip1) != UINT_MAX);
}
#define KADT_CONDITION \
ip_set_ip_t port, ip1; \
\
- if (flags[index+2] == 0) \
+ if (flags[2] == 0) \
return 0; \
\
- port = get_port(skb, flags[index+1]); \
- ip1 = ipaddr(skb, flags[index+2]); \
+ port = get_port(skb, flags++); \
+ ip1 = ipaddr(skb, flags++); \
\
if (port == INVALID_PORT) \
return 0;
@@ -85,23 +83,23 @@ KADT(ipportiphash, test, ipaddr, port, ip1)
static inline int
__ipportip_add(struct ip_set_ipportiphash *map,
- ip_set_ip_t hash_ip, ip_set_ip_t ip1)
+ ip_set_ip_t ip, ip_set_ip_t ip1)
{
__u32 probe;
u_int16_t i;
struct ipportip *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) {
- probe = jhash_ip2(map, i, hash_ip, ip1) % map->hashsize;
+ probe = jhash_ip2(map, i, ip, ip1) % map->hashsize;
elem = HARRAY_ELEM(map->members, struct ipportip *, probe);
- if (elem->ip == hash_ip && elem->ip1 == ip1)
+ if (elem->ip == ip && elem->ip1 == ip1)
return -EEXIST;
if (!(slot || elem->ip || elem->ip1))
slot = elem;
/* There can be deleted entries, must check all slots */
}
if (slot) {
- slot->ip = hash_ip;
+ slot->ip = ip;
slot->ip1 = ip1;
map->elements++;
return 0;
@@ -118,7 +116,7 @@ __ipportiphash_add(struct ip_set_ipportiphash *map,
}
static inline int
-ipportiphash_add(struct ip_set *set, ip_set_ip_t *hash_ip,
+ipportiphash_add(struct ip_set *set,
ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t ip1)
{
struct ip_set_ipportiphash *map = set->data;
@@ -128,11 +126,11 @@ ipportiphash_add(struct ip_set *set, ip_set_ip_t *hash_ip,
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- *hash_ip = pack_ip_port(map, ip, port);
- if (!(*hash_ip || ip1))
+ ip = pack_ip_port(map, ip, port);
+ if (!(ip || ip1))
return -ERANGE;
- return __ipportip_add(map, *hash_ip, ip1);
+ return __ipportip_add(map, ip, ip1);
}
UADT(ipportiphash, add, req->port, req->ip1)
@@ -149,7 +147,7 @@ __ipportiphash_retry(struct ip_set_ipportiphash *tmp,
HASH_RETRY2(ipportiphash, struct ipportip)
static inline int
-ipportiphash_del(struct ip_set *set, ip_set_ip_t *hash_ip,
+ipportiphash_del(struct ip_set *set,
ip_set_ip_t ip, ip_set_ip_t port, ip_set_ip_t ip1)
{
struct ip_set_ipportiphash *map = set->data;
@@ -159,7 +157,7 @@ ipportiphash_del(struct ip_set *set, ip_set_ip_t *hash_ip,
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- id = ipportiphash_id(set, hash_ip, ip, port, ip1);
+ id = ipportiphash_id(set, ip, port, ip1);
if (id == UINT_MAX)
return -EEXIST;