On Wed, Oct 28, 2015 at 7:04 PM, Jesse Hathaway <[email protected]> wrote:
> On Wed, Oct 28, 2015 at 12:00 PM, Baptiste <[email protected]> wrote:
>> Good catch, forget about patch 00001, It was 2AM in the morning when I
>> wrote it :'(...
>> I wanted to apply the same code as DNS_UPD_NO_IP_FOUND, and increment
>> the OTHER error.
>
> That is interesting, but I was asking about the second patch,
> 0002-BUG-MINOR-dns-unable-to-parse-CNAMEs-response.patch
Ah, ok!
Anyway, your mail made me read my patches and find the ugly thing in
the other patch :)
So, when you write
if (cname && memcmp(ptr, cname, cnamelen))
return DNS_UPD_NAME_ERROR;
else if (memcmp(ptr, dn_name, dn_name_len))
return DNS_UPD_NAME_ERROR;
your compare cname againt name in current record only if cname is set.
In Ben's case, cname is set and ptr and cname comparison was true,
hence memcmp returned 0.
Since memcmp returns 0, then HAProxy checks the next condition and
compare ptr to dn_name, which lead to return the DNS_UPD_NAME_ERROR
since we're evaluating a cname and ptr points to the CNAME while
dn_name points to the queried name.
Basically, the code parsed the first response record, the CNAME, then
returned an error because the value of the cname does not match
anymore the name in the A record.
With the code below, when cname is set, there is no chance you compare
ptr and dn_name...
if (cname) {
if (memcmp(ptr, cname, cnamelen)) {
return DNS_UPD_NAME_ERROR;
}
}
else if (memcmp(ptr, dn_name, dn_name_len))
return DNS_UPD_NAME_ERROR;
Baptiste