Hi Olivier,
On Tue, Mar 14, Olivier Houchard wrote:
> Hi guys,
>
> You'll find attached patches to add support for dynamically-generated session
> cookies for each server, the said cookies will be a hash of the IP, the
> TCP port, and a secret key provided.
> This adds 2 keywords to the config file, a "dynamic" keyword in the cookie
> line, which just enables dynamic cookie, and a "dynamic-cookie-key" keyword,
> for backends, which specifies the secret key to use.
> This is a first step to be able to add and remove servers on the fly,
> without modifying the configuration. That way, we can have cookies that are
> automatically usable for all the load-balancers.
>
> Any comment would be welcome.
If I omit dynamic-cookie-key then I'll get a crash:
(gdb) bt
#0 0x00007ffff6a72e71 in __strlen_sse2_pminub () from /lib64/libc.so.6
#1 0x000000000044bbe4 in srv_set_dyncookie (s=s@entry=0x720050)
at src/server.c:88
(I think p->dyncookie_key is NULL).
#2 0x0000000000429720 in check_config_validity () at src/cfgparse.c:8480
#3 0x0000000000487b25 in init (argc=<optimized out>, argc@entry=4,
argv=<optimized out>, argv@entry=0x7fffffffdcb8) at src/haproxy.c:814
#4 0x000000000040820b in main (argc=4, argv=0x7fffffffdcb8)
at src/haproxy.c:1643
with this config(defaults/global omitted):
frontend test
bind [email protected]:8080
default_backend test_be
backend test_be
balance roundrobin
#dynamic-cookie-key "dymmykey"
cookie WEBSRV insert dynamic
server wp1 127.0.0.1:8084 id 1
server wp2 127.0.0.1:8085 id 2
Is the hash same with little/big endian processors ?
memcpy(&(tmpbuf[key_len]),
s->addr.ss_family == AF_INET ?
(void *)&((struct sockaddr_in *)&s->addr)->sin_addr.s_addr :
(void *)&(((struct sockaddr_in6 *)&s->addr)->sin6_addr.s6_addr),
addr_len);
-Jarno
(Also there's a minor typo in comments:
> +/* Calculates the dynamic persitent cookie for a server, if a secret key has
> + * been provided.
> + */
...
> + else if (!strcmp(args[cur_arg], "dynamic")) { /*
> Dynamic persitent cookies secret key */
s/persitent/persistent/)
--
Jarno Huuskonen