+3.0
+ - New kernel-userspace protocol release
+ - Bigendian and 64/32bit fixes (Stefan Gula, bugzilla id 593)
+ - tests/runtests.sh changed to support old bash shells
+
2.5.0
- On parisc architecture cast increases required aligment (bugzilla
id 582), fixed.
V=0
endif
-IPSET_VERSION:=2.5.0
+IPSET_VERSION:=3.0
PREFIX:=/usr/local
LIBDIR:=$(PREFIX)/lib
*/
/* Size of create data. Will be sent to kernel */
- size_t create_size;
+ u_int32_t create_size;
/* Initialize the create. */
void (*create_init) (void *data);
*/
/* Size of data. Will be sent to kernel */
- size_t adt_size;
+ u_int32_t adt_size;
/* Function which parses command options */
ip_set_ip_t (*adt_parser) (int cmd, const char *optarg, void *data);
*/
/* Size of header. */
- size_t header_size;
+ u_int32_t header_size;
/* Initialize the type-header */
void (*initheader) (struct set *set, const void *data);
void (*printheader) (struct set *set, unsigned options);
/* Pretty print all IPs */
- void (*printips) (struct set *set, void *data, size_t len, unsigned options);
+ void (*printips) (struct set *set, void *data, u_int32_t len, unsigned options);
/* Pretty print all IPs sorted */
- void (*printips_sorted) (struct set *set, void *data, size_t len, unsigned options);
+ void (*printips_sorted) (struct set *set, void *data, u_int32_t len, unsigned options);
/* Print save arguments for creating the set */
void (*saveheader) (struct set *set, unsigned options);
/* Print save for all IPs */
- void (*saveips) (struct set *set, void *data, size_t len, unsigned options);
+ void (*saveips) (struct set *set, void *data, u_int32_t len, unsigned options);
/* Conver a single IP (binding) to string */
char * (*bindip_tostring)(struct set *set, ip_set_ip_t ip, unsigned options);
extern unsigned warn_once;
-#define BITSPERBYTE (8*sizeof(char))
-#define ID2BYTE(id) ((id)/BITSPERBYTE)
-#define ID2MASK(id) (1 << ((id)%BITSPERBYTE))
-#define test_bit(id, heap) ((((char *)(heap))[ID2BYTE(id)] & ID2MASK(id)) != 0)
+#define BITS_PER_LONG (8*sizeof(unsigned long))
+#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+
+static inline int test_bit(int nr, const unsigned long *addr)
+{
+ return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+}
#define UNUSED __attribute__ ((unused))
#define CONSTRUCTOR(module) \
}
static void
-printips(struct set *set UNUSED, void *data, size_t len, unsigned options)
+printips(struct set *set UNUSED, void *data, u_int32_t len, unsigned options)
{
size_t offset = 0;
ip_set_ip_t *ip;
/* Print save for an IP */
static void
-saveips(struct set *set UNUSED, void *data, size_t len, unsigned options)
+saveips(struct set *set UNUSED, void *data, u_int32_t len, unsigned options)
{
size_t offset = 0;
ip_set_ip_t *ip;
static void
printips_sorted(struct set *set, void *data,
- size_t len UNUSED, unsigned options)
+ u_int32_t len UNUSED, unsigned options)
{
struct ip_set_ipmap *mysetdata = set->settype->header;
ip_set_ip_t id;
}
static void
-saveips(struct set *set, void *data, size_t len UNUSED, unsigned options)
+saveips(struct set *set, void *data, u_int32_t len UNUSED, unsigned options)
{
struct ip_set_ipmap *mysetdata = set->settype->header;
ip_set_ip_t id;
}
static void
-printips(struct set *set, void *data, size_t len, unsigned options)
+printips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipporthash *mysetdata = set->settype->header;
size_t offset = 0;
/* Print save for an IP */
static void
-saveips(struct set *set, void *data, size_t len, unsigned options)
+saveips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipporthash *mysetdata = set->settype->header;
size_t offset = 0;
}
static void
-printips(struct set *set, void *data, size_t len, unsigned options)
+printips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipportiphash *mysetdata = set->settype->header;
size_t offset = 0;
/* Print save for an IP */
static void
-saveips(struct set *set, void *data, size_t len, unsigned options)
+saveips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipportiphash *mysetdata = set->settype->header;
size_t offset = 0;
}
static void
-printips(struct set *set, void *data, size_t len, unsigned options)
+printips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipportnethash *mysetdata = set->settype->header;
size_t offset = 0;
/* Print save for an IP */
static void
-saveips(struct set *set, void *data, size_t len, unsigned options)
+saveips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_ipportnethash *mysetdata = set->settype->header;
size_t offset = 0;
}
static void
-printips_sorted(struct set *set, void *data, size_t len, unsigned options)
+printips_sorted(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_iptree *mysetdata = set->settype->header;
struct ip_set_req_iptree *req;
}
static void
-saveips(struct set *set, void *data, size_t len, unsigned options)
+saveips(struct set *set, void *data, u_int32_t len, unsigned options)
{
struct ip_set_iptree *mysetdata = set->settype->header;
struct ip_set_req_iptree *req;
static void
printips_sorted(struct set *set UNUSED, void *data,
- size_t len, unsigned int options)
+ u_int32_t len, unsigned int options)
{
struct ip_set_req_iptreemap *req;
size_t offset = 0;
static void
saveips(struct set *set UNUSED, void *data,
- size_t len, unsigned int options)
+ u_int32_t len, unsigned int options)
{
struct ip_set_req_iptreemap *req;
size_t offset = 0;
static void
printips_sorted(struct set *set, void *data,
- size_t len UNUSED, unsigned options)
+ u_int32_t len UNUSED, unsigned options)
{
struct ip_set_macipmap *mysetdata = set->settype->header;
struct ip_set_macip *table = data;
u_int32_t addr = mysetdata->first_ip;
while (addr <= mysetdata->last_ip) {
- if (test_bit(IPSET_MACIP_ISSET,
- (void *)&table[addr - mysetdata->first_ip].flags)) {
+ if (table[addr - mysetdata->first_ip].match) {
printf("%s,", ip_tostring(addr, options));
print_mac(table[addr - mysetdata->first_ip].
ethernet);
static void
saveips(struct set *set, void *data,
- size_t len UNUSED, unsigned options)
+ u_int32_t len UNUSED, unsigned options)
{
struct ip_set_macipmap *mysetdata = set->settype->header;
struct ip_set_macip *table = data;
u_int32_t addr = mysetdata->first_ip;
while (addr <= mysetdata->last_ip) {
- if (test_bit(IPSET_MACIP_ISSET,
- (void *)&table[addr - mysetdata->first_ip].flags)) {
+ if (table[addr - mysetdata->first_ip].match) {
printf("-A %s %s,",
set->name, ip_tostring(addr, options));
print_mac(table[addr - mysetdata->first_ip].
}
static void
-printips(struct set *set UNUSED, void *data, size_t len, unsigned options)
+printips(struct set *set UNUSED, void *data, u_int32_t len, unsigned options)
{
size_t offset = 0;
ip_set_ip_t *ip;
/* Print save for an IP */
static void
-saveips(struct set *set UNUSED, void *data, size_t len, unsigned options)
+saveips(struct set *set UNUSED, void *data, u_int32_t len, unsigned options)
{
size_t offset = 0;
ip_set_ip_t *ip;
static void
printports_sorted(struct set *set, void *data,
- size_t len UNUSED, unsigned options)
+ u_int32_t len UNUSED, unsigned options)
{
struct ip_set_portmap *mysetdata = set->settype->header;
u_int32_t addr = mysetdata->first_ip;
static void
saveports(struct set *set, void *data,
- size_t len UNUSED, unsigned options)
+ u_int32_t len UNUSED, unsigned options)
{
struct ip_set_portmap *mysetdata = set->settype->header;
u_int32_t addr = mysetdata->first_ip;
static void
printips_sorted(struct set *set, void *data,
- size_t len UNUSED, unsigned options UNUSED)
+ u_int32_t len UNUSED, unsigned options UNUSED)
{
struct ip_set_setlist *mysetdata = set->settype->header;
int i;
static void
saveips(struct set *set, void *data,
- size_t len UNUSED, unsigned options UNUSED)
+ u_int32_t len UNUSED, unsigned options UNUSED)
{
struct ip_set_setlist *mysetdata = set->settype->header;
int i;
+3.0
+ - New kernel-userspace protocol release
+ - Bigendian and 64/32bit fixes (Stefan Gula, bugzilla id 593)
+ - Support of 2.4.3[67].* kernels fixed
+ - Compiling with debugging enabled fixed
+
2.5.0
- Use the spinlock initiator instead of setting the locks directly
as it causes compilation errors with 2.6.29-rt (Jan Engelhardt).
/*
* Used so that the kernel module and ipset-binary can match their versions
*/
-#define IP_SET_PROTOCOL_VERSION 2
+#define IP_SET_PROTOCOL_VERSION 3
#define IP_SET_MAXNAMELEN 32 /* set names and set typenames */
struct ip_set_req_setnames {
unsigned op;
ip_set_id_t index; /* set to list/save */
- size_t size; /* size to get setdata/bindings */
+ u_int32_t size; /* size to get setdata/bindings */
/* followed by sets number of struct ip_set_name_list */
};
ip_set_id_t index;
ip_set_id_t binding;
u_int32_t ref;
- size_t header_size; /* Set header data of header_size */
- size_t members_size; /* Set members data of members_size */
- size_t bindings_size; /* Set bindings data of bindings_size */
+ u_int32_t header_size; /* Set header data of header_size */
+ u_int32_t members_size; /* Set members data of members_size */
+ u_int32_t bindings_size;/* Set bindings data of bindings_size */
};
struct ip_set_hash_list {
struct ip_set_save {
ip_set_id_t index;
ip_set_id_t binding;
- size_t header_size; /* Set header data of header_size */
- size_t members_size; /* Set members data of members_size */
+ u_int32_t header_size; /* Set header data of header_size */
+ u_int32_t members_size; /* Set members data of members_size */
};
/* At restoring, ip == 0 means default binding for the given set: */
char name[IP_SET_MAXNAMELEN];
char typename[IP_SET_MAXNAMELEN];
ip_set_id_t index;
- size_t header_size; /* Create data of header_size */
- size_t members_size; /* Set members data of members_size */
+ u_int32_t header_size; /* Create data of header_size */
+ u_int32_t members_size; /* Set members data of members_size */
};
static inline int bitmap_bytes(ip_set_ip_t a, ip_set_ip_t b)
* return 0 if not in set, 1 if in set.
*/
int (*testip) (struct ip_set *set,
- const void *data, size_t size,
+ const void *data, u_int32_t size,
ip_set_ip_t *ip);
/*
* Size of the data structure passed by when
* adding/deletin/testing an entry.
*/
- size_t reqsize;
+ u_int32_t reqsize;
/* Add IP into set (userspace: ipset -A set IP)
* Return -EEXIST if the address is already in the set,
* If the address was not already in the set, 0 is returned.
*/
int (*addip) (struct ip_set *set,
- const void *data, size_t size,
+ const void *data, u_int32_t size,
ip_set_ip_t *ip);
/* Add IP into set (kernel: iptables ... -j SET set src|dst)
* If the address really was in the set, 0 is returned.
*/
int (*delip) (struct ip_set *set,
- const void *data, size_t size,
+ const void *data, u_int32_t size,
ip_set_ip_t *ip);
/* remove IP from set (kernel: iptables ... -j SET --entry x)
/* new set creation - allocated type specific items
*/
int (*create) (struct ip_set *set,
- const void *data, size_t size);
+ const void *data, u_int32_t size);
/* retry the operation after successfully tweaking the set
*/
/* Listing: size needed for header
*/
- size_t header_size;
+ u_int32_t header_size;
/* Listing: Get the header
*
#define UADT0(type, adt, args...) \
static int \
-FNAME(type,_u,adt)(struct ip_set *set, const void *data, size_t size, \
+FNAME(type,_u,adt)(struct ip_set *set, const void *data, u_int32_t size,\
ip_set_ip_t *hash_ip) \
{ \
const STRUCT(ip_set_req_,type) *req = data; \
#ifdef __KERNEL__
#define BITMAP_CREATE(type) \
static int \
-type##_create(struct ip_set *set, const void *data, size_t size) \
+type##_create(struct ip_set *set, const void *data, u_int32_t size) \
{ \
int newbytes; \
const struct ip_set_req_##type##_create *req = data; \
\
map = kmalloc(sizeof(struct ip_set_##type), GFP_KERNEL); \
if (!map) { \
- DP("out of memory for %d bytes", \
- sizeof(struct ip_set_#type)); \
+ DP("out of memory for %lu bytes", \
+ sizeof(struct ip_set_##type)); \
return -ENOMEM; \
} \
map->first_ip = req->from; \
map->size = newbytes; \
map->members = ip_set_malloc(newbytes); \
if (!map->members) { \
- DP("out of memory for %d bytes", newbytes); \
+ DP("out of memory for %i bytes", newbytes); \
kfree(map); \
return -ENOMEM; \
} \
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+#include <linux/netfilter.h>
#define KMEM_CACHE_CREATE(name, size) \
kmem_cache_create(name, size, 0, 0, NULL, NULL)
#else
hashsize++; \
\
ip_set_printk("rehashing of set %s triggered: " \
- "hashsize grows from %u to %u", \
- set->name, map->hashsize, hashsize); \
+ "hashsize grows from %lu to %lu", \
+ set->name, \
+ (long unsigned)map->hashsize, \
+ (long unsigned)hashsize); \
\
tmp = kmalloc(sizeof(struct ip_set_##type) \
+ map->probes * sizeof(initval_t), GFP_ATOMIC); \
if (!tmp) { \
- DP("out of memory for %d bytes", \
+ DP("out of memory for %lu bytes", \
sizeof(struct ip_set_##type) \
+ map->probes * sizeof(initval_t)); \
return -ENOMEM; \
} \
tmp->members = harray_malloc(hashsize, sizeof(dtype), GFP_ATOMIC);\
if (!tmp->members) { \
- DP("out of memory for %d bytes", hashsize * sizeof(dtype));\
+ DP("out of memory for %lu bytes", hashsize * sizeof(dtype));\
kfree(tmp); \
return -ENOMEM; \
} \
#define HASH_CREATE(type, dtype) \
static int \
-type##_create(struct ip_set *set, const void *data, size_t size) \
+type##_create(struct ip_set *set, const void *data, u_int32_t size) \
{ \
const struct ip_set_req_##type##_create *req = data; \
struct ip_set_##type *map; \
map = kmalloc(sizeof(struct ip_set_##type) \
+ req->probes * sizeof(initval_t), GFP_KERNEL); \
if (!map) { \
- DP("out of memory for %d bytes", \
+ DP("out of memory for %lu bytes", \
sizeof(struct ip_set_##type) \
+ req->probes * sizeof(initval_t)); \
return -ENOMEM; \
} \
map->members = harray_malloc(map->hashsize, sizeof(dtype), GFP_KERNEL);\
if (!map->members) { \
- DP("out of memory for %d bytes", map->hashsize * sizeof(dtype));\
+ DP("out of memory for %lu bytes", map->hashsize * sizeof(dtype));\
kfree(map); \
return -ENOMEM; \
} \
ip_set_ip_t netmask; /* subnet netmask */
ip_set_ip_t sizeid; /* size of set in IPs */
ip_set_ip_t hosts; /* number of hosts in a subnet */
- size_t size; /* size of the ipmap proper */
+ u_int32_t size; /* size of the ipmap proper */
};
struct ip_set_req_ipmap_create {
ip_set_ip_t first_ip; /* host byte order, included in range */
ip_set_ip_t last_ip; /* host byte order, included in range */
u_int32_t flags;
- size_t size; /* size of the ipmap proper */
+ u_int32_t size; /* size of the ipmap proper */
};
struct ip_set_req_macipmap_create {
};
struct ip_set_macip {
- unsigned short flags;
+ unsigned short match;
unsigned char ethernet[ETH_ALEN];
};
void *members; /* the portmap proper */
ip_set_ip_t first_ip; /* host byte order, included in range */
ip_set_ip_t last_ip; /* host byte order, included in range */
- size_t size; /* size of the ipmap proper */
+ u_int32_t size; /* size of the ipmap proper */
};
struct ip_set_req_portmap_create {
static inline int
__ip_set_testip(struct ip_set *set,
const void *data,
- size_t size,
+ u_int32_t size,
ip_set_ip_t *ip)
{
int res;
static int
__ip_set_addip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
ip_set_ip_t ip;
static int
ip_set_addip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
IP_SET_ASSERT(set);
if (size - sizeof(struct ip_set_req_adt) != set->type->reqsize) {
- ip_set_printk("data length wrong (want %zu, have %zu)",
- set->type->reqsize,
+ ip_set_printk("data length wrong (want %lu, have %lu)",
+ (long unsigned)set->type->reqsize,
size - sizeof(struct ip_set_req_adt));
return -EINVAL;
}
static int
ip_set_delip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
ip_set_ip_t ip;
IP_SET_ASSERT(set);
if (size - sizeof(struct ip_set_req_adt) != set->type->reqsize) {
- ip_set_printk("data length wrong (want %zu, have %zu)",
- set->type->reqsize,
+ ip_set_printk("data length wrong (want %lu, have %lu)",
+ (long unsigned)set->type->reqsize,
size - sizeof(struct ip_set_req_adt));
return -EINVAL;
}
static int
ip_set_testip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
ip_set_ip_t ip;
IP_SET_ASSERT(set);
if (size - sizeof(struct ip_set_req_adt) != set->type->reqsize) {
- ip_set_printk("data length wrong (want %zu, have %zu)",
- set->type->reqsize,
+ ip_set_printk("data length wrong (want %lu, have %lu)",
+ (long unsigned)set->type->reqsize,
size - sizeof(struct ip_set_req_adt));
return -EINVAL;
}
static int
ip_set_bindip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
const struct ip_set_req_bind *req_bind;
static int
ip_set_unbindip(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set;
const struct ip_set_req_bind *req_bind;
static int
ip_set_testbind(ip_set_id_t index,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set = ip_set_list[index];
const struct ip_set_req_bind *req_bind;
const char *typename,
ip_set_id_t restore,
const void *data,
- size_t size)
+ u_int32_t size)
{
struct ip_set *set;
ip_set_id_t index = 0, id;
/* Check request size */
if (size != set->type->header_size) {
- ip_set_printk("data length wrong (want %zu, have %zu)",
- set->type->header_size,
- size);
+ ip_set_printk("data length wrong (want %lu, have %lu)",
+ (long unsigned)set->type->header_size,
+ (long unsigned)size);
goto put_out;
}
static inline void
__set_hash_bindings_size_list(struct ip_set_hash *set_hash,
- ip_set_id_t id, size_t *size)
+ ip_set_id_t id, u_int32_t *size)
{
if (set_hash->id == id)
*size += sizeof(struct ip_set_hash_list);
static inline void
__set_hash_bindings_size_save(struct ip_set_hash *set_hash,
- ip_set_id_t id, size_t *size)
+ ip_set_id_t id, u_int32_t *size)
{
if (set_hash->id == id)
*size += sizeof(struct ip_set_hash_save);
*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: %i(%i) %p %p", set->name, *used, len,
data, data + *used);
read_lock_bh(&set->lock);
set->type->list_header(set, data + *used);
*used += set_save->header_size;
- DP("set header filled: %s, used: %u(%u) %p %p", set->name, *used,
- set_save->header_size, data, data + *used);
+ DP("set header filled: %s, used: %i(%lu) %p %p", set->name, *used,
+ (unsigned long)set_save->header_size, data, data + *used);
/* Get and ensure set specific members size */
set_save->members_size = set->type->list_members_size(set);
if (*used + set_save->members_size > len)
set->type->list_members(set, data + *used);
*used += set_save->members_size;
read_unlock_bh(&set->lock);
- DP("set members filled: %s, used: %u(%u) %p %p", set->name, *used,
- set_save->members_size, data, data + *used);
+ DP("set members filled: %s, used: %i(%lu) %p %p", set->name, *used,
+ (unsigned long)set_save->members_size, data, data + *used);
return 0;
unlock_set:
while (1) {
line++;
- DP("%u %u %u", used, sizeof(struct ip_set_restore), len);
+ DP("%i %lu %i", used, sizeof(struct ip_set_restore), len);
/* Get and ensure header size */
if (used + sizeof(struct ip_set_restore) > len)
return line;
/* Try to restore members data */
set = ip_set_list[index];
members_size = 0;
- DP("members_size %u reqsize %u",
- set_restore->members_size, set->type->reqsize);
+ DP("members_size %lu reqsize %lu",
+ (unsigned long)set_restore->members_size,
+ (unsigned long)set->type->reqsize);
while (members_size + set->type->reqsize <=
set_restore->members_size) {
line++;
- DP("members: %u, line %u", members_size, line);
+ DP("members: %i, line %i", members_size, line);
res = __ip_set_addip(index,
data + used + members_size,
set->type->reqsize);
members_size += set->type->reqsize;
}
- DP("members_size %u %u",
- set_restore->members_size, members_size);
+ DP("members_size %lu %i",
+ (unsigned long)set_restore->members_size, members_size);
if (members_size != set_restore->members_size)
return line++;
used += set_restore->members_size;
struct ip_set_req_adt *req_adt;
ip_set_id_t index = IP_SET_INVALID_ID;
int (*adtfn)(ip_set_id_t index,
- const void *data, size_t size);
+ const void *data, u_int32_t size);
struct fn_table {
int (*fn)(ip_set_id_t index,
- const void *data, size_t size);
+ const void *data, u_int32_t size);
} adtfn_table[] =
{ { ip_set_addip }, { ip_set_delip }, { ip_set_testip},
{ ip_set_bindip}, { ip_set_unbindip }, { ip_set_testbind },
if (*len < sizeof(struct ip_set_req_setnames)
|| *len != req_restore->size) {
- ip_set_printk("invalid RESTORE (want =%zu, got %d)",
- req_restore->size, *len);
+ ip_set_printk("invalid RESTORE (want =%lu, got %u)",
+ (long unsigned)req_restore->size, *len);
res = -EINVAL;
goto done;
}
}
static int
-ipportnethash_utest(struct ip_set *set, const void *data, size_t size,
+ipportnethash_utest(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
const struct ip_set_req_ipportnethash *req = data;
}
static int
-iptree_create(struct ip_set *set, const void *data, size_t size)
+iptree_create(struct ip_set *set, const void *data, u_int32_t size)
{
const struct ip_set_req_iptree_create *req = data;
struct ip_set_iptree *map;
if (size != sizeof(struct ip_set_req_iptree_create)) {
- ip_set_printk("data length wrong (want %zu, have %zu)",
+ ip_set_printk("data length wrong (want %lu, have %lu)",
sizeof(struct ip_set_req_iptree_create),
- size);
+ (unsigned long)size);
return -EINVAL;
}
map = kmalloc(sizeof(struct ip_set_iptree), GFP_KERNEL);
if (!map) {
- DP("out of memory for %d bytes",
+ DP("out of memory for %lu bytes",
sizeof(struct ip_set_iptree));
return -ENOMEM;
}
}
static int
-iptreemap_create(struct ip_set *set, const void *data, size_t size)
+iptreemap_create(struct ip_set *set, const void *data, u_int32_t size)
{
const struct ip_set_req_iptreemap_create *req = data;
struct ip_set_iptreemap *map;
return (count * sizeof(struct ip_set_req_iptreemap));
}
-static inline size_t
+static inline u_int32_t
add_member(void *data, size_t offset, ip_set_ip_t start, ip_set_ip_t end)
{
struct ip_set_req_iptreemap *entry = data + offset;
#include <linux/netfilter_ipv4/ip_set_macipmap.h>
static int
-macipmap_utest(struct ip_set *set, const void *data, size_t size,
+macipmap_utest(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
const struct ip_set_macipmap *map = set->data;
*hash_ip = req->ip;
DP("set: %s, ip:%u.%u.%u.%u, %u.%u.%u.%u",
set->name, HIPQUAD(req->ip), HIPQUAD(*hash_ip));
- if (test_bit(IPSET_MACIP_ISSET,
- (void *) &table[req->ip - map->first_ip].flags)) {
+ if (table[req->ip - map->first_ip].match) {
return (memcmp(req->ethernet,
&table[req->ip - map->first_ip].ethernet,
ETH_ALEN) == 0);
*hash_ip = ip;
DP("set: %s, ip:%u.%u.%u.%u, %u.%u.%u.%u",
set->name, HIPQUAD(ip), HIPQUAD(*hash_ip));
- if (test_bit(IPSET_MACIP_ISSET,
- (void *) &table[ip - map->first_ip].flags)) {
+ if (table[ip - map->first_ip].match) {
/* Is mac pointer valid?
* If so, compare... */
return (skb_mac_header(skb) >= skb->head
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- if (test_and_set_bit(IPSET_MACIP_ISSET,
- (void *) &table[ip - map->first_ip].flags))
+ if (table[ip - map->first_ip].match)
return -EEXIST;
*hash_ip = ip;
DP("%u.%u.%u.%u, %u.%u.%u.%u", HIPQUAD(ip), HIPQUAD(*hash_ip));
memcpy(&table[ip - map->first_ip].ethernet, ethernet, ETH_ALEN);
+ table[ip - map->first_ip].match = IPSET_MACIP_ISSET;
return 0;
}
if (ip < map->first_ip || ip > map->last_ip)
return -ERANGE;
- if (!test_and_clear_bit(IPSET_MACIP_ISSET,
- (void *)&table[ip - map->first_ip].flags))
+ if (!table[ip - map->first_ip].match)
return -EEXIST;
*hash_ip = ip;
+ table[ip - map->first_ip].match = 0;
DP("%u.%u.%u.%u, %u.%u.%u.%u", HIPQUAD(ip), HIPQUAD(*hash_ip));
return 0;
}
}
static int
-nethash_utest(struct ip_set *set, const void *data, size_t size,
+nethash_utest(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
const struct ip_set_req_nethash *req = data;
}
static int
-setlist_utest(struct ip_set *set, const void *data, size_t size,
+setlist_utest(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
const struct ip_set_setlist *map = set->data;
}
static int
-setlist_uadd(struct ip_set *set, const void *data, size_t size,
+setlist_uadd(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
struct ip_set_setlist *map = set->data;
}
static int
-setlist_udel(struct ip_set *set, const void *data, size_t size,
+setlist_udel(struct ip_set *set, const void *data, u_int32_t size,
ip_set_ip_t *hash_ip)
{
struct ip_set_setlist *map = set->data;
}
static int
-setlist_create(struct ip_set *set, const void *data, size_t size)
+setlist_create(struct ip_set *set, const void *data, u_int32_t size)
{
struct ip_set_setlist *map;
const struct ip_set_req_setlist_create *req = data;
#!/bin/bash
tests="init"
-tests+=" ipmap macipmap portmap"
-tests+=" iphash nethash ipporthash"
-tests+=" ipportiphash ipportnethash"
-tests+=" iptree iptreemap"
-tests+=" setlist"
+tests="$tests ipmap macipmap portmap"
+tests="$tests iphash nethash ipporthash"
+tests="$tests ipportiphash ipportnethash"
+tests="$tests iptree iptreemap"
+tests="$tests setlist"
if [ "$1" ]; then
tests="init $@"