]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: allow thread kw for rhttp bind
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Nov 2023 16:31:05 +0000 (17:31 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Nov 2023 16:46:00 +0000 (17:46 +0100)
Thanks to previous commit, a reverse HTTP listener is able to distribute
actively opened connections accross its threads. To be able to exploit
this, allow "thread" keyword for such a listener.

An extra check is added to explicitely forbids a reverse bind to span
multiple thread groups. Without this, multiple listeners instances will
be created, each with its owned "nbconn" value. This may surprise users
so for now, better to deactivate this possibility.

doc/configuration.txt
src/listener.c

index fe0669df921f8d88a288bbd24ab68e3df821963f..2cb2c1ba68209ec59ce4f1a4f4847089e67c2c18 100644 (file)
@@ -15773,6 +15773,10 @@ thread [<thread-group>/]<thread-set>[,...]
   See also the "shards" keyword above that automates duplication of "bind"
   lines and their assignment to multiple groups of threads.
 
+  This keyword is compatible with reverse HTTP binds. However, it is forbidden
+  to specify a thread set which spans accross several thread groups for such a
+  listener as this may caused "nbconn" to not work as intended.
+
 tls-ticket-keys <keyfile>
   Sets the TLS ticket keys file to load the keys from. The keys need to be 48
   or 80 bytes long, depending if aes128 or aes256 is used, encoded with base64
index 824041ae47d3cc942f33a0b69885f346c163cc43..6ce5deaa8190f437544883f6c0687dee013a996c 100644 (file)
@@ -2355,12 +2355,22 @@ static int bind_parse_shards(char **args, int cur_arg, struct proxy *px, struct
 /* parse the "thread" bind keyword. This will replace any preset thread_set */
 static int bind_parse_thread(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
+       const struct listener *l;
+
        /* note that the thread set is zeroed before first call, and we don't
         * want to reset it so that it remains possible to chain multiple
         * "thread" directives.
         */
        if (parse_thread_set(args[cur_arg+1], &conf->thread_set, err) < 0)
                return ERR_ALERT | ERR_FATAL;
+
+       l = LIST_NEXT(&conf->listeners, struct listener *, by_bind);
+       if (l->rx.addr.ss_family == AF_CUST_RHTTP_SRV &&
+           atleast2(conf->thread_set.grps)) {
+               memprintf(err, "'%s' : reverse HTTP bind cannot span multiple thread groups.", args[cur_arg]);
+               return ERR_ALERT | ERR_FATAL;
+       }
+
        return 0;
 }
 
@@ -2446,7 +2456,7 @@ static struct bind_kw_list bind_kws = { "ALL", { }, {
        { "process",      bind_parse_process,      1, 0 }, /* set list of allowed process for this socket */
        { "proto",        bind_parse_proto,        1, 0 }, /* set the proto to use for all incoming connections */
        { "shards",       bind_parse_shards,       1, 0 }, /* set number of shards */
-       { "thread",       bind_parse_thread,       1, 0 }, /* set list of allowed threads for this socket */
+       { "thread",       bind_parse_thread,       1, 1 }, /* set list of allowed threads for this socket */
        { /* END */ },
 }};