MINOR: protocol: replace ctrl_type with xprt_type and clarify it
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.
diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h
index 8f51a7a..b0765cf 100644
--- a/include/haproxy/protocol-t.h
+++ b/include/haproxy/protocol-t.h
@@ -89,8 +89,8 @@
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() */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 3364529..d841223 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -161,7 +161,7 @@
* 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);
}
diff --git a/src/log.c b/src/log.c
index be98982..1294262 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1005,7 +1005,7 @@
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
diff --git a/src/proto_quic.c b/src/proto_quic.c
index 5c20045..55aa4b5 100644
--- a/src/proto_quic.c
+++ b/src/proto_quic.c
@@ -65,7 +65,7 @@
.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 @@
.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,
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 9126fe6..54cc34f 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -65,7 +65,7 @@
.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,
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 42342d6..2dbfb64 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -54,7 +54,7 @@
.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 @@
.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,
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 3474d4e..542d287 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -49,7 +49,7 @@
.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 @@
.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,
diff --git a/src/proto_uxdg.c b/src/proto_uxdg.c
index 8951651..41e0100 100644
--- a/src/proto_uxdg.c
+++ b/src/proto_uxdg.c
@@ -40,7 +40,7 @@
.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,
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 2a32fa6..c9639e7 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -50,7 +50,7 @@
.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,
diff --git a/src/protocol.c b/src/protocol.c
index 3d908a1..7da0727 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -44,7 +44,7 @@
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);
}
diff --git a/src/resolvers.c b/src/resolvers.c
index aba2d24..c221f82 100644
--- a/src/resolvers.c
+++ b/src/resolvers.c
@@ -3455,7 +3455,7 @@
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)) {