IPv4: correct limit on loopback_prefix

Commit efe58855f3 allowed the net.inet.ip.loopback_prefix value
to be 32.  However, with a 32-bit mask, 127.0.0.1 is not included
in the reserved loopback range, which should not be allowed.
Change the max prefix length to 31.
This commit is contained in:
Mike Karels 2022-07-21 08:10:15 -05:00
parent e89841f893
commit fb8ef16bab
1 changed files with 1 additions and 1 deletions

View File

@ -297,7 +297,7 @@ sysctl_loopback_prefixlen(SYSCTL_HANDLER_ARGS)
error = sysctl_handle_int(oidp, &preflen, 0, req);
if (error || !req->newptr)
return (error);
if (preflen < 8 || preflen > 32)
if (preflen < 8 || preflen > 31)
return (EINVAL);
V_in_loopback_mask = 0xffffffff << (32 - preflen);
return (0);