]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sock: Add protocol and socket types parameters to sock_create_server_socket()
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 3 Jun 2025 14:25:53 +0000 (16:25 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 16:37:34 +0000 (18:37 +0200)
This patch only adds <proto_type> new proto_type enum parameter and <sock_type>
socket type parameter to sock_create_server_socket() and adapts its callers.
This is to prepare the use of this function by QUIC servers/backends.

include/haproxy/sock.h
src/proto_quic.c
src/proto_tcp.c
src/proto_uxst.c
src/sock.c

index 017e0ad1d65b44c8475082878ced85c46b7a71ac..9aa0147517118e4dbb42561b4fe514a57216529f 100644 (file)
 #include <haproxy/api.h>
 #include <haproxy/connection-t.h>
 #include <haproxy/listener-t.h>
+#include <haproxy/protocol-t.h>
 #include <haproxy/sock-t.h>
 
-int sock_create_server_socket(struct connection *conn, struct proxy *be, int *stream_err);
+int sock_create_server_socket(struct connection *conn, struct proxy *be,
+                              enum proto_type proto_type, int sock_type, int *stream_err);
 void sock_enable(struct receiver *rx);
 void sock_disable(struct receiver *rx);
 void sock_unbind(struct receiver *rx);
index c68cf33c2087ec8cd9aeb12bc2a203e2eceefeb7..210b25ac676403c9504d2c8b1f0bb86f83931d1b 100644 (file)
@@ -306,7 +306,7 @@ int quic_connect_server(struct connection *conn, int flags)
        }
 
        /* perform common checks on obtained socket FD, return appropriate Stream Error Flag in case of failure */
-       fd = conn->handle.fd = sock_create_server_socket(conn, be, &stream_err);
+       fd = conn->handle.fd = sock_create_server_socket(conn, be, PROTO_TYPE_DGRAM, SOCK_DGRAM, &stream_err);
        if (fd == -1)
                return stream_err;
 
index 51b9e9950c2db5e7bb0657daf6b24610e71dc537..0de67c4ebe7af249b18710bfb6c95cb96205f285 100644 (file)
@@ -397,7 +397,7 @@ int tcp_connect_server(struct connection *conn, int flags)
 
 
        /* perform common checks on obtained socket FD, return appropriate Stream Error Flag in case of failure */
-       fd = conn->handle.fd = sock_create_server_socket(conn, be, &stream_err);
+       fd = conn->handle.fd = sock_create_server_socket(conn, be, PROTO_TYPE_STREAM, SOCK_STREAM, &stream_err);
        if (fd == -1)
                return stream_err;
 
index 8122ad384f66538a7c8468a89be8473ff9e61bce..434a702aa5439d98c0a4f86165324ecfeb30280f 100644 (file)
@@ -330,7 +330,7 @@ static int uxst_connect_server(struct connection *conn, int flags)
        }
 
        /* perform common checks on obtained socket FD, return appropriate Stream Error Flag in case of failure */
-       fd = conn->handle.fd = sock_create_server_socket(conn, be, &stream_err);
+       fd = conn->handle.fd = sock_create_server_socket(conn, be, PROTO_TYPE_STREAM, SOCK_STREAM, &stream_err);
        if (fd == -1)
                return stream_err;
 
index 9d7892954895a633461f9eb89bb4f87c03bc923d..83db745955171bfb8c98c968eb0679bb21388e1e 100644 (file)
@@ -265,7 +265,8 @@ static int sock_handle_system_err(struct connection *conn, struct proxy *be)
  * upper level is set as SF_ERR_NONE; -1 on failure, stream_err is set to
  * appropriate value.
  */
-int sock_create_server_socket(struct connection *conn, struct proxy *be, int *stream_err)
+int sock_create_server_socket(struct connection *conn, struct proxy *be,
+                              enum proto_type proto_type, int sock_type, int *stream_err)
 {
        const struct netns_entry *ns = NULL;
        const struct protocol *proto;
@@ -279,9 +280,9 @@ int sock_create_server_socket(struct connection *conn, struct proxy *be, int *st
                        ns = __objt_server(conn->target)->netns;
        }
 #endif
-       proto = protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, conn->ctrl->sock_prot == IPPROTO_MPTCP);
+       proto = protocol_lookup(conn->dst->ss_family, proto_type , conn->ctrl->sock_prot == IPPROTO_MPTCP);
        BUG_ON(!proto);
-       sock_fd = my_socketat(ns, proto->fam->sock_domain, SOCK_STREAM, proto->sock_prot);
+       sock_fd = my_socketat(ns, proto->fam->sock_domain, sock_type, proto->sock_prot);
 
        /* at first, handle common to all proto families system limits and permission related errors */
        if (sock_fd == -1) {