From e42d87f3de4c5310e65f52a60e825a8349bf7d8c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 16 Sep 2020 20:04:17 +0200 Subject: [PATCH] BUG/MINOR: dns: gracefully handle the "udp@" address format for nameservers Just like with previous commit, DNS nameservers are affected as well with addresses starting in "udp@", but here it's different, because due to another bug in the DNS parser, the address is rejected, indicating that it doesn't have a ->connect() method. Similarly, the DNS code believes it's working on top of TCP at this point and this used to work because of this. The same fix is applied to remap the protocol and the ->connect test was dropped. No backport is needed, as the ->connect() test will never strike in 2.2 or below. --- src/cfgparse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index 7fc499a6f..c5b2b20dd 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1041,8 +1041,14 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm) goto out; } + /* handle nicely the case where "udp@" is forced */ + if (sk->ss_family == AF_CUST_UDP4) + sk->ss_family = AF_INET; + else if (sk->ss_family == AF_CUST_UDP6) + sk->ss_family = AF_INET6; + proto = protocol_by_family(sk->ss_family); - if (!proto || !proto->connect) { + if (!proto) { ha_alert("parsing [%s:%d] : '%s %s' : connect() not supported for this address family.\n", file, linenum, args[0], args[1]); err_code |= ERR_ALERT | ERR_FATAL;