Questions regarding dns_lookup_int() in lib/roken/resolve.c #1198
Replies: 2 comments 1 reply
-
Is this the correct place for me to be asking these kind of questions? |
Beta Was this translation helpful? Give feedback.
-
The resolver functions return the size of the reply irrespective of whether the reply fit in the provided buffer. The loop is about resizing the buffer until it fits the reply. From this code I suspect that there are systems where the resolver functions return |
Beta Was this translation helpful? Give feedback.
-
I'm looking through the
dns_lookup_int()
function inlib/roken/resolve.c
and have some questions.Once in the
while(1)
loop I see the call to the#defined resolve_search()
function followed by the checking of its return value. I understand theif (size > len)
and theif (size > 0)
checks but I'm confused by what's done in theif (size <= 0 && len < rk_DNS_MAX_PACKET_SIZE)
test.First, when would the
resolve_search()
function (eitherdns_search()
,res_nsearch()
, orres_search()
depending on the#ifdefined
) return 0? From the documentation I've found those underlying functions either return the size of the DNS response or -1 if there's an error. Even if the DNS resource record is not found I would expect some sort of reply with a DNS response code likeNXDOMAIN
, etc. and not a zero byte reply.Also, even if the resolver returned a zero byte response or -1 for an error why would doubling the size of the reply buffer hope to improve things? For example,
NXDOMAIN
isNXDOMAIN
andETIMEDOUT
isETIMEDOUT
no matter how big a reply buffer you provide. Doubling the reply buffer size and retrying multiple times can significantly delay this function returning an error if the reason for the error isETIMEDOUT
.Any insight into why the
if (size <= 0 && len < rk_DNS_MAX_PACKET_SIZE)
check is doing what it's doing would be greatly appreciated.Beta Was this translation helpful? Give feedback.
All reactions