From 034974106fc3e15a9eaf243dfbb7c94fd86caa83 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 9 Aug 2024 21:02:24 +0200 Subject: [PATCH] MINOR: socket: don't ban all custom families from reuseport The test on ss_family >= AF_MAX is too strict if we want to support new custom families, let's apply this to the real_family instead so that we check that the underlying socket supports reuseport. --- src/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sock.c b/src/sock.c index 867a0ed76e..c857820df3 100644 --- a/src/sock.c +++ b/src/sock.c @@ -1150,7 +1150,7 @@ int _sock_supports_reuseport(const struct proto_fam *fam, int type, int protocol fd1 = fd2 = -1; /* ignore custom sockets */ - if (!fam || fam->sock_family >= AF_MAX) + if (!fam || real_family(fam->sock_family) >= AF_MAX) goto leave; fd1 = socket(fam->sock_domain, type, protocol); @@ -1162,7 +1162,7 @@ int _sock_supports_reuseport(const struct proto_fam *fam, int type, int protocol /* bind to any address assigned by the kernel, we'll then try to do it twice */ memset(&ss, 0, sizeof(ss)); - ss.ss_family = fam->sock_family; + ss.ss_family = real_family(fam->sock_family); if (bind(fd1, (struct sockaddr *)&ss, fam->sock_addrlen) < 0) goto leave; -- 2.47.3