diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-20 11:12:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-20 11:23:31 +0200 |
commit | 49ebc73e1db87793fe536480739cdd31587d554d (patch) | |
tree | 58d6608b8f9dbfa76bd71c4367f5b5042cad4474 /mDNSResponder/mDNSCore | |
parent | mDNSResponder: Update to v567 (diff) | |
download | rtems-libbsd-49ebc73e1db87793fe536480739cdd31587d554d.tar.bz2 |
mDNSResponder: Update to v576.30.4
The sources can be obtained via:
https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-576.30.4.tar.gz
Update #3522.
Diffstat (limited to 'mDNSResponder/mDNSCore')
-rw-r--r-- | mDNSResponder/mDNSCore/DNSCommon.c | 2 | ||||
-rwxr-xr-x | mDNSResponder/mDNSCore/mDNS.c | 74 | ||||
-rwxr-xr-x | mDNSResponder/mDNSCore/mDNSEmbeddedAPI.h | 6 | ||||
-rwxr-xr-x | mDNSResponder/mDNSCore/uDNS.c | 6 |
4 files changed, 56 insertions, 32 deletions
diff --git a/mDNSResponder/mDNSCore/DNSCommon.c b/mDNSResponder/mDNSCore/DNSCommon.c index 3b2f2ceb..249e3b23 100644 --- a/mDNSResponder/mDNSCore/DNSCommon.c +++ b/mDNSResponder/mDNSCore/DNSCommon.c @@ -1467,6 +1467,8 @@ mDNSexport void mDNS_SetupQuestion(DNSQuestion *const q, const mDNSInterfaceID I q->ForceMCast = mDNSfalse; q->ReturnIntermed = mDNSfalse; q->SuppressUnusable = mDNSfalse; + q->DenyOnCellInterface = mDNSfalse; + q->DenyOnExpInterface = mDNSfalse; q->SearchListIndex = 0; q->AppendSearchDomains = 0; q->RetryWithSearchDomains = mDNSfalse; 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++; diff --git a/mDNSResponder/mDNSCore/mDNSEmbeddedAPI.h b/mDNSResponder/mDNSCore/mDNSEmbeddedAPI.h index 81b4192b..bafeb026 100755 --- a/mDNSResponder/mDNSCore/mDNSEmbeddedAPI.h +++ b/mDNSResponder/mDNSCore/mDNSEmbeddedAPI.h @@ -1983,10 +1983,12 @@ struct DNSQuestion_struct mDNSBool ForceMCast; // Set by client to force mDNS query, even for apparently uDNS names mDNSBool ReturnIntermed; // Set by client to request callbacks for intermediate CNAME/NXDOMAIN results mDNSBool SuppressUnusable; // Set by client to suppress unusable queries to be sent on the wire + mDNSBool DenyOnCellInterface; // Set by client to suppress uDNS queries on cellular interface + mDNSBool DenyOnExpInterface; // Set by client to suppress uDNS queries on expensive interface mDNSu8 RetryWithSearchDomains; // Retry with search domains if there is no entry in the cache or AuthRecords mDNSu8 TimeoutQuestion; // Timeout this question if there is no reply in configured time mDNSu8 WakeOnResolve; // Send wakeup on resolve - mDNSu8 UseBackgroundTrafficClass; // Use background traffic class for request + mDNSu8 UseBackgroundTrafficClass; // Set by client to use background traffic class for request mDNSs8 SearchListIndex; // Index into SearchList; Used by the client layer but not touched by core mDNSs8 AppendSearchDomains; // Search domains can be appended for this query mDNSs8 AppendLocalSearchDomains; // Search domains ending in .local can be appended for this query @@ -3336,7 +3338,7 @@ extern void mDNSPlatformSleepAssertion(mDNS *const m, double timeout); extern mDNSBool mDNSPlatformAllowPID(mDNS *const m, DNSQuestion *q); extern mDNSs32 mDNSPlatformGetServiceID(mDNS *const m, DNSQuestion *q); -extern void mDNSPlatformSetDelegatePID(UDPSocket *src, const mDNSAddr *dst, DNSQuestion *q); +extern void mDNSPlatformSetuDNSSocktOpt(UDPSocket *src, const mDNSAddr *dst, DNSQuestion *q); extern mDNSs32 mDNSPlatformGetPID(void); // *************************************************************************** diff --git a/mDNSResponder/mDNSCore/uDNS.c b/mDNSResponder/mDNSCore/uDNS.c index 8c7c3300..ce12d01a 100755 --- a/mDNSResponder/mDNSCore/uDNS.c +++ b/mDNSResponder/mDNSCore/uDNS.c @@ -1880,6 +1880,8 @@ mDNSlocal mStatus GetZoneData_StartQuery(mDNS *const m, ZoneData *zd, mDNSu16 qt zd->question.ForceMCast = mDNSfalse; zd->question.ReturnIntermed = mDNStrue; zd->question.SuppressUnusable = mDNSfalse; + zd->question.DenyOnCellInterface = mDNSfalse; + zd->question.DenyOnExpInterface = mDNSfalse; zd->question.SearchListIndex = 0; zd->question.AppendSearchDomains = 0; zd->question.RetryWithSearchDomains = mDNSfalse; @@ -2567,6 +2569,8 @@ mDNSlocal void GetStaticHostname(mDNS *m) q->ForceMCast = mDNSfalse; q->ReturnIntermed = mDNStrue; q->SuppressUnusable = mDNSfalse; + q->DenyOnCellInterface = mDNSfalse; + q->DenyOnExpInterface = mDNSfalse; q->SearchListIndex = 0; q->AppendSearchDomains = 0; q->RetryWithSearchDomains = mDNSfalse; @@ -4791,7 +4795,7 @@ mDNSexport void uDNS_CheckCurrentQuestion(mDNS *const m) { q->LocalSocket = mDNSPlatformUDPSocket(m, zeroIPPort); if (q->LocalSocket) - mDNSPlatformSetDelegatePID(q->LocalSocket, &q->qDNSServer->addr, q); + mDNSPlatformSetuDNSSocktOpt(q->LocalSocket, &q->qDNSServer->addr, q); } if (!q->LocalSocket) err = mStatus_NoMemoryErr; // If failed to make socket (should be very rare), we'll try again next time else err = mDNSSendDNSMessage(m, &m->omsg, end, q->qDNSServer->interface, q->LocalSocket, &q->qDNSServer->addr, q->qDNSServer->port, mDNSNULL, mDNSNULL, q->UseBackgroundTrafficClass); |