On Wed, Oct 28, 2015 at 4:41 PM, Baptiste <[email protected]> wrote:
> 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;

Thank you for the careful explanation Baptiste, that riddle was confounding
our understanding.

Reply via email to