Commit 9b03a5ef49c01515387133ac5bd47073fae56318
Committed by
Patrick McHardy
1 parent
9d8832320f
Exists in
master
and in
4 other branches
netfilter: ipset: use the stored first cidr value instead of '1'
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
Showing 3 changed files with 16 additions and 8 deletions Side-by-side Diff
net/netfilter/ipset/ip_set_hash_ipportnet.c
... | ... | @@ -156,8 +156,9 @@ |
156 | 156 | { |
157 | 157 | const struct ip_set_hash *h = set->data; |
158 | 158 | ipset_adtfn adtfn = set->variant->adt[adt]; |
159 | - struct hash_ipportnet4_elem data = | |
160 | - { .cidr = h->nets[0].cidr || HOST_MASK }; | |
159 | + struct hash_ipportnet4_elem data = { | |
160 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
161 | + }; | |
161 | 162 | |
162 | 163 | if (data.cidr == 0) |
163 | 164 | return -EINVAL; |
... | ... | @@ -434,8 +435,9 @@ |
434 | 435 | { |
435 | 436 | const struct ip_set_hash *h = set->data; |
436 | 437 | ipset_adtfn adtfn = set->variant->adt[adt]; |
437 | - struct hash_ipportnet6_elem data = | |
438 | - { .cidr = h->nets[0].cidr || HOST_MASK }; | |
438 | + struct hash_ipportnet6_elem data = { | |
439 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
440 | + }; | |
439 | 441 | |
440 | 442 | if (data.cidr == 0) |
441 | 443 | return -EINVAL; |
net/netfilter/ipset/ip_set_hash_net.c
... | ... | @@ -139,7 +139,9 @@ |
139 | 139 | { |
140 | 140 | const struct ip_set_hash *h = set->data; |
141 | 141 | ipset_adtfn adtfn = set->variant->adt[adt]; |
142 | - struct hash_net4_elem data = { .cidr = h->nets[0].cidr || HOST_MASK }; | |
142 | + struct hash_net4_elem data = { | |
143 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
144 | + }; | |
143 | 145 | |
144 | 146 | if (data.cidr == 0) |
145 | 147 | return -EINVAL; |
... | ... | @@ -336,7 +338,9 @@ |
336 | 338 | { |
337 | 339 | const struct ip_set_hash *h = set->data; |
338 | 340 | ipset_adtfn adtfn = set->variant->adt[adt]; |
339 | - struct hash_net6_elem data = { .cidr = h->nets[0].cidr || HOST_MASK }; | |
341 | + struct hash_net6_elem data = { | |
342 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
343 | + }; | |
340 | 344 | |
341 | 345 | if (data.cidr == 0) |
342 | 346 | return -EINVAL; |
net/netfilter/ipset/ip_set_hash_netport.c
... | ... | @@ -153,7 +153,8 @@ |
153 | 153 | const struct ip_set_hash *h = set->data; |
154 | 154 | ipset_adtfn adtfn = set->variant->adt[adt]; |
155 | 155 | struct hash_netport4_elem data = { |
156 | - .cidr = h->nets[0].cidr || HOST_MASK }; | |
156 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
157 | + }; | |
157 | 158 | |
158 | 159 | if (data.cidr == 0) |
159 | 160 | return -EINVAL; |
... | ... | @@ -397,7 +398,8 @@ |
397 | 398 | const struct ip_set_hash *h = set->data; |
398 | 399 | ipset_adtfn adtfn = set->variant->adt[adt]; |
399 | 400 | struct hash_netport6_elem data = { |
400 | - .cidr = h->nets[0].cidr || HOST_MASK }; | |
401 | + .cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK | |
402 | + }; | |
401 | 403 | |
402 | 404 | if (data.cidr == 0) |
403 | 405 | return -EINVAL; |