diff options
Diffstat (limited to 'mDNSResponder/mDNSCore/mDNS.c')
-rwxr-xr-x | mDNSResponder/mDNSCore/mDNS.c | 74 |
1 files changed, 45 insertions, 29 deletions
diff --git a/mDNSResponder/mDNSCore/mDNS.c b/mDNSResponder/mDNSCore/mDNS.c index e15b7cf8..e0af1f1a 100755 --- a/mDNSResponder/mDNSCore/mDNS.c +++ b/mDNSResponder/mDNSCore/mDNS.c @@ -466,8 +466,10 @@ mDNSexport void AnswerQuestionByFollowingCNAME(mDNS *const m, DNSQuestion *q, Re { const mDNSBool selfref = SameDomainName(&q->qname, &rr->rdata->u.name); if (q->CNAMEReferrals >= 10 || selfref) + { LogMsg("AnswerQuestionByFollowingCNAME: %p %##s (%s) NOT following CNAME referral %d%s for %s", q, q->qname.c, DNSTypeName(q->qtype), q->CNAMEReferrals, selfref ? " (Self-Referential)" : "", RRDisplayString(m, rr)); + } else { const mDNSu32 c = q->CNAMEReferrals + 1; // Stash a copy of the new q->CNAMEReferrals value @@ -1254,19 +1256,6 @@ mDNSexport mStatus mDNS_Register_internal(mDNS *const m, AuthRecord *const rr) } } - // If this resource record is referencing a specific interface, make sure it exists. - // Skip checks for LocalOnly and P2P as they are not valid InterfaceIDs. Also, for scoped - // entries in /etc/hosts skip that check as that interface may not be valid at this time. - if (rr->resrec.InterfaceID && rr->ARType != AuthRecordLocalOnly && rr->ARType != AuthRecordP2P) - { - NetworkInterfaceInfo *intf = FirstInterfaceForID(m, rr->resrec.InterfaceID); - if (!intf) - { - debugf("mDNS_Register_internal: Bogus InterfaceID %p in resource record", rr->resrec.InterfaceID); - return(mStatus_BadReferenceErr); - } - } - rr->next = mDNSNULL; // Field Group 1: The actual information pertaining to this resource record @@ -2821,7 +2810,8 @@ mDNSlocal void SendResponses(mDNS *const m) if (rr->SendRNow) { if (rr->ARType != AuthRecordLocalOnly && rr->ARType != AuthRecordP2P) - LogMsg("SendResponses: No active interface %p to send: %p %02X %s", rr->SendRNow, rr->resrec.InterfaceID, rr->resrec.RecordType, ARDisplayString(m, rr)); + LogInfo("SendResponses: No active interface %d to send: %d %02X %s", + (uint32_t)rr->SendRNow, (uint32_t)rr->resrec.InterfaceID, rr->resrec.RecordType, ARDisplayString(m, rr)); rr->SendRNow = mDNSNULL; } @@ -3467,6 +3457,11 @@ mDNSlocal void SendQueries(mDNS *const m) { if (ar->AddressProxy.type == mDNSAddrType_IPv4) { + // There's a problem here. If a host is waking up, and we probe to see if it responds, then + // it will see those ARP probes as signalling intent to use the address, so it picks a different one. + // A more benign way to find out if a host is responding to ARPs might be send a standard ARP *request* + // (using our sender IP address) instead of an ARP *probe* (using all-zero sender IP address). + // A similar concern may apply to the NDP Probe too. -- SC LogSPS("SendQueries ARP Probe %d %s %s", ar->ProbeCount, InterfaceNameForID(m, ar->resrec.InterfaceID), ARDisplayString(m,ar)); SendARP(m, 1, ar, &zerov4Addr, &zeroEthAddr, &ar->AddressProxy.ip.v4, &ar->WakeUp.IMAC); } @@ -3747,7 +3742,8 @@ mDNSlocal void SendQueries(mDNS *const m) if (ar->SendRNow) { if (ar->ARType != AuthRecordLocalOnly && ar->ARType != AuthRecordP2P) - LogMsg("SendQueries: No active interface %p to send probe: %p %s", ar->SendRNow, ar->resrec.InterfaceID, ARDisplayString(m, ar)); + LogInfo("SendQueries: No active interface %d to send probe: %d %s", + (uint32_t)ar->SendRNow, (uint32_t)ar->resrec.InterfaceID, ARDisplayString(m, ar)); ar->SendRNow = mDNSNULL; } @@ -3778,7 +3774,8 @@ mDNSlocal void SendQueries(mDNS *const m) { DNSQuestion *x; for (x = m->NewQuestions; x; x=x->next) if (x == q) break; // Check if this question is a NewQuestion - LogMsg("SendQueries: No active interface %p to send %s question: %p %##s (%s)", q->SendQNow, x ? "new" : "old", q->InterfaceID, q->qname.c, DNSTypeName(q->qtype)); + LogInfo("SendQueries: No active interface %d to send %s question: %d %##s (%s)", + (uint32_t)q->SendQNow, x ? "new" : "old", (uint32_t)q->InterfaceID, q->qname.c, DNSTypeName(q->qtype)); q->SendQNow = mDNSNULL; } q->CachedAnswerNeedsUpdate = mDNSfalse; @@ -10347,6 +10344,7 @@ mDNSexport void mDNSCoreReceive(mDNS *const m, void *const pkt, const mDNSu8 *co // (b) being performed by a unicast DNS long-lived query (either full LLQ, or polling) // for multicast questions, we don't want to treat LongLived as anything special #define IsLLQ(Q) ((Q)->LongLived && !mDNSOpaque16IsZero((Q)->TargetQID)) +#define IsAWDLIncluded(Q) (((Q)->flags & kDNSServiceFlagsIncludeAWDL) != 0) mDNSlocal DNSQuestion *FindDuplicateQuestion(const mDNS *const m, const DNSQuestion *const question) { @@ -10369,6 +10367,7 @@ mDNSlocal DNSQuestion *FindDuplicateQuestion(const mDNS *const m, const DNSQuest (q->DisallowPID == question->DisallowPID) && // Disallowing a PID should not affect a PID that is allowed (q->BrowseThreshold == question->BrowseThreshold) && // browse thresholds must match q->qnamehash == question->qnamehash && + (IsAWDLIncluded(q) == IsAWDLIncluded(question)) && // Inclusion of AWDL interface must match SameDomainName(&q->qname, &question->qname)) // and name return(q); return(mDNSNULL); @@ -11334,8 +11333,8 @@ mDNSlocal mStatus ValidateParameters(mDNS *const m, DNSQuestion *const question) { NetworkInterfaceInfo *intf = FirstInterfaceForID(m, question->InterfaceID); if (!intf) - LogMsg("ValidateParameters: Note: InterfaceID %p for question %##s (%s) not currently found in active interface list", - question->InterfaceID, question->qname.c, DNSTypeName(question->qtype)); + LogInfo("ValidateParameters: Note: InterfaceID %d for question %##s (%s) not currently found in active interface list", + (uint32_t)question->InterfaceID, question->qname.c, DNSTypeName(question->qtype)); } return(mStatus_NoError); @@ -11445,9 +11444,15 @@ mDNSlocal mDNSBool InitCommonState(mDNS *const m, DNSQuestion *const question) question->LOAddressAnswers = 0; question->FlappingInterface1 = mDNSNULL; question->FlappingInterface2 = mDNSNULL; - - question->ServiceID = mDNSPlatformGetServiceID(m, question); - + + // if kDNSServiceFlagsServiceIndex flag is SET by the client, then do NOT call mDNSPlatformGetServiceID() + // since we would already have the question->ServiceID in that case. + if (!(question->flags & kDNSServiceFlagsServiceIndex)) + question->ServiceID = mDNSPlatformGetServiceID(m, question); + else + LogInfo("InitCommonState: Query for %##s (%s), PID[%d], ServiceID %d is already set by client", question->qname.c, + DNSTypeName(question->qtype), question->pid, question->ServiceID); + InitDNSConfig(m, question); question->AuthInfo = GetAuthInfoForQuestion(m, question); @@ -11459,10 +11464,8 @@ mDNSlocal mDNSBool InitCommonState(mDNS *const m, DNSQuestion *const question) // set DisallowPID question->DisallowPID = (question->ServiceID == 0 || (mDNSPlatformAllowPID(m, question) == 0)); if (question->DisallowPID) - { LogInfo("InitCommonState: Query suppressed for %##s (%s), PID %d/ServiceID %d not allowed", question->qname.c, - DNSTypeName(question->qtype), question->pid, question->ServiceID); - } + DNSTypeName(question->qtype), question->pid, question->ServiceID); question->NextInDQList = mDNSNULL; question->SendQNow = mDNSNULL; @@ -11983,6 +11986,8 @@ mDNSlocal mStatus mDNS_StartBrowse_internal(mDNS *const m, DNSQuestion *const qu question->ForceMCast = ForceMCast; question->ReturnIntermed = mDNSfalse; question->SuppressUnusable = mDNSfalse; + question->DenyOnCellInterface = mDNSfalse; + question->DenyOnExpInterface = mDNSfalse; question->SearchListIndex = 0; question->AppendSearchDomains = 0; question->RetryWithSearchDomains = mDNSfalse; @@ -12179,6 +12184,8 @@ mDNSexport mStatus mDNS_StartResolveService(mDNS *const m, query->qSRV.ForceMCast = mDNSfalse; query->qSRV.ReturnIntermed = mDNSfalse; query->qSRV.SuppressUnusable = mDNSfalse; + query->qSRV.DenyOnCellInterface = mDNSfalse; + query->qSRV.DenyOnExpInterface = mDNSfalse; query->qSRV.SearchListIndex = 0; query->qSRV.AppendSearchDomains = 0; query->qSRV.RetryWithSearchDomains = mDNSfalse; @@ -12205,6 +12212,8 @@ mDNSexport mStatus mDNS_StartResolveService(mDNS *const m, query->qTXT.ForceMCast = mDNSfalse; query->qTXT.ReturnIntermed = mDNSfalse; query->qTXT.SuppressUnusable = mDNSfalse; + query->qTXT.DenyOnCellInterface = mDNSfalse; + query->qTXT.DenyOnExpInterface = mDNSfalse; query->qTXT.SearchListIndex = 0; query->qTXT.AppendSearchDomains = 0; query->qTXT.RetryWithSearchDomains = mDNSfalse; @@ -12231,6 +12240,8 @@ mDNSexport mStatus mDNS_StartResolveService(mDNS *const m, query->qAv4.ForceMCast = mDNSfalse; query->qAv4.ReturnIntermed = mDNSfalse; query->qAv4.SuppressUnusable = mDNSfalse; + query->qAv4.DenyOnCellInterface = mDNSfalse; + query->qAv4.DenyOnExpInterface = mDNSfalse; query->qAv4.SearchListIndex = 0; query->qAv4.AppendSearchDomains = 0; query->qAv4.RetryWithSearchDomains = mDNSfalse; @@ -12257,6 +12268,8 @@ mDNSexport mStatus mDNS_StartResolveService(mDNS *const m, query->qAv6.ForceMCast = mDNSfalse; query->qAv6.ReturnIntermed = mDNSfalse; query->qAv6.SuppressUnusable = mDNSfalse; + query->qAv6.DenyOnCellInterface = mDNSfalse; + query->qAv6.DenyOnExpInterface = mDNSfalse; query->qAv6.SearchListIndex = 0; query->qAv6.AppendSearchDomains = 0; query->qAv6.RetryWithSearchDomains = mDNSfalse; @@ -12318,6 +12331,8 @@ mDNSexport mStatus mDNS_GetDomains(mDNS *const m, DNSQuestion *const question, m question->ForceMCast = mDNSfalse; question->ReturnIntermed = mDNSfalse; question->SuppressUnusable = mDNSfalse; + question->DenyOnCellInterface = mDNSfalse; + question->DenyOnExpInterface = mDNSfalse; question->SearchListIndex = 0; question->AppendSearchDomains = 0; question->RetryWithSearchDomains = mDNSfalse; @@ -12817,7 +12832,8 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s if (set->Advertise) AdvertiseInterface(m, set); - LogInfo("mDNS_RegisterInterface: InterfaceID %p %s (%#a) %s", set->InterfaceID, set->ifname, &set->ip, + LogInfo("mDNS_RegisterInterface: InterfaceID %d %s (%#a) %s", + (uint32_t)set->InterfaceID, set->ifname, &set->ip, set->InterfaceActive ? "not represented in list; marking active and retriggering queries" : "already represented in list; marking inactive for now"); @@ -12961,8 +12977,8 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se NetworkInterfaceInfo *intf = FirstInterfaceForID(m, set->InterfaceID); if (intf) { - LogInfo("mDNS_DeregisterInterface: Another representative of InterfaceID %p %s (%#a) exists;" - " making it active", set->InterfaceID, set->ifname, &set->ip); + LogInfo("mDNS_DeregisterInterface: Another representative of InterfaceID %d %s (%#a) exists;" + " making it active", (uint32_t)set->InterfaceID, set->ifname, &set->ip); if (intf->InterfaceActive) LogMsg("mDNS_DeregisterInterface: ERROR intf->InterfaceActive already set for %s (%#a)", set->ifname, &set->ip); intf->InterfaceActive = mDNStrue; @@ -12984,8 +13000,8 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se CacheRecord *rr; DNSQuestion *q; - LogInfo("mDNS_DeregisterInterface: Last representative of InterfaceID %p %s (%#a) deregistered;" - " marking questions etc. dormant", set->InterfaceID, set->ifname, &set->ip); + LogInfo("mDNS_DeregisterInterface: Last representative of InterfaceID %d %s (%#a) deregistered;" + " marking questions etc. dormant", (uint32_t)set->InterfaceID, set->ifname, &set->ip); m->mDNSStats.InterfaceDown++; |