]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux/frontend: Add 'proto' keyword to force the mux protocol
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Apr 2018 12:43:00 +0000 (14:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Aug 2018 08:41:11 +0000 (10:41 +0200)
For now, it is parsed but not used. Tests are done on it to check if the side
and the mode are compatible with the proxy's definition.

doc/configuration.txt
include/types/listener.h
src/cfgparse.c
src/listener.c

index ff2771f277522a517f1e4520c52b8ae6f1403811..181e5230af8fc059897869655cee1126fa237ea0 100644 (file)
@@ -10995,6 +10995,16 @@ process <process-set>[/<thread-set>]
   smoother inter-process load balancing. Currently Linux 3.9 and above is known
   for supporting this. See also "bind-process" and "nbproc".
 
+proto <name>
+  Forces the multiplexer's protocol to use for the incoming connections. It
+  must be compatible with the mode of the frontend (TCP or HTTP). It must also
+  be usable on the frontend side. The list of available protocols is reported
+  in haproxy -vv.
+  Idea behind this optipon is to bypass the selection of the best multiplexer's
+  protocol for all connections instantiated from this listening socket. For
+  instance, it is possible to force the http/2 on clear TCP by specifing "proto
+  h2" on the bind line.
+
 ssl
   This setting is only available when support for OpenSSL was built in. It
   enables SSL deciphering on connections instantiated from this listener. A
index c55569cd33a3ef9afa2652c9e8d23e6c9e4614ae..09b11044a08ad7c5c0cc0234dc6feda5f5692588 100644 (file)
@@ -156,6 +156,7 @@ struct bind_conf {
        EVP_PKEY *ca_sign_pkey;    /* CA private key referenced by ca_key */
 #endif
        struct proxy *frontend;    /* the frontend all these listeners belong to, or NULL */
+       struct mux_proto_list *mux_proto; /* the mux to use for all incoming connections (specified by the "proto" keyword) */
        struct xprt_ops *xprt;     /* transport-layer operations for all listeners */
        int is_ssl;                /* SSL is required for these listeners */
        int generate_certs;        /* 1 if generate-certificates option is set, else 0 */
index 1451243adcf54bc7ccd5d3bdefbe9140c00ff361..16f70d631201cbe8e547e25413f2498bd2653775 100644 (file)
@@ -8768,6 +8768,23 @@ out_uri_auth_compat:
                                }
                        }
                }
+
+               /* Check the mux protocols, if any, for each listener
+                * attached to the current proxy */
+               list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
+                       int mode = (1 << (curproxy->mode == PR_MODE_HTTP));
+
+                       if (!bind_conf->mux_proto)
+                               continue;
+                       if (!(bind_conf->mux_proto->mode & mode)) {
+                               ha_alert("config : %s '%s' : MUX protocol '%.*s' is not usable for 'bind %s' at [%s:%d].\n",
+                                        proxy_type_str(curproxy), curproxy->id,
+                                        (int)bind_conf->mux_proto->token.len,
+                                        bind_conf->mux_proto->token.ptr,
+                                        bind_conf->arg, bind_conf->file, bind_conf->line);
+                               cfgerr++;
+                       }
+               }
        }
 
        /***********************************************************/
index 20244056f06dcdec9d75f6b553e891039816315e..a30d4fb4f6dda180fc50b7760bf93564cfad9602 100644 (file)
@@ -30,6 +30,7 @@
 #include <types/protocol.h>
 
 #include <proto/acl.h>
+#include <proto/connection.h>
 #include <proto/fd.h>
 #include <proto/freq_ctr.h>
 #include <proto/log.h>
@@ -964,6 +965,30 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct
        return 0;
 }
 
+/* parse the "proto" bind keyword */
+static int bind_parse_proto(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
+{
+       struct ist proto;
+
+       if (!*args[cur_arg + 1]) {
+               memprintf(err, "'%s' : missing value", args[cur_arg]);
+               return ERR_ALERT | ERR_FATAL;
+       }
+
+       proto = ist2(args[cur_arg + 1], strlen(args[cur_arg + 1]));
+       conf->mux_proto = get_mux_proto(proto);
+       if (!conf->mux_proto) {
+               memprintf(err, "'%s' :  unknown MUX protocol '%s'", args[cur_arg], args[cur_arg+1]);
+               return ERR_ALERT | ERR_FATAL;
+       }
+       else if (!(conf->mux_proto->side & PROTO_SIDE_FE)) {
+               memprintf(err, "'%s' :  MUX protocol '%s' cannot be used for incoming connections",
+                         args[cur_arg], args[cur_arg+1]);
+               return ERR_ALERT | ERR_FATAL;
+       }
+       return 0;
+}
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
  */
@@ -996,6 +1021,7 @@ static struct bind_kw_list bind_kws = { "ALL", { }, {
        { "name",         bind_parse_name,         1 }, /* set name of listening socket */
        { "nice",         bind_parse_nice,         1 }, /* set nice of listening socket */
        { "process",      bind_parse_process,      1 }, /* set list of allowed process for this socket */
+       { "proto",        bind_parse_proto,        1 }, /* set the proto to use for all incoming connections */
        { /* END */ },
 }};