summaryrefslogtreecommitdiffstats
path: root/kernel/net/netfilter/ipset/ip_set_hash_net.c
diff options
context:
space:
mode:
authorSergey Popovich <popovich_sergei@mail.ua>2014-11-17 18:45:10 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2015-03-20 19:16:45 +0100
commit4c54de30906e8a048211d43bfcdeeab52617378c (patch)
tree4a6c5ba494dd3c2927a9d198d2693b5697646606 /kernel/net/netfilter/ipset/ip_set_hash_net.c
parent1ea77bdaa53b396366ec50062298fabf70130ad2 (diff)
netfilter: ipset: Check CIDR value only when attribute is given
There is no reason to check CIDR value regardless attribute specifying CIDR is given. Initialize cidr array in element structure on element structure declaration to let more freedom to the compiler to optimize initialization right before element structure is used. Remove local variables cidr and cidr2 for netnet and netportnet hashes as we do not use packed cidr value for such set types and can store value directly in e.cidr[]. Signed-off-by: Sergey Popovich <popovich_sergei@mail.ua> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Diffstat (limited to 'kernel/net/netfilter/ipset/ip_set_hash_net.c')
-rw-r--r--kernel/net/netfilter/ipset/ip_set_hash_net.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/net/netfilter/ipset/ip_set_hash_net.c b/kernel/net/netfilter/ipset/ip_set_hash_net.c
index 1f148f5..01fe64a 100644
--- a/kernel/net/netfilter/ipset/ip_set_hash_net.c
+++ b/kernel/net/netfilter/ipset/ip_set_hash_net.c
@@ -330,11 +330,11 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[],
if (ret)
return ret;
- if (tb[IPSET_ATTR_CIDR])
+ if (tb[IPSET_ATTR_CIDR]) {
e.cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
-
- if (!e.cidr || e.cidr > HOST_MASK)
- return -IPSET_ERR_INVALID_CIDR;
+ if (!e.cidr || e.cidr > HOST_MASK)
+ return -IPSET_ERR_INVALID_CIDR;
+ }
ip6_netmask(&e.ip, e.cidr);