[ldns-users] How to use _searchlist provided by ldns_struct_resolver?

Zbynek Michl zbynek.michl at nic.cz
Fri Oct 15 13:01:23 UTC 2010


Hi Matthijs,

thanks for your bug fixes. However I am still in doubt with 
ldns_resolver_search() function. I think it is not a good idea to use 
ldns_dname_str_absolute(str_dname) there.

1. When I use
---CODE---
domain = ldns_dname_new_frm_str("myhostname");
p = ldns_resolver_search(res, domain, LDNS_RR_TYPE_A,
                          LDNS_RR_CLASS_IN, LDNS_RD);
---/CODE---
then searchlist is not used because ldns_dname_new_frm_str() creates absolute 
dname everytime.

2. When I use
---CODE---
domain = ldns_dname_new_frm_str("myhostname.mydomain.cz");
new_domain = ldns_dname_new_frm_data(ldns_rdf_size(domain) - 1,
                                      ldns_rdf_data(domain));
p = ldns_resolver_search(res, new_domain, LDNS_RR_TYPE_A,
                          LDNS_RR_CLASS_IN, LDNS_RD);
---/CODE---
then searchlist is used indeed, however alone "myhostname.mydomain.cz" is never 
tried.

So I would expect ldns_resolver_search() should try every combination for given 
name (with and without suffix(es)).


Btw reading of searchlist from resolv.conf containing more than one suffix (e.g. 
search mydomain.com mydomain.cz) still does not work properly.

Thanks,
Zbynek

On 20.9.2010 12:40, Matthijs Mekking wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Zbynek,
>
> I noticed that the dname2str function prints a dot after every label.
> And that function is used in ldns_resolver_search(...) to determine if
> the domain is a relative or a fqdn. I fixed this in trunk, r3347.
>
> I found another bug in the ldns_resolver_search function. The
> ldns_resolver stops as soon it founds a packet. But it would be nice if
> the ldns_resolver continues its search if the RCODE of that packet is
> not NOERROR. This fix is in trunk since r3349.
>
> Thanks for your report.
>
> Best regards,
>
> Matthijs
>
>
> On 09/14/2010 06:46 PM, Zbynek Michl wrote:
>> Hi Matthijs,
>>
>> I have tried to make a dname like this:
>>
>> domain = ldns_dname_new_frm_str("myhostname");
>> new_domain = ldns_dname_new_frm_data(ldns_rdf_size(domain) - 1,
>>                                       ldns_rdf_data(domain));
>> printf("domain: %s\n", ldns_rdf2str(domain));
>> printf("new_domain: %s\n", ldns_rdf2str(new_domain));
>>
>> It is strange for me that both printf()s print the same result (with dot
>> at the end). And then when I use:
>>
>> p = ldns_resolver_search(res, new_domain, LDNS_RR_TYPE_A,
>>                           LDNS_RR_CLASS_IN, LDNS_RD);
>>
>> resolver returns FORMERR, because ldns_resolver_search() uses
>> ldns_rdf2str() which causes to call ldns_resolver_query() with incorrect
>> domain name.
>>
>>
>> Another error of ldns_resolver_search() is that it does not check RCODE.
>> In case of this resolv.conf:
>>
>> search mydomain.com
>> search mydomain.cz
>>
>> and query for "myhostname" will try just first search value even if
>> NXDOMAIN is returned.
>>
>> Last error that I have observed is that ldns_resolver_new_frm_file()
>> reads just first domain name on line, so this searchlist definition is
>> not read completely:
>>
>> search mydomain.com mydomain.cz
>>
>>
>> Regards,
>> Zbynek
>>
>> On 12.5.2010 09:04, Matthijs Mekking wrote:
>> Hi Zbynek,
>>
>> Sorry for the late follow-up. You are right that making a dname from
>> string always returns an absolute dname. You can try making a dname with
>> ldns_dname_new_frm_data().
>>
>> Best regards,
>>
>> Matthijs
>>
>> Zbynek Michl wrote:
>>>>> Hello,
>>>>>
>>>>> I am trying to use search list, but unsuccessfully. Here is an sample:
>>>>>
>>>>> --- CODE ---
>>>>> ldns_rdf *domain = ldns_dname_new_frm_str("myhostname");
>>>>> ldns_rdf *search = ldns_dname_new_frm_str("mydomain.cz");
>>>>>
>>>>> ldns_resolver_push_searchlist(res, search);
>>>>>
>>>>> p = ldns_resolver_search(res, domain, LDNS_RR_TYPE_A,
>>>>>                LDNS_RR_CLASS_IN, LDNS_RD);
>>>>> --- /CODE ---
>>>>>
>>>>> The problem is that "myhostname.mydomain.cz" will never be tried,
>>>>> because of ldns_dname_new_frm_str() adds "." to the end of "myhostname"
>>>>> and therefore ldns_resolver_search() will not concatenate "mydomain.cz".
>>>>> So how can I create "myhostname" RDF without trailing "."? Or any other
>>>>> suggestion?
>>>>>
>>>>> Cheers,
>>>>> Zbynek
>>>>> _______________________________________________
>>>>> ldns-users mailing list
>>>>> ldns-users at open.nlnetlabs.nl
>>>>> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJMlzoGAAoJEA8yVCPsQCW54RAIANqfP6o7Jex8E2gFfXoXQNl1
> lIDjPGSWfuFPeAcQS4G7YA7Tav2/0SKLX1RXdIuclWkzW+dI74z5FwPIhrqGV9ef
> +lWLO/jL2OvP6CDVTy/cc3abbU04rGl/PmYgCFJblJ4m98DjIrEF7OvfzviwH3G3
> cePtHcCiZy/cmSU450IzZ35PezSGFvaTLif04aFSMwIsMvhsfixNn+H7R0lmklZM
> 6K42z/zuYKnuEAU5tadHStfAi4Et04SBEs4B1xRkWp+Sdy/dRhYaj103bypC6qMH
> UiREaRCvbRkAnD5ukrodYvhjEmDrAnDPFo9MnSBCKZtDl+2nrWa9CUS2fVvqYxs=
> =nOFm
> -----END PGP SIGNATURE-----



More information about the ldns-users mailing list