Hi Pierre,

On Tue, Jan 16, 2018 at 06:08:40PM +0100, Pierre Cheynier wrote:
> Hi Olivier,
> 
> 
> On 16/01/2018 15:43, Olivier Houchard wrote:
> > I'm not so sure about this.
> > It won't be checked again when server are enabled, so you won't get the
> > warning if it's still the case.
> > You shouldn't get those warnings unless multiple servers have the same IP,
> > though. What does your server-template look like ?
> In fact, it's a confusion between 3 level of templating... /
> At the end it's not a server template in HAProxy, but raw servers, in a
> disabled state:
> 
> backend be_service
>     server srv0 10.0.0.2:1234
>     server srv1 0.0.0.0:0 check disabled
>     server srv2 0.0.0.0:0 check disabled
>     server srv3 0.0.0.0:0 check disabled
>     server srv4 0.0.0.0:0 check disabled
> 
> So I guess this warning was intended to cover this case, right ?
> 

Not really :) That's not a case I thought of.
The attached patch disables the generation of the dynamic cookie if the IP
is 0.0.0.0 or ::, so that it only gets generated when the server gets a real
IP. Is it OK with you ?

Regards,

Olivier
>From ede677c8625fed5984d98ccaddcba2eee12d6c43 Mon Sep 17 00:00:00 2001
From: Olivier Houchard <ohouch...@haproxy.com>
Date: Tue, 16 Jan 2018 18:42:07 +0100
Subject: [PATCH] MINOR: server: Don't generate dynamic cookies if addr is
 INADDR_ANY.

Don't attempt to generate a dynamic cookie if the server address is set
to INADDR_ANY or IN6ADDR_ANY, that makes little sense, and produce
useless warning if there are multiple such servers.

This should be backported to 1.8.
---
 src/server.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/server.c b/src/server.c
index a37e91968..03caf3772 100644
--- a/src/server.c
+++ b/src/server.c
@@ -103,8 +103,8 @@ void srv_set_dyncookie(struct server *s)
                return;
        key_len = strlen(p->dyncookie_key);
 
-       if (s->addr.ss_family != AF_INET &&
-           s->addr.ss_family != AF_INET6)
+       if (s->addr.ss_family == AF_UNIX ||
+           !is_addr(&s->addr))
                return;
        /*
         * Buffer to calculate the cookie value.
-- 
2.14.3

Reply via email to