summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include/linux')
-rw-r--r--kernel/include/linux/netfilter_ipv4/ip_set_hashes.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/kernel/include/linux/netfilter_ipv4/ip_set_hashes.h b/kernel/include/linux/netfilter_ipv4/ip_set_hashes.h
index f62ae37..8eeced3 100644
--- a/kernel/include/linux/netfilter_ipv4/ip_set_hashes.h
+++ b/kernel/include/linux/netfilter_ipv4/ip_set_hashes.h
@@ -186,7 +186,7 @@ type##_list_members_size(const struct ip_set *set, char dont_align) \
{ \
const struct ip_set_##type *map = set->data; \
\
- return (map->hashsize * IPSET_VALIGN(sizeof(dtype), dont_align));\
+ return (map->elements * IPSET_VALIGN(sizeof(dtype), dont_align));\
}
#define HASH_LIST_MEMBERS(type, dtype) \
@@ -195,27 +195,33 @@ type##_list_members(const struct ip_set *set, void *data, char dont_align)\
{ \
const struct ip_set_##type *map = set->data; \
dtype *elem, *d; \
- uint32_t i; \
+ uint32_t i, n = 0; \
\
for (i = 0; i < map->hashsize; i++) { \
elem = HARRAY_ELEM(map->members, dtype *, i); \
- d = data + i * IPSET_VALIGN(sizeof(dtype), dont_align); \
- *d = *elem; \
+ if (*elem) { \
+ d = data + n * IPSET_VALIGN(sizeof(dtype), dont_align);\
+ *d = *elem; \
+ n++; \
+ } \
} \
}
-#define HASH_LIST_MEMBERS_MEMCPY(type, dtype) \
+#define HASH_LIST_MEMBERS_MEMCPY(type, dtype, nonzero) \
static void \
type##_list_members(const struct ip_set *set, void *data, char dont_align)\
{ \
const struct ip_set_##type *map = set->data; \
dtype *elem; \
- uint32_t i; \
+ uint32_t i, n = 0; \
\
for (i = 0; i < map->hashsize; i++) { \
elem = HARRAY_ELEM(map->members, dtype *, i); \
- memcpy(data + i * IPSET_VALIGN(sizeof(dtype), dont_align),\
- elem, sizeof(dtype)); \
+ if (nonzero) { \
+ memcpy(data + n * IPSET_VALIGN(sizeof(dtype), dont_align),\
+ elem, sizeof(dtype)); \
+ n++; \
+ } \
} \
}