Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/apache2/mDNSResponder/dist Import mDNSResponder-320...
details: https://anonhg.NetBSD.org/src/rev/cfc354162378
branches: trunk
changeset: 328343:cfc354162378
user: pettai <pettai%NetBSD.org@localhost>
date: Mon Mar 31 23:21:21 2014 +0000
description:
Import mDNSResponder-320.16, as previous import (258.14) is quite old
diffstat:
external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h | 4 +-
external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c | 427 +++++----
external/apache2/mDNSResponder/dist/mDNSCore/uDNS.h | 16 +-
external/apache2/mDNSResponder/dist/mDNSShared/PlatformCommon.c | 2 +-
external/apache2/mDNSResponder/dist/mDNSShared/uds_daemon.h | 1 +
5 files changed, 265 insertions(+), 185 deletions(-)
diffs (truncated from 768 to 300 lines):
diff -r 934d3c42fda9 -r cfc354162378 external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h
--- a/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h Mon Mar 31 20:51:20 2014 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h Mon Mar 31 23:21:21 2014 +0000
@@ -164,7 +164,8 @@
extern mDNSBool SameNameRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
extern mDNSBool ResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
extern mDNSBool AnyTypeRecordAnswersQuestion (const ResourceRecord *const rr, const DNSQuestion *const q);
-extern mDNSBool UnicastResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
+extern mDNSBool ResourceRecordAnswersUnicastResponse(const ResourceRecord *const rr, const DNSQuestion *const q);
+extern mDNSBool LocalOnlyRecordAnswersQuestion(AuthRecord *const rr, const DNSQuestion *const q);
extern mDNSu16 GetRDLength(const ResourceRecord *const rr, mDNSBool estimate);
extern mDNSBool ValidateRData(const mDNSu16 rrtype, const mDNSu16 rdlength, const RData *const rd);
@@ -226,6 +227,7 @@
#pragma mark - DNS Message Parsing Functions
#endif
+#define AuthHashSlot(X) (DomainNameHashValue(X) % AUTH_HASH_SLOTS)
#define HashSlot(X) (DomainNameHashValue(X) % CACHE_HASH_SLOTS)
extern mDNSu32 DomainNameHashValue(const domainname *const name);
extern void SetNewRData(ResourceRecord *const rr, RData *NewRData, mDNSu16 rdlength);
diff -r 934d3c42fda9 -r cfc354162378 external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c
--- a/external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c Mon Mar 31 20:51:20 2014 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c Mon Mar 31 23:21:21 2014 +0000
@@ -20,6 +20,9 @@
* Any dynamic run-time requirements should be handled by the platform layer below or client layer above
*/
+#if APPLE_OSX_mDNSResponder
+#include <TargetConditionals.h>
+#endif
#include "uDNS.h"
#if(defined(_MSC_VER))
@@ -98,7 +101,7 @@
#pragma mark - Name Server List Management
#endif
-mDNSexport DNSServer *mDNS_AddDNSServer(mDNS *const m, const domainname *d, const mDNSInterfaceID interface, const mDNSAddr *addr, const mDNSIPPort port, mDNSBool scoped)
+mDNSexport DNSServer *mDNS_AddDNSServer(mDNS *const m, const domainname *d, const mDNSInterfaceID interface, const mDNSAddr *addr, const mDNSIPPort port, mDNSBool scoped, mDNSu32 timeout)
{
DNSServer **p = &m->DNSServers;
DNSServer *tmp = mDNSNULL;
@@ -146,6 +149,7 @@
(*p)->flags = DNSServer_FlagNew;
(*p)->teststate = /* DNSServer_Untested */ DNSServer_Passed;
(*p)->lasttest = m->timenow - INIT_UCAST_POLL_INTERVAL;
+ (*p)->timeout = timeout;
AssignDomainName(&(*p)->domain, d);
(*p)->next = mDNSNULL;
}
@@ -345,17 +349,25 @@
// MUST be called with the lock held
mDNSexport mStatus mDNS_SetSecretForDomain(mDNS *m, DomainAuthInfo *info,
- const domainname *domain, const domainname *keyname, const char *b64keydata, mDNSBool AutoTunnel)
+ const domainname *domain, const domainname *keyname, const char *b64keydata, const domainname *hostname, mDNSIPPort *port, const char *autoTunnelPrefix)
{
DNSQuestion *q;
DomainAuthInfo **p = &m->AuthInfoList;
if (!info || !b64keydata) { LogMsg("mDNS_SetSecretForDomain: ERROR: info %p b64keydata %p", info, b64keydata); return(mStatus_BadParamErr); }
- LogInfo("mDNS_SetSecretForDomain: domain %##s key %##s%s", domain->c, keyname->c, AutoTunnel ? " AutoTunnel" : "");
-
- info->AutoTunnel = AutoTunnel;
+ LogInfo("mDNS_SetSecretForDomain: domain %##s key %##s%s%s", domain->c, keyname->c, autoTunnelPrefix ? " prefix " : "", autoTunnelPrefix ? autoTunnelPrefix : "");
+
+ info->AutoTunnel = autoTunnelPrefix;
AssignDomainName(&info->domain, domain);
AssignDomainName(&info->keyname, keyname);
+ if (hostname)
+ AssignDomainName(&info->hostname, hostname);
+ else
+ info->hostname.c[0] = 0;
+ if (port)
+ info->port = *port;
+ else
+ info->port = zeroIPPort;
mDNS_snprintf(info->b64keydata, sizeof(info->b64keydata), "%s", b64keydata);
if (DNSDigest_ConstructHMACKeyfromBase64(info, b64keydata) < 0)
@@ -372,12 +384,13 @@
// Caution: Only zero AutoTunnelHostRecord.namestorage and AutoTunnelNAT.clientContext AFTER we've determined that this is a NEW DomainAuthInfo
// being added to the list. Otherwise we risk smashing our AutoTunnel host records and NATOperation that are already active and in use.
- info->AutoTunnelHostRecord.resrec.RecordType = kDNSRecordTypeUnregistered;
- info->AutoTunnelHostRecord.namestorage.c[0] = 0;
- info->AutoTunnelTarget .resrec.RecordType = kDNSRecordTypeUnregistered;
- info->AutoTunnelDeviceInfo.resrec.RecordType = kDNSRecordTypeUnregistered;
- info->AutoTunnelService .resrec.RecordType = kDNSRecordTypeUnregistered;
- info->AutoTunnel6Record .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnelHostRecord .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnelHostRecord .namestorage.c[0] = 0;
+ info->AutoTunnelTarget .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnelDeviceInfo .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnelService .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnel6Record .resrec.RecordType = kDNSRecordTypeUnregistered;
+ info->AutoTunnel6MetaRecord.resrec.RecordType = kDNSRecordTypeUnregistered;
info->AutoTunnelNAT.clientContext = mDNSNULL;
info->next = mDNSNULL;
*p = info;
@@ -553,6 +566,9 @@
{
LogMsg("Error! Tried to add a NAT traversal that's already in the active list: request %p Prot %d Int %d TTL %d",
traversal, traversal->Protocol, mDNSVal16(traversal->IntPort), traversal->NATLease);
+ #if ForceAlerts
+ *(long*)0 = 0;
+ #endif
return(mStatus_AlreadyRegistered);
}
if (traversal->Protocol && traversal->Protocol == (*n)->Protocol && mDNSSameIPPort(traversal->IntPort, (*n)->IntPort) &&
@@ -698,7 +714,7 @@
// !!!KRS implement me
// format opt rr (fields not specified are zero-valued)
- mDNS_SetupResourceRecord(&rr, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, mDNSNULL, mDNSNULL);
+ mDNS_SetupResourceRecord(&rr, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, mDNSNULL, mDNSNULL);
opt->rrclass = NormalMaxDNSMessageData;
opt->rdlength = sizeof(rdataOPT); // One option in this OPT record
opt->rdestimate = sizeof(rdataOPT);
@@ -1572,6 +1588,12 @@
zd->question.ForceMCast = mDNSfalse;
zd->question.ReturnIntermed = mDNStrue;
zd->question.SuppressUnusable = mDNSfalse;
+ zd->question.SearchListIndex = 0;
+ zd->question.AppendSearchDomains = 0;
+ zd->question.RetryWithSearchDomains = mDNSfalse;
+ zd->question.TimeoutQuestion = 0;
+ zd->question.WakeOnResolve = 0;
+ zd->question.qnameOrig = mDNSNULL;
zd->question.QuestionCallback = GetZoneData_QuestionCallback;
zd->question.QuestionContext = zd;
@@ -1600,15 +1622,46 @@
zd->ZoneDataContext = ZoneDataContext;
zd->question.QuestionContext = zd;
- AssignDomainName(&zd->question.qname, zd->CurrentSOA);
mDNS_DropLockBeforeCallback(); // GetZoneData_StartQuery expects to be called from a normal callback, so we emulate that here
- GetZoneData_StartQuery(m, zd, kDNSType_SOA);
+ if (AuthInfo && AuthInfo->AutoTunnel && !mDNSIPPortIsZero(AuthInfo->port))
+ {
+ LogInfo("StartGetZoneData: Bypassing SOA, SRV query for %##s", AuthInfo->domain.c);
+ // We bypass SOA and SRV queries if we know the hostname and port already from the configuration.
+ // Today this is only true for AutoTunnel. As we bypass, we need to infer a few things:
+ //
+ // 1. Zone name is the same as the AuthInfo domain
+ // 2. ZoneClass is kDNSClass_IN which should be a safe assumption
+ //
+ // If we want to make this bypass mechanism work for non-AutoTunnels also, (1) has to hold
+ // good. Otherwise, it has to be configured also.
+
+ AssignDomainName(&zd->ZoneName, &AuthInfo->domain);
+ zd->ZoneClass = kDNSClass_IN;
+ AssignDomainName(&zd->Host, &AuthInfo->hostname);
+ zd->Port = AuthInfo->port;
+ AssignDomainName(&zd->question.qname, &zd->Host);
+ GetZoneData_StartQuery(m, zd, kDNSType_A);
+ }
+ else
+ {
+ if (AuthInfo && AuthInfo->AutoTunnel) LogInfo("StartGetZoneData: Not Bypassing SOA, SRV query for %##s", AuthInfo->domain.c);
+ AssignDomainName(&zd->question.qname, zd->CurrentSOA);
+ GetZoneData_StartQuery(m, zd, kDNSType_SOA);
+ }
mDNS_ReclaimLockAfterCallback();
return zd;
}
+// Returns if the question is a GetZoneData question. These questions are special in
+// that they are created internally while resolving a private query or LLQs.
+mDNSexport mDNSBool IsGetZoneDataQuestion(DNSQuestion *q)
+ {
+ if (q->QuestionCallback == GetZoneData_QuestionCallback) return(mDNStrue);
+ else return(mDNSfalse);
+ }
+
// GetZoneData queries are a special case -- even if we have a key for them, we don't do them privately,
// because that would result in an infinite loop (i.e. to do a private query we first need to get
// the _dns-query-tls SRV record for the zone, and we can't do *that* privately because to do so
@@ -1664,7 +1717,7 @@
}
else
{
- // Clearing SRVchanged is a safety measure. If our pewvious dereg never
+ // Clearing SRVchanged is a safety measure. If our pevious dereg never
// came back and we had a target change, we are starting fresh
r->SRVChanged = mDNSfalse;
// if it is already registered or in the process of registering, then don't
@@ -1709,7 +1762,7 @@
if (!rr->nta || mDNSIPv4AddressIsZero(rr->nta->Addr.ip.v4))
{
LogInfo("CompleteRecordNatMap called for %s but no zone information!", ARDisplayString(m, rr));
- // We need to clear out the NATinfo state so that it will result in re-acuqiring the mapping
+ // We need to clear out the NATinfo state so that it will result in re-acquiring the mapping
// and hence this callback called again.
if (rr->NATinfo.clientContext)
{
@@ -1802,8 +1855,13 @@
else if (SameDomainLabel(p, (mDNSu8 *)"\x4" "_udp")) protocol = NATOp_MapUDP;
else { LogMsg("StartRecordNatMap: could not determine transport protocol of service %##s", rr->resrec.name->c); return; }
+ //LogMsg("StartRecordNatMap: clientContext %p IntPort %d srv.port %d %s",
+ // rr->NATinfo.clientContext, mDNSVal16(rr->NATinfo.IntPort), mDNSVal16(rr->resrec.rdata->u.srv.port), ARDisplayString(m, rr));
if (rr->NATinfo.clientContext) mDNS_StopNATOperation_internal(m, &rr->NATinfo);
rr->NATinfo.Protocol = protocol;
+
+ // Shouldn't be trying to set IntPort here --
+ // BuildUpdateMessage overwrites srs->RR_SRV.resrec.rdata->u.srv.port with external (mapped) port number
rr->NATinfo.IntPort = rr->resrec.rdata->u.srv.port;
rr->NATinfo.RequestedPort = rr->resrec.rdata->u.srv.port;
rr->NATinfo.NATLease = 0; // Request default lease
@@ -1818,6 +1876,19 @@
// record is temporarily left in the ResourceRecords list so that we can initialize later
// when the target is resolvable. Similarly, when host name changes, we enter regState_NoTarget
// and we do the same.
+
+// This UnlinkResourceRecord routine is very worrying. It bypasses all the normal cleanup performed
+// by mDNS_Deregister_internal and just unceremoniously cuts the record from the active list.
+// This is why re-regsitering this record was producing syslog messages like this:
+// "Error! Tried to add a NAT traversal that's already in the active list"
+// Right now UnlinkResourceRecord is fortunately only called by RegisterAllServiceRecords,
+// which then immediately calls mDNS_Register_internal to re-register the record, which probably
+// masked more serious problems. Any other use of UnlinkResourceRecord is likely to lead to crashes.
+// For now we'll workaround that specific problem by explicitly calling mDNS_StopNATOperation_internal,
+// but long-term we should either stop cancelling the record registration and then re-registering it,
+// or if we really do need to do this for some reason it should be done via the usual
+// mDNS_Deregister_internal path instead of just cutting the record from the list.
+
mDNSlocal mStatus UnlinkResourceRecord(mDNS *const m, AuthRecord *const rr)
{
AuthRecord **list = &m->ResourceRecords;
@@ -1826,6 +1897,15 @@
{
*list = rr->next;
rr->next = mDNSNULL;
+
+ // Temporary workaround to cancel any active NAT mapping operation
+ if (rr->NATinfo.clientContext)
+ {
+ mDNS_StopNATOperation_internal(m, &rr->NATinfo);
+ rr->NATinfo.clientContext = mDNSNULL;
+ if (rr->resrec.rrtype == kDNSType_SRV) rr->resrec.rdata->u.srv.port = rr->NATinfo.IntPort;
+ }
+
return(mStatus_NoError);
}
LogMsg("UnlinkResourceRecord:ERROR!! - no such active record %##s", rr->resrec.name->c);
@@ -2022,7 +2102,7 @@
{
if (!mDNSIPv4AddressIsZero(m->AdvertisedV4.ip.v4) && h->arv4.resrec.RecordType == kDNSRecordTypeUnregistered)
{
- mDNS_SetupResourceRecord(&h->arv4, mDNSNULL, mDNSInterface_Any, kDNSType_A, kHostNameTTL, kDNSRecordTypeUnregistered, HostnameCallback, h);
+ mDNS_SetupResourceRecord(&h->arv4, mDNSNULL, mDNSInterface_Any, kDNSType_A, kHostNameTTL, kDNSRecordTypeUnregistered, AuthRecordAny, HostnameCallback, h);
AssignDomainName(&h->arv4.namestorage, &h->fqdn);
h->arv4.resrec.rdata->u.ipv4 = m->AdvertisedV4.ip.v4;
h->arv4.state = regState_Unregistered;
@@ -2048,7 +2128,7 @@
if (!mDNSIPv6AddressIsZero(m->AdvertisedV6.ip.v6) && h->arv6.resrec.RecordType == kDNSRecordTypeUnregistered)
{
- mDNS_SetupResourceRecord(&h->arv6, mDNSNULL, mDNSInterface_Any, kDNSType_AAAA, kHostNameTTL, kDNSRecordTypeKnownUnique, HostnameCallback, h);
+ mDNS_SetupResourceRecord(&h->arv6, mDNSNULL, mDNSInterface_Any, kDNSType_AAAA, kHostNameTTL, kDNSRecordTypeKnownUnique, AuthRecordAny, HostnameCallback, h);
AssignDomainName(&h->arv6.namestorage, &h->fqdn);
h->arv6.resrec.rdata->u.ipv6 = m->AdvertisedV6.ip.v6;
h->arv6.state = regState_Unregistered;
@@ -2189,6 +2269,12 @@
q->ForceMCast = mDNSfalse;
q->ReturnIntermed = mDNStrue;
q->SuppressUnusable = mDNSfalse;
+ q->SearchListIndex = 0;
+ q->AppendSearchDomains = 0;
+ q->RetryWithSearchDomains = mDNSfalse;
+ q->TimeoutQuestion = 0;
+ q->WakeOnResolve = 0;
+ q->qnameOrig = mDNSNULL;
q->QuestionCallback = FoundStaticHostname;
q->QuestionContext = mDNSNULL;
@@ -2927,7 +3013,7 @@
}
spaceleft -= rrSize;
oldnext = next;
- LogInfo("SendGroupUpdates: Building a message with resource record %s, next %p, state %d", ARDisplayString(m, rr), next, rr->state);
+ LogInfo("SendGroupUpdates: Building a message with resource record %s, next %p, state %d, ttl %d", ARDisplayString(m, rr), next, rr->state, rr->resrec.rroriginalttl);
if (!(next = BuildUpdateMessage(m, next, rr, limit)))
{
// We calculated the space and if we can't fit in, we had some bug in the calculation,
@@ -3071,7 +3157,7 @@
rr->updateError = err;
#if APPLE_OSX_mDNSResponder
- if (err == mStatus_BadSig) UpdateAutoTunnelDomainStatuses(m);
+ if (err == mStatus_BadSig || err == mStatus_BadKey) UpdateAutoTunnelDomainStatuses(m);
#endif
SetRecordRetry(m, rr, random);
@@ -4030,7 +4116,6 @@
Home |
Main Index |
Thread Index |
Old Index