merge conflicts; also:

- Do the reuse-port first like MacOS/X otherwise we can't bind
- Disable SO_RECV_ANYIF hack
This commit is contained in:
christos 2018-02-25 20:04:55 +00:00
parent 200e8a27b2
commit e68081c947
6 changed files with 34 additions and 14 deletions

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -4172,12 +4172,12 @@ mDNSexport void AnswerCurrentQuestionWithResourceRecord(mDNS *const m, CacheReco
responseLatencyMs = 0;
}
MetricsUpdateUDNSQueryStats(queryName, q->qtype, &rr->resrec, q->metrics.querySendCount, responseLatencyMs, isForCellular);
MetricsUpdateDNSQueryStats(queryName, q->qtype, &rr->resrec, q->metrics.querySendCount, responseLatencyMs, isForCellular);
q->metrics.answered = mDNStrue;
}
if (q->metrics.querySendCount > 0)
{
MetricsUpdateUDNSResolveStats(queryName, &rr->resrec, isForCellular);
MetricsUpdateDNSResolveStats(queryName, &rr->resrec, isForCellular);
}
}
#endif
@ -8946,6 +8946,13 @@ mDNSlocal void mDNSCoreReceiveResponse(mDNS *const m,
response->h.numAuthorities, response->h.numAuthorities == 1 ? "y, " : "ies,",
response->h.numAdditionals, response->h.numAdditionals == 1 ? " " : "s", end - response->data, LLQType);
#if AWD_METRICS
if (mDNSSameIPPort(srcport, UnicastDNSPort))
{
MetricsUpdateDNSResponseSize((mDNSu32)(end - (mDNSu8 *)response));
}
#endif
// According to RFC 2181 <http://www.ietf.org/rfc/rfc2181.txt>
// When a DNS client receives a reply with TC
// set, it should ignore that response, and query again, using a
@ -12129,7 +12136,7 @@ mDNSexport mStatus mDNS_StopQuery_internal(mDNS *const m, DNSQuestion *const que
queryName = question->metrics.originalQName ? question->metrics.originalQName : &question->qname;
isForCell = (question->qDNSServer && question->qDNSServer->cellIntf);
durationMs = ((m->timenow - question->metrics.firstQueryTime) * 1000) / mDNSPlatformOneSecond;
MetricsUpdateUDNSQueryStats(queryName, question->qtype, mDNSNULL, question->metrics.querySendCount, durationMs, isForCell);
MetricsUpdateDNSQueryStats(queryName, question->qtype, mDNSNULL, question->metrics.querySendCount, durationMs, isForCell);
}
#endif
// Take care to cut question from list *before* calling UpdateQuestionDuplicates

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1896,7 +1896,7 @@ typedef enum { DNSSECValNotRequired = 0, DNSSECValRequired, DNSSECValInProgress,
// RFC 4122 defines it to be 16 bytes
#define UUID_SIZE 16
#define AWD_METRICS (USE_AWD && TARGET_OS_EMBEDDED)
#define AWD_METRICS (USE_AWD && TARGET_OS_IOS)
#if AWD_METRICS
typedef struct
@ -2039,7 +2039,7 @@ struct DNSQuestion_struct
domainname *qnameOrig; // Copy of the original question name if it is not fully qualified
mDNSQuestionCallback *QuestionCallback;
void *QuestionContext;
#if TARGET_OS_EMBEDDED
#if AWD_METRICS
uDNSMetrics metrics; // Data used for collecting unicast DNS query metrics.
#endif
#if USE_DNS64

View File

@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2002-2015 Apple Inc. All rights reserved.
* Copyright (c) 2002-2017 Apple Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,6 +25,10 @@
#endif
#include "uDNS.h"
#if AWD_METRICS
#include "Metrics.h"
#endif
#if (defined(_MSC_VER))
// Disable "assignment within conditional expression".
// Other compilers understand the convention that if you place the assignment expression within an extra pair
@ -1329,6 +1333,12 @@ mDNSlocal void tcpCallback(TCPSocket *sock, void *context, mDNSBool ConnectionEs
err = mDNSSendDNSMessage(m, &tcpInfo->request, end, mDNSInterface_Any, mDNSNULL, &tcpInfo->Addr, tcpInfo->Port, sock, AuthInfo, mDNSfalse);
if (err) { debugf("ERROR: tcpCallback: mDNSSendDNSMessage - %d", err); err = mStatus_UnknownErr; goto exit; }
#if AWD_METRICS
if (mDNSSameIPPort(tcpInfo->Port, UnicastDNSPort))
{
MetricsUpdateDNSQuerySize((mDNSu32)(end - (mDNSu8 *)&tcpInfo->request));
}
#endif
// Record time we sent this question
if (q)
@ -4758,9 +4768,10 @@ mDNSexport void uDNS_CheckCurrentQuestion(mDNS *const m)
else
{
err = mDNSSendDNSMessage(m, &m->omsg, end, q->qDNSServer->interface, q->LocalSocket, &q->qDNSServer->addr, q->qDNSServer->port, mDNSNULL, mDNSNULL, q->UseBackgroundTrafficClass);
#if TARGET_OS_EMBEDDED
#if AWD_METRICS
if (!err)
{
MetricsUpdateDNSQuerySize((mDNSu32)(end - (mDNSu8 *)&m->omsg));
if (q->metrics.answered)
{
q->metrics.querySendCount = 0;

View File

@ -657,7 +657,7 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
// to bind to the socket. Our suggestion was to switch the order in which
// SO_REUSEPORT and SO_REUSEADDR was tested so that SO_REUSEADDR stays on
// top and SO_REUSEPORT to be used only if SO_REUSEADDR doesn't exist.
#if defined(SO_REUSEADDR) && !defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
#if defined(SO_REUSEADDR) && !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && !defined(__NetBSD__)
err = setsockopt(*sktPtr, SOL_SOCKET, SO_REUSEADDR, &kOn, sizeof(kOn));
#elif defined(SO_REUSEPORT)
err = setsockopt(*sktPtr, SOL_SOCKET, SO_REUSEPORT, &kOn, sizeof(kOn));
@ -666,6 +666,7 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
#endif
if (err < 0) { err = errno; perror("setsockopt - SO_REUSExxxx"); }
#ifndef __NetBSD__
// Enable inbound packets on IFEF_AWDL interface.
// Only done for multicast sockets, since we don't expect unicast socket operations
// on the IFEF_AWDL interface. Operation is a no-op for other interface types.
@ -673,6 +674,7 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
#define SO_RECV_ANYIF 0x1104 /* unrestricted inbound processing */
#endif
if (setsockopt(*sktPtr, SOL_SOCKET, SO_RECV_ANYIF, &kOn, sizeof(kOn)) < 0) perror("setsockopt - SO_RECV_ANYIF");
#endif
}
// We want to receive destination addresses and interface identifiers.

View File

@ -66,7 +66,7 @@
*/
#ifndef _DNS_SD_H
#define _DNS_SD_H 8780101
#define _DNS_SD_H 8783004
#ifdef __cplusplus
extern "C" {

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $NetBSD: prepare-import.sh,v 1.4 2018/01/14 22:51:12 christos Exp $
# $NetBSD: prepare-import.sh,v 1.5 2018/02/25 20:04:55 christos Exp $
#
# Extract the new tarball and run this script with the first argument
# the mDNSResponder-X.Y directory that was created. cd to that directory
@ -10,8 +10,8 @@
set -e
cd "$1"
rm -rf mDNSMacOS9 mDNSMacOSX mDNSVxWorks mDNSWindows
rm -f Makefile mDNSResponder.sln README.txt PrivateDNS.txt Documents
rm -rf mDNSMacOS9 mDNSMacOSX mDNSVxWorks mDNSWindows Documents
rm -f Makefile mDNSResponder.sln README.txt PrivateDNS.txt
(cd Clients
rm -rf BonjourExample DNS-SD.VisualStudio DNS-SD.xcodeproj