mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 04:17:25 +00:00
mdns: improve numerous aspects of Posix backend
Apple's default implementation of the Posix backend for mDNSResponder has a number of weaknesses. Address several of them, most notably: * Improve interface tracking, preventing confusion to mdns's state machine. Prevents spurious removal/republication cycles whenever network interfaces are added or removed. * Support network interfaces whose indeces are great than 31. Indices grow past that range surprisingly quickly, especially with multi- homed, mobile, wifi, Bluetooth, VPN, VLANs, or other interfaces present. * Correctly handle edge cases during removal of a network interface. The fixes are kept as a patch series for clarity. Signed-off-by: Matt Hoosier <matt.hoosier@garmin.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
From 382b3b924e43abd1bdc5792918161d0922666691 Mon Sep 17 00:00:00 2001
|
||||
From: Nate Karstens <nate.karstens@garmin.com>
|
||||
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 <nate.karstens@garmin.com>
|
||||
---
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user