git: c33f8dd282ae - releng/14.5 - Revert "sys/socket.h: Fix AF_MAX"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 13 Aug 2026 23:47:42 UTC
The branch releng/14.5 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=c33f8dd282ae314458946c3dfb3add311b765875
commit c33f8dd282ae314458946c3dfb3add311b765875
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2026-08-13 23:44:33 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-08-13 23:44:33 +0000
Revert "sys/socket.h: Fix AF_MAX"
Back out this change for 14.5-BETA2. It might come back with
changes, but in its current form it breaks ABI.
This reverts commit f77a60a27ad64e3acf26f3dc088c6e80fdd15754.
Approved by: re (cperciva)
---
lib/libifconfig/libifconfig.c | 4 ++--
lib/libifconfig/libifconfig_internal.c | 2 +-
sys/kern/vfs_export.c | 2 +-
sys/net/route.c | 2 +-
sys/net/route/route_ddb.c | 2 +-
sys/net/route/route_helpers.c | 4 ++--
sys/net/rtsock.c | 4 ++--
sys/netlink/route/rt.c | 6 +++---
sys/sys/socket.h | 4 +---
9 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/lib/libifconfig/libifconfig.c b/lib/libifconfig/libifconfig.c
index 9b2f1fd753c8..f844ae235a71 100644
--- a/lib/libifconfig/libifconfig.c
+++ b/lib/libifconfig/libifconfig.c
@@ -81,7 +81,7 @@ ifconfig_open(void)
if (h == NULL) {
return (NULL);
}
- for (int i = 0; i < AF_MAX; i++) {
+ for (int i = 0; i <= AF_MAX; i++) {
h->sockets[i] = -1;
}
@@ -92,7 +92,7 @@ void
ifconfig_close(ifconfig_handle_t *h)
{
- for (int i = 0; i < AF_MAX; i++) {
+ for (int i = 0; i <= AF_MAX; i++) {
if (h->sockets[i] != -1) {
(void)close(h->sockets[i]);
}
diff --git a/lib/libifconfig/libifconfig_internal.c b/lib/libifconfig/libifconfig_internal.c
index 91de1ece59fb..c6c955debb3d 100644
--- a/lib/libifconfig/libifconfig_internal.c
+++ b/lib/libifconfig/libifconfig_internal.c
@@ -78,7 +78,7 @@ int
ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s)
{
- if (addressfamily >= AF_MAX) {
+ if (addressfamily > AF_MAX) {
h->error.errtype = SOCKET;
h->error.errcode = EINVAL;
return (-1);
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 5e8253c4f149..96b4464436e3 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -162,7 +162,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
saddr = (struct sockaddr *) (np + 1);
if ((error = copyin(argp->ex_addr, saddr, argp->ex_addrlen)))
goto out;
- if (saddr->sa_family == AF_UNSPEC || saddr->sa_family >= AF_MAX) {
+ if (saddr->sa_family == AF_UNSPEC || saddr->sa_family > AF_MAX) {
error = EINVAL;
vfs_mount_error(mp, "Invalid saddr->sa_family: %d");
goto out;
diff --git a/sys/net/route.c b/sys/net/route.c
index 9543b3359a18..d86f40dedec9 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -518,7 +518,7 @@ rt_updatemtu(struct ifnet *ifp)
* Unfortunately the only way to do this is to traverse all
* routing tables in all fibs/domains.
*/
- for (i = 1; i < AF_MAX; i++) {
+ for (i = 1; i <= AF_MAX; i++) {
mtu = if_getmtu_family(ifp, i);
for (j = 0; j < rt_numfibs; j++) {
rnh = rt_tables_get_rnh(j, i);
diff --git a/sys/net/route/route_ddb.c b/sys/net/route/route_ddb.c
index c93370d0a570..71bffd98663b 100644
--- a/sys/net/route/route_ddb.c
+++ b/sys/net/route/route_ddb.c
@@ -174,7 +174,7 @@ DB_SHOW_COMMAND(routetable, db_show_routetable)
i = lim = addr;
else {
i = 1;
- lim = AF_MAX - 1;
+ lim = AF_MAX;
}
for (; i <= lim; i++) {
diff --git a/sys/net/route/route_helpers.c b/sys/net/route/route_helpers.c
index bee01f28a81d..2c0df15b04b7 100644
--- a/sys/net/route/route_helpers.c
+++ b/sys/net/route/route_helpers.c
@@ -184,7 +184,7 @@ rib_foreach_table_walk(int family, bool wlock, rib_walktree_f_t *wa_f,
continue;
}
- for (int i = 1; i < AF_MAX; i++)
+ for (int i = 1; i <= AF_MAX; i++)
rib_walk_ext(fibnum, i, wlock, wa_f, hook_f, arg);
}
}
@@ -206,7 +206,7 @@ rib_foreach_table_walk_del(int family, rib_filter_f_t *filter_f, void *arg)
continue;
}
- for (int i = 1; i < AF_MAX; i++)
+ for (int i = 1; i <= AF_MAX; i++)
rib_walk_del(fibnum, i, filter_f, arg, 0);
}
}
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index a8e62f5046ce..e3116b8ee4b5 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -2605,7 +2605,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
} else if (namelen != 3)
return ((namelen < 3) ? EISDIR : ENOTDIR);
af = name[0];
- if (af >= AF_MAX)
+ if (af > AF_MAX)
return (EINVAL);
bzero(&w, sizeof(w));
w.w_op = name[1];
@@ -2629,7 +2629,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
case NET_RT_FLAGS:
if (af == 0) { /* dump all tables */
i = 1;
- lim = AF_MAX - 1;
+ lim = AF_MAX;
} else /* dump only one table */
i = lim = af;
diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index 810ed219df27..fac174e01efd 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -960,7 +960,7 @@ rtnl_handle_newroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
/* pre-2.6.19 Linux API compatibility */
if (attrs.rtm_table > 0 && attrs.rta_table == 0)
attrs.rta_table = attrs.rtm_table;
- if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family >= AF_MAX) {
+ if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}
@@ -1023,7 +1023,7 @@ rtnl_handle_delroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
return (ESRCH);
}
- if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family >= AF_MAX) {
+ if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}
@@ -1046,7 +1046,7 @@ rtnl_handle_getroute(struct nlmsghdr *hdr, struct nlpcb *nlp, struct nl_pstate *
if (error != 0)
return (error);
- if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family >= AF_MAX) {
+ if (attrs.rta_table >= V_rt_numfibs || attrs.rtm_family > AF_MAX) {
NLMSG_REPORT_ERR_MSG(npt, "invalid fib");
return (EINVAL);
}
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index ce6fe421d44b..b2afc735a383 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -271,9 +271,7 @@ struct accept_filter_arg {
#define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */
#define AF_HYPERV 43 /* HyperV sockets */
#define AF_DIVERT 44 /* divert(4) */
-
-#define AF_MAX 45
-
+#define AF_MAX 44
/*
* When allocating a new AF_ constant, please only allocate
* even numbered constants for FreeBSD until 134 as odd numbered AF_