1From beab76b5708862f44d9acbe7a92db45e2f99259f Mon Sep 17 00:00:00 2001
2From: Nate Karstens <nate.karstens@garmin.com>
3Date: Tue, 1 Aug 2017 17:06:01 -0500
4Subject: [PATCH 4/8] Indicate loopback interface to mDNS core
5
6Tells the mDNS core if an interface is a loopback interface,
7similar to AddInterfaceToList() in the MacOS implementation.
8
9Upstream-Status: Submitted [dts@apple.com]
10
11Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
12Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
13---
14 mDNSPosix/mDNSPosix.c | 7 ++++---
15 1 file changed, 4 insertions(+), 3 deletions(-)
16
17Index: mDNSResponder/mDNSPosix/mDNSPosix.c
18===================================================================
19--- mDNSResponder.orig/mDNSPosix/mDNSPosix.c
20+++ mDNSResponder/mDNSPosix/mDNSPosix.c
21@@ -1348,7 +1348,7 @@ mDNSlocal void CleanRecentInterfaces(voi
22 // Creates a PosixNetworkInterface for the interface whose IP address is
23 // intfAddr and whose name is intfName and registers it with mDNS core.
24 mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct sockaddr *intfMask,
25-    const mDNSu8 *intfHaddr, mDNSu16 intfHlen, const char *intfName, int intfIndex)
26+    const mDNSu8 *intfHaddr, mDNSu16 intfHlen, const char *intfName, int intfIndex, int intfFlags)
27 {
28     int err = 0;
29     PosixNetworkInterface *intf;
30@@ -1411,6 +1411,7 @@ mDNSlocal int SetupOneInterface(mDNS *co
31
32         intf->coreIntf.Advertise = m->AdvertiseLocalAddresses;
33         intf->coreIntf.McastTxRx = mDNStrue;
34+        intf->coreIntf.Loopback = ((intfFlags & IFF_LOOPBACK) != 0) ? mDNStrue : mDNSfalse;
35
36         // Set up the extra fields in PosixNetworkInterface.
37         assert(intf->intfName != NULL);         // intf->intfName already set up above
38@@ -1561,7 +1562,7 @@ mDNSlocal int SetupInterfaceList(mDNS *c
39                     }
40 #endif
41                     if (SetupOneInterface(m, i->ifa_addr, i->ifa_netmask,
42-                                          hwaddr, hwaddr_len, i->ifa_name, ifIndex) == 0)
43+                                          hwaddr, hwaddr_len, i->ifa_name, ifIndex, i->ifa_flags) == 0)
44                     {
45                         if (i->ifa_addr->sa_family == AF_INET)
46                             foundav4 = mDNStrue;
47@@ -1578,7 +1579,7 @@ mDNSlocal int SetupInterfaceList(mDNS *c
48         // if ((m->HostInterfaces == NULL) && (firstLoopback != NULL))
49         if (!foundav4 && firstLoopback)
50             (void) SetupOneInterface(m, firstLoopback->ifa_addr, firstLoopback->ifa_netmask,
51-                NULL, 0, firstLoopback->ifa_name, firstLoopbackIndex);
52+                NULL, 0, firstLoopback->ifa_name, firstLoopbackIndex, firstLoopback->ifa_flags);
53     }
54
55     // Clean up.
56