Add a new field alt_proto to the server structures that
specify if an alternate protocol should be used for this server.
This field can be transparently passed to protocol_lookup to get
an appropriate protocol structure.
This change allows thus to create servers with different protocols,
and not only TCP anymore.
---
include/haproxy/server-t.h | 1 +
src/server.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/haproxy/server-t.h b/include/haproxy/server-t.h
index af58a5609..4233fff80 100644
--- a/include/haproxy/server-t.h
+++ b/include/haproxy/server-t.h
@@ -381,6 +381,7 @@ struct server {
const struct netns_entry *netns; /* contains network namespace
name or NULL. Network namespace comes from configuration */
struct xprt_ops *xprt; /* transport-layer operations */
+ int alt_proto; /* alternate protocol to use in
protocol_lookup */
unsigned int svc_port; /* the port to connect to (for
relevant families) */
unsigned down_time; /* total time the server was
down */
diff --git a/src/server.c b/src/server.c
index a4f78cc66..3e0b99e92 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3306,6 +3306,7 @@ static int _srv_parse_init(struct server **srv, char
**args, int *cur_arg,
const char *err = NULL;
int err_code = 0;
char *fqdn = NULL;
+ int alt_proto = 0;
int tmpl_range_low = 0, tmpl_range_high = 0;
char *errmsg = NULL;
@@ -3396,7 +3397,7 @@ static int _srv_parse_init(struct server **srv, char
**args, int *cur_arg,
goto skip_addr;
sk = str2sa_range(args[*cur_arg], &port, &port1, &port2, NULL,
NULL, &newsrv->addr_type,
- &errmsg, NULL, &fqdn, NULL,
+ &errmsg, NULL, &fqdn, &alt_proto,
(parse_flags & SRV_PARSE_INITIAL_RESOLVE ?
PA_O_RESOLVE : 0) | PA_O_PORT_OK |
(parse_flags & SRV_PARSE_IN_PEER_SECTION ?
PA_O_PORT_MAND : PA_O_PORT_OFS) |
PA_O_STREAM | PA_O_DGRAM | PA_O_XPRT);
@@ -3439,6 +3440,7 @@ static int _srv_parse_init(struct server **srv, char
**args, int *cur_arg,
newsrv->addr = *sk;
newsrv->svc_port = port;
+ newsrv->alt_proto = alt_proto;
/*
* we don't need to lock the server here, because
* we are in the process of initializing.
--
2.46.0