From: Amaury Denoyelle Date: Thu, 23 Nov 2023 16:31:05 +0000 (+0100) Subject: MINOR: listener: allow thread kw for rhttp bind X-Git-Tag: v2.9-dev11~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71ed381249976cd5ed9a8ce3fcc1658aee6c32e1;p=thirdparty%2Fhaproxy.git MINOR: listener: allow thread kw for rhttp bind 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. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index fe0669df92..2cb2c1ba68 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -15773,6 +15773,10 @@ thread [/][,...] 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 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 diff --git a/src/listener.c b/src/listener.c index 824041ae47..6ce5deaa81 100644 --- a/src/listener.c +++ b/src/listener.c @@ -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 */ }, }};