From 0d2ebb53f752502137479c9e753a96046d3254ab Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 18 Dec 2023 12:35:35 +0100 Subject: [PATCH] BUG/MINOR: resolvers: default resolvers fails when network not configured Bug #1740 was opened again, this time a user is complaining about the "can't create socket for nameserver". This can happen if the resolv.conf file contains a class of address which was not configured on the machine, for example IPv6. The fix does the same as b10b1196b ("MINOR: resolvers: shut the warning when "default" resolvers is implicit"), and uses the "resolvers->conf.implicit" variable to emit the error. Though it is not needed to convert the explicit behavior with a ERR_WARN, because this is supposed to be an unrecoverable error, unlike the connect(). Should fix issue #1740. Must be backported were b10b1196b was backported. (as far as 2.6) --- src/resolvers.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/resolvers.c b/src/resolvers.c index 4ef55b913..3275cd22d 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2567,9 +2567,11 @@ static int resolvers_finalize_config(void) if (ns->dgram) { /* Check nameserver info */ if ((fd = socket(ns->dgram->conn.addr.to.ss_family, SOCK_DGRAM, IPPROTO_UDP)) == -1) { - ha_alert("resolvers '%s': can't create socket for nameserver '%s'.\n", - resolvers->id, ns->id); - err_code |= (ERR_ALERT|ERR_ABORT); + if (!resolvers->conf.implicit) { /* emit a warning only if it was configured manually */ + ha_alert("resolvers '%s': can't create socket for nameserver '%s'.\n", + resolvers->id, ns->id); + err_code |= (ERR_ALERT|ERR_ABORT); + } continue; } if (connect(fd, (struct sockaddr*)&ns->dgram->conn.addr.to, get_addr_len(&ns->dgram->conn.addr.to)) == -1) {