MINOR: resolvers: Reset server IP on error in resolv_get_ip_from_response()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Jun 2021 13:33:52 +0000 (15:33 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Jul 2021 16:14:20 +0000 (18:14 +0200)
If resolv_get_ip_from_response() returns an error (or an unexpected return
value), the server is set to RMAINT status. However, its address must also
be reset. Otherwise, it is still reported by the cli on "show servers state"
commands. This may be confusing. Note that it is a theorical patch because
this code path does not exist. Thus it is not tagged as a BUG.

This patch may be backported as far as 2.0.

(cherry picked from commit 07ecff589d5e67eacfacfe62bccd70ea825b8bc0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit b142fb40a4ce7566ee2ca42fb6b164f9402bbdcd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/server.c

index 6a7ffe2..e83dd84 100644 (file)
@@ -3922,9 +3922,6 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na
                case DNS_UPD_SRVIP_NOT_FOUND:
                        goto save_ip;
 
-               case DNS_UPD_CNAME:
-                       goto invalid;
-
                case DNS_UPD_NO_IP_FOUND:
                        has_no_ip = 1;
                        goto update_status;
@@ -3932,9 +3929,11 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na
                case DNS_UPD_NAME_ERROR:
                        /* update resolution status to OTHER error type */
                        resolution->status = RSLV_STATUS_OTHER;
+                       has_no_ip = 1;
                        goto update_status;
 
                default:
+                       has_no_ip = 1;
                        goto invalid;
 
        }
@@ -3959,7 +3958,8 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *na
                nameserver->counters->invalid++;
                goto update_status;
        }
-       snr_update_srv_status(s, has_no_ip);
+       if (!snr_update_srv_status(s, has_no_ip) && has_no_ip)
+               memset(&s->addr, 0, sizeof(s->addr));
        return 0;
 }