r7553 - in trunk/patch-o-matic-ng/patchlets/set/linux-2.6: include/linux/netfilter_ipv4 net/ipv4/netfilter
kadlec at blackhole.kfki.hu
kadlec at blackhole.kfki.hu
Wed Jul 2 12:36:02 CEST 2008
Author: kadlec at blackhole.kfki.hu
Date: 2008-07-02 12:36:01 +0200 (Wed, 02 Jul 2008)
New Revision: 7553
Modified:
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipmap.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptree.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptreemap.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_portmap.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_SET.c
trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_set.c
Log:
Swen's patches applied for iptreemap:
- Remove needless casts of void pointers
- Use min/max from kernel.h
- Use non-atomic bit operations
- Update description of set type
- Whitespace cleanup
Plus
- needless casts removed everywhere
- dangling whitespace cleanups
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/include/linux/netfilter_ipv4/ip_set_malloc.h 2008-07-02 10:36:01 UTC (rev 7553)
@@ -14,7 +14,7 @@
#include <linux/kmalloc_sizes.h>
#undef CACHE
if (page_size) {
- if (!max_malloc_size)
+ if (max_malloc_size == 0)
max_malloc_size = page_size;
max_page_size = page_size;
@@ -35,6 +35,8 @@
struct harray *harray;
size_t max_elements, size, i, j;
+ BUG_ON(max_page_size == 0);
+
if (typesize > max_page_size)
return NULL;
@@ -80,9 +82,6 @@
{
void *harray;
- if (!max_page_size)
- init_max_page_size();
-
do {
harray = __harray_malloc(hashsize, typesize, flags|__GFP_NOWARN);
} while (harray == NULL && init_max_page_size());
@@ -121,8 +120,7 @@
/* General memory allocation and deallocation */
static inline void * ip_set_malloc(size_t bytes)
{
- if (!max_malloc_size)
- init_max_page_size();
+ BUG_ON(max_malloc_size == 0);
if (bytes > max_malloc_size)
return vmalloc(bytes);
@@ -132,6 +130,8 @@
static inline void ip_set_free(void * data, size_t bytes)
{
+ BUG_ON(max_malloc_size == 0);
+
if (bytes > max_malloc_size)
vfree(data);
else
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -4,7 +4,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module for IP set management */
@@ -41,14 +41,16 @@
static struct list_head *ip_set_hash; /* hash of bindings */
static unsigned int ip_set_hash_random; /* random seed */
+#define SETNAME_EQ(a,b) (strncmp(a,b,IP_SET_MAXNAMELEN) == 0)
+
/*
* Sets are identified either by the index in ip_set_list or by id.
- * The id never changes and is used to find a key in the hash.
- * The index may change by swapping and used at all other places
+ * The id never changes and is used to find a key in the hash.
+ * The index may change by swapping and used at all other places
* (set/SET netfilter modules, binding value, etc.)
*
* Userspace requests are serialized by ip_set_mutex and sets can
- * be deleted only from userspace. Therefore ip_set_list locking
+ * be deleted only from userspace. Therefore ip_set_list locking
* must obey the following rules:
*
* - kernel requests: read and write locking mandatory
@@ -86,7 +88,7 @@
static ip_set_id_t
ip_set_find_in_hash(ip_set_id_t id, ip_set_ip_t ip)
{
- u_int32_t key = jhash_2words(id, ip, ip_set_hash_random)
+ u_int32_t key = jhash_2words(id, ip, ip_set_hash_random)
% ip_set_bindings_hash_size;
struct ip_set_hash *set_hash;
@@ -96,14 +98,14 @@
set_hash = __ip_set_find(key, id, ip);
- DP("set: %s, ip: %u.%u.%u.%u, binding: %s", ip_set_list[id]->name,
+ DP("set: %s, ip: %u.%u.%u.%u, binding: %s", ip_set_list[id]->name,
HIPQUAD(ip),
set_hash != NULL ? ip_set_list[set_hash->binding]->name : "");
return (set_hash != NULL ? set_hash->binding : IP_SET_INVALID_ID);
}
-static inline void
+static inline void
__set_hash_del(struct ip_set_hash *set_hash)
{
ASSERT_WRITE_LOCK(&ip_set_lock);
@@ -135,7 +137,7 @@
return 0;
}
-static int
+static int
ip_set_hash_add(ip_set_id_t id, ip_set_ip_t ip, ip_set_id_t binding)
{
u_int32_t key = jhash_2words(id, ip, ip_set_hash_random)
@@ -145,7 +147,7 @@
IP_SET_ASSERT(ip_set_list[id]);
IP_SET_ASSERT(ip_set_list[binding]);
- DP("set: %s, ip: %u.%u.%u.%u, binding: %s", ip_set_list[id]->name,
+ DP("set: %s, ip: %u.%u.%u.%u, binding: %s", ip_set_list[id]->name,
HIPQUAD(ip), ip_set_list[binding]->name);
write_lock_bh(&ip_set_lock);
set_hash = __ip_set_find(key, id, ip);
@@ -224,8 +226,8 @@
res = set->type->testip_kernel(set, skb, &ip, flags, i++);
read_unlock_bh(&set->lock);
i += !!(set->type->features & IPSET_DATA_DOUBLE);
- } while (res > 0
- && flags[i]
+ } while (res > 0
+ && flags[i]
&& follow_bindings(index, set, ip));
read_unlock_bh(&ip_set_lock);
@@ -254,7 +256,7 @@
write_unlock_bh(&set->lock);
i += !!(set->type->features & IPSET_DATA_DOUBLE);
} while ((res == 0 || res == -EEXIST)
- && flags[i]
+ && flags[i]
&& follow_bindings(index, set, ip));
read_unlock_bh(&ip_set_lock);
@@ -285,7 +287,7 @@
write_unlock_bh(&set->lock);
i += !!(set->type->features & IPSET_DATA_DOUBLE);
} while ((res == 0 || res == -EEXIST)
- && flags[i]
+ && flags[i]
&& follow_bindings(index, set, ip));
read_unlock_bh(&ip_set_lock);
}
@@ -303,7 +305,7 @@
return NULL;
}
-int
+int
ip_set_register_set_type(struct ip_set_type *set_type)
{
int ret = 0;
@@ -319,7 +321,7 @@
write_lock_bh(&ip_set_lock);
if (find_set_type(set_type->typename)) {
/* Duplicate! */
- ip_set_printk("'%s' already registered!",
+ ip_set_printk("'%s' already registered!",
set_type->typename);
ret = -EINVAL;
goto unlock;
@@ -369,7 +371,7 @@
down(&ip_set_app_mutex);
for (i = 0; i < ip_set_max; i++) {
if (ip_set_list[i] != NULL
- && strcmp(ip_set_list[i]->name, name) == 0) {
+ && SETNAME_EQ(ip_set_list[i]->name, name)) {
__ip_set_get(i);
index = i;
break;
@@ -422,7 +424,7 @@
for (i = 0; i < ip_set_max; i++) {
if (ip_set_list[i] != NULL
- && strcmp(ip_set_list[i]->name, name) == 0) {
+ && SETNAME_EQ(ip_set_list[i]->name, name)) {
index = i;
break;
}
@@ -534,7 +536,7 @@
size_t size)
{
struct ip_set *set = ip_set_list[index];
- struct ip_set_req_bind *req_bind;
+ const struct ip_set_req_bind *req_bind;
ip_set_id_t binding;
ip_set_ip_t ip;
int res;
@@ -543,18 +545,16 @@
if (size < sizeof(struct ip_set_req_bind))
return -EINVAL;
- req_bind = (struct ip_set_req_bind *) data;
- req_bind->binding[IP_SET_MAXNAMELEN - 1] = '\0';
+ req_bind = data;
- if (strcmp(req_bind->binding, IPSET_TOKEN_DEFAULT) == 0) {
+ if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_DEFAULT)) {
/* Default binding of a set */
- char *binding_name;
+ const char *binding_name;
if (size != sizeof(struct ip_set_req_bind) + IP_SET_MAXNAMELEN)
return -EINVAL;
- binding_name = (char *)(data + sizeof(struct ip_set_req_bind));
- binding_name[IP_SET_MAXNAMELEN - 1] = '\0';
+ binding_name = data + sizeof(struct ip_set_req_bind);
binding = ip_set_find_byname(binding_name);
if (binding == IP_SET_INVALID_ID)
@@ -622,7 +622,7 @@
size_t size)
{
struct ip_set *set;
- struct ip_set_req_bind *req_bind;
+ const struct ip_set_req_bind *req_bind;
ip_set_ip_t ip;
int res;
@@ -630,19 +630,18 @@
if (size < sizeof(struct ip_set_req_bind))
return -EINVAL;
- req_bind = (struct ip_set_req_bind *) data;
- req_bind->binding[IP_SET_MAXNAMELEN - 1] = '\0';
+ req_bind = data;
DP("%u %s", index, req_bind->binding);
if (index == IP_SET_INVALID_ID) {
/* unbind :all: */
- if (strcmp(req_bind->binding, IPSET_TOKEN_DEFAULT) == 0) {
+ if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_DEFAULT)) {
/* Default binding of sets */
write_lock_bh(&ip_set_lock);
FOREACH_SET_DO(__unbind_default);
write_unlock_bh(&ip_set_lock);
return 0;
- } else if (strcmp(req_bind->binding, IPSET_TOKEN_ALL) == 0) {
+ } else if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_ALL)) {
/* Flush all bindings of all sets*/
write_lock_bh(&ip_set_lock);
FOREACH_HASH_RW_DO(__set_hash_del);
@@ -655,7 +654,7 @@
set = ip_set_list[index];
IP_SET_ASSERT(set);
- if (strcmp(req_bind->binding, IPSET_TOKEN_DEFAULT) == 0) {
+ if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_DEFAULT)) {
/* Default binding of set */
ip_set_id_t binding = ip_set_find_byindex(set->binding);
@@ -669,7 +668,7 @@
write_unlock_bh(&ip_set_lock);
return 0;
- } else if (strcmp(req_bind->binding, IPSET_TOKEN_ALL) == 0) {
+ } else if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_ALL)) {
/* Flush all bindings */
write_lock_bh(&ip_set_lock);
@@ -696,7 +695,7 @@
size_t size)
{
struct ip_set *set = ip_set_list[index];
- struct ip_set_req_bind *req_bind;
+ const struct ip_set_req_bind *req_bind;
ip_set_id_t binding;
ip_set_ip_t ip;
int res;
@@ -705,18 +704,16 @@
if (size < sizeof(struct ip_set_req_bind))
return -EINVAL;
- req_bind = (struct ip_set_req_bind *) data;
- req_bind->binding[IP_SET_MAXNAMELEN - 1] = '\0';
+ req_bind = data;
- if (strcmp(req_bind->binding, IPSET_TOKEN_DEFAULT) == 0) {
+ if (SETNAME_EQ(req_bind->binding, IPSET_TOKEN_DEFAULT)) {
/* Default binding of set */
- char *binding_name;
+ const char *binding_name;
if (size != sizeof(struct ip_set_req_bind) + IP_SET_MAXNAMELEN)
return -EINVAL;
- binding_name = (char *)(data + sizeof(struct ip_set_req_bind));
- binding_name[IP_SET_MAXNAMELEN - 1] = '\0';
+ binding_name = data + sizeof(struct ip_set_req_bind);
binding = ip_set_find_byname(binding_name);
if (binding == IP_SET_INVALID_ID)
@@ -737,7 +734,7 @@
&ip);
DP("set %s, ip: %u.%u.%u.%u, binding %s",
set->name, HIPQUAD(ip), ip_set_list[binding]->name);
-
+
if (res >= 0)
res = (ip_set_find_in_hash(set->id, ip) == binding)
? -EEXIST : 0;
@@ -770,7 +767,7 @@
if (ip_set_list[i] == NULL) {
if (*id == IP_SET_INVALID_ID)
*id = *index = i;
- } else if (strcmp(name, ip_set_list[i]->name) == 0)
+ } else if (SETNAME_EQ(name, ip_set_list[i]->name))
/* Name clash */
return -EEXIST;
}
@@ -858,7 +855,7 @@
/*
* Here, we have a valid, constructed set. &ip_set_lock again,
- * find free id/index and check that it is not already in
+ * find free id/index and check that it is not already in
* ip_set_list.
*/
write_lock_bh(&ip_set_lock);
@@ -873,7 +870,7 @@
res = -ERANGE;
goto cleanup;
}
-
+
/*
* Finally! Add our shiny new set to the list, and be done.
*/
@@ -932,7 +929,7 @@
ip_set_destroy_set(index);
} else {
for (i = 0; i < ip_set_max; i++) {
- if (ip_set_list[i] != NULL
+ if (ip_set_list[i] != NULL
&& (atomic_read(&ip_set_list[i]->ref)))
return -EBUSY;
}
@@ -955,7 +952,7 @@
write_unlock_bh(&set->lock);
}
-/*
+/*
* Flush data in a set - or in all sets
*/
static int
@@ -982,9 +979,7 @@
write_lock_bh(&ip_set_lock);
for (i = 0; i < ip_set_max; i++) {
if (ip_set_list[i] != NULL
- && strncmp(ip_set_list[i]->name,
- name,
- IP_SET_MAXNAMELEN - 1) == 0) {
+ && SETNAME_EQ(ip_set_list[i]->name, name)) {
res = -EEXIST;
goto unlock;
}
@@ -1054,8 +1049,7 @@
ip_set_id_t id, void *data, int *used)
{
if (set_hash->id == id) {
- struct ip_set_hash_list *hash_list =
- (struct ip_set_hash_list *)(data + *used);
+ struct ip_set_hash_list *hash_list = data + *used;
hash_list->ip = set_hash->ip;
hash_list->binding = set_hash->binding;
@@ -1072,7 +1066,7 @@
struct ip_set_list *set_list;
/* Pointer to our header */
- set_list = (struct ip_set_list *) (data + *used);
+ set_list = data + *used;
DP("set: %s, used: %d %p %p", set->name, *used, data, data + *used);
@@ -1139,7 +1133,7 @@
struct ip_set_save *set_save;
/* Pointer to our header */
- set_save = (struct ip_set_save *) (data + *used);
+ set_save = data + *used;
/* Get and ensure header size */
if (*used + sizeof(struct ip_set_save) > len)
@@ -1147,7 +1141,7 @@
*used += sizeof(struct ip_set_save);
set = ip_set_list[index];
- DP("set: %s, used: %u(%u) %p %p", set->name, *used, len,
+ DP("set: %s, used: %u(%u) %p %p", set->name, *used, len,
data, data + *used);
read_lock_bh(&set->lock);
@@ -1196,8 +1190,7 @@
{
if (*res == 0
&& (id == IP_SET_INVALID_ID || set_hash->id == id)) {
- struct ip_set_hash_save *hash_save =
- (struct ip_set_hash_save *)(data + *used);
+ struct ip_set_hash_save *hash_save = data + *used;
/* Ensure bindings size */
if (*used + sizeof(struct ip_set_hash_save) > len) {
*res = -ENOMEM;
@@ -1224,7 +1217,7 @@
return -ENOMEM;
/* Marker */
- set_save = (struct ip_set_save *) (data + *used);
+ set_save = data + *used;
set_save->index = IP_SET_INVALID_ID;
set_save->header_size = 0;
set_save->members_size = 0;
@@ -1261,12 +1254,12 @@
/* Get and ensure header size */
if (used + sizeof(struct ip_set_restore) > len)
return line;
- set_restore = (struct ip_set_restore *) (data + used);
+ set_restore = data + used;
used += sizeof(struct ip_set_restore);
/* Ensure data size */
- if (used
- + set_restore->header_size
+ if (used
+ + set_restore->header_size
+ set_restore->members_size > len)
return line;
@@ -1304,7 +1297,7 @@
res = __ip_set_addip(index,
data + used + members_size,
set->type->reqsize);
- if (!(res == 0 || res == -EEXIST))
+ if (!(res == 0 || res == -EEXIST))
return line;
members_size += set->type->reqsize;
}
@@ -1325,7 +1318,7 @@
/* Get and ensure size */
if (used + sizeof(struct ip_set_hash_save) > len)
return line;
- hash_save = (struct ip_set_hash_save *) (data + used);
+ hash_save = data + used;
used += sizeof(struct ip_set_hash_save);
/* hash_save->id is used to store the index */
@@ -1341,7 +1334,7 @@
set = ip_set_list[hash_save->id];
/* Null valued IP means default binding */
if (hash_save->ip)
- res = ip_set_hash_add(set->id,
+ res = ip_set_hash_add(set->id,
hash_save->ip,
hash_save->binding);
else {
@@ -1408,8 +1401,7 @@
if (*op < IP_SET_OP_VERSION) {
/* Check the version at the beginning of operations */
- struct ip_set_req_version *req_version =
- (struct ip_set_req_version *) data;
+ struct ip_set_req_version *req_version = data;
if (req_version->version != IP_SET_PROTOCOL_VERSION) {
res = -EPROTO;
goto done;
@@ -1418,8 +1410,7 @@
switch (*op) {
case IP_SET_OP_CREATE:{
- struct ip_set_req_create *req_create
- = (struct ip_set_req_create *) data;
+ struct ip_set_req_create *req_create = data;
if (len < sizeof(struct ip_set_req_create)) {
ip_set_printk("short CREATE data (want >=%zu, got %u)",
@@ -1437,8 +1428,7 @@
goto done;
}
case IP_SET_OP_DESTROY:{
- struct ip_set_req_std *req_destroy
- = (struct ip_set_req_std *) data;
+ struct ip_set_req_std *req_destroy = data;
if (len != sizeof(struct ip_set_req_std)) {
ip_set_printk("invalid DESTROY data (want %zu, got %u)",
@@ -1446,7 +1436,7 @@
res = -EINVAL;
goto done;
}
- if (strcmp(req_destroy->name, IPSET_TOKEN_ALL) == 0) {
+ if (SETNAME_EQ(req_destroy->name, IPSET_TOKEN_ALL)) {
/* Destroy all sets */
index = IP_SET_INVALID_ID;
} else {
@@ -1463,8 +1453,7 @@
goto done;
}
case IP_SET_OP_FLUSH:{
- struct ip_set_req_std *req_flush =
- (struct ip_set_req_std *) data;
+ struct ip_set_req_std *req_flush = data;
if (len != sizeof(struct ip_set_req_std)) {
ip_set_printk("invalid FLUSH data (want %zu, got %u)",
@@ -1472,7 +1461,7 @@
res = -EINVAL;
goto done;
}
- if (strcmp(req_flush->name, IPSET_TOKEN_ALL) == 0) {
+ if (SETNAME_EQ(req_flush->name, IPSET_TOKEN_ALL)) {
/* Flush all sets */
index = IP_SET_INVALID_ID;
} else {
@@ -1488,8 +1477,7 @@
goto done;
}
case IP_SET_OP_RENAME:{
- struct ip_set_req_create *req_rename
- = (struct ip_set_req_create *) data;
+ struct ip_set_req_create *req_rename = data;
if (len != sizeof(struct ip_set_req_create)) {
ip_set_printk("invalid RENAME data (want %zu, got %u)",
@@ -1510,8 +1498,7 @@
goto done;
}
case IP_SET_OP_SWAP:{
- struct ip_set_req_create *req_swap
- = (struct ip_set_req_create *) data;
+ struct ip_set_req_create *req_swap = data;
ip_set_id_t to_index;
if (len != sizeof(struct ip_set_req_create)) {
@@ -1537,7 +1524,7 @@
res = ip_set_swap(index, to_index);
goto done;
}
- default:
+ default:
break; /* Set identified by id */
}
@@ -1554,10 +1541,10 @@
res = -EINVAL;
goto done;
}
- req_adt = (struct ip_set_req_adt *) data;
+ req_adt = data;
/* -U :all: :all:|:default: uses IP_SET_INVALID_ID */
- if (!(*op == IP_SET_OP_UNBIND_SET
+ if (!(*op == IP_SET_OP_UNBIND_SET
&& req_adt->index == IP_SET_INVALID_ID)) {
index = ip_set_find_byindex(req_adt->index);
if (index == IP_SET_INVALID_ID) {
@@ -1576,7 +1563,7 @@
return res;
}
-static int
+static int
ip_set_sockfn_get(struct sock *sk, int optval, void *user, int *len)
{
int res = 0;
@@ -1614,8 +1601,7 @@
if (*op < IP_SET_OP_VERSION) {
/* Check the version at the beginning of operations */
- struct ip_set_req_version *req_version =
- (struct ip_set_req_version *) data;
+ struct ip_set_req_version *req_version = data;
if (req_version->version != IP_SET_PROTOCOL_VERSION) {
res = -EPROTO;
goto done;
@@ -1624,8 +1610,7 @@
switch (*op) {
case IP_SET_OP_VERSION: {
- struct ip_set_req_version *req_version =
- (struct ip_set_req_version *) data;
+ struct ip_set_req_version *req_version = data;
if (*len != sizeof(struct ip_set_req_version)) {
ip_set_printk("invalid VERSION (want %zu, got %d)",
@@ -1641,8 +1626,7 @@
goto done;
}
case IP_SET_OP_GET_BYNAME: {
- struct ip_set_req_get_set *req_get
- = (struct ip_set_req_get_set *) data;
+ struct ip_set_req_get_set *req_get = data;
if (*len != sizeof(struct ip_set_req_get_set)) {
ip_set_printk("invalid GET_BYNAME (want %zu, got %d)",
@@ -1656,8 +1640,7 @@
goto copy;
}
case IP_SET_OP_GET_BYINDEX: {
- struct ip_set_req_get_set *req_get
- = (struct ip_set_req_get_set *) data;
+ struct ip_set_req_get_set *req_get = data;
if (*len != sizeof(struct ip_set_req_get_set)) {
ip_set_printk("invalid GET_BYINDEX (want %zu, got %d)",
@@ -1673,8 +1656,7 @@
goto copy;
}
case IP_SET_OP_ADT_GET: {
- struct ip_set_req_adt_get *req_get
- = (struct ip_set_req_adt_get *) data;
+ struct ip_set_req_adt_get *req_get = data;
if (*len != sizeof(struct ip_set_req_adt_get)) {
ip_set_printk("invalid ADT_GET (want %zu, got %d)",
@@ -1696,8 +1678,7 @@
goto copy;
}
case IP_SET_OP_MAX_SETS: {
- struct ip_set_req_max_sets *req_max_sets
- = (struct ip_set_req_max_sets *) data;
+ struct ip_set_req_max_sets *req_max_sets = data;
ip_set_id_t i;
if (*len != sizeof(struct ip_set_req_max_sets)) {
@@ -1707,11 +1688,11 @@
goto done;
}
- if (strcmp(req_max_sets->set.name, IPSET_TOKEN_ALL) == 0) {
+ if (SETNAME_EQ(req_max_sets->set.name, IPSET_TOKEN_ALL)) {
req_max_sets->set.index = IP_SET_INVALID_ID;
} else {
req_max_sets->set.name[IP_SET_MAXNAMELEN - 1] = '\0';
- req_max_sets->set.index =
+ req_max_sets->set.index =
ip_set_find_byname(req_max_sets->set.name);
if (req_max_sets->set.index == IP_SET_INVALID_ID) {
res = -ENOENT;
@@ -1726,10 +1707,9 @@
}
goto copy;
}
- case IP_SET_OP_LIST_SIZE:
+ case IP_SET_OP_LIST_SIZE:
case IP_SET_OP_SAVE_SIZE: {
- struct ip_set_req_setnames *req_setnames
- = (struct ip_set_req_setnames *) data;
+ struct ip_set_req_setnames *req_setnames = data;
struct ip_set_name_list *name_list;
struct ip_set *set;
ip_set_id_t i;
@@ -1747,8 +1727,7 @@
for (i = 0; i < ip_set_max; i++) {
if (ip_set_list[i] == NULL)
continue;
- name_list = (struct ip_set_name_list *)
- (data + used);
+ name_list = data + used;
used += sizeof(struct ip_set_name_list);
if (used > copylen) {
res = -EAGAIN;
@@ -1777,7 +1756,7 @@
+ set->type->header_size
+ set->type->list_members_size(set);
/* Sets are identified by id in the hash */
- FOREACH_HASH_DO(__set_hash_bindings_size_list,
+ FOREACH_HASH_DO(__set_hash_bindings_size_list,
set->id, &req_setnames->size);
break;
}
@@ -1800,8 +1779,7 @@
goto copy;
}
case IP_SET_OP_LIST: {
- struct ip_set_req_list *req_list
- = (struct ip_set_req_list *) data;
+ struct ip_set_req_list *req_list = data;
ip_set_id_t i;
int used;
@@ -1837,8 +1815,7 @@
goto copy;
}
case IP_SET_OP_SAVE: {
- struct ip_set_req_list *req_save
- = (struct ip_set_req_list *) data;
+ struct ip_set_req_list *req_save = data;
ip_set_id_t i;
int used;
@@ -1877,8 +1854,7 @@
goto copy;
}
case IP_SET_OP_RESTORE: {
- struct ip_set_req_setnames *req_restore
- = (struct ip_set_req_setnames *) data;
+ struct ip_set_req_setnames *req_restore = data;
int line;
if (*len < sizeof(struct ip_set_req_setnames)
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iphash.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -2,7 +2,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing an ip hash set */
@@ -37,7 +37,7 @@
static inline __u32
hash_id(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ struct ip_set_iphash *map = set->data;
__u32 id;
u_int16_t i;
ip_set_ip_t *elem;
@@ -68,8 +68,7 @@
testip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iphash *req =
- (struct ip_set_req_iphash *) data;
+ const struct ip_set_req_iphash *req = data;
if (size != sizeof(struct ip_set_req_iphash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -81,19 +80,19 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __testip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -130,8 +129,7 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iphash *req =
- (struct ip_set_req_iphash *) data;
+ const struct ip_set_req_iphash *req = data;
if (size != sizeof(struct ip_set_req_iphash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -139,23 +137,23 @@
size);
return -EINVAL;
}
- return __addip((struct ip_set_iphash *) set->data, req->ip, hash_ip);
+ return __addip(set->data, req->ip, hash_ip);
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __addip((struct ip_set_iphash *) set->data,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -163,7 +161,7 @@
static int retry(struct ip_set *set)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ struct ip_set_iphash *map = set->data;
ip_set_ip_t hash_ip, *elem;
void *members;
u_int32_t i, hashsize = map->hashsize;
@@ -185,7 +183,7 @@
"hashsize grows from %u to %u",
set->name, map->hashsize, hashsize);
- tmp = kmalloc(sizeof(struct ip_set_iphash)
+ tmp = kmalloc(sizeof(struct ip_set_iphash)
+ map->probes * sizeof(uint32_t), GFP_ATOMIC);
if (!tmp) {
DP("out of memory for %d bytes",
@@ -207,7 +205,7 @@
memcpy(tmp->initval, map->initval, map->probes * sizeof(uint32_t));
write_lock_bh(&set->lock);
- map = (struct ip_set_iphash *) set->data; /* Play safe */
+ map = set->data; /* Play safe */
for (i = 0; i < map->hashsize && res == 0; i++) {
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, i);
if (*elem)
@@ -237,7 +235,7 @@
static inline int
__delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ struct ip_set_iphash *map = set->data;
ip_set_ip_t id, *elem;
if (!ip)
@@ -258,8 +256,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iphash *req =
- (struct ip_set_req_iphash *) data;
+ const struct ip_set_req_iphash *req = data;
if (size != sizeof(struct ip_set_req_iphash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -271,19 +268,19 @@
}
static int
-delip_kernel(struct ip_set *set,
+delip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __delip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -291,8 +288,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
- struct ip_set_req_iphash_create *req =
- (struct ip_set_req_iphash_create *) data;
+ const struct ip_set_req_iphash_create *req = data;
struct ip_set_iphash *map;
uint16_t i;
@@ -313,7 +309,7 @@
return -ENOEXEC;
}
- map = kmalloc(sizeof(struct ip_set_iphash)
+ map = kmalloc(sizeof(struct ip_set_iphash)
+ req->probes * sizeof(uint32_t), GFP_KERNEL);
if (!map) {
DP("out of memory for %d bytes",
@@ -341,7 +337,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ struct ip_set_iphash *map = set->data;
harray_free(map->members);
kfree(map);
@@ -351,16 +347,15 @@
static void flush(struct ip_set *set)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ struct ip_set_iphash *map = set->data;
harray_flush(map->members, map->hashsize, sizeof(ip_set_ip_t));
map->elements = 0;
}
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
- struct ip_set_req_iphash_create *header =
- (struct ip_set_req_iphash_create *) data;
+ struct ip_set_iphash *map = set->data;
+ struct ip_set_req_iphash_create *header = data;
header->hashsize = map->hashsize;
header->probes = map->probes;
@@ -370,14 +365,14 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ const struct ip_set_iphash *map = set->data;
return (map->hashsize * sizeof(ip_set_ip_t));
}
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_iphash *map = (struct ip_set_iphash *) set->data;
+ const struct ip_set_iphash *map = set->data;
ip_set_ip_t i, *elem;
for (i = 0; i < map->hashsize; i++) {
@@ -416,6 +411,7 @@
static int __init ip_set_iphash_init(void)
{
+ init_max_page_size();
return ip_set_register_set_type(&ip_set_iphash);
}
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipmap.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipmap.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipmap.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -4,7 +4,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing an IP set type: the single bitmap type */
@@ -31,7 +31,7 @@
static inline int
__testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ struct ip_set_ipmap *map = set->data;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
@@ -46,8 +46,7 @@
testip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipmap *req =
- (struct ip_set_req_ipmap *) data;
+ const struct ip_set_req_ipmap *req = data;
if (size != sizeof(struct ip_set_req_ipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -59,7 +58,7 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -68,10 +67,10 @@
int res = __testip(set,
ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -81,7 +80,7 @@
static inline int
__addip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ struct ip_set_ipmap *map = set->data;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
@@ -98,8 +97,7 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipmap *req =
- (struct ip_set_req_ipmap *) data;
+ const struct ip_set_req_ipmap *req = data;
if (size != sizeof(struct ip_set_req_ipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -112,28 +110,28 @@
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __addip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
}
-static inline int
+static inline int
__delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ struct ip_set_ipmap *map = set->data;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
@@ -150,8 +148,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipmap *req =
- (struct ip_set_req_ipmap *) data;
+ const struct ip_set_req_ipmap *req = data;
if (size != sizeof(struct ip_set_req_ipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -170,12 +167,12 @@
unsigned char index)
{
return __delip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -184,8 +181,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
int newbytes;
- struct ip_set_req_ipmap_create *req =
- (struct ip_set_req_ipmap_create *) data;
+ const struct ip_set_req_ipmap_create *req = data;
struct ip_set_ipmap *map;
if (size != sizeof(struct ip_set_req_ipmap_create)) {
@@ -256,7 +252,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ struct ip_set_ipmap *map = set->data;
kfree(map->members);
kfree(map);
@@ -266,15 +262,14 @@
static void flush(struct ip_set *set)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ struct ip_set_ipmap *map = set->data;
memset(map->members, 0, bitmap_bytes(0, map->sizeid - 1));
}
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
- struct ip_set_req_ipmap_create *header =
- (struct ip_set_req_ipmap_create *) data;
+ const struct ip_set_ipmap *map = set->data;
+ struct ip_set_req_ipmap_create *header = data;
header->from = map->first_ip;
header->to = map->last_ip;
@@ -283,14 +278,14 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ const struct ip_set_ipmap *map = set->data;
return bitmap_bytes(0, map->sizeid - 1);
}
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_ipmap *map = (struct ip_set_ipmap *) set->data;
+ const struct ip_set_ipmap *map = set->data;
int bytes = bitmap_bytes(0, map->sizeid - 1);
memcpy(data, map->members, bytes);
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_ipporthash.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -2,7 +2,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing an ip+port hash set */
@@ -94,8 +94,7 @@
hash_id(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t port,
ip_set_ip_t *hash_ip)
{
- struct ip_set_ipporthash *map =
- (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
__u32 id;
u_int16_t i;
ip_set_ip_t *elem;
@@ -120,7 +119,7 @@
__testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t port,
ip_set_ip_t *hash_ip)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
@@ -132,8 +131,7 @@
testip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipporthash *req =
- (struct ip_set_req_ipporthash *) data;
+ const struct ip_set_req_ipporthash *req = data;
if (size != sizeof(struct ip_set_req_ipporthash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -145,7 +143,7 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -169,18 +167,18 @@
NIPQUAD(skb->nh.iph->daddr));
#endif
DP("flag %s port %u",
- flags[index+1] & IPSET_SRC ? "SRC" : "DST",
+ flags[index+1] & IPSET_SRC ? "SRC" : "DST",
port);
if (port == INVALID_PORT)
return 0;
res = __testip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
port,
@@ -229,8 +227,7 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipporthash *req =
- (struct ip_set_req_ipporthash *) data;
+ const struct ip_set_req_ipporthash *req = data;
if (size != sizeof(struct ip_set_req_ipporthash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -238,12 +235,11 @@
size);
return -EINVAL;
}
- return __addip((struct ip_set_ipporthash *) set->data,
- req->ip, req->port, hash_ip);
+ return __addip(set->data, req->ip, req->port, hash_ip);
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -265,19 +261,19 @@
NIPQUAD(skb->nh.iph->saddr),
NIPQUAD(skb->nh.iph->daddr));
#endif
- DP("flag %s port %u",
- flags[index+1] & IPSET_SRC ? "SRC" : "DST",
+ DP("flag %s port %u",
+ flags[index+1] & IPSET_SRC ? "SRC" : "DST",
port);
if (port == INVALID_PORT)
return -EINVAL;
- return __addip((struct ip_set_ipporthash *) set->data,
- ntohl(flags[index] & IPSET_SRC
+ return __addip(set->data,
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
port,
@@ -286,7 +282,7 @@
static int retry(struct ip_set *set)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
ip_set_ip_t *elem;
void *members;
u_int32_t i, hashsize = map->hashsize;
@@ -308,7 +304,7 @@
"hashsize grows from %u to %u",
set->name, map->hashsize, hashsize);
- tmp = kmalloc(sizeof(struct ip_set_ipporthash)
+ tmp = kmalloc(sizeof(struct ip_set_ipporthash)
+ map->probes * sizeof(uint32_t), GFP_ATOMIC);
if (!tmp) {
DP("out of memory for %d bytes",
@@ -331,7 +327,7 @@
memcpy(tmp->initval, map->initval, map->probes * sizeof(uint32_t));
write_lock_bh(&set->lock);
- map = (struct ip_set_ipporthash *) set->data; /* Play safe */
+ map = set->data; /* Play safe */
for (i = 0; i < map->hashsize && res == 0; i++) {
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, i);
if (*elem)
@@ -362,7 +358,7 @@
__delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t port,
ip_set_ip_t *hash_ip)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
ip_set_ip_t id;
ip_set_ip_t *elem;
@@ -385,8 +381,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_ipporthash *req =
- (struct ip_set_req_ipporthash *) data;
+ const struct ip_set_req_ipporthash *req = data;
if (size != sizeof(struct ip_set_req_ipporthash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -398,7 +393,7 @@
}
static int
-delip_kernel(struct ip_set *set,
+delip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -421,18 +416,18 @@
NIPQUAD(skb->nh.iph->daddr));
#endif
DP("flag %s port %u",
- flags[index+1] & IPSET_SRC ? "SRC" : "DST",
+ flags[index+1] & IPSET_SRC ? "SRC" : "DST",
port);
if (port == INVALID_PORT)
return -EINVAL;
return __delip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
port,
@@ -441,8 +436,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
- struct ip_set_req_ipporthash_create *req =
- (struct ip_set_req_ipporthash_create *) data;
+ const struct ip_set_req_ipporthash_create *req = data;
struct ip_set_ipporthash *map;
uint16_t i;
@@ -463,7 +457,7 @@
return -ENOEXEC;
}
- map = kmalloc(sizeof(struct ip_set_ipporthash)
+ map = kmalloc(sizeof(struct ip_set_ipporthash)
+ req->probes * sizeof(uint32_t), GFP_KERNEL);
if (!map) {
DP("out of memory for %d bytes",
@@ -492,7 +486,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
harray_free(map->members);
kfree(map);
@@ -502,16 +496,15 @@
static void flush(struct ip_set *set)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ struct ip_set_ipporthash *map = set->data;
harray_flush(map->members, map->hashsize, sizeof(ip_set_ip_t));
map->elements = 0;
}
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
- struct ip_set_req_ipporthash_create *header =
- (struct ip_set_req_ipporthash_create *) data;
+ const struct ip_set_ipporthash *map = set->data;
+ struct ip_set_req_ipporthash_create *header = data;
header->hashsize = map->hashsize;
header->probes = map->probes;
@@ -522,14 +515,14 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ const struct ip_set_ipporthash *map = set->data;
return (map->hashsize * sizeof(ip_set_ip_t));
}
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_ipporthash *map = (struct ip_set_ipporthash *) set->data;
+ const struct ip_set_ipporthash *map = set->data;
ip_set_ip_t i, *elem;
for (i = 0; i < map->hashsize; i++) {
@@ -568,6 +561,7 @@
static int __init ip_set_ipporthash_init(void)
{
+ init_max_page_size();
return ip_set_register_set_type(&ip_set_ipporthash);
}
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptree.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptree.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptree.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -2,7 +2,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing an IP set type: the iptree type */
@@ -31,8 +31,8 @@
/* Garbage collection interval in seconds: */
#define IPTREE_GC_TIME 5*60
-/* Sleep so many milliseconds before trying again
- * to delete the gc timer at destroying/flushing a set */
+/* Sleep so many milliseconds before trying again
+ * to delete the gc timer at destroying/flushing a set */
#define IPTREE_DESTROY_SLEEP 100
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
@@ -71,7 +71,7 @@
static inline int
__testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -96,8 +96,7 @@
testip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iptree *req =
- (struct ip_set_req_iptree *) data;
+ const struct ip_set_req_iptree *req = data;
if (size != sizeof(struct ip_set_req_iptree)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -109,7 +108,7 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -128,12 +127,12 @@
#endif
res = __testip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -159,7 +158,7 @@
__addip(struct ip_set *set, ip_set_ip_t ip, unsigned int timeout,
ip_set_ip_t *hash_ip)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -194,9 +193,8 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
- struct ip_set_req_iptree *req =
- (struct ip_set_req_iptree *) data;
+ struct ip_set_iptree *map = set->data;
+ const struct ip_set_req_iptree *req = data;
if (size != sizeof(struct ip_set_req_iptree)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -211,21 +209,21 @@
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
return __addip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
map->timeout,
@@ -239,10 +237,10 @@
return -EEXIST; \
} while (0)
-static inline int
+static inline int
__delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -269,8 +267,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iptree *req =
- (struct ip_set_req_iptree *) data;
+ const struct ip_set_req_iptree *req = data;
if (size != sizeof(struct ip_set_req_iptree)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -282,19 +279,19 @@
}
static int
-delip_kernel(struct ip_set *set,
+delip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __delip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -310,8 +307,8 @@
static void ip_tree_gc(unsigned long ul_set)
{
- struct ip_set *set = (void *) ul_set;
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set *set = (struct ip_set *) ul_set;
+ struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -380,7 +377,7 @@
static inline void init_gc_timer(struct ip_set *set)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
/* Even if there is no timeout for the entries,
* we still have to call gc because delete
@@ -395,8 +392,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
- struct ip_set_req_iptree_create *req =
- (struct ip_set_req_iptree_create *) data;
+ const struct ip_set_req_iptree_create *req = data;
struct ip_set_iptree *map;
if (size != sizeof(struct ip_set_req_iptree_create)) {
@@ -443,7 +439,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
/* gc might be running */
while (!del_timer(&map->gc))
@@ -455,7 +451,7 @@
static void flush(struct ip_set *set)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ struct ip_set_iptree *map = set->data;
unsigned int timeout = map->timeout;
/* gc might be running */
@@ -470,16 +466,15 @@
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
- struct ip_set_req_iptree_create *header =
- (struct ip_set_req_iptree_create *) data;
+ const struct ip_set_iptree *map = set->data;
+ struct ip_set_req_iptree_create *header = data;
header->timeout = map->timeout;
}
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ const struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -504,7 +499,7 @@
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_iptree *map = (struct ip_set_iptree *) set->data;
+ const struct ip_set_iptree *map = set->data;
struct ip_set_iptreeb *btree;
struct ip_set_iptreec *ctree;
struct ip_set_iptreed *dtree;
@@ -518,9 +513,9 @@
for (d = 0; d < 256; d++) {
if (dtree->expires[d]
&& (!map->timeout || time_after(dtree->expires[d], jiffies))) {
- entry = (struct ip_set_req_iptree *)(data + offset);
+ entry = data + offset;
entry->ip = ((a << 24) | (b << 16) | (c << 8) | d);
- entry->timeout = !map->timeout ? 0
+ entry->timeout = !map->timeout ? 0
: (dtree->expires[d] - jiffies)/HZ;
offset += sizeof(struct ip_set_req_iptree);
}
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptreemap.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptreemap.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_iptreemap.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -6,12 +6,13 @@
*/
/* This modules implements the iptreemap ipset type. It uses bitmaps to
- * represent every single IPv4 address as a single bit. The bitmaps are managed
- * in a tree structure, where the first three octets of an addresses are used
- * as an index to find the bitmap and the last octet is used as the bit number.
+ * represent every single IPv4 address as a bit. The bitmaps are managed in a
+ * tree structure, where the first three octets of an address are used as an
+ * index to find the bitmap and the last octet is used as the bit number.
*/
#include <linux/version.h>
+#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/ip.h>
#include <linux/skbuff.h>
@@ -186,9 +187,6 @@
#define LOOP_WALK_END_COUNT() \
}
-#define MIN(a, b) (a < b ? a : b)
-#define MAX(a, b) (a > b ? a : b)
-
#define GETVALUE1(a, a1, b1, r) \
(a == a1 ? b1 : r)
@@ -260,7 +258,7 @@
static inline int
__testip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -280,7 +278,7 @@
static int
testip(struct ip_set *set, const void *data, size_t size, ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iptreemap *req = (struct ip_set_req_iptreemap *) data;
+ const struct ip_set_req_iptreemap *req = data;
if (size != sizeof(struct ip_set_req_iptreemap)) {
ip_set_printk("data length wrong (want %zu, have %zu)", sizeof(struct ip_set_req_iptreemap), size);
@@ -295,13 +293,13 @@
{
int res;
- res = __testip(set,
- ntohl(flags[index] & IPSET_SRC
+ res = __testip(set,
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -326,10 +324,10 @@
ADDIP_WALK(btree, b, ctree, struct ip_set_iptreemap_c, cachep_c, fullbitmap_c);
ADDIP_WALK(ctree, c, dtree, struct ip_set_iptreemap_d, cachep_d, fullbitmap_d);
- if (test_and_set_bit(d, (void *) dtree->bitmap))
+ if (__test_and_set_bit(d, (void *) dtree->bitmap))
return -EEXIST;
- set_bit(b, (void *) btree->dirty);
+ __set_bit(b, (void *) btree->dirty);
return 0;
}
@@ -337,7 +335,7 @@
static inline int
__addip_range(struct ip_set *set, ip_set_ip_t start, ip_set_ip_t end, ip_set_ip_t *hash_ip)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -358,8 +356,8 @@
ADDIP_RANGE_LOOP(btree, b, GETVALUE1(a, a1, b1, 0), GETVALUE1(a, a2, b2, 255), CHECK2(a, b, a1, a2, b1, b2, c1, c2, d1, d2), ctree, fullbitmap_c, cachep_c, free_c) {
ADDIP_RANGE_LOOP(ctree, c, GETVALUE2(a, b, a1, b1, c1, 0), GETVALUE2(a, b, a2, b2, c2, 255), CHECK3(a, b, c, a1, a2, b1, b2, c1, c2, d1, d2), dtree, fullbitmap_d, cachep_d, free_d) {
for (d = GETVALUE3(a, b, c, a1, b1, c1, d1, 0); d <= GETVALUE3(a, b, c, a2, b2, c2, d2, 255); d++)
- set_bit(d, (void *) dtree->bitmap);
- set_bit(b, (void *) btree->dirty);
+ __set_bit(d, (void *) dtree->bitmap);
+ __set_bit(b, (void *) btree->dirty);
} ADDIP_RANGE_LOOP_END();
} ADDIP_RANGE_LOOP_END();
} ADDIP_RANGE_LOOP_END();
@@ -370,14 +368,14 @@
static int
addip(struct ip_set *set, const void *data, size_t size, ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iptreemap *req = (struct ip_set_req_iptreemap *) data;
+ const struct ip_set_req_iptreemap *req = data;
if (size != sizeof(struct ip_set_req_iptreemap)) {
ip_set_printk("data length wrong (want %zu, have %zu)", sizeof(struct ip_set_req_iptreemap), size);
return -EINVAL;
}
- return __addip_range(set, MIN(req->start, req->end), MAX(req->start, req->end), hash_ip);
+ return __addip_range(set, min(req->start, req->end), max(req->start, req->end), hash_ip);
}
static int
@@ -385,12 +383,12 @@
{
return __addip_single(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -399,7 +397,7 @@
static inline int
__delip_single(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip, unsigned int __nocast flags)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -413,10 +411,10 @@
DELIP_WALK(btree, b, ctree, cachep_c, fullbitmap_c, flags);
DELIP_WALK(ctree, c, dtree, cachep_d, fullbitmap_d, flags);
- if (!test_and_clear_bit(d, (void *) dtree->bitmap))
+ if (!__test_and_clear_bit(d, (void *) dtree->bitmap))
return -EEXIST;
- set_bit(b, (void *) btree->dirty);
+ __set_bit(b, (void *) btree->dirty);
return 0;
}
@@ -424,7 +422,7 @@
static inline int
__delip_range(struct ip_set *set, ip_set_ip_t start, ip_set_ip_t end, ip_set_ip_t *hash_ip, unsigned int __nocast flags)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -445,8 +443,8 @@
DELIP_RANGE_LOOP(btree, b, GETVALUE1(a, a1, b1, 0), GETVALUE1(a, a2, b2, 255), CHECK2(a, b, a1, a2, b1, b2, c1, c2, d1, d2), ctree, fullbitmap_c, cachep_c, free_c, flags) {
DELIP_RANGE_LOOP(ctree, c, GETVALUE2(a, b, a1, b1, c1, 0), GETVALUE2(a, b, a2, b2, c2, 255), CHECK3(a, b, c, a1, a2, b1, b2, c1, c2, d1, d2), dtree, fullbitmap_d, cachep_d, free_d, flags) {
for (d = GETVALUE3(a, b, c, a1, b1, c1, d1, 0); d <= GETVALUE3(a, b, c, a2, b2, c2, d2, 255); d++)
- clear_bit(d, (void *) dtree->bitmap);
- set_bit(b, (void *) btree->dirty);
+ __clear_bit(d, (void *) dtree->bitmap);
+ __set_bit(b, (void *) btree->dirty);
} DELIP_RANGE_LOOP_END();
} DELIP_RANGE_LOOP_END();
} DELIP_RANGE_LOOP_END();
@@ -457,26 +455,26 @@
static int
delip(struct ip_set *set, const void *data, size_t size, ip_set_ip_t *hash_ip)
{
- struct ip_set_req_iptreemap *req = (struct ip_set_req_iptreemap *) data;
+ const struct ip_set_req_iptreemap *req = data;
if (size != sizeof(struct ip_set_req_iptreemap)) {
ip_set_printk("data length wrong (want %zu, have %zu)", sizeof(struct ip_set_req_iptreemap), size);
return -EINVAL;
}
- return __delip_range(set, MIN(req->start, req->end), MAX(req->start, req->end), hash_ip, GFP_KERNEL);
+ return __delip_range(set, min(req->start, req->end), max(req->start, req->end), hash_ip, GFP_KERNEL);
}
static int
delip_kernel(struct ip_set *set, const struct sk_buff *skb, ip_set_ip_t *hash_ip, const u_int32_t *flags, unsigned char index)
{
- return __delip_single(set,
- ntohl(flags[index] & IPSET_SRC
+ return __delip_single(set,
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip,
@@ -505,7 +503,7 @@
gc(unsigned long addr)
{
struct ip_set *set = (struct ip_set *) addr;
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -516,7 +514,7 @@
LOOP_WALK_BEGIN_GC(map, a, btree, fullbitmap_b, cachep_b, i) {
LOOP_WALK_BEGIN_GC(btree, b, ctree, fullbitmap_c, cachep_c, j) {
- if (!test_and_clear_bit(b, (void *) btree->dirty))
+ if (!__test_and_clear_bit(b, (void *) btree->dirty))
continue;
LOOP_WALK_BEGIN_GC(ctree, c, dtree, fullbitmap_d, cachep_d, k) {
switch (bitmap_status(dtree)) {
@@ -544,7 +542,7 @@
static inline void
init_gc_timer(struct ip_set *set)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
init_timer(&map->gc);
map->gc.data = (unsigned long) set;
@@ -555,7 +553,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
- struct ip_set_req_iptreemap_create *req = (struct ip_set_req_iptreemap_create *) data;
+ const struct ip_set_req_iptreemap_create *req = data;
struct ip_set_iptreemap *map;
if (size != sizeof(struct ip_set_req_iptreemap_create)) {
@@ -588,7 +586,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
while (!del_timer(&map->gc))
msleep(IPTREEMAP_DESTROY_SLEEP);
@@ -601,7 +599,7 @@
static void flush(struct ip_set *set)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
while (!del_timer(&map->gc))
msleep(IPTREEMAP_DESTROY_SLEEP);
@@ -615,15 +613,15 @@
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
- struct ip_set_req_iptreemap_create *header = (struct ip_set_req_iptreemap_create *) data;
+ struct ip_set_iptreemap *map = set->data;
+ struct ip_set_req_iptreemap_create *header = data;
header->gc_interval = map->gc_interval;
}
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -652,7 +650,7 @@
static inline size_t add_member(void *data, size_t offset, ip_set_ip_t start, ip_set_ip_t end)
{
- struct ip_set_req_iptreemap *entry = (struct ip_set_req_iptreemap *) (data + offset);
+ struct ip_set_req_iptreemap *entry = data + offset;
entry->start = start;
entry->end = end;
@@ -662,7 +660,7 @@
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_iptreemap *map = (struct ip_set_iptreemap *) set->data;
+ struct ip_set_iptreemap *map = set->data;
struct ip_set_iptreemap_b *btree;
struct ip_set_iptreemap_c *ctree;
struct ip_set_iptreemap_d *dtree;
@@ -728,12 +726,12 @@
int a;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
- cachep_b = kmem_cache_create("ip_set_iptreemap_b",
- sizeof(struct ip_set_iptreemap_b),
+ cachep_b = kmem_cache_create("ip_set_iptreemap_b",
+ sizeof(struct ip_set_iptreemap_b),
0, 0, NULL);
#else
- cachep_b = kmem_cache_create("ip_set_iptreemap_b",
- sizeof(struct ip_set_iptreemap_b),
+ cachep_b = kmem_cache_create("ip_set_iptreemap_b",
+ sizeof(struct ip_set_iptreemap_b),
0, 0, NULL, NULL);
#endif
if (!cachep_b) {
@@ -742,11 +740,11 @@
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
- cachep_c = kmem_cache_create("ip_set_iptreemap_c",
+ cachep_c = kmem_cache_create("ip_set_iptreemap_c",
sizeof(struct ip_set_iptreemap_c),
0, 0, NULL);
#else
- cachep_c = kmem_cache_create("ip_set_iptreemap_c",
+ cachep_c = kmem_cache_create("ip_set_iptreemap_c",
sizeof(struct ip_set_iptreemap_c),
0, 0, NULL, NULL);
#endif
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_macipmap.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -5,7 +5,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing an IP set type: the macipmap type */
@@ -29,9 +29,9 @@
static int
testip(struct ip_set *set, const void *data, size_t size, ip_set_ip_t *hash_ip)
{
- struct ip_set_macipmap *map = (struct ip_set_macipmap *) set->data;
- struct ip_set_macip *table = (struct ip_set_macip *) map->members;
- struct ip_set_req_macipmap *req = (struct ip_set_req_macipmap *) data;
+ struct ip_set_macipmap *map = set->data;
+ struct ip_set_macip *table = map->members;
+ const struct ip_set_req_macipmap *req = data;
if (size != sizeof(struct ip_set_req_macipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -57,21 +57,19 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
- struct ip_set_macip *table =
- (struct ip_set_macip *) map->members;
+ struct ip_set_macipmap *map = set->data;
+ struct ip_set_macip *table = map->members;
ip_set_ip_t ip;
ip = ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr);
#else
? skb->nh.iph->saddr
@@ -105,17 +103,15 @@
/* returns 0 on success */
static inline int
-__addip(struct ip_set *set,
- ip_set_ip_t ip, unsigned char *ethernet, ip_set_ip_t *hash_ip)
+__addip(struct ip_set *set,
+ ip_set_ip_t ip, const unsigned char *ethernet, ip_set_ip_t *hash_ip)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
- struct ip_set_macip *table =
- (struct ip_set_macip *) map->members;
+ struct ip_set_macipmap *map = set->data;
+ struct ip_set_macip *table = map->members;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- if (test_and_set_bit(IPSET_MACIP_ISSET,
+ if (test_and_set_bit(IPSET_MACIP_ISSET,
(void *) &table[ip - map->first_ip].flags))
return -EEXIST;
@@ -129,8 +125,7 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_macipmap *req =
- (struct ip_set_req_macipmap *) data;
+ const struct ip_set_req_macipmap *req = data;
if (size != sizeof(struct ip_set_req_macipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -142,7 +137,7 @@
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
@@ -152,7 +147,7 @@
ip = ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr);
#else
? skb->nh.iph->saddr
@@ -174,14 +169,12 @@
static inline int
__delip(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
- struct ip_set_macip *table =
- (struct ip_set_macip *) map->members;
+ struct ip_set_macipmap *map = set->data;
+ struct ip_set_macip *table = map->members;
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- if (!test_and_clear_bit(IPSET_MACIP_ISSET,
+ if (!test_and_clear_bit(IPSET_MACIP_ISSET,
(void *)&table[ip - map->first_ip].flags))
return -EEXIST;
@@ -194,8 +187,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_macipmap *req =
- (struct ip_set_req_macipmap *) data;
+ const struct ip_set_req_macipmap *req = data;
if (size != sizeof(struct ip_set_req_macipmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -214,27 +206,26 @@
unsigned char index)
{
return __delip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
}
-static inline size_t members_size(ip_set_id_t from, ip_set_id_t to)
+static inline size_t members_size(ip_set_ip_t from, ip_set_ip_t to)
{
return (size_t)((to - from + 1) * sizeof(struct ip_set_macip));
}
static int create(struct ip_set *set, const void *data, size_t size)
{
- int newbytes;
- struct ip_set_req_macipmap_create *req =
- (struct ip_set_req_macipmap_create *) data;
+ size_t newbytes;
+ const struct ip_set_req_macipmap_create *req = data;
struct ip_set_macipmap *map;
if (size != sizeof(struct ip_set_req_macipmap_create)) {
@@ -283,8 +274,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
+ struct ip_set_macipmap *map = set->data;
ip_set_free(map->members, members_size(map->first_ip, map->last_ip));
kfree(map);
@@ -294,17 +284,14 @@
static void flush(struct ip_set *set)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
+ struct ip_set_macipmap *map = set->data;
memset(map->members, 0, members_size(map->first_ip, map->last_ip));
}
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
- struct ip_set_req_macipmap_create *header =
- (struct ip_set_req_macipmap_create *) data;
+ const struct ip_set_macipmap *map = set->data;
+ struct ip_set_req_macipmap_create *header = data;
DP("list_header %x %x %u", map->first_ip, map->last_ip,
map->flags);
@@ -316,8 +303,7 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
+ const struct ip_set_macipmap *map = set->data;
DP("%u", members_size(map->first_ip, map->last_ip));
return members_size(map->first_ip, map->last_ip);
@@ -325,8 +311,7 @@
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_macipmap *map =
- (struct ip_set_macipmap *) set->data;
+ const struct ip_set_macipmap *map = set->data;
int bytes = members_size(map->first_ip, map->last_ip);
@@ -361,6 +346,7 @@
static int __init ip_set_macipmap_init(void)
{
+ init_max_page_size();
return ip_set_register_set_type(&ip_set_macipmap);
}
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_nethash.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -2,7 +2,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing a cidr nethash set */
@@ -59,7 +59,7 @@
static inline __u32
hash_id(struct ip_set *set, ip_set_ip_t ip, ip_set_ip_t *hash_ip)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
__u32 id = UINT_MAX;
int i;
@@ -75,7 +75,7 @@
__testip_cidr(struct ip_set *set, ip_set_ip_t ip, unsigned char cidr,
ip_set_ip_t *hash_ip)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
return (ip && hash_id_cidr(map, ip, cidr, hash_ip) != UINT_MAX);
}
@@ -90,8 +90,7 @@
testip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_nethash *req =
- (struct ip_set_req_nethash *) data;
+ const struct ip_set_req_nethash *req = data;
if (size != sizeof(struct ip_set_req_nethash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -104,19 +103,19 @@
}
static int
-testip_kernel(struct ip_set *set,
+testip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
return __testip(set,
- ntohl(flags[index] & IPSET_SRC
+ ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr),
#else
- ? skb->nh.iph->saddr
+ ? skb->nh.iph->saddr
: skb->nh.iph->daddr),
#endif
hash_ip);
@@ -180,8 +179,7 @@
addip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_nethash *req =
- (struct ip_set_req_nethash *) data;
+ const struct ip_set_req_nethash *req = data;
int ret;
if (size != sizeof(struct ip_set_req_nethash)) {
@@ -190,28 +188,26 @@
size);
return -EINVAL;
}
- ret = __addip((struct ip_set_nethash *) set->data,
- req->ip, req->cidr, hash_ip);
+ ret = __addip(set->data, req->ip, req->cidr, hash_ip);
if (ret == 0)
- update_cidr_sizes((struct ip_set_nethash *) set->data,
- req->cidr);
+ update_cidr_sizes(set->data, req->cidr);
return ret;
}
static int
-addip_kernel(struct ip_set *set,
+addip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
int ret = -ERANGE;
- ip_set_ip_t ip = ntohl(flags[index] & IPSET_SRC
+ ip_set_ip_t ip = ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr);
#else
? skb->nh.iph->saddr
@@ -226,7 +222,7 @@
static int retry(struct ip_set *set)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
ip_set_ip_t *elem;
void *members;
u_int32_t i, hashsize = map->hashsize;
@@ -248,7 +244,7 @@
"hashsize grows from %u to %u",
set->name, map->hashsize, hashsize);
- tmp = kmalloc(sizeof(struct ip_set_nethash)
+ tmp = kmalloc(sizeof(struct ip_set_nethash)
+ map->probes * sizeof(uint32_t), GFP_ATOMIC);
if (!tmp) {
DP("out of memory for %d bytes",
@@ -270,7 +266,7 @@
memcpy(tmp->cidr, map->cidr, 30 * sizeof(unsigned char));
write_lock_bh(&set->lock);
- map = (struct ip_set_nethash *) set->data; /* Play safe */
+ map = set->data; /* Play safe */
for (i = 0; i < map->hashsize && res == 0; i++) {
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, i);
if (*elem)
@@ -320,8 +316,7 @@
delip(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_ip)
{
- struct ip_set_req_nethash *req =
- (struct ip_set_req_nethash *) data;
+ const struct ip_set_req_nethash *req = data;
if (size != sizeof(struct ip_set_req_nethash)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -330,22 +325,21 @@
return -EINVAL;
}
/* TODO: no garbage collection in map->cidr */
- return __delip((struct ip_set_nethash *) set->data,
- req->ip, req->cidr, hash_ip);
+ return __delip(set->data, req->ip, req->cidr, hash_ip);
}
static int
-delip_kernel(struct ip_set *set,
+delip_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_ip,
const u_int32_t *flags,
unsigned char index)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
int ret = -ERANGE;
- ip_set_ip_t ip = ntohl(flags[index] & IPSET_SRC
+ ip_set_ip_t ip = ntohl(flags[index] & IPSET_SRC
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- ? ip_hdr(skb)->saddr
+ ? ip_hdr(skb)->saddr
: ip_hdr(skb)->daddr);
#else
? skb->nh.iph->saddr
@@ -360,8 +354,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
- struct ip_set_req_nethash_create *req =
- (struct ip_set_req_nethash_create *) data;
+ const struct ip_set_req_nethash_create *req = data;
struct ip_set_nethash *map;
uint16_t i;
@@ -409,7 +402,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
harray_free(map->members);
kfree(map);
@@ -419,7 +412,7 @@
static void flush(struct ip_set *set)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
harray_flush(map->members, map->hashsize, sizeof(ip_set_ip_t));
memset(map->cidr, 0, 30 * sizeof(unsigned char));
map->elements = 0;
@@ -427,9 +420,8 @@
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
- struct ip_set_req_nethash_create *header =
- (struct ip_set_req_nethash_create *) data;
+ const struct ip_set_nethash *map = set->data;
+ struct ip_set_req_nethash_create *header = data;
header->hashsize = map->hashsize;
header->probes = map->probes;
@@ -438,14 +430,14 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ struct ip_set_nethash *map = set->data;
return (map->hashsize * sizeof(ip_set_ip_t));
}
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_nethash *map = (struct ip_set_nethash *) set->data;
+ const struct ip_set_nethash *map = set->data;
ip_set_ip_t i, *elem;
for (i = 0; i < map->hashsize; i++) {
@@ -484,6 +476,7 @@
static int __init ip_set_nethash_init(void)
{
+ init_max_page_size();
return ip_set_register_set_type(&ip_set_nethash);
}
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_portmap.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_portmap.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ip_set_portmap.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -2,7 +2,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module implementing a port set type as a bitmap */
@@ -78,7 +78,7 @@
static inline int
__testport(struct ip_set *set, ip_set_ip_t port, ip_set_ip_t *hash_port)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ struct ip_set_portmap *map = set->data;
if (port < map->first_port || port > map->last_port)
return -ERANGE;
@@ -92,8 +92,7 @@
testport(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_port)
{
- struct ip_set_req_portmap *req =
- (struct ip_set_req_portmap *) data;
+ const struct ip_set_req_portmap *req = data;
if (size != sizeof(struct ip_set_req_portmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -105,7 +104,7 @@
}
static int
-testport_kernel(struct ip_set *set,
+testport_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_port,
const u_int32_t *flags,
@@ -126,7 +125,7 @@
static inline int
__addport(struct ip_set *set, ip_set_ip_t port, ip_set_ip_t *hash_port)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ struct ip_set_portmap *map = set->data;
if (port < map->first_port || port > map->last_port)
return -ERANGE;
@@ -142,8 +141,7 @@
addport(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_port)
{
- struct ip_set_req_portmap *req =
- (struct ip_set_req_portmap *) data;
+ const struct ip_set_req_portmap *req = data;
if (size != sizeof(struct ip_set_req_portmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -155,7 +153,7 @@
}
static int
-addport_kernel(struct ip_set *set,
+addport_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_port,
const u_int32_t *flags,
@@ -172,7 +170,7 @@
static inline int
__delport(struct ip_set *set, ip_set_ip_t port, ip_set_ip_t *hash_port)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ struct ip_set_portmap *map = set->data;
if (port < map->first_port || port > map->last_port)
return -ERANGE;
@@ -188,8 +186,7 @@
delport(struct ip_set *set, const void *data, size_t size,
ip_set_ip_t *hash_port)
{
- struct ip_set_req_portmap *req =
- (struct ip_set_req_portmap *) data;
+ const struct ip_set_req_portmap *req = data;
if (size != sizeof(struct ip_set_req_portmap)) {
ip_set_printk("data length wrong (want %zu, have %zu)",
@@ -201,7 +198,7 @@
}
static int
-delport_kernel(struct ip_set *set,
+delport_kernel(struct ip_set *set,
const struct sk_buff *skb,
ip_set_ip_t *hash_port,
const u_int32_t *flags,
@@ -218,8 +215,7 @@
static int create(struct ip_set *set, const void *data, size_t size)
{
int newbytes;
- struct ip_set_req_portmap_create *req =
- (struct ip_set_req_portmap_create *) data;
+ const struct ip_set_req_portmap_create *req = data;
struct ip_set_portmap *map;
if (size != sizeof(struct ip_set_req_portmap_create)) {
@@ -265,7 +261,7 @@
static void destroy(struct ip_set *set)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ struct ip_set_portmap *map = set->data;
kfree(map->members);
kfree(map);
@@ -275,15 +271,14 @@
static void flush(struct ip_set *set)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ struct ip_set_portmap *map = set->data;
memset(map->members, 0, bitmap_bytes(map->first_port, map->last_port));
}
static void list_header(const struct ip_set *set, void *data)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
- struct ip_set_req_portmap_create *header =
- (struct ip_set_req_portmap_create *) data;
+ const struct ip_set_portmap *map = set->data;
+ struct ip_set_req_portmap_create *header = data;
DP("list_header %u %u", map->first_port, map->last_port);
@@ -293,14 +288,14 @@
static int list_members_size(const struct ip_set *set)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ const struct ip_set_portmap *map = set->data;
return bitmap_bytes(map->first_port, map->last_port);
}
static void list_members(const struct ip_set *set, void *data)
{
- struct ip_set_portmap *map = (struct ip_set_portmap *) set->data;
+ const struct ip_set_portmap *map = set->data;
int bytes = bitmap_bytes(map->first_port, map->last_port);
memcpy(data, map->members, bytes);
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_SET.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_SET.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_SET.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -5,7 +5,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* ipt_SET.c - netfilter target to manipulate IP sets */
@@ -78,12 +78,11 @@
#endif
void *targinfo,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
- unsigned int targinfosize,
+ unsigned int targinfosize,
#endif
unsigned int hook_mask)
{
- struct ipt_set_info_target *info =
- (struct ipt_set_info_target *) targinfo;
+ struct ipt_set_info_target *info = targinfo;
ip_set_id_t index;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
Modified: trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_set.c
===================================================================
--- trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_set.c 2008-06-27 13:40:54 UTC (rev 7552)
+++ trunk/patch-o-matic-ng/patchlets/set/linux-2.6/net/ipv4/netfilter/ipt_set.c 2008-07-02 10:36:01 UTC (rev 7553)
@@ -5,7 +5,7 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation.
*/
/* Kernel module to match an IP set. */
@@ -57,7 +57,7 @@
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
-bool
+static bool
#else
static int
#endif
@@ -76,8 +76,7 @@
#endif
unsigned int hook_mask)
{
- struct ipt_set_info_match *info =
- (struct ipt_set_info_match *) matchinfo;
+ struct ipt_set_info_match *info = matchinfo;
ip_set_id_t index;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
More information about the netfilter-cvslog
mailing list