]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: replace ctrl_type with xprt_type and clarify it
authorWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 14:36:46 +0000 (16:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 16:39:43 +0000 (18:39 +0200)
There's been some great confusion between proto_type, ctrl_type and
sock_type. It turns out that ctrl_type was improperly chosen because
it's not the control layer that is of this or that type, but the
transport layer, and it turns out that the transport layer doesn't
(normally) denaturate the underlying control layer, except for QUIC
which turns dgrams to streams. The fact that the SOCK_{DGRAM|STREAM}
set of values was used added to the confusion.

Let's replace it with xprt_type which reuses the later introduced
PROTO_TYPE_* values, and update the comments to explain which one
works at what level.

include/haproxy/protocol-t.h
src/cfgparse.c
src/log.c
src/proto_quic.c
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxdg.c
src/proto_uxst.c
src/protocol.c
src/resolvers.c

index 8f51a7a51ca6c82109d9ffabee1946244b10d9ac..b0765cf87255b5c05d5d6836f2bee035016d7eda 100644 (file)
@@ -89,8 +89,8 @@ struct proto_fam {
 struct protocol {
        char name[PROTO_NAME_LEN];                      /* protocol name, zero-terminated */
        struct proto_fam *fam;                          /* protocol family */
-       int ctrl_type;                                  /* control layer type (SOCK_STREAM/SOCK_DGRAM) */
-       enum proto_type proto_type;                     /* protocol type (PROTO_TYPE_*) */
+       int xprt_type;                                  /* transport layer type (PROTO_TYPE_STREAM/PROTO_TYPE_DGRAM) */
+       enum proto_type proto_type;                     /* protocol type at the socket layer (PROTO_TYPE_*) */
        int sock_type;                                  /* socket type, as passed to socket()     */
        int sock_prot;                                  /* socket protocol, as passed to socket() */
 
index 33645294962083b4a1719483621c55a58640c157..d8412239793bd8b6e14256af31a79cd88fab3e1b 100644 (file)
@@ -161,7 +161,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
                 * is selected, regardless of bind_conf settings. We then need
                 * to initialize QUIC params.
                 */
-               if (proto->proto_type == PROTO_TYPE_DGRAM && proto->ctrl_type == SOCK_STREAM) {
+               if (proto->proto_type == PROTO_TYPE_DGRAM && proto->xprt_type == PROTO_TYPE_STREAM) {
                        bind_conf->xprt = xprt_get(XPRT_QUIC);
                        quic_transport_params_init(&bind_conf->quic_params, 1);
                }
index be989828b2e8931126c3b69c7ae8a70bd61e537d..1294262243039338f2495ba5f0dac8cc117c1105 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1005,7 +1005,7 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, const char *file
                        set_host_port(&logsrv->addr, SYSLOG_PORT);
        }
 
-       if (proto && proto->ctrl_type == SOCK_STREAM) {
+       if (proto && proto->xprt_type == PROTO_TYPE_STREAM) {
                static unsigned long ring_ids;
 
                /* Implicit sink buffer will be
index 5c20045276a236e6d81004e6fd4a133c8066913f..55aa4b50fe40041e3b2994038d9d2504f8908705 100644 (file)
@@ -65,7 +65,7 @@ struct protocol proto_quic4 = {
        .name           = "quic4",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = quic_bind_listener,
        .enable         = quic_enable_listener,
        .disable        = quic_disable_listener,
@@ -105,7 +105,7 @@ struct protocol proto_quic6 = {
        .name            = "quic6",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = quic_bind_listener,
        .enable         = quic_enable_listener,
        .disable        = quic_disable_listener,
index 9126fe63de59203cdbfa4446488204c0f1e173c8..54cc34f236ce425b1be288dcb4fc711caf0fe7b7 100644 (file)
@@ -65,7 +65,7 @@ struct protocol proto_sockpair = {
        .name           = "sockpair",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = sockpair_bind_listener,
        .enable         = sockpair_enable_listener,
        .disable        = sockpair_disable_listener,
index 42342d652cc0fab4412c406a9cb62f12773b358b..2dbfb64f895e1526dd7187c5a65fab3ee456608b 100644 (file)
@@ -54,7 +54,7 @@ struct protocol proto_tcpv4 = {
        .name           = "tcpv4",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = tcp_bind_listener,
        .enable         = tcp_enable_listener,
        .disable        = tcp_disable_listener,
@@ -97,7 +97,7 @@ struct protocol proto_tcpv6 = {
        .name           = "tcpv6",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = tcp_bind_listener,
        .enable         = tcp_enable_listener,
        .disable        = tcp_disable_listener,
index 3474d4e787eadbe9d362667650f6cad1624a230e..542d287c01e414aa43e0eacfe8af5380a5632b60 100644 (file)
@@ -49,7 +49,7 @@ struct protocol proto_udp4 = {
        .name           = "udp4",
 
        /* connection layer */
-       .ctrl_type      = SOCK_DGRAM,
+       .xprt_type      = PROTO_TYPE_DGRAM,
        .listen         = udp_bind_listener,
        .enable         = udp_enable_listener,
        .disable        = udp_disable_listener,
@@ -83,7 +83,7 @@ struct protocol proto_udp6 = {
        .name           = "udp6",
 
        /* connection layer */
-       .ctrl_type      = SOCK_DGRAM,
+       .xprt_type      = PROTO_TYPE_DGRAM,
        .listen         = udp_bind_listener,
        .enable         = udp_enable_listener,
        .disable        = udp_disable_listener,
index 8951651f493af69fe7d28decb8def29b230e8c35..41e01004fa36bf52f46da73f15c4334546c7a998 100644 (file)
@@ -40,7 +40,7 @@ struct protocol proto_uxdg = {
        .name           = "uxdg",
 
        /* connection layer */
-       .ctrl_type      = SOCK_DGRAM,
+       .xprt_type      = PROTO_TYPE_DGRAM,
        .listen         = uxdg_bind_listener,
        .enable         = uxdg_enable_listener,
        .disable        = uxdg_disable_listener,
index 2a32fa677d904a6862261f5dde4b76ff645fe6ac..c9639e76ee22b43228293639dde8e958b6964996 100644 (file)
@@ -50,7 +50,7 @@ struct protocol proto_uxst = {
        .name           = "unix_stream",
 
        /* connection layer */
-       .ctrl_type      = SOCK_STREAM,
+       .xprt_type      = PROTO_TYPE_STREAM,
        .listen         = uxst_bind_listener,
        .enable         = uxst_enable_listener,
        .disable        = uxst_disable_listener,
index 3d908a1335bc186b87d7a51cf4ad7e4aa590dd93..7da0727386460e066e7e323a3be6e8a3a4b64fb4 100644 (file)
@@ -44,7 +44,7 @@ void protocol_register(struct protocol *proto)
        LIST_APPEND(&protocols, &proto->list);
        __protocol_by_family[sock_domain]
                            [proto->proto_type]
-                           [proto->ctrl_type == SOCK_DGRAM] = proto;
+                           [proto->xprt_type == PROTO_TYPE_DGRAM] = proto;
        HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);
 }
 
index aba2d245f7e678c381489a68e4731c44c262c2e2..c221f82c771489d2c625664c98979566b69f327d 100644 (file)
@@ -3455,7 +3455,7 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
-               if (proto && proto->ctrl_type == SOCK_STREAM) {
+               if (proto && proto->xprt_type == PROTO_TYPE_STREAM) {
                        err_code |= parse_server(file, linenum, args, curr_resolvers->px, NULL,
                                                 SRV_PARSE_PARSE_ADDR|SRV_PARSE_INITIAL_RESOLVE);
                        if (err_code & (ERR_FATAL|ERR_ABORT)) {