git: fb8ef16bab0d - main - IPv4: correct limit on loopback_prefix

From: Mike Karels <karels_at_FreeBSD.org>
Date: Thu, 21 Jul 2022 14:38:55 UTC
The branch main has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=fb8ef16bab0d23e185deed5a6b2e44e72ad53d43

commit fb8ef16bab0d23e185deed5a6b2e44e72ad53d43
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2022-07-21 13:10:15 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2022-07-21 14:38:17 +0000

    IPv4: correct limit on loopback_prefix
    
    Commit efe58855f3ea 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.
---
 sys/netinet/in.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index c3880c4ba983..1c44623bdec1 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -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);