aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/utils.c')
-rw-r--r--networking/libiproute/utils.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 4ce230356..3cce4a06e 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -175,14 +175,13 @@ static void get_prefix_1(inet_prefix *dst, char *arg, int family)
175 if (netmask_pfx.family == AF_INET) { 175 if (netmask_pfx.family == AF_INET) {
176 /* fill in prefix length of dotted quad */ 176 /* fill in prefix length of dotted quad */
177 uint32_t mask = ntohl(netmask_pfx.data[0]); 177 uint32_t mask = ntohl(netmask_pfx.data[0]);
178 uint32_t host = ~mask; 178 uint32_t inv = ~mask;
179 179
180 /* a valid netmask must be 2^n - 1 */ 180 /* a valid netmask must be 11..10..00 */
181 if (host & (host + 1)) 181 if (inv & (inv + 1))
182 goto bad; 182 goto bad; /* inv is not 00..01..11 */
183 183
184 for (plen = 0; mask; mask <<= 1) 184 plen = bb_popcnt_32(mask);
185 ++plen;
186 if (plen > dst->bitlen) 185 if (plen > dst->bitlen)
187 goto bad; 186 goto bad;
188 /* dst->flags |= PREFIXLEN_SPECIFIED; */ 187 /* dst->flags |= PREFIXLEN_SPECIFIED; */