From 30f4c2b3ae182513b967185e06bc8409a0ee6092 Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Wed, 15 Feb 2023 12:09:18 +0100 Subject: mdns: use git fetcher * https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-${PV}.tar.gz is just redirect to unsafe github archives which are regenerated from time to time. * We do have src-uri-bad QA check which prevents to use github archives in SRC_URI since 2019: https://github.com/openembedded/openembedded-core/commit/21f84fcdd659544437fe393285c407e1e9432043 but this cannot catch such redirects, see: $ wget https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-878.30.4.tar.gz --2023-01-31 10:06:02-- https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-878.30.4.tar.gz Resolving opensource.apple.com (opensource.apple.com)... 17.253.73.203, 17.253.73.206, 2a01:b740:a26:f000::5, ... Connecting to opensource.apple.com (opensource.apple.com)|17.253.73.203|:443... connected. HTTP request sent, awaiting response... 302 Redirect Location: https://github.com/apple-oss-distributions/mDNSResponder/archive/refs/tags/mDNSResponder-878.30.4.tar.gz [following] --2023-01-31 10:06:02-- https://github.com/apple-oss-distributions/mDNSResponder/archive/refs/tags/mDNSResponder-878.30.4.tar.gz Resolving github.com (github.com)... 140.82.121.3 Connecting to github.com (github.com)|140.82.121.3|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/apple-oss-distributions/mDNSResponder/tar.gz/refs/tags/mDNSResponder-878.30.4 [following] --2023-01-31 10:06:02-- https://codeload.github.com/apple-oss-distributions/mDNSResponder/tar.gz/refs/tags/mDNSResponder-878.30.4 Resolving codeload.github.com (codeload.github.com)... 140.82.121.10 Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/x-gzip] Saving to: ?mDNSResponder-878.30.4.tar.gz? * The tarball was regenerated recently as discussed in: https://github.com/orgs/community/discussions/45830 * Use top-level directory in S to fix DEBUG_PREFIX_MAP usage like the version in master does, the only exception here is that there still was top-level Makefile (which fails to set VER with: Makefile:26: *** missing separator. Stop. so use the simple one like newer version in master) * it's already included in master as part of version upgrade in: https://github.com/openembedded/meta-openembedded/commit/ec96eb577bd518b89e2e7834bd569ba269df458f Signed-off-by: Martin Jansa Signed-off-by: Armin Kuster --- ...subroutine-for-cleaning-recent-interfaces.patch | 59 ------- .../0001-dns-sd-Include-missing-headers.patch | 41 ----- .../0001-mdns-include-stddef.h-for-NULL.patch | 40 ----- ...-subroutine-for-tearing-down-an-interface.patch | 58 ------- ...-mdns-cross-compilation-fixes-for-bitbake.patch | 145 ----------------- .../files/0003-Track-interface-socket-family.patch | 50 ------ .../0004-Use-list-for-changed-interfaces.patch | 177 --------------------- .../mdns/files/0006-Remove-unneeded-function.patch | 51 ------ ...-Mark-deleted-interfaces-as-being-changed.patch | 39 ----- .../files/0009-Fix-possible-NULL-dereference.patch | 45 ------ .../0010-Handle-errors-from-socket-calls.patch | 62 -------- ...dynamic-allocation-to-file-scope-variable.patch | 53 ------ .../recipes-protocols/mdns/files/mdns.service | 15 -- ...subroutine-for-cleaning-recent-interfaces.patch | 59 +++++++ .../mdns/0001-dns-sd-Include-missing-headers.patch | 41 +++++ .../mdns/0001-mdns-include-stddef.h-for-NULL.patch | 40 +++++ ...-subroutine-for-tearing-down-an-interface.patch | 58 +++++++ ...-mdns-cross-compilation-fixes-for-bitbake.patch | 145 +++++++++++++++++ .../mdns/0003-Track-interface-socket-family.patch | 50 ++++++ .../0004-Use-list-for-changed-interfaces.patch | 177 +++++++++++++++++++++ .../mdns/mdns/0006-Remove-unneeded-function.patch | 51 ++++++ .../mdns/0006-make-Add-top-level-Makefile.patch | 175 ++++++++++++++++++++ ...-Mark-deleted-interfaces-as-being-changed.patch | 39 +++++ .../mdns/0009-Fix-possible-NULL-dereference.patch | 45 ++++++ .../0010-Handle-errors-from-socket-calls.patch | 62 ++++++++ ...dynamic-allocation-to-file-scope-variable.patch | 53 ++++++ .../recipes-protocols/mdns/mdns/mdns.service | 15 ++ .../recipes-protocols/mdns/mdns_1310.140.1.bb | 44 +++-- 28 files changed, 1038 insertions(+), 851 deletions(-) delete mode 100644 meta-networking/recipes-protocols/mdns/files/0001-Create-subroutine-for-cleaning-recent-interfaces.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0001-dns-sd-Include-missing-headers.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0001-mdns-include-stddef.h-for-NULL.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0002-Create-subroutine-for-tearing-down-an-interface.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0002-mdns-cross-compilation-fixes-for-bitbake.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0003-Track-interface-socket-family.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0004-Use-list-for-changed-interfaces.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0006-Remove-unneeded-function.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0008-Mark-deleted-interfaces-as-being-changed.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0009-Fix-possible-NULL-dereference.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0010-Handle-errors-from-socket-calls.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch delete mode 100644 meta-networking/recipes-protocols/mdns/files/mdns.service create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0001-Create-subroutine-for-cleaning-recent-interfaces.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0001-dns-sd-Include-missing-headers.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0001-mdns-include-stddef.h-for-NULL.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0002-Create-subroutine-for-tearing-down-an-interface.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0002-mdns-cross-compilation-fixes-for-bitbake.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0003-Track-interface-socket-family.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0004-Use-list-for-changed-interfaces.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0006-Remove-unneeded-function.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0006-make-Add-top-level-Makefile.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0008-Mark-deleted-interfaces-as-being-changed.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0009-Fix-possible-NULL-dereference.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0010-Handle-errors-from-socket-calls.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch create mode 100644 meta-networking/recipes-protocols/mdns/mdns/mdns.service diff --git a/meta-networking/recipes-protocols/mdns/files/0001-Create-subroutine-for-cleaning-recent-interfaces.patch b/meta-networking/recipes-protocols/mdns/files/0001-Create-subroutine-for-cleaning-recent-interfaces.patch deleted file mode 100644 index f8efc1044..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0001-Create-subroutine-for-cleaning-recent-interfaces.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 6d90f9fdaf008f5c3b8fd8d91594fa1461437888 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Wed, 28 Jun 2017 17:30:00 -0500 -Subject: [PATCH] Create subroutine for cleaning recent interfaces - -Moves functionality for cleaning the list of recent -interfaces into its own subroutine. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 23 ++++++++++++++--------- - 1 file changed, 14 insertions(+), 9 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index a63cd19..7aeee7b 100755 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -1199,6 +1199,19 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf - return err; - } - -+// Clean up any interfaces that have been hanging around on the RecentInterfaces list for more than a minute -+mDNSlocal void CleanRecentInterfaces(void) -+{ -+ PosixNetworkInterface **ri = &gRecentInterfaces; -+ const mDNSs32 utc = mDNSPlatformUTC(); -+ while (*ri) -+ { -+ PosixNetworkInterface *pi = *ri; -+ if (utc - pi->LastSeen < 60) ri = (PosixNetworkInterface **)&pi->coreIntf.next; -+ else { *ri = (PosixNetworkInterface *)pi->coreIntf.next; free(pi); } -+ } -+} -+ - // Creates a PosixNetworkInterface for the interface whose IP address is - // intfAddr and whose name is intfName and registers it with mDNS core. - mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct sockaddr *intfMask, const char *intfName, int intfIndex) -@@ -1388,15 +1401,7 @@ mDNSlocal int SetupInterfaceList(mDNS *const m) - // Clean up. - if (intfList != NULL) freeifaddrs(intfList); - -- // Clean up any interfaces that have been hanging around on the RecentInterfaces list for more than a minute -- PosixNetworkInterface **ri = &gRecentInterfaces; -- const mDNSs32 utc = mDNSPlatformUTC(); -- while (*ri) -- { -- PosixNetworkInterface *pi = *ri; -- if (utc - pi->LastSeen < 60) ri = (PosixNetworkInterface **)&pi->coreIntf.next; -- else { *ri = (PosixNetworkInterface *)pi->coreIntf.next; free(pi); } -- } -+ CleanRecentInterfaces(); - - return err; - } --- -2.20.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0001-dns-sd-Include-missing-headers.patch b/meta-networking/recipes-protocols/mdns/files/0001-dns-sd-Include-missing-headers.patch deleted file mode 100644 index c743b3edd..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0001-dns-sd-Include-missing-headers.patch +++ /dev/null @@ -1,41 +0,0 @@ -From ea442b57f7a9bcd41d5b5bd1cafde4dbe5685d41 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Thu, 4 Nov 2021 07:31:32 -0700 -Subject: [PATCH] dns-sd: Include missing headers - -Fixes build on Musl - -Upstream-Status: Pending -Signed-off-by: Khem Raj ---- - Clients/dns-sd.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/Clients/dns-sd.c -+++ b/Clients/dns-sd.c -@@ -58,11 +58,13 @@ - //#define TEST_NEW_CLIENTSTUB 1 - - #include -+#include // For va_args - #include // For stdout, stderr - #include // For exit() - #include // For strlen(), strcpy() - #include // For errno, EINTR - #include -+#include // For MIN - #include // For u_char - #ifdef APPLE_OSX_mDNSResponder - #include // For PRId64 ---- a/mDNSPosix/nss_mdns.c -+++ b/mDNSPosix/nss_mdns.c -@@ -89,6 +89,9 @@ - - #include - -+#if !defined(NETDB_INTERNAL) -+# define NETDB_INTERNAL (-1) -+#endif - - //---------- - // Public functions diff --git a/meta-networking/recipes-protocols/mdns/files/0001-mdns-include-stddef.h-for-NULL.patch b/meta-networking/recipes-protocols/mdns/files/0001-mdns-include-stddef.h-for-NULL.patch deleted file mode 100644 index c57ce8fa5..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0001-mdns-include-stddef.h-for-NULL.patch +++ /dev/null @@ -1,40 +0,0 @@ -From d744609c56f9872e5aa71707f1f71feec9867f51 Mon Sep 17 00:00:00 2001 -From: Mikko Rapeli -Date: Tue, 14 Jul 2020 16:36:29 +0000 -Subject: [PATCH 1/2] mdns: include for NULL - -Fixes build error with version 1096.40.7: - -../mDNSCore/mDNS.c:11385:26: error: 'NULL' undeclared (first use in this function) -11385 | const char *reason = NULL; - | ^~~~ -../mDNSCore/mDNS.c:56:1: note: 'NULL' is defined in header ''; did you forget to '#include '? - 55 | #include "dns_sd_internal.h" - +++ |+#include - 56 | -../mDNSCore/mDNS.c:11385:26: note: each undeclared identifier is reported only once for each function it appears in -11385 | const char *reason = NULL; - | ^~~~ - -Upstream-Status: Pending - -Signed-off-by: Mikko Rapeli ---- - mDNSCore/mDNS.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/mDNSCore/mDNS.c b/mDNSCore/mDNS.c -index 2fbea04..d4b9af5 100755 ---- a/mDNSCore/mDNS.c -+++ b/mDNSCore/mDNS.c -@@ -23,6 +23,7 @@ - * routines, or types (which may or may not be present on any given platform). - */ - -+#include /* for NULL */ - #include "DNSCommon.h" // Defines general DNS utility routines - #include "uDNS.h" // Defines entry points into unicast-specific routines - --- -2.20.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0002-Create-subroutine-for-tearing-down-an-interface.patch b/meta-networking/recipes-protocols/mdns/files/0002-Create-subroutine-for-tearing-down-an-interface.patch deleted file mode 100644 index 21ba31849..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0002-Create-subroutine-for-tearing-down-an-interface.patch +++ /dev/null @@ -1,58 +0,0 @@ -From a2148df99ddcd122247f95c4cbcce5c4118581a1 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Wed, 28 Jun 2017 17:30:00 -0500 -Subject: [PATCH 02/11] Create subroutine for tearing down an interface - -Creates a subroutine for tearing down an interface. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 22 ++++++++++++++++------ - 1 file changed, 16 insertions(+), 6 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index ffc9696..5e5b2cd 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -591,6 +591,19 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf) - gRecentInterfaces = intf; - } - -+mDNSlocal void TearDownInterface(mDNS *const m, PosixNetworkInterface *intf) -+{ -+ mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); -+ if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); -+ FreePosixNetworkInterface(intf); -+ -+ num_registered_interfaces--; -+ if (num_registered_interfaces == 0) { -+ num_pkts_accepted = 0; -+ num_pkts_rejected = 0; -+ } -+} -+ - // Grab the first interface, deregister it, free it, and repeat until done. - mDNSlocal void ClearInterfaceList(mDNS *const m) - { -@@ -599,13 +612,10 @@ mDNSlocal void ClearInterfaceList(mDNS *const m) - while (m->HostInterfaces) - { - PosixNetworkInterface *intf = (PosixNetworkInterface*)(m->HostInterfaces); -- mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); -- if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); -- FreePosixNetworkInterface(intf); -+ TearDownInterface(m, intf); - } -- num_registered_interfaces = 0; -- num_pkts_accepted = 0; -- num_pkts_rejected = 0; -+ -+ assert(num_registered_interfaces == 0); - } - - // Sets up a send/receive socket. --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0002-mdns-cross-compilation-fixes-for-bitbake.patch b/meta-networking/recipes-protocols/mdns/files/0002-mdns-cross-compilation-fixes-for-bitbake.patch deleted file mode 100644 index 33590ffc5..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0002-mdns-cross-compilation-fixes-for-bitbake.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 72405143f9d16514e70b88bc4843c9634b88036a Mon Sep 17 00:00:00 2001 -From: Brendan Le Foll -Date: Tue, 3 Mar 2015 11:42:57 +0000 -Subject: [PATCH 2/2] mdns: cross compilation fixes for bitbake - -Fixes several build errors when incorrect compiler or -compiler flags are used. - -Upstream-Status: Inappropriate [OE-specific] - -Signed-off-by: Paul Eggleton -Signed-off-by: Mikko Rapeli ---- - mDNSPosix/Makefile | 44 ++++++++++++++++++++------------------------ - 1 file changed, 20 insertions(+), 24 deletions(-) - -diff --git a/mDNSPosix/Makefile b/mDNSPosix/Makefile -index 78222e0..18a3af5 100755 ---- a/mDNSPosix/Makefile -+++ b/mDNSPosix/Makefile -@@ -50,6 +50,7 @@ - - LIBVERS = 1 - -+POSIXDIR = ../mDNSPosix - COREDIR = ../mDNSCore - SHAREDDIR ?= ../mDNSShared - DSODIR ?= ../DSO -@@ -62,16 +63,16 @@ else ifeq ($(SYSTEM), Linux) - os=linux - endif - --CC = cc --BISON = bison --FLEX = flex --ST = strip --LD = ld -+CC ?= cc -+BISON ?= bison -+FLEX ?= flex -+ST ?= strip -+LD ?= ld - SOOPTS = -shared - CP = cp - RM = rm - LN = ln -s -f --CFLAGS_COMMON = -I$(COREDIR) -I$(SHAREDDIR) -I$(DSODIR) -I$(PROXYDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" -+CFLAGS_COMMON = -I$(POSIXDIR) -I$(COREDIR) -I$(SHAREDDIR) -I$(DSODIR) -I$(PROXYDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" - CFLAGS_PTHREAD = - LINKOPTS = - LINKOPTS_PTHREAD = -lpthread -@@ -85,6 +86,7 @@ CFLAGS_OPEN_SOURCE= - endif - - # Set up diverging paths for debug vs. prod builds -+DEBUG ?= 1 - ifeq "$(DEBUG)" "1" - CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=2 - OBJDIR = objects/debug -@@ -101,8 +103,8 @@ else - # 1. We want to make small binaries, suitable for putting into hardware devices - # 2. Some of the code analysis warnings only work when some form of optimization is enabled - CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=0 --OBJDIR ?= objects/prod --BUILDDIR ?= build/prod -+OBJDIR = objects/prod -+BUILDDIR = build/prod - STRIP = $(ST) -S - endif - endif -@@ -125,7 +127,7 @@ else - # any target that contains the string "linux" - ifeq ($(findstring linux,$(os)),linux) - CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -ftabstop=4 --LD = $(CC) -+LD ?= $(CC) - SOOPTS = -shared - FLEXFLAGS_OS = -l - JAVACFLAGS_OS += -I$(JDK)/include/linux -@@ -276,8 +278,7 @@ Daemon: setup $(BUILDDIR)/mdnsd - @echo "Responder daemon done" - - $(BUILDDIR)/mdnsd: $(DAEMONOBJS) -- $(CC) -o $@ $+ $(LINKOPTS) -- $(STRIP) $@ -+ $(LD) -o $@ $+ - - # libdns_sd target builds the client library - libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX) -@@ -286,13 +287,9 @@ libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX) - CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o - - $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS) -- $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+ -- $(STRIP) $@ -- --Clients: setup libdns_sd ../Clients/build/dns-sd -- @echo "Clients done" -+ $(LD) -shared $(LINKOPTS) -Wl,-soname,libdns_sd.$(LDSUFFIX).1 -o $@ $+ - --../Clients/build/dns-sd: ../Clients/dns-sd.c -+Clients: setup libdns_sd - $(MAKE) -C ../Clients DEBUG=$(DEBUG) SUPMAKE_CFLAGS="$(MDNSCFLAGS)" - - # nss_mdns target builds the Name Service Switch module -@@ -300,8 +297,7 @@ nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE) - @echo "Name Service Switch module done" - - $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o -- $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+ -- $(STRIP) $@ -+ $(LD) -shared $(LINKOPTS) -o $@ $+ - - ############################################################################# - -@@ -494,21 +490,21 @@ dnsextd: setup $(BUILDDIR)/dnsextd - @echo "dnsextd done" - - $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o -- $(CC) $+ -o $@ $(LINKOPTS) -+ $(CC) $+ -o $@ - - $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o -- $(CC) $+ -o $@ $(LINKOPTS) -+ $(CC) $+ -o $@ - - $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o -- $(CC) $+ -o $@ $(LINKOPTS) -+ $(CC) $+ -o $@ - - $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o -- $(CC) $+ -o $@ $(LINKOPTS) -+ $(CC) $+ -o $@ - - $(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c - - $(BUILDDIR)/dnsextd: $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o -- $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD) -+ $(CC) $+ -o $@ $(LINKOPTS_PTHREAD) - - ############################################################################# - --- -2.20.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0003-Track-interface-socket-family.patch b/meta-networking/recipes-protocols/mdns/files/0003-Track-interface-socket-family.patch deleted file mode 100644 index 8c0e6bf39..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0003-Track-interface-socket-family.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 71a7c728ae0d8143b66aa40decca74ebaa9aa2ce Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Wed, 28 Jun 2017 17:30:00 -0500 -Subject: [PATCH 03/11] Track interface socket family - -Tracks the socket family associated with the interface. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 1 + - mDNSPosix/mDNSPosix.h | 2 ++ - 2 files changed, 3 insertions(+) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 5e5b2cd..8fe22be 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -918,6 +918,7 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct - // Set up the extra fields in PosixNetworkInterface. - assert(intf->intfName != NULL); // intf->intfName already set up above - intf->index = intfIndex; -+ intf->sa_family = intfAddr->sa_family; - intf->multicastSocket4 = -1; - #if HAVE_IPV6 - intf->multicastSocket6 = -1; -diff --git a/mDNSPosix/mDNSPosix.h b/mDNSPosix/mDNSPosix.h -index ca60d80..f77c185 100644 ---- a/mDNSPosix/mDNSPosix.h -+++ b/mDNSPosix/mDNSPosix.h -@@ -19,6 +19,7 @@ - #define __mDNSPlatformPosix_h - - #include -+#include - #include - - #ifdef __cplusplus -@@ -40,6 +41,7 @@ struct PosixNetworkInterface - const char * intfName; - PosixNetworkInterface * aliasIntf; - int index; -+ sa_family_t sa_family; - int multicastSocket4; - #if HAVE_IPV6 - int multicastSocket6; --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0004-Use-list-for-changed-interfaces.patch b/meta-networking/recipes-protocols/mdns/files/0004-Use-list-for-changed-interfaces.patch deleted file mode 100644 index db3a63ea4..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0004-Use-list-for-changed-interfaces.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 798bfb5e984845a27874d1a244686db6e384d7b8 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Thu, 13 Jul 2017 09:00:00 -0500 -Subject: [PATCH 04/11] Use list for changed interfaces - -Uses a linked list to store the index of changed network interfaces -instead of a bitfield. This allows for network interfaces with an -index greater than 31 (an index of 36 was seen on Android). - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 67 +++++++++++++++++++++++++++++++++---------- - 1 file changed, 52 insertions(+), 15 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 195d04b..bb883c1 100755 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -67,6 +67,14 @@ struct IfChangeRec - }; - typedef struct IfChangeRec IfChangeRec; - -+// Used to build a list of network interface indices -+struct NetworkInterfaceIndex -+{ -+ int if_index; -+ struct NetworkInterfaceIndex *Next; -+}; -+typedef struct NetworkInterfaceIndex NetworkInterfaceIndex; -+ - // Note that static data is initialized to zero in (modern) C. - static PosixEventSource *gEventSources; // linked list of PosixEventSource's - static sigset_t gEventSignalSet; // Signals which event loop listens for -@@ -1458,6 +1466,32 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD) - return err; - } - -+mDNSlocal mDNSBool ListContainsInterfaceIndex(GenLinkedList *list, int if_index) -+{ -+ NetworkInterfaceIndex *item; -+ -+ for (item = (NetworkInterfaceIndex*)list->Head; item != NULL; item = item->Next) -+ { -+ if (if_index == item->if_index) return mDNStrue; -+ } -+ -+ return mDNSfalse; -+} -+ -+mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) -+{ -+ NetworkInterfaceIndex *item; -+ -+ if (ListContainsInterfaceIndex(list, if_index)) return; -+ -+ item = malloc(sizeof *item); -+ if (item == NULL) return; -+ -+ item->if_index = if_index; -+ item->Next = NULL; -+ AddToTail(list, item); -+} -+ - #if MDNS_DEBUGMSGS - mDNSlocal void PrintNetLinkMsg(const struct nlmsghdr *pNLMsg) - { -@@ -1485,14 +1519,13 @@ mDNSlocal void PrintNetLinkMsg(const struct nlmsghdr *pNLMsg) - } - #endif - --mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) -+mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *changedInterfaces) - // Read through the messages on sd and if any indicate that any interface records should - // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. - { - ssize_t readCount; - char buff[4096]; - struct nlmsghdr *pNLMsg = (struct nlmsghdr*) buff; -- mDNSu32 result = 0; - - // The structure here is more complex than it really ought to be because, - // unfortunately, there's no good way to size a buffer in advance large -@@ -1528,9 +1561,9 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) - - // Process the NetLink message - if (pNLMsg->nlmsg_type == RTM_GETLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) -- result |= 1 << ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index; -+ AddInterfaceIndexToList(changedInterfaces, ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index); - else if (pNLMsg->nlmsg_type == RTM_DELADDR || pNLMsg->nlmsg_type == RTM_NEWADDR) -- result |= 1 << ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index; -+ AddInterfaceIndexToList(changedInterfaces, ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index); - - // Advance pNLMsg to the next message in the buffer - if ((pNLMsg->nlmsg_flags & NLM_F_MULTI) != 0 && pNLMsg->nlmsg_type != NLMSG_DONE) -@@ -1541,8 +1574,6 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) - else - break; // all done! - } -- -- return result; - } - - #else // USES_NETLINK -@@ -1574,14 +1605,13 @@ mDNSlocal void PrintRoutingSocketMsg(const struct ifa_msghdr *pRSMsg) - } - #endif - --mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) -+mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *changedInterfaces) - // Read through the messages on sd and if any indicate that any interface records should - // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. - { - ssize_t readCount; - char buff[4096]; - struct ifa_msghdr *pRSMsg = (struct ifa_msghdr*) buff; -- mDNSu32 result = 0; - - readCount = read(sd, buff, sizeof buff); - if (readCount < (ssize_t) sizeof(struct ifa_msghdr)) -@@ -1596,12 +1626,10 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) - pRSMsg->ifam_type == RTM_IFINFO) - { - if (pRSMsg->ifam_type == RTM_IFINFO) -- result |= 1 << ((struct if_msghdr*) pRSMsg)->ifm_index; -+ AddInterfaceIndexToList(changedInterfaces, ((struct if_msghdr*) pRSMsg)->ifm_index); - else -- result |= 1 << pRSMsg->ifam_index; -+ AddInterfaceIndexToList(changedInterfaces, pRSMsg->ifam_index); - } -- -- return result; - } - - #endif // USES_NETLINK -@@ -1611,7 +1639,8 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) - { - IfChangeRec *pChgRec = (IfChangeRec*) context; - fd_set readFDs; -- mDNSu32 changedInterfaces = 0; -+ GenLinkedList changedInterfaces; -+ NetworkInterfaceIndex *changedInterface; - struct timeval zeroTimeout = { 0, 0 }; - - (void)fd; // Unused -@@ -1619,17 +1648,25 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) - FD_ZERO(&readFDs); - FD_SET(pChgRec->NotifySD, &readFDs); - -+ InitLinkedList(&changedInterfaces, offsetof(NetworkInterfaceIndex, Next)); -+ - do - { -- changedInterfaces |= ProcessRoutingNotification(pChgRec->NotifySD); -+ ProcessRoutingNotification(pChgRec->NotifySD, &changedInterfaces); - } - while (0 < select(pChgRec->NotifySD + 1, &readFDs, (fd_set*) NULL, (fd_set*) NULL, &zeroTimeout)); - - // Currently we rebuild the entire interface list whenever any interface change is - // detected. If this ever proves to be a performance issue in a multi-homed - // configuration, more care should be paid to changedInterfaces. -- if (changedInterfaces) -+ if (changedInterfaces.Head != NULL) - mDNSPlatformPosixRefreshInterfaceList(pChgRec->mDNS); -+ -+ while ((changedInterface = (NetworkInterfaceIndex*)changedInterfaces.Head) != NULL) -+ { -+ RemoveFromList(&changedInterfaces, changedInterface); -+ free(changedInterface); -+ } - } - - // Register with either a Routing Socket or RtNetLink to listen for interface changes. --- -2.20.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0006-Remove-unneeded-function.patch b/meta-networking/recipes-protocols/mdns/files/0006-Remove-unneeded-function.patch deleted file mode 100644 index b461a60df..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0006-Remove-unneeded-function.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 157d67f152777754c059ced7511352102f23ffae Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Mon, 24 Jul 2017 09:39:18 -0500 -Subject: [PATCH 06/11] Remove unneeded function - -Removes a function we no longer need by integrating it into the only -function that calls it. This was originally separated so that we could -only process network interfaces that netlink indicated had been changed, -this has since been extended to test for all network intefaces. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 13 ++----------- - 1 file changed, 2 insertions(+), 11 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 59a8b8c..3fc5451 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -1079,24 +1079,15 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD) - return err; - } - --mDNSlocal mDNSBool ListContainsInterfaceIndex(GenLinkedList *list, int if_index) -+mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) - { - NetworkInterfaceIndex *item; - - for (item = (NetworkInterfaceIndex*)list->Head; item != NULL; item = item->Next) - { -- if (if_index == item->if_index) return mDNStrue; -+ if (if_index == item->if_index) return; - } - -- return mDNSfalse; --} -- --mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) --{ -- NetworkInterfaceIndex *item; -- -- if (ListContainsInterfaceIndex(list, if_index)) return; -- - item = malloc(sizeof *item); - if (item == NULL) return; - --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0008-Mark-deleted-interfaces-as-being-changed.patch b/meta-networking/recipes-protocols/mdns/files/0008-Mark-deleted-interfaces-as-being-changed.patch deleted file mode 100644 index fdc5105cb..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0008-Mark-deleted-interfaces-as-being-changed.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0fcc0f210f3a9310a1963de640b384ce866410fd Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Wed, 9 Aug 2017 09:16:58 -0500 -Subject: [PATCH 08/11] Mark deleted interfaces as being changed - -Netlink notification handling ignores messages for deleted links, -RTM_DELLINK. It does handle RTM_GETLINK. According to libnl docu- -mentation (http://www.infradead.org/~tgr/libnl/doc/route.html) -RTM_DELLINK can be sent by the kernel, but RTM_GETLINK cannot. -There was likely a mixup in the original implementation, so this -change replaces handling for RTM_GETLINK with RTM_DELLINK. - -Testing and Verification Instructions: - 1. Use ip-link to add and remove a VLAN interface and verify - that mDNSResponder handles the deleted link. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 798ab10..a8a57df 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -1163,7 +1163,7 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change - #endif - - // Process the NetLink message -- if (pNLMsg->nlmsg_type == RTM_GETLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) -+ if (pNLMsg->nlmsg_type == RTM_DELLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) - AddInterfaceIndexToList(changedInterfaces, ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index); - else if (pNLMsg->nlmsg_type == RTM_DELADDR || pNLMsg->nlmsg_type == RTM_NEWADDR) - AddInterfaceIndexToList(changedInterfaces, ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index); --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0009-Fix-possible-NULL-dereference.patch b/meta-networking/recipes-protocols/mdns/files/0009-Fix-possible-NULL-dereference.patch deleted file mode 100644 index 362d69768..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0009-Fix-possible-NULL-dereference.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 38cff19781f81586926b02f0fd1cb36c040395e0 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Thu, 10 Aug 2017 08:21:53 -0500 -Subject: [PATCH 09/11] Fix possible NULL dereference - -Fixes a possible NULL dereference if memory for -the PosixNetworkInterface could not be allocated. -Other logic seems to prevent dereferencing this -variable if NULL, but this instance seems to have -been overlooked. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index a8a57df..3243ed4 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -951,12 +951,15 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct ifi_info *const ifi) - - // If interface is a direct link, address record will be marked as kDNSRecordTypeKnownUnique - // and skip the probe phase of the probe/announce packet sequence. -- intf->coreIntf.DirectLink = mDNSfalse; -+ if (err == 0) -+ { -+ intf->coreIntf.DirectLink = mDNSfalse; - #ifdef DIRECTLINK_INTERFACE_NAME -- if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) -- intf->coreIntf.DirectLink = mDNStrue; -+ if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) -+ intf->coreIntf.DirectLink = mDNStrue; - #endif -- intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; -+ intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; -+ } - - // The interface is all ready to go, let's register it with the mDNS core. - if (err == 0) --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0010-Handle-errors-from-socket-calls.patch b/meta-networking/recipes-protocols/mdns/files/0010-Handle-errors-from-socket-calls.patch deleted file mode 100644 index b9b015727..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0010-Handle-errors-from-socket-calls.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 382b3b924e43abd1bdc5792918161d0922666691 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Thu, 10 Aug 2017 08:27:32 -0500 -Subject: [PATCH 10/11] Handle errors from socket calls - -Adds handling for socket() or read() returning a -negative value (indicating an error has occurred). - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 3243ed4..84af26b 100644 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -1129,7 +1129,7 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change - // Read through the messages on sd and if any indicate that any interface records should - // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. - { -- ssize_t readCount; -+ ssize_t readVal, readCount; - char buff[4096]; - struct nlmsghdr *pNLMsg = (struct nlmsghdr*) buff; - -@@ -1138,7 +1138,10 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change - // enough to hold all pending data and so avoid message fragmentation. - // (Note that FIONREAD is not supported on AF_NETLINK.) - -- readCount = read(sd, buff, sizeof buff); -+ readVal = read(sd, buff, sizeof buff); -+ if (readVal < 0) return; -+ readCount = readVal; -+ - while (1) - { - // Make sure we've got an entire nlmsghdr in the buffer, and payload, too. -@@ -1154,7 +1157,9 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change - pNLMsg = (struct nlmsghdr*) buff; - - // read more data -- readCount += read(sd, buff + readCount, sizeof buff - readCount); -+ readVal = read(sd, buff + readCount, sizeof buff - readCount); -+ if (readVal < 0) return; -+ readCount += readVal; - continue; // spin around and revalidate with new readCount - } - else -@@ -1429,6 +1434,7 @@ mDNSlocal mDNSBool mDNSPlatformInit_CanReceiveUnicast(void) - int err; - int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - struct sockaddr_in s5353; -+ if (s < 0) return mDNSfalse; - s5353.sin_family = AF_INET; - s5353.sin_port = MulticastDNSPort.NotAnInteger; - s5353.sin_addr.s_addr = 0; --- -2.17.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch b/meta-networking/recipes-protocols/mdns/files/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch deleted file mode 100644 index d9adde04c..000000000 --- a/meta-networking/recipes-protocols/mdns/files/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 9ff06108cd44e84ba6c68bfa6737e793f117e303 Mon Sep 17 00:00:00 2001 -From: Nate Karstens -Date: Thu, 10 Aug 2017 08:46:03 -0500 -Subject: [PATCH] Change a dynamic allocation to file-scope variable - -Changes a variable from being dynamically-allocated to being -statically-allocated at the file scope. Addresses a Coverity -issue where it appeared that the memory was being leaked. - -Upstream-Status: Submitted [dts@apple.com] - -Signed-off-by: Nate Karstens ---- - mDNSPosix/mDNSPosix.c | 14 ++++---------- - 1 file changed, 4 insertions(+), 10 deletions(-) - -diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c -index 7aeee7b..2d25016 100755 ---- a/mDNSPosix/mDNSPosix.c -+++ b/mDNSPosix/mDNSPosix.c -@@ -81,6 +81,7 @@ static sigset_t gEventSignalSet; // Signals which event loop list - static sigset_t gEventSignals; // Signals which were received while inside loop - - static PosixNetworkInterface *gRecentInterfaces; -+static IfChangeRec gChgRec; - - // *************************************************************************** - // Globals (for debugging) -@@ -1641,18 +1642,11 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) - mDNSlocal mStatus WatchForInterfaceChange(mDNS *const m) - { - mStatus err; -- IfChangeRec *pChgRec; - -- pChgRec = (IfChangeRec*) mDNSPlatformMemAllocateClear(sizeof *pChgRec); -- if (pChgRec == NULL) -- return mStatus_NoMemoryErr; -- -- pChgRec->mDNS = m; -- err = OpenIfNotifySocket(&pChgRec->NotifySD); -+ gChgRec.mDNS = m; -+ err = OpenIfNotifySocket(&gChgRec.NotifySD); - if (err == 0) -- err = mDNSPosixAddFDToEventLoop(pChgRec->NotifySD, InterfaceChangeCallback, pChgRec); -- if (err) -- mDNSPlatformMemFree(pChgRec); -+ err = mDNSPosixAddFDToEventLoop(gChgRec.NotifySD, InterfaceChangeCallback, &gChgRec); - - return err; - } --- -2.20.1 - diff --git a/meta-networking/recipes-protocols/mdns/files/mdns.service b/meta-networking/recipes-protocols/mdns/files/mdns.service deleted file mode 100644 index 531d142dc..000000000 --- a/meta-networking/recipes-protocols/mdns/files/mdns.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Zero-configuration networking -After=network.target - -[Service] -Type=forking -ExecStartPre=/bin/rm -f /var/run/mdnsd.pid -ExecStart=/usr/sbin/mdnsd -ExecReload=/bin/kill -HUP $MAINPID -PIDFile=/var/run/mdnsd.pid -Restart=always -RestartSec=10s - -[Install] -WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/mdns/mdns/0001-Create-subroutine-for-cleaning-recent-interfaces.patch b/meta-networking/recipes-protocols/mdns/mdns/0001-Create-subroutine-for-cleaning-recent-interfaces.patch new file mode 100644 index 000000000..f8efc1044 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0001-Create-subroutine-for-cleaning-recent-interfaces.patch @@ -0,0 +1,59 @@ +From 6d90f9fdaf008f5c3b8fd8d91594fa1461437888 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Wed, 28 Jun 2017 17:30:00 -0500 +Subject: [PATCH] Create subroutine for cleaning recent interfaces + +Moves functionality for cleaning the list of recent +interfaces into its own subroutine. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 23 ++++++++++++++--------- + 1 file changed, 14 insertions(+), 9 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index a63cd19..7aeee7b 100755 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -1199,6 +1199,19 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf + return err; + } + ++// Clean up any interfaces that have been hanging around on the RecentInterfaces list for more than a minute ++mDNSlocal void CleanRecentInterfaces(void) ++{ ++ PosixNetworkInterface **ri = &gRecentInterfaces; ++ const mDNSs32 utc = mDNSPlatformUTC(); ++ while (*ri) ++ { ++ PosixNetworkInterface *pi = *ri; ++ if (utc - pi->LastSeen < 60) ri = (PosixNetworkInterface **)&pi->coreIntf.next; ++ else { *ri = (PosixNetworkInterface *)pi->coreIntf.next; free(pi); } ++ } ++} ++ + // Creates a PosixNetworkInterface for the interface whose IP address is + // intfAddr and whose name is intfName and registers it with mDNS core. + mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct sockaddr *intfMask, const char *intfName, int intfIndex) +@@ -1388,15 +1401,7 @@ mDNSlocal int SetupInterfaceList(mDNS *const m) + // Clean up. + if (intfList != NULL) freeifaddrs(intfList); + +- // Clean up any interfaces that have been hanging around on the RecentInterfaces list for more than a minute +- PosixNetworkInterface **ri = &gRecentInterfaces; +- const mDNSs32 utc = mDNSPlatformUTC(); +- while (*ri) +- { +- PosixNetworkInterface *pi = *ri; +- if (utc - pi->LastSeen < 60) ri = (PosixNetworkInterface **)&pi->coreIntf.next; +- else { *ri = (PosixNetworkInterface *)pi->coreIntf.next; free(pi); } +- } ++ CleanRecentInterfaces(); + + return err; + } +-- +2.20.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0001-dns-sd-Include-missing-headers.patch b/meta-networking/recipes-protocols/mdns/mdns/0001-dns-sd-Include-missing-headers.patch new file mode 100644 index 000000000..c743b3edd --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0001-dns-sd-Include-missing-headers.patch @@ -0,0 +1,41 @@ +From ea442b57f7a9bcd41d5b5bd1cafde4dbe5685d41 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 4 Nov 2021 07:31:32 -0700 +Subject: [PATCH] dns-sd: Include missing headers + +Fixes build on Musl + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + Clients/dns-sd.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/Clients/dns-sd.c ++++ b/Clients/dns-sd.c +@@ -58,11 +58,13 @@ + //#define TEST_NEW_CLIENTSTUB 1 + + #include ++#include // For va_args + #include // For stdout, stderr + #include // For exit() + #include // For strlen(), strcpy() + #include // For errno, EINTR + #include ++#include // For MIN + #include // For u_char + #ifdef APPLE_OSX_mDNSResponder + #include // For PRId64 +--- a/mDNSPosix/nss_mdns.c ++++ b/mDNSPosix/nss_mdns.c +@@ -89,6 +89,9 @@ + + #include + ++#if !defined(NETDB_INTERNAL) ++# define NETDB_INTERNAL (-1) ++#endif + + //---------- + // Public functions diff --git a/meta-networking/recipes-protocols/mdns/mdns/0001-mdns-include-stddef.h-for-NULL.patch b/meta-networking/recipes-protocols/mdns/mdns/0001-mdns-include-stddef.h-for-NULL.patch new file mode 100644 index 000000000..c57ce8fa5 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0001-mdns-include-stddef.h-for-NULL.patch @@ -0,0 +1,40 @@ +From d744609c56f9872e5aa71707f1f71feec9867f51 Mon Sep 17 00:00:00 2001 +From: Mikko Rapeli +Date: Tue, 14 Jul 2020 16:36:29 +0000 +Subject: [PATCH 1/2] mdns: include for NULL + +Fixes build error with version 1096.40.7: + +../mDNSCore/mDNS.c:11385:26: error: 'NULL' undeclared (first use in this function) +11385 | const char *reason = NULL; + | ^~~~ +../mDNSCore/mDNS.c:56:1: note: 'NULL' is defined in header ''; did you forget to '#include '? + 55 | #include "dns_sd_internal.h" + +++ |+#include + 56 | +../mDNSCore/mDNS.c:11385:26: note: each undeclared identifier is reported only once for each function it appears in +11385 | const char *reason = NULL; + | ^~~~ + +Upstream-Status: Pending + +Signed-off-by: Mikko Rapeli +--- + mDNSCore/mDNS.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/mDNSCore/mDNS.c b/mDNSCore/mDNS.c +index 2fbea04..d4b9af5 100755 +--- a/mDNSCore/mDNS.c ++++ b/mDNSCore/mDNS.c +@@ -23,6 +23,7 @@ + * routines, or types (which may or may not be present on any given platform). + */ + ++#include /* for NULL */ + #include "DNSCommon.h" // Defines general DNS utility routines + #include "uDNS.h" // Defines entry points into unicast-specific routines + +-- +2.20.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0002-Create-subroutine-for-tearing-down-an-interface.patch b/meta-networking/recipes-protocols/mdns/mdns/0002-Create-subroutine-for-tearing-down-an-interface.patch new file mode 100644 index 000000000..21ba31849 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0002-Create-subroutine-for-tearing-down-an-interface.patch @@ -0,0 +1,58 @@ +From a2148df99ddcd122247f95c4cbcce5c4118581a1 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Wed, 28 Jun 2017 17:30:00 -0500 +Subject: [PATCH 02/11] Create subroutine for tearing down an interface + +Creates a subroutine for tearing down an interface. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 22 ++++++++++++++++------ + 1 file changed, 16 insertions(+), 6 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index ffc9696..5e5b2cd 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -591,6 +591,19 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf) + gRecentInterfaces = intf; + } + ++mDNSlocal void TearDownInterface(mDNS *const m, PosixNetworkInterface *intf) ++{ ++ mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); ++ if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); ++ FreePosixNetworkInterface(intf); ++ ++ num_registered_interfaces--; ++ if (num_registered_interfaces == 0) { ++ num_pkts_accepted = 0; ++ num_pkts_rejected = 0; ++ } ++} ++ + // Grab the first interface, deregister it, free it, and repeat until done. + mDNSlocal void ClearInterfaceList(mDNS *const m) + { +@@ -599,13 +612,10 @@ mDNSlocal void ClearInterfaceList(mDNS *const m) + while (m->HostInterfaces) + { + PosixNetworkInterface *intf = (PosixNetworkInterface*)(m->HostInterfaces); +- mDNS_DeregisterInterface(m, &intf->coreIntf, NormalActivation); +- if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName); +- FreePosixNetworkInterface(intf); ++ TearDownInterface(m, intf); + } +- num_registered_interfaces = 0; +- num_pkts_accepted = 0; +- num_pkts_rejected = 0; ++ ++ assert(num_registered_interfaces == 0); + } + + // Sets up a send/receive socket. +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0002-mdns-cross-compilation-fixes-for-bitbake.patch b/meta-networking/recipes-protocols/mdns/mdns/0002-mdns-cross-compilation-fixes-for-bitbake.patch new file mode 100644 index 000000000..33590ffc5 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0002-mdns-cross-compilation-fixes-for-bitbake.patch @@ -0,0 +1,145 @@ +From 72405143f9d16514e70b88bc4843c9634b88036a Mon Sep 17 00:00:00 2001 +From: Brendan Le Foll +Date: Tue, 3 Mar 2015 11:42:57 +0000 +Subject: [PATCH 2/2] mdns: cross compilation fixes for bitbake + +Fixes several build errors when incorrect compiler or +compiler flags are used. + +Upstream-Status: Inappropriate [OE-specific] + +Signed-off-by: Paul Eggleton +Signed-off-by: Mikko Rapeli +--- + mDNSPosix/Makefile | 44 ++++++++++++++++++++------------------------ + 1 file changed, 20 insertions(+), 24 deletions(-) + +diff --git a/mDNSPosix/Makefile b/mDNSPosix/Makefile +index 78222e0..18a3af5 100755 +--- a/mDNSPosix/Makefile ++++ b/mDNSPosix/Makefile +@@ -50,6 +50,7 @@ + + LIBVERS = 1 + ++POSIXDIR = ../mDNSPosix + COREDIR = ../mDNSCore + SHAREDDIR ?= ../mDNSShared + DSODIR ?= ../DSO +@@ -62,16 +63,16 @@ else ifeq ($(SYSTEM), Linux) + os=linux + endif + +-CC = cc +-BISON = bison +-FLEX = flex +-ST = strip +-LD = ld ++CC ?= cc ++BISON ?= bison ++FLEX ?= flex ++ST ?= strip ++LD ?= ld + SOOPTS = -shared + CP = cp + RM = rm + LN = ln -s -f +-CFLAGS_COMMON = -I$(COREDIR) -I$(SHAREDDIR) -I$(DSODIR) -I$(PROXYDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" ++CFLAGS_COMMON = -I$(POSIXDIR) -I$(COREDIR) -I$(SHAREDDIR) -I$(DSODIR) -I$(PROXYDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\" + CFLAGS_PTHREAD = + LINKOPTS = + LINKOPTS_PTHREAD = -lpthread +@@ -85,6 +86,7 @@ CFLAGS_OPEN_SOURCE= + endif + + # Set up diverging paths for debug vs. prod builds ++DEBUG ?= 1 + ifeq "$(DEBUG)" "1" + CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=2 + OBJDIR = objects/debug +@@ -101,8 +103,8 @@ else + # 1. We want to make small binaries, suitable for putting into hardware devices + # 2. Some of the code analysis warnings only work when some form of optimization is enabled + CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=0 +-OBJDIR ?= objects/prod +-BUILDDIR ?= build/prod ++OBJDIR = objects/prod ++BUILDDIR = build/prod + STRIP = $(ST) -S + endif + endif +@@ -125,7 +127,7 @@ else + # any target that contains the string "linux" + ifeq ($(findstring linux,$(os)),linux) + CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -ftabstop=4 +-LD = $(CC) ++LD ?= $(CC) + SOOPTS = -shared + FLEXFLAGS_OS = -l + JAVACFLAGS_OS += -I$(JDK)/include/linux +@@ -276,8 +278,7 @@ Daemon: setup $(BUILDDIR)/mdnsd + @echo "Responder daemon done" + + $(BUILDDIR)/mdnsd: $(DAEMONOBJS) +- $(CC) -o $@ $+ $(LINKOPTS) +- $(STRIP) $@ ++ $(LD) -o $@ $+ + + # libdns_sd target builds the client library + libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX) +@@ -286,13 +287,9 @@ libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX) + CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o + + $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS) +- $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+ +- $(STRIP) $@ +- +-Clients: setup libdns_sd ../Clients/build/dns-sd +- @echo "Clients done" ++ $(LD) -shared $(LINKOPTS) -Wl,-soname,libdns_sd.$(LDSUFFIX).1 -o $@ $+ + +-../Clients/build/dns-sd: ../Clients/dns-sd.c ++Clients: setup libdns_sd + $(MAKE) -C ../Clients DEBUG=$(DEBUG) SUPMAKE_CFLAGS="$(MDNSCFLAGS)" + + # nss_mdns target builds the Name Service Switch module +@@ -300,8 +297,7 @@ nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE) + @echo "Name Service Switch module done" + + $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o +- $(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+ +- $(STRIP) $@ ++ $(LD) -shared $(LINKOPTS) -o $@ $+ + + ############################################################################# + +@@ -494,21 +490,21 @@ dnsextd: setup $(BUILDDIR)/dnsextd + @echo "dnsextd done" + + $(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o +- $(CC) $+ -o $@ $(LINKOPTS) ++ $(CC) $+ -o $@ + + $(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o +- $(CC) $+ -o $@ $(LINKOPTS) ++ $(CC) $+ -o $@ + + $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ) $(OBJDIR)/ProxyResponder.c.o +- $(CC) $+ -o $@ $(LINKOPTS) ++ $(CC) $+ -o $@ + + $(BUILDDIR)/mDNSNetMonitor: $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o +- $(CC) $+ -o $@ $(LINKOPTS) ++ $(CC) $+ -o $@ + + $(OBJDIR)/NetMonitor.c.o: $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c + + $(BUILDDIR)/dnsextd: $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o +- $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD) ++ $(CC) $+ -o $@ $(LINKOPTS_PTHREAD) + + ############################################################################# + +-- +2.20.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0003-Track-interface-socket-family.patch b/meta-networking/recipes-protocols/mdns/mdns/0003-Track-interface-socket-family.patch new file mode 100644 index 000000000..8c0e6bf39 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0003-Track-interface-socket-family.patch @@ -0,0 +1,50 @@ +From 71a7c728ae0d8143b66aa40decca74ebaa9aa2ce Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Wed, 28 Jun 2017 17:30:00 -0500 +Subject: [PATCH 03/11] Track interface socket family + +Tracks the socket family associated with the interface. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 1 + + mDNSPosix/mDNSPosix.h | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 5e5b2cd..8fe22be 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -918,6 +918,7 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct + // Set up the extra fields in PosixNetworkInterface. + assert(intf->intfName != NULL); // intf->intfName already set up above + intf->index = intfIndex; ++ intf->sa_family = intfAddr->sa_family; + intf->multicastSocket4 = -1; + #if HAVE_IPV6 + intf->multicastSocket6 = -1; +diff --git a/mDNSPosix/mDNSPosix.h b/mDNSPosix/mDNSPosix.h +index ca60d80..f77c185 100644 +--- a/mDNSPosix/mDNSPosix.h ++++ b/mDNSPosix/mDNSPosix.h +@@ -19,6 +19,7 @@ + #define __mDNSPlatformPosix_h + + #include ++#include + #include + + #ifdef __cplusplus +@@ -40,6 +41,7 @@ struct PosixNetworkInterface + const char * intfName; + PosixNetworkInterface * aliasIntf; + int index; ++ sa_family_t sa_family; + int multicastSocket4; + #if HAVE_IPV6 + int multicastSocket6; +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0004-Use-list-for-changed-interfaces.patch b/meta-networking/recipes-protocols/mdns/mdns/0004-Use-list-for-changed-interfaces.patch new file mode 100644 index 000000000..db3a63ea4 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0004-Use-list-for-changed-interfaces.patch @@ -0,0 +1,177 @@ +From 798bfb5e984845a27874d1a244686db6e384d7b8 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Thu, 13 Jul 2017 09:00:00 -0500 +Subject: [PATCH 04/11] Use list for changed interfaces + +Uses a linked list to store the index of changed network interfaces +instead of a bitfield. This allows for network interfaces with an +index greater than 31 (an index of 36 was seen on Android). + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 67 +++++++++++++++++++++++++++++++++---------- + 1 file changed, 52 insertions(+), 15 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 195d04b..bb883c1 100755 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -67,6 +67,14 @@ struct IfChangeRec + }; + typedef struct IfChangeRec IfChangeRec; + ++// Used to build a list of network interface indices ++struct NetworkInterfaceIndex ++{ ++ int if_index; ++ struct NetworkInterfaceIndex *Next; ++}; ++typedef struct NetworkInterfaceIndex NetworkInterfaceIndex; ++ + // Note that static data is initialized to zero in (modern) C. + static PosixEventSource *gEventSources; // linked list of PosixEventSource's + static sigset_t gEventSignalSet; // Signals which event loop listens for +@@ -1458,6 +1466,32 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD) + return err; + } + ++mDNSlocal mDNSBool ListContainsInterfaceIndex(GenLinkedList *list, int if_index) ++{ ++ NetworkInterfaceIndex *item; ++ ++ for (item = (NetworkInterfaceIndex*)list->Head; item != NULL; item = item->Next) ++ { ++ if (if_index == item->if_index) return mDNStrue; ++ } ++ ++ return mDNSfalse; ++} ++ ++mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) ++{ ++ NetworkInterfaceIndex *item; ++ ++ if (ListContainsInterfaceIndex(list, if_index)) return; ++ ++ item = malloc(sizeof *item); ++ if (item == NULL) return; ++ ++ item->if_index = if_index; ++ item->Next = NULL; ++ AddToTail(list, item); ++} ++ + #if MDNS_DEBUGMSGS + mDNSlocal void PrintNetLinkMsg(const struct nlmsghdr *pNLMsg) + { +@@ -1485,14 +1519,13 @@ mDNSlocal void PrintNetLinkMsg(const struct nlmsghdr *pNLMsg) + } + #endif + +-mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) ++mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *changedInterfaces) + // Read through the messages on sd and if any indicate that any interface records should + // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. + { + ssize_t readCount; + char buff[4096]; + struct nlmsghdr *pNLMsg = (struct nlmsghdr*) buff; +- mDNSu32 result = 0; + + // The structure here is more complex than it really ought to be because, + // unfortunately, there's no good way to size a buffer in advance large +@@ -1528,9 +1561,9 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) + + // Process the NetLink message + if (pNLMsg->nlmsg_type == RTM_GETLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) +- result |= 1 << ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index; ++ AddInterfaceIndexToList(changedInterfaces, ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index); + else if (pNLMsg->nlmsg_type == RTM_DELADDR || pNLMsg->nlmsg_type == RTM_NEWADDR) +- result |= 1 << ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index; ++ AddInterfaceIndexToList(changedInterfaces, ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index); + + // Advance pNLMsg to the next message in the buffer + if ((pNLMsg->nlmsg_flags & NLM_F_MULTI) != 0 && pNLMsg->nlmsg_type != NLMSG_DONE) +@@ -1541,8 +1574,6 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) + else + break; // all done! + } +- +- return result; + } + + #else // USES_NETLINK +@@ -1574,14 +1605,13 @@ mDNSlocal void PrintRoutingSocketMsg(const struct ifa_msghdr *pRSMsg) + } + #endif + +-mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) ++mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *changedInterfaces) + // Read through the messages on sd and if any indicate that any interface records should + // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. + { + ssize_t readCount; + char buff[4096]; + struct ifa_msghdr *pRSMsg = (struct ifa_msghdr*) buff; +- mDNSu32 result = 0; + + readCount = read(sd, buff, sizeof buff); + if (readCount < (ssize_t) sizeof(struct ifa_msghdr)) +@@ -1596,12 +1626,10 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd) + pRSMsg->ifam_type == RTM_IFINFO) + { + if (pRSMsg->ifam_type == RTM_IFINFO) +- result |= 1 << ((struct if_msghdr*) pRSMsg)->ifm_index; ++ AddInterfaceIndexToList(changedInterfaces, ((struct if_msghdr*) pRSMsg)->ifm_index); + else +- result |= 1 << pRSMsg->ifam_index; ++ AddInterfaceIndexToList(changedInterfaces, pRSMsg->ifam_index); + } +- +- return result; + } + + #endif // USES_NETLINK +@@ -1611,7 +1639,8 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) + { + IfChangeRec *pChgRec = (IfChangeRec*) context; + fd_set readFDs; +- mDNSu32 changedInterfaces = 0; ++ GenLinkedList changedInterfaces; ++ NetworkInterfaceIndex *changedInterface; + struct timeval zeroTimeout = { 0, 0 }; + + (void)fd; // Unused +@@ -1619,17 +1648,25 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) + FD_ZERO(&readFDs); + FD_SET(pChgRec->NotifySD, &readFDs); + ++ InitLinkedList(&changedInterfaces, offsetof(NetworkInterfaceIndex, Next)); ++ + do + { +- changedInterfaces |= ProcessRoutingNotification(pChgRec->NotifySD); ++ ProcessRoutingNotification(pChgRec->NotifySD, &changedInterfaces); + } + while (0 < select(pChgRec->NotifySD + 1, &readFDs, (fd_set*) NULL, (fd_set*) NULL, &zeroTimeout)); + + // Currently we rebuild the entire interface list whenever any interface change is + // detected. If this ever proves to be a performance issue in a multi-homed + // configuration, more care should be paid to changedInterfaces. +- if (changedInterfaces) ++ if (changedInterfaces.Head != NULL) + mDNSPlatformPosixRefreshInterfaceList(pChgRec->mDNS); ++ ++ while ((changedInterface = (NetworkInterfaceIndex*)changedInterfaces.Head) != NULL) ++ { ++ RemoveFromList(&changedInterfaces, changedInterface); ++ free(changedInterface); ++ } + } + + // Register with either a Routing Socket or RtNetLink to listen for interface changes. +-- +2.20.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0006-Remove-unneeded-function.patch b/meta-networking/recipes-protocols/mdns/mdns/0006-Remove-unneeded-function.patch new file mode 100644 index 000000000..b461a60df --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0006-Remove-unneeded-function.patch @@ -0,0 +1,51 @@ +From 157d67f152777754c059ced7511352102f23ffae Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Mon, 24 Jul 2017 09:39:18 -0500 +Subject: [PATCH 06/11] Remove unneeded function + +Removes a function we no longer need by integrating it into the only +function that calls it. This was originally separated so that we could +only process network interfaces that netlink indicated had been changed, +this has since been extended to test for all network intefaces. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 13 ++----------- + 1 file changed, 2 insertions(+), 11 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 59a8b8c..3fc5451 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -1079,24 +1079,15 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD) + return err; + } + +-mDNSlocal mDNSBool ListContainsInterfaceIndex(GenLinkedList *list, int if_index) ++mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) + { + NetworkInterfaceIndex *item; + + for (item = (NetworkInterfaceIndex*)list->Head; item != NULL; item = item->Next) + { +- if (if_index == item->if_index) return mDNStrue; ++ if (if_index == item->if_index) return; + } + +- return mDNSfalse; +-} +- +-mDNSlocal void AddInterfaceIndexToList(GenLinkedList *list, int if_index) +-{ +- NetworkInterfaceIndex *item; +- +- if (ListContainsInterfaceIndex(list, if_index)) return; +- + item = malloc(sizeof *item); + if (item == NULL) return; + +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0006-make-Add-top-level-Makefile.patch b/meta-networking/recipes-protocols/mdns/mdns/0006-make-Add-top-level-Makefile.patch new file mode 100644 index 000000000..b7d9ad5bb --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0006-make-Add-top-level-Makefile.patch @@ -0,0 +1,175 @@ +From 177abf68e5ac5f82c6261af63528f8b6160bca0f Mon Sep 17 00:00:00 2001 +From: Alex Kiernan +Date: Tue, 6 Dec 2022 13:28:31 +0000 +Subject: [PATCH] make: Add top-level Makefile + +Simple top level Makefile that just delegates to mDNSPosix. + +Upstream-Status: Inappropriate [oe-specific] +Signed-off-by: Alex Kiernan +--- + Makefile | 154 +------------------------------------------------------ + 1 file changed, 2 insertions(+), 152 deletions(-) + +diff --git a/Makefile b/Makefile +index 8b6fa77..feb6ac6 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,152 +1,2 @@ +-# +-# Copyright (c) 2003-2018 Apple Inc. All rights reserved. +-# +-# Top level makefile for Build & Integration (B&I). +-# +-# This file is used to facilitate checking the mDNSResponder project directly from git and submitting to B&I at Apple. +-# +-# The various platform directories contain makefiles or projects specific to that platform. +-# +-# B&I builds must respect the following target: +-# install: +-# installsrc: +-# installhdrs: +-# installapi: +-# clean: +-# +- +-include $(MAKEFILEPATH)/pb_makefiles/platform.make +- +-MVERS = "mDNSResponder-1310.140.1" +- +-VER = +-ifneq ($(strip $(GCC_VERSION)),) +- VER = -- GCC_VERSION=$(GCC_VERSION) +-endif +-echo "VER = $(VER)" +- +-projectdir := $(SRCROOT)/mDNSMacOSX +-buildsettings := OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS) SDKROOT=$(SDKROOT) +- +-.PHONY: install installSome installEmpty installExtras SystemLibraries installhdrs installapi installsrc java clean +- +-# Sanitizer support +-# Disable Sanitizer instrumentation in LibSystem contributors. See rdar://problem/29952210. +-UNSUPPORTED_SANITIZER_PROJECTS := mDNSResponderSystemLibraries mDNSResponderSystemLibraries_Sim +-PROJECT_SUPPORTS_SANITIZERS := 1 +-ifneq ($(words $(filter $(UNSUPPORTED_SANITIZER_PROJECTS), $(RC_ProjectName))), 0) +- PROJECT_SUPPORTS_SANITIZERS := 0 +-endif +-ifeq ($(RC_ENABLE_ADDRESS_SANITIZATION),1) +- ifeq ($(PROJECT_SUPPORTS_SANITIZERS),1) +- $(info Enabling Address Sanitizer) +- buildsettings += -enableAddressSanitizer YES +- else +- $(warning WARNING: Address Sanitizer not supported for project $(RC_ProjectName)) +- endif +-endif +-ifeq ($(RC_ENABLE_THREAD_SANITIZATION),1) +- ifeq ($(PROJECT_SUPPORTS_SANITIZERS),1) +- $(info Enabling Thread Sanitizer) +- buildsettings += -enableThreadSanitizer YES +- else +- $(warning WARNING: Thread Sanitizer not supported for project $(RC_ProjectName)) +- endif +-endif +-ifeq ($(RC_ENABLE_UNDEFINED_BEHAVIOR_SANITIZATION),1) +- ifeq ($(PROJECT_SUPPORTS_SANITIZERS),1) +- $(info Enabling Undefined Behavior Sanitizer) +- buildsettings += -enableUndefinedBehaviorSanitizer YES +- else +- $(warning WARNING: Undefined Behavior Sanitizer not supported for project $(RC_ProjectName)) +- endif +-endif +- +-# B&I install build targets +-# +-# For the mDNSResponder build alias, the make target used by B&I depends on the platform: +-# +-# Platform Make Target +-# -------- ----------- +-# osx install +-# ios installSome +-# atv installSome +-# watch installSome +-# +-# For the mDNSResponderSystemLibraries and mDNSResponderSystemLibraries_sim build aliases, B&I uses the SystemLibraries +-# target for all platforms. +- +-install: +-ifeq ($(RC_ProjectName), mDNSResponderServices) +-ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), osx) +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Services-macOS' $(VER) +-else +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Services' $(VER) +-endif +-else ifeq ($(RC_ProjectName), mDNSResponderServices_Sim) +- mkdir -p $(DSTROOT)/AppleInternal +-else +- cd '$(projectdir)'; xcodebuild install $(buildsettings) $(VER) +-endif +- +-installSome: +- cd '$(projectdir)'; xcodebuild install $(buildsettings) $(VER) +- +-installEmpty: +- mkdir -p $(DSTROOT)/AppleInternal +- +-installExtras: +-ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), osx) +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Extras-macOS' $(VER) +-else ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), ios) +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Extras-iOS' $(VER) +-else ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), atv) +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Extras-tvOS' $(VER) +-else +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target 'Build Extras' $(VER) +-endif +- +-SystemLibraries: +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target SystemLibraries $(VER) +- +-# B&I installhdrs build targets +- +-installhdrs:: +-ifeq ($(RC_ProjectName), mDNSResponderServices) +-ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), osx) +- cd '$(projectdir)'; xcodebuild installhdrs $(buildsettings) -target 'Build Services-macOS' $(VER) +-else +- cd '$(projectdir)'; xcodebuild installhdrs $(buildsettings) -target 'Build Services' $(VER) +-endif +-else ifeq ($(RC_ProjectName), mDNSResponderServices_Sim) +- mkdir -p $(DSTROOT)/AppleInternal +-else ifneq ($(findstring SystemLibraries,$(RC_ProjectName)),) +- cd '$(projectdir)'; xcodebuild installhdrs $(buildsettings) -target SystemLibraries $(VER) +-endif +- +-# B&I installapi build targets +- +-installapi: +-ifeq ($(RC_ProjectName), mDNSResponderServices) +-ifeq ($(RC_PROJECT_COMPILATION_PLATFORM), osx) +- cd '$(projectdir)'; xcodebuild installapi $(buildsettings) -target 'Build Services-macOS' $(VER) +-else +- cd '$(projectdir)'; xcodebuild installapi $(buildsettings) -target 'Build Services' $(VER) +-endif +-else ifeq ($(RC_ProjectName), mDNSResponderServices_Sim) +- mkdir -p $(DSTROOT)/AppleInternal +-else ifneq ($(findstring SystemLibraries,$(RC_ProjectName)),) +- cd '$(projectdir)'; xcodebuild installapi $(buildsettings) -target SystemLibrariesDynamic $(VER) +-endif +- +-# Misc. targets +- +-installsrc: +- ditto . '$(SRCROOT)' +- rm -rf '$(SRCROOT)/mDNSWindows' '$(SRCROOT)/Clients/FirefoxExtension' +- +-java: +- cd '$(projectdir)'; xcodebuild install $(buildsettings) -target libjdns_sd.jnilib $(VER) +- +-clean:: +- echo clean ++all clean: ++ cd mDNSPosix && $(MAKE) $@ +-- +2.38.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0008-Mark-deleted-interfaces-as-being-changed.patch b/meta-networking/recipes-protocols/mdns/mdns/0008-Mark-deleted-interfaces-as-being-changed.patch new file mode 100644 index 000000000..fdc5105cb --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0008-Mark-deleted-interfaces-as-being-changed.patch @@ -0,0 +1,39 @@ +From 0fcc0f210f3a9310a1963de640b384ce866410fd Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Wed, 9 Aug 2017 09:16:58 -0500 +Subject: [PATCH 08/11] Mark deleted interfaces as being changed + +Netlink notification handling ignores messages for deleted links, +RTM_DELLINK. It does handle RTM_GETLINK. According to libnl docu- +mentation (http://www.infradead.org/~tgr/libnl/doc/route.html) +RTM_DELLINK can be sent by the kernel, but RTM_GETLINK cannot. +There was likely a mixup in the original implementation, so this +change replaces handling for RTM_GETLINK with RTM_DELLINK. + +Testing and Verification Instructions: + 1. Use ip-link to add and remove a VLAN interface and verify + that mDNSResponder handles the deleted link. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 798ab10..a8a57df 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -1163,7 +1163,7 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change + #endif + + // Process the NetLink message +- if (pNLMsg->nlmsg_type == RTM_GETLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) ++ if (pNLMsg->nlmsg_type == RTM_DELLINK || pNLMsg->nlmsg_type == RTM_NEWLINK) + AddInterfaceIndexToList(changedInterfaces, ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index); + else if (pNLMsg->nlmsg_type == RTM_DELADDR || pNLMsg->nlmsg_type == RTM_NEWADDR) + AddInterfaceIndexToList(changedInterfaces, ((struct ifaddrmsg*) NLMSG_DATA(pNLMsg))->ifa_index); +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0009-Fix-possible-NULL-dereference.patch b/meta-networking/recipes-protocols/mdns/mdns/0009-Fix-possible-NULL-dereference.patch new file mode 100644 index 000000000..362d69768 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0009-Fix-possible-NULL-dereference.patch @@ -0,0 +1,45 @@ +From 38cff19781f81586926b02f0fd1cb36c040395e0 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Thu, 10 Aug 2017 08:21:53 -0500 +Subject: [PATCH 09/11] Fix possible NULL dereference + +Fixes a possible NULL dereference if memory for +the PosixNetworkInterface could not be allocated. +Other logic seems to prevent dereferencing this +variable if NULL, but this instance seems to have +been overlooked. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index a8a57df..3243ed4 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -951,12 +951,15 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct ifi_info *const ifi) + + // If interface is a direct link, address record will be marked as kDNSRecordTypeKnownUnique + // and skip the probe phase of the probe/announce packet sequence. +- intf->coreIntf.DirectLink = mDNSfalse; ++ if (err == 0) ++ { ++ intf->coreIntf.DirectLink = mDNSfalse; + #ifdef DIRECTLINK_INTERFACE_NAME +- if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) +- intf->coreIntf.DirectLink = mDNStrue; ++ if (strcmp(intfName, STRINGIFY(DIRECTLINK_INTERFACE_NAME)) == 0) ++ intf->coreIntf.DirectLink = mDNStrue; + #endif +- intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; ++ intf->coreIntf.SupportsUnicastMDNSResponse = mDNStrue; ++ } + + // The interface is all ready to go, let's register it with the mDNS core. + if (err == 0) +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0010-Handle-errors-from-socket-calls.patch b/meta-networking/recipes-protocols/mdns/mdns/0010-Handle-errors-from-socket-calls.patch new file mode 100644 index 000000000..b9b015727 --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0010-Handle-errors-from-socket-calls.patch @@ -0,0 +1,62 @@ +From 382b3b924e43abd1bdc5792918161d0922666691 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Thu, 10 Aug 2017 08:27:32 -0500 +Subject: [PATCH 10/11] Handle errors from socket calls + +Adds handling for socket() or read() returning a +negative value (indicating an error has occurred). + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 3243ed4..84af26b 100644 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -1129,7 +1129,7 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change + // Read through the messages on sd and if any indicate that any interface records should + // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0. + { +- ssize_t readCount; ++ ssize_t readVal, readCount; + char buff[4096]; + struct nlmsghdr *pNLMsg = (struct nlmsghdr*) buff; + +@@ -1138,7 +1138,10 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change + // enough to hold all pending data and so avoid message fragmentation. + // (Note that FIONREAD is not supported on AF_NETLINK.) + +- readCount = read(sd, buff, sizeof buff); ++ readVal = read(sd, buff, sizeof buff); ++ if (readVal < 0) return; ++ readCount = readVal; ++ + while (1) + { + // Make sure we've got an entire nlmsghdr in the buffer, and payload, too. +@@ -1154,7 +1157,9 @@ mDNSlocal void ProcessRoutingNotification(int sd, GenLinkedList *change + pNLMsg = (struct nlmsghdr*) buff; + + // read more data +- readCount += read(sd, buff + readCount, sizeof buff - readCount); ++ readVal = read(sd, buff + readCount, sizeof buff - readCount); ++ if (readVal < 0) return; ++ readCount += readVal; + continue; // spin around and revalidate with new readCount + } + else +@@ -1429,6 +1434,7 @@ mDNSlocal mDNSBool mDNSPlatformInit_CanReceiveUnicast(void) + int err; + int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + struct sockaddr_in s5353; ++ if (s < 0) return mDNSfalse; + s5353.sin_family = AF_INET; + s5353.sin_port = MulticastDNSPort.NotAnInteger; + s5353.sin_addr.s_addr = 0; +-- +2.17.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch b/meta-networking/recipes-protocols/mdns/mdns/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch new file mode 100644 index 000000000..d9adde04c --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/0011-Change-a-dynamic-allocation-to-file-scope-variable.patch @@ -0,0 +1,53 @@ +From 9ff06108cd44e84ba6c68bfa6737e793f117e303 Mon Sep 17 00:00:00 2001 +From: Nate Karstens +Date: Thu, 10 Aug 2017 08:46:03 -0500 +Subject: [PATCH] Change a dynamic allocation to file-scope variable + +Changes a variable from being dynamically-allocated to being +statically-allocated at the file scope. Addresses a Coverity +issue where it appeared that the memory was being leaked. + +Upstream-Status: Submitted [dts@apple.com] + +Signed-off-by: Nate Karstens +--- + mDNSPosix/mDNSPosix.c | 14 ++++---------- + 1 file changed, 4 insertions(+), 10 deletions(-) + +diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c +index 7aeee7b..2d25016 100755 +--- a/mDNSPosix/mDNSPosix.c ++++ b/mDNSPosix/mDNSPosix.c +@@ -81,6 +81,7 @@ static sigset_t gEventSignalSet; // Signals which event loop list + static sigset_t gEventSignals; // Signals which were received while inside loop + + static PosixNetworkInterface *gRecentInterfaces; ++static IfChangeRec gChgRec; + + // *************************************************************************** + // Globals (for debugging) +@@ -1641,18 +1642,11 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context) + mDNSlocal mStatus WatchForInterfaceChange(mDNS *const m) + { + mStatus err; +- IfChangeRec *pChgRec; + +- pChgRec = (IfChangeRec*) mDNSPlatformMemAllocateClear(sizeof *pChgRec); +- if (pChgRec == NULL) +- return mStatus_NoMemoryErr; +- +- pChgRec->mDNS = m; +- err = OpenIfNotifySocket(&pChgRec->NotifySD); ++ gChgRec.mDNS = m; ++ err = OpenIfNotifySocket(&gChgRec.NotifySD); + if (err == 0) +- err = mDNSPosixAddFDToEventLoop(pChgRec->NotifySD, InterfaceChangeCallback, pChgRec); +- if (err) +- mDNSPlatformMemFree(pChgRec); ++ err = mDNSPosixAddFDToEventLoop(gChgRec.NotifySD, InterfaceChangeCallback, &gChgRec); + + return err; + } +-- +2.20.1 + diff --git a/meta-networking/recipes-protocols/mdns/mdns/mdns.service b/meta-networking/recipes-protocols/mdns/mdns/mdns.service new file mode 100644 index 000000000..531d142dc --- /dev/null +++ b/meta-networking/recipes-protocols/mdns/mdns/mdns.service @@ -0,0 +1,15 @@ +[Unit] +Description=Zero-configuration networking +After=network.target + +[Service] +Type=forking +ExecStartPre=/bin/rm -f /var/run/mdnsd.pid +ExecStart=/usr/sbin/mdnsd +ExecReload=/bin/kill -HUP $MAINPID +PIDFile=/var/run/mdnsd.pid +Restart=always +RestartSec=10s + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/mdns/mdns_1310.140.1.bb b/meta-networking/recipes-protocols/mdns/mdns_1310.140.1.bb index 205dc929b..65f4847d8 100644 --- a/meta-networking/recipes-protocols/mdns/mdns_1310.140.1.bb +++ b/meta-networking/recipes-protocols/mdns/mdns_1310.140.1.bb @@ -2,28 +2,31 @@ SUMMARY = "Publishes & browses available services on a link according to the Zer DESCRIPTION = "Bonjour, also known as zero-configuration networking, enables automatic discovery of computers, devices, and services on IP networks." HOMEPAGE = "http://developer.apple.com/networking/bonjour/" LICENSE = "Apache-2.0 & BSD-3-Clause" -LIC_FILES_CHKSUM = "file://../LICENSE;md5=31c50371921e0fb731003bbc665f29bf" +LIC_FILES_CHKSUM = "file://LICENSE;md5=31c50371921e0fb731003bbc665f29bf" DEPENDS:append:libc-musl = " musl-nscd" RPROVIDES:${PN} += "libdns_sd.so" -SRC_URI = "https://opensource.apple.com/tarballs/mDNSResponder/mDNSResponder-${PV}.tar.gz \ +# matches annotated tag mDNSResponder-1310.140.1 +SRCREV = "1d1de95b98fba2077d34c9d78b839a96aa0e1c77" +BRANCH = "rel/mDNSResponder-1310" +SRC_URI = "git://github.com/apple-oss-distributions/mDNSResponder;protocol=https;branch=${BRANCH} \ file://mdns.service \ - file://0001-mdns-include-stddef.h-for-NULL.patch;patchdir=.. \ - file://0002-mdns-cross-compilation-fixes-for-bitbake.patch;patchdir=.. \ - file://0001-Create-subroutine-for-cleaning-recent-interfaces.patch;patchdir=.. \ - file://0002-Create-subroutine-for-tearing-down-an-interface.patch;patchdir=.. \ - file://0003-Track-interface-socket-family.patch;patchdir=.. \ - file://0004-Use-list-for-changed-interfaces.patch;patchdir=.. \ - file://0006-Remove-unneeded-function.patch;patchdir=.. \ - file://0008-Mark-deleted-interfaces-as-being-changed.patch;patchdir=.. \ - file://0009-Fix-possible-NULL-dereference.patch;patchdir=.. \ - file://0010-Handle-errors-from-socket-calls.patch;patchdir=.. \ - file://0011-Change-a-dynamic-allocation-to-file-scope-variable.patch;patchdir=.. \ - file://0001-dns-sd-Include-missing-headers.patch;patchdir=.. \ + file://0001-mdns-include-stddef.h-for-NULL.patch \ + file://0002-mdns-cross-compilation-fixes-for-bitbake.patch \ + file://0001-Create-subroutine-for-cleaning-recent-interfaces.patch \ + file://0002-Create-subroutine-for-tearing-down-an-interface.patch \ + file://0003-Track-interface-socket-family.patch \ + file://0004-Use-list-for-changed-interfaces.patch \ + file://0006-Remove-unneeded-function.patch \ + file://0008-Mark-deleted-interfaces-as-being-changed.patch \ + file://0009-Fix-possible-NULL-dereference.patch \ + file://0010-Handle-errors-from-socket-calls.patch \ + file://0011-Change-a-dynamic-allocation-to-file-scope-variable.patch \ + file://0001-dns-sd-Include-missing-headers.patch \ + file://0006-make-Add-top-level-Makefile.patch \ " -SRC_URI[sha256sum] = "040f6495c18b9f0557bcf9e00cbcfc82b03405f5ba6963dc147730ca0ca90d6f" CVE_PRODUCT = "apple:mdnsresponder" @@ -42,13 +45,22 @@ CVE_CHECK_IGNORE += "CVE-2007-0613" PARALLEL_MAKE = "" -S = "${WORKDIR}/mDNSResponder-${PV}/mDNSPosix" +# We install a stub Makefile in the top directory so that the various checks +# in base.bbclass pass their tests for a Makefile, this ensures (that amongst +# other things) the sstate checks will clean the build directory when the +# task hashes changes. +# +# We can't use the approach of setting ${S} to mDNSPosix as we need +# DEBUG_PREFIX_MAP to cover files which come from the Clients directory too. +S = "${WORKDIR}/git" EXTRA_OEMAKE += "os=linux DEBUG=0 'CC=${CC}' 'LD=${CCLD} ${LDFLAGS}'" TARGET_CC_ARCH += "${LDFLAGS}" do_install () { + cd mDNSPosix + install -d ${D}${sbindir} install -m 0755 build/prod/mdnsd ${D}${sbindir} -- cgit v1.2.3-54-g00ecf