musl dns client stop further search domain when one search domain return something unexpected.
When making dns query with multiple search domain, alpine dns client would stop further search when on search domain return something unexpected.
- cat /etc/resolv.conf
search default.svc.enn.cn svc.enn.cn enn.cn some.something.com
when make query of some common name, e.g. baidu.com, the dns client should query following names and eventually return a correct resolved ip addr:
- baidu.com.default.svc.enn.cn (The DNS 10.254.0.10 return NXDOMAIN)
- baidu.com.svc.enn.cn (The DNS 10.254.0.10 return NXDOMAIN)
- baidu.com.enn.cn (The DNS 10.254.0.10 return NXDOMAIN)
- baidu.com.some.something.com (Somehow dns server return code 0, or some error code)
- baidu.com (return correct answer.)
but with musl dns client, it would fail in step 4 when dns server return
code 0 without answers(or return errors).
I think this is a musl bug after checking musl code. The cause is that name_from_dns would return error code, but name_from_dns_search would return whenever a error received from name_from_dns. It is more acceptable for musl to keep trying further domain when cnt is negative.
I tried following code change, and it seems fix it
diff —git a/src/network/lookup_name.c b/src/network/lookup_name.c
index 209c20f..abb7da5 100644
@@ –202,7 +202,7 @@ static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[
memcpy(canon+l+1, p, z-p);
canon[z-p+1+l] = 0;
int cnt = name_from_dns(buf, canon, canon, family, &conf);
- if (cnt) return cnt;
- if (cnt >0 || cnt == EAI_AGAIN) return cnt;
I tried to contact musl authors, but on luck yet. Hope this is the right place to put the issue.
(from redmine: issue id 9017, created on 2018-06-17, closed on 2018-07-18)