<rdar://problem/7299177> DNS-SD sometimes delivers duplicate browse add events during...
authormparthasarathy@apple.com <mparthasarathy@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Tue, 20 Oct 2009 19:45:37 +0000 (19:45 +0000)
committermparthasarathy@apple.com <mparthasarathy@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Tue, 20 Oct 2009 19:45:37 +0000 (19:45 +0000)
mDNSInterfaceMark has the special interfaceID value -1 which conflicts with mDNSInterface_LocalOnly. There is also code (for NSEC) that uses 1 as special value for InterfaceID. This fix now keeps all the special InterfaceID values in one place to avoid future conflicts and NSEC related code now starts using mDNSInterfaceMark.

git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6749 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSCore/DNSCommon.c
mDNSCore/mDNS.c
mDNSCore/mDNSEmbeddedAPI.h

index 76508ce..0ce127e 100644 (file)
@@ -47,8 +47,9 @@ mDNSexport const mDNSEthAddr     onesEthAddr       = { { 255, 255, 255, 255, 255
 mDNSexport const OwnerOptData    zeroOwner         = { 0, 0, { { 0 } }, { { 0 } }, { { 0 } } };
 
 mDNSexport const mDNSInterfaceID mDNSInterface_Any       = 0;
-mDNSexport const mDNSInterfaceID mDNSInterface_LocalOnly = (mDNSInterfaceID)-1;
-mDNSexport const mDNSInterfaceID mDNSInterface_Unicast   = (mDNSInterfaceID)-2;
+mDNSexport const mDNSInterfaceID mDNSInterfaceMark = (mDNSInterfaceID)-1;
+mDNSexport const mDNSInterfaceID mDNSInterface_LocalOnly = (mDNSInterfaceID)-2;
+mDNSexport const mDNSInterfaceID mDNSInterface_Unicast   = (mDNSInterfaceID)-3;
 
 // Note: Microsoft's proposed "Link Local Multicast Name Resolution Protocol" (LLMNR) is essentially a limited version of
 // Multicast DNS, using the same packet formats, naming syntax, and record types as Multicast DNS, but on a different UDP
index 3a382e3..6c94223 100755 (executable)
@@ -65,7 +65,6 @@ mDNSlocal void RetrySPSRegistrations(mDNS *const m);
 
 #define NO_HINFO 1
 
-mDNSlocal const mDNSInterfaceID mDNSInterfaceMark = (mDNSInterfaceID)~0;
 
 // Any records bigger than this are considered 'large' records
 #define SmallRecordLimit 1024
@@ -1438,7 +1437,7 @@ mDNSlocal void SendResponses(mDNS *const m)
 
                                        // The first time through (pktcount==0), if this record is verified unique
                                        // (i.e. typically A, AAAA, SRV and TXT), set the flag to add an NSEC too.
-                                       if (!pktcount && active && rr->resrec.RecordType == kDNSRecordTypeVerified && !rr->SendNSECNow) rr->SendNSECNow = (mDNSInterfaceID)1;
+                                       if (!pktcount && active && rr->resrec.RecordType == kDNSRecordTypeVerified && !rr->SendNSECNow) rr->SendNSECNow = mDNSInterfaceMark;
                                        }
 
                                if (newptr)             // If succeeded in sending, advance to next interface
@@ -1478,7 +1477,7 @@ mDNSlocal void SendResponses(mDNS *const m)
                                                {
                                                // The first time through (pktcount==0), if this record is verified unique
                                                // (i.e. typically A, AAAA, SRV and TXT), set the flag to add an NSEC too.
-                                               if (!pktcount && rr->resrec.RecordType == kDNSRecordTypeVerified && !rr->SendNSECNow) rr->SendNSECNow = (mDNSInterfaceID)1;
+                                               if (!pktcount && rr->resrec.RecordType == kDNSRecordTypeVerified && !rr->SendNSECNow) rr->SendNSECNow = mDNSInterfaceMark;
 
                                                if (rr->resrec.RecordType & kDNSRecordTypeUniqueMask)
                                                        rr->resrec.rrclass |= kDNSClass_UniqueRRSet;    // Temporarily set the cache flush bit so PutResourceRecord will set it
@@ -1501,7 +1500,7 @@ mDNSlocal void SendResponses(mDNS *const m)
 
                // Third Pass. Add NSEC records, if there's space.
                for (rr = m->ResourceRecords; rr; rr=rr->next)
-                       if (rr->SendNSECNow == (mDNSInterfaceID)1 || rr->SendNSECNow == intf->InterfaceID)
+                       if (rr->SendNSECNow == mDNSInterfaceMark || rr->SendNSECNow == intf->InterfaceID)
                                {
                                AuthRecord nsec;
                                mDNS_SetupResourceRecord(&nsec, mDNSNULL, mDNSInterface_Any, kDNSType_NSEC, rr->resrec.rroriginalttl, kDNSRecordTypeUnique, mDNSNULL, mDNSNULL);
@@ -1523,13 +1522,13 @@ mDNSlocal void SendResponses(mDNS *const m)
 
                                // If we successfully put the NSEC record, clear the SendNSECNow flag
                                // If we consider this NSEC optional, then we unconditionally clear the SendNSECNow flag, even if we fail to put this additional record
-                               if (newptr || rr->SendNSECNow == (mDNSInterfaceID)1)
+                               if (newptr || rr->SendNSECNow == mDNSInterfaceMark)
                                        {
                                        rr->SendNSECNow = mDNSNULL;
                                        // Run through remainder of list clearing SendNSECNow flag for all other records which would generate the same NSEC
                                        for (r2 = rr->next; r2; r2=r2->next)
                                                if (SameResourceRecordNameClassInterface(r2, rr))
-                                                       if (r2->SendNSECNow == (mDNSInterfaceID)1 || r2->SendNSECNow == intf->InterfaceID)
+                                                       if (r2->SendNSECNow == mDNSInterfaceMark || r2->SendNSECNow == intf->InterfaceID)
                                                                r2->SendNSECNow = mDNSNULL;
                                        }
                                }
index ee43b47..d635b17 100755 (executable)
@@ -1793,6 +1793,7 @@ extern const OwnerOptData    zeroOwner;
 extern const mDNSInterfaceID mDNSInterface_Any;                                // Zero
 extern const mDNSInterfaceID mDNSInterface_LocalOnly;          // Special value
 extern const mDNSInterfaceID mDNSInterface_Unicast;                    // Special value
+extern const mDNSInterfaceID mDNSInterfaceMark;                                // Special value
 
 extern const mDNSIPPort   DiscardPort;
 extern const mDNSIPPort   SSHPort;