diff options
Diffstat (limited to 'net/netfilter/ipset/ip_set_hash_net.c')
-rw-r--r-- | net/netfilter/ipset/ip_set_hash_net.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c index c57a6a09906..29e94b981f3 100644 --- a/net/netfilter/ipset/ip_set_hash_net.c +++ b/net/netfilter/ipset/ip_set_hash_net.c | |||
@@ -23,9 +23,13 @@ | |||
23 | #include <linux/netfilter/ipset/ip_set_timeout.h> | 23 | #include <linux/netfilter/ipset/ip_set_timeout.h> |
24 | #include <linux/netfilter/ipset/ip_set_hash.h> | 24 | #include <linux/netfilter/ipset/ip_set_hash.h> |
25 | 25 | ||
26 | #define REVISION_MIN 0 | ||
27 | /* 1 Range as input support for IPv4 added */ | ||
28 | #define REVISION_MAX 2 /* nomatch flag support added */ | ||
29 | |||
26 | MODULE_LICENSE("GPL"); | 30 | MODULE_LICENSE("GPL"); |
27 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); | 31 | MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>"); |
28 | MODULE_DESCRIPTION("hash:net type of IP sets"); | 32 | IP_SET_MODULE_DESC("hash:net", REVISION_MIN, REVISION_MAX); |
29 | MODULE_ALIAS("ip_set_hash:net"); | 33 | MODULE_ALIAS("ip_set_hash:net"); |
30 | 34 | ||
31 | /* Type specific function prefix */ | 35 | /* Type specific function prefix */ |
@@ -86,10 +90,10 @@ hash_net4_data_flags(struct hash_net4_elem *dst, u32 flags) | |||
86 | dst->nomatch = flags & IPSET_FLAG_NOMATCH; | 90 | dst->nomatch = flags & IPSET_FLAG_NOMATCH; |
87 | } | 91 | } |
88 | 92 | ||
89 | static inline bool | 93 | static inline int |
90 | hash_net4_data_match(const struct hash_net4_elem *elem) | 94 | hash_net4_data_match(const struct hash_net4_elem *elem) |
91 | { | 95 | { |
92 | return !elem->nomatch; | 96 | return elem->nomatch ? -ENOTEMPTY : 1; |
93 | } | 97 | } |
94 | 98 | ||
95 | static inline void | 99 | static inline void |
@@ -152,7 +156,7 @@ static inline void | |||
152 | hash_net4_data_next(struct ip_set_hash *h, | 156 | hash_net4_data_next(struct ip_set_hash *h, |
153 | const struct hash_net4_elem *d) | 157 | const struct hash_net4_elem *d) |
154 | { | 158 | { |
155 | h->next.ip = ntohl(d->ip); | 159 | h->next.ip = d->ip; |
156 | } | 160 | } |
157 | 161 | ||
158 | static int | 162 | static int |
@@ -235,7 +239,7 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[], | |||
235 | return -IPSET_ERR_HASH_RANGE; | 239 | return -IPSET_ERR_HASH_RANGE; |
236 | } | 240 | } |
237 | if (retried) | 241 | if (retried) |
238 | ip = h->next.ip; | 242 | ip = ntohl(h->next.ip); |
239 | while (!after(ip, ip_to)) { | 243 | while (!after(ip, ip_to)) { |
240 | data.ip = htonl(ip); | 244 | data.ip = htonl(ip); |
241 | last = ip_set_range_to_cidr(ip, ip_to, &data.cidr); | 245 | last = ip_set_range_to_cidr(ip, ip_to, &data.cidr); |
@@ -307,10 +311,10 @@ hash_net6_data_flags(struct hash_net6_elem *dst, u32 flags) | |||
307 | dst->nomatch = flags & IPSET_FLAG_NOMATCH; | 311 | dst->nomatch = flags & IPSET_FLAG_NOMATCH; |
308 | } | 312 | } |
309 | 313 | ||
310 | static inline bool | 314 | static inline int |
311 | hash_net6_data_match(const struct hash_net6_elem *elem) | 315 | hash_net6_data_match(const struct hash_net6_elem *elem) |
312 | { | 316 | { |
313 | return !elem->nomatch; | 317 | return elem->nomatch ? -ENOTEMPTY : 1; |
314 | } | 318 | } |
315 | 319 | ||
316 | static inline void | 320 | static inline void |
@@ -532,12 +536,11 @@ hash_net_create(struct ip_set *set, struct nlattr *tb[], u32 flags) | |||
532 | static struct ip_set_type hash_net_type __read_mostly = { | 536 | static struct ip_set_type hash_net_type __read_mostly = { |
533 | .name = "hash:net", | 537 | .name = "hash:net", |
534 | .protocol = IPSET_PROTOCOL, | 538 | .protocol = IPSET_PROTOCOL, |
535 | .features = IPSET_TYPE_IP, | 539 | .features = IPSET_TYPE_IP | IPSET_TYPE_NOMATCH, |
536 | .dimension = IPSET_DIM_ONE, | 540 | .dimension = IPSET_DIM_ONE, |
537 | .family = NFPROTO_UNSPEC, | 541 | .family = NFPROTO_UNSPEC, |
538 | .revision_min = 0, | 542 | .revision_min = REVISION_MIN, |
539 | /* = 1 Range as input support for IPv4 added */ | 543 | .revision_max = REVISION_MAX, |
540 | .revision_max = 2, /* nomatch flag support added */ | ||
541 | .create = hash_net_create, | 544 | .create = hash_net_create, |
542 | .create_policy = { | 545 | .create_policy = { |
543 | [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, | 546 | [IPSET_ATTR_HASHSIZE] = { .type = NLA_U32 }, |