On Thu, Mar 21, 2024 at 02:37:06PM +0000, Damien Claisse wrote:
> When adding a server dynamically, we observe that when a backend has a
> dynamic persistence cookie, the new server has no cookie as we receive
> the following HTTP header:
> set-cookie: test-cookie=; Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/
> Whereas we were expecting to receive something like the following, which
> is what we receive for a server added in the config file:
> set-cookie: test-cookie=abcdef1234567890; path=/
> After investigating code path, it seems srv_set_dyncookie() is never
> called when adding a server through CLI, it is only called when parsing
> config file or using "set server bkd1/srv1 addr".
> To fix this, add a call to srv_set_dyncookie() inside _srv_parse_init()
> which is used on the dynamic server initialization path.
> ---
>  src/server.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> diff --git a/src/server.c b/src/server.c
> index e22b33806..c954a8de3 100644
> --- a/src/server.c
> +++ b/src/server.c
> @@ -3306,7 +3306,9 @@ static int _srv_parse_init(struct server **srv, char 
> **args, int *cur_arg,
>               /*
>                * we don't need to lock the server here, because
>                * we are in the process of initializing.
> -              *
> +              */
> +             srv_set_dyncookie(newsrv);
> +             /*
>                * Note that the server is not attached into the proxy tree if
>                * this is a dynamic server.
>                */
> -- 
> 2.34.1
> 

Thanks for your contribution !

This patch raises several interrogations. First, dynamic servers are
currently intended to not support cookies, hence why the keyword is
disabled for them. It has been done as a convenience but maybe it would
be a good time to review it carefully and see if whole cookie support
can be enabled.

Second, I'm unsure srv_set_dyncookie() should be called on
_srv_parse_init(). This function is also called for configuration file
servers. In particular, I do not know how we should handled duplicate
cookie values in this case.

-- 
Amaury Denoyelle

Reply via email to