When parsing the check address, store the associated proto too.
That way we can use the notation like quic4@address, and the right
protocol will be used. It is possible for checks to use a different
protocol than the server, ie we can have a QUIC server but want to run
TCP checks, so we can't just reuse whatever the server uses.
WIP: store the protocol in checks
char **envp; /* the environment to use if running a process-based check */
struct pid_list *curpid; /* entry in pid_list used for current process-based test, or -1 if not in test */
struct sockaddr_storage addr; /* the address to check */
+ struct protocol *proto; /* protocol used for check, may be different from the server's one */
char *pool_conn_name; /* conn name used on reuse */
char *sni; /* Server name */
char *alpn_str; /* ALPN to use for checks */
char **errmsg)
{
struct sockaddr_storage *sk;
+ struct protocol *proto;
int port1, port2, err_code = 0;
goto error;
}
- sk = str2sa_range(args[*cur_arg+1], NULL, &port1, &port2, NULL, NULL, NULL, errmsg, NULL, NULL, NULL,
+ sk = str2sa_range(args[*cur_arg+1], NULL, &port1, &port2, NULL, &proto, NULL, errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
memprintf(errmsg, "'%s' : %s", args[*cur_arg], *errmsg);
}
srv->check.addr = *sk;
+ srv->check.proto = proto;
/* if agentaddr was never set, we can use addr */
if (!(srv->flags & SRV_F_AGENTADDR))
srv->agent.addr = *sk;
goto error;
}
set_srv_agent_addr(srv, &sk);
-
+ /* Agent currently only uses TCP */
+ if (sk.ss_family == AF_INET)
+ srv->agent.proto = &proto_tcpv4;
+ else
+ srv->agent.proto = &proto_tcpv6;
out:
return err_code;
#include <haproxy/namespace.h>
#include <haproxy/port_range.h>
#include <haproxy/protocol.h>
+#include <haproxy/proto_tcp.h>
#include <haproxy/proxy.h>
#include <haproxy/queue.h>
#include <haproxy/quic_tp.h>
}
srv->use_ssl = src->use_ssl;
srv->check.addr = src->check.addr;
+ srv->check.proto = src->check.proto;
srv->agent.addr = src->agent.addr;
+ srv->agent.proto = src->agent.proto;
srv->check.use_ssl = src->check.use_ssl;
srv->check.port = src->check.port;
if (src->check.sni != NULL)
set_srv_agent_addr(s, &sk);
if (port)
set_srv_agent_port(s, new_port);
+ /* Agent currently only uses TCP */
+ if (sk.ss_family == AF_INET)
+ s->agent.proto = &proto_tcpv4;
+ else
+ s->agent.proto = &proto_tcpv6;
}
return NULL;
}
*/
const char *srv_update_check_addr_port(struct server *s, const char *addr, const char *port)
{
- struct sockaddr_storage sk;
+ struct sockaddr_storage *sk = NULL;
+ struct protocol *proto = NULL;
struct buffer *msg;
int new_port;
}
if (addr) {
memset(&sk, 0, sizeof(struct sockaddr_storage));
- if (str2ip2(addr, &sk, 0) == NULL) {
+ sk = str2sa_range(addr, NULL, NULL, NULL, NULL, &proto, NULL, NULL, NULL, NULL, NULL, 0);
+ if (sk == NULL) {
chunk_appendf(msg, "invalid addr '%s'", addr);
goto out;
}
if (msg->data)
return msg->area;
else {
- if (addr)
- s->check.addr = sk;
+ if (sk) {
+ s->check.addr = *sk;
+ s->check.proto = proto;
+ }
if (port)
s->check.port = new_port;
check->mux_proto = NULL;
}
else {
- proto = s ?
- protocol_lookup(conn->dst->ss_family, s->addr_type.proto_type, s->alt_proto) :
- protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, 0);
+ if (check->proto)
+ proto = check->proto;
+ else {
+ if (is_addr(&connect->addr))
+ proto = protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, 0);
+ else
+ proto = protocol_lookup(conn->dst->ss_family, s->addr_type.proto_type, s->alt_proto);
+
+ }
}
port = 0;