From 8cac7c139908eff0124a4a6f9d25f3b3fe10a254 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Aug 2006 12:13:57 +0000 Subject: r17795: Finally track down the "ads_connect: Interrupted system call" error. Fix our DNS SRV lookup code to deal with multi-homed hosts. We were noly remembering one IP address per host from the Additional records section in the SRV response which could have been an unreachable address. (This used to be commit 899179d2b9fba13cc6f4dab6efc3c22e44e062bc) --- source3/include/ads_dns.h | 5 +++-- source3/libads/dns.c | 35 +++++++++++++++++++++++++++++++-- source3/libsmb/namequery.c | 48 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/source3/include/ads_dns.h b/source3/include/ads_dns.h index 74762a9242..6c3430e21b 100644 --- a/source3/include/ads_dns.h +++ b/source3/include/ads_dns.h @@ -47,10 +47,11 @@ struct dns_rr_srv { uint16 priority; uint16 weight; uint16 port; - struct in_addr ip; + size_t num_ips; + struct in_addr *ips; /* support multi-homed hosts */ }; -/* SRV records */ +/* NS records */ struct dns_rr_ns { const char *hostname; diff --git a/source3/libads/dns.c b/source3/libads/dns.c index 903d19b753..c946ab0bdd 100644 --- a/source3/libads/dns.c +++ b/source3/libads/dns.c @@ -398,14 +398,45 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx, const char *name, struct dn } /* only interested in A records as a shortcut for having to come - back later and lookup the name */ + back later and lookup the name. For multi-homed hosts, the + number of additional records and exceed the number of answer + records. */ + if ( (rr.type != T_A) || (rr.rdatalen != 4) ) continue; + /* FIX ME!!! Should this be a list of IP addresses for + each host? */ + for ( i=0; iip = *interpret_addr2(dcs[i].hostname); - else - r->ip = dcs[i].ip; - r->port = dcs[i].port; + + /* If we don't have an IP list for a name, lookup it up */ + + if ( !dcs[i].ips ) { + r->ip = *interpret_addr2(dcs[i].hostname); + i++; + j = 0; + } else { + /* use the IP addresses from the SRV sresponse */ + + if ( j >= dcs[i].num_ips ) { + i++; + j = 0; + continue; + } + + r->ip = dcs[i].ips[j]; + j++; + } /* make sure it is a valid IP. I considered checking the negative connection cache, but this is the wrong place for it. Maybe only @@ -1358,7 +1379,6 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, *ordered = False; - /* if we are restricted to solely using DNS for looking up a domain controller, make sure that host lookups are enabled for the 'name resolve order'. If host lookups @@ -1374,9 +1394,9 @@ static BOOL get_dc_list(const char *domain, struct ip_service **ip_list, /* DNS SRV lookups used by the ads resolver are already sorted by priority and weight */ *ordered = True; + } else { + fstrcpy( resolve_order, "NULL" ); } - else - fstrcpy( resolve_order, "NULL" ); } /* fetch the server we have affinity for. Add the -- cgit