summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@netfilter.org>2021-07-28 16:06:46 +0200
committerJozsef Kadlecsik <kadlec@netfilter.org>2021-07-28 16:09:01 +0200
commit73e5366e2295f009da5ac3fd608dfe8464c795d3 (patch)
tree039be16b08e4efcbc7e2fce26a26e02dfceceeca /kernel
parent8a0df0c759cf9f0ca6f0cfa512ebf4832fd73729 (diff)
64bit division isn't allowed on 32bit, replace it with shift
The number of hosts in a netblock must be a power of two, so use shift instead of division. Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/net/netfilter/ipset/ip_set_hash_ip.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/net/netfilter/ipset/ip_set_hash_ip.c b/kernel/net/netfilter/ipset/ip_set_hash_ip.c
index 789b28a..baa5e14 100644
--- a/kernel/net/netfilter/ipset/ip_set_hash_ip.c
+++ b/kernel/net/netfilter/ipset/ip_set_hash_ip.c
@@ -148,7 +148,8 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
- if (((u64)ip_to - ip + 1)/hosts > IPSET_MAX_RANGE)
+ /* 64bit division is not allowed on 32bit */
+ if (((u64)ip_to - ip + 1) >> (32 - h->netmask) > IPSET_MAX_RANGE)
return -ERANGE;
if (retried) {