Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs for mDNSResponder-1790 on linux platform #5

Open
wants to merge 6 commits into
base: rel/mDNSResponder-1790
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mDNSCore/mDNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -9849,7 +9849,7 @@ mDNSlocal void mDNSCoreReceiveNoUnicastAnswers(mDNS *const m, const DNSMessage *
#else
const DNSServRef dnsserv = qptr->qDNSServer;
#endif
debugf("mDNSCoreReceiveNoUnicastAnswers making negative cache entry TTL %d for %##s (%s)", negttl, name->c, DNSTypeName(q.qtype));
debugf("mDNSCoreReceiveNoUnicastAnswers making negative cache entry TTL %d for %##s (%s)", negttl, currentQName->c, DNSTypeName(q.qtype));
// Create a negative record for the current name in the CNAME chain.
MakeNegativeCacheRecord(m, &m->rec.r, currentQName, currentQNameHash, q.qtype, q.qclass, negttl, mDNSInterface_Any,
dnsserv, response->h.flags);
Expand Down
1 change: 1 addition & 0 deletions mDNSCore/mDNSEmbeddedAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -3037,6 +3037,7 @@ extern void mDNS_SetPrimaryInterfaceInfo(mDNS *m, const mDNSAddr *v4addr, const
extern DNSServer *mDNS_AddDNSServer(mDNS *const m, const domainname *d, const mDNSInterfaceID interface, mDNSs32 serviceID, const mDNSAddr *addr,
const mDNSIPPort port, ScopeType scopeType, mDNSu32 timeout, mDNSBool cellIntf, mDNSBool isExpensive, mDNSBool isConstrained, mDNSBool isCLAT46,
mDNSu32 resGroupID, mDNSBool reqA, mDNSBool reqAAAA, mDNSBool reqDO);
extern void mDNS_ClearDNSServers(mDNS *const m);
extern void PenalizeDNSServer(mDNS *const m, DNSQuestion *q, mDNSOpaque16 responseFlags);
#endif
extern void mDNS_AddSearchDomain(const domainname *const domain, mDNSInterfaceID InterfaceID);
Expand Down
21 changes: 20 additions & 1 deletion mDNSCore/uDNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ mDNSexport DNSServer *mDNS_AddDNSServer(mDNS *const m, const domainname *domain,
return(server);
}

void mDNS_ClearDNSServers(mDNS *const m)
{
mDNS_CheckLock(m);
DNSServer *p = m->DNSServers;
DNSServer *next = mDNSNULL;
while (p)
{
next = p->next;
mDNSPlatformMemFree(p);
p = next;
}
m->DNSServers = mDNSNULL;
}

// PenalizeDNSServer is called when the number of queries to the unicast
// DNS server exceeds MAX_UCAST_UNANSWERED_QUERIES or when we receive an
// error e.g., SERV_FAIL from DNS server.
Expand Down Expand Up @@ -7243,7 +7257,7 @@ mDNSexport mStatus mDNS_SetSecretForDomain(mDNS *m, DomainAuthInfo *info, const
return mStatus_UnsupportedErr;
}

mDNSexport domainname *uDNS_GetNextSearchDomain(mDNSInterfaceID InterfaceID, mDNSs8 *searchIndex, mDNSBool ignoreDotLocal)
mDNSexport domainname *uDNS_GetNextSearchDomain(mDNSInterfaceID InterfaceID, int *searchIndex, mDNSBool ignoreDotLocal)
{
(void) InterfaceID;
(void) searchIndex;
Expand Down Expand Up @@ -7300,6 +7314,11 @@ mDNSexport DNSServer *mDNS_AddDNSServer(mDNS *const m, const domainname *d, cons
return mDNSNULL;
}

void mDNS_ClearDNSServers(mDNS *const m)
{
(void) m;
}

mDNSexport void uDNS_SetupWABQueries(mDNS *const m)
{
(void) m;
Expand Down
54 changes: 34 additions & 20 deletions mDNSPosix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@

#############################################################################

LIBVERS = 1


LIB_MAJOR_VER = 1
LIB_MINOR_VER = 0
LIB_PATCH_VER = 0
LIBVERS = $(LIB_MAJOR_VER).$(LIB_MINOR_VER).$(LIB_PATCH_VER)


COREDIR = ../mDNSCore
SHAREDDIR ?= ../mDNSShared
Expand All @@ -53,42 +59,52 @@ else ifeq ($(SYSTEM), Linux)
os=linux
endif

CC = cc
ifneq ($(findstring $(os),solaris x),)
CC ?= gcc
LD ?= gcc
else
CC ?= cc
LD ?= ld
endif

BISON = bison
FLEX = flex
ST = strip
LD = ld
STRIP ?= strip
SOOPTS = -shared
CP = cp
RM = rm
LN = ln -s -f
CFLAGS_COMMON = -I$(COREDIR) -I$(SHAREDDIR) -I$(UTILDIR) -I$(DSODIR) -I$(SERVICEREGISTRATIONDIR) -I$(OBJDIR) -fwrapv -W -Wall -DPOSIX_BUILD -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
CFLAGS_PTHREAD =
LINKOPTS =
LINKOPTS += ${LDFLAGS}
LINKOPTS_PTHREAD = -lpthread
LDSUFFIX = so
JAVACFLAGS_OS = -fPIC -shared -ldns_sd

ifeq ($(unicast_disabled), y)
CFLAGS_COMMON += -DUNICAST_DISABLED
endif

# Set up diverging paths for debug vs. prod builds
ifeq "$(DEBUG)" "1"
CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=2
OBJDIR = objects/debug
BUILDDIR = build/debug
STRIP = echo
MDNS_STRIP = echo
else
ifeq "$(DEBUGSYMS)" "1"
CFLAGS_DEBUGGING = -g -DMDNS_DEBUGMSGS=0
OBJDIR = objects/prod
BUILDDIR = build/prod
STRIP = echo
MDNS_STRIP = echo
else
# We use -Os for two reasons:
# 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
STRIP = $(ST) -S
MDNS_STRIP = $(STRIP) -S
endif
endif

Expand All @@ -97,13 +113,11 @@ ifeq ($(os),solaris)
CFLAGS_DEBUGGING = -O0 -DMDNS_DEBUGMSGS=0
CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_IF_NAMETOINDEX \
-DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME -DTARGET_OS_SOLARIS
CC = gcc
LD = gcc
SOOPTS = -shared
LINKOPTS = -lsocket -lnsl -lresolv
LINKOPTS += -lsocket -lnsl -lresolv
JAVACFLAGS_OS += -I$(JDK)/include/solaris
ifneq ($(DEBUG),1)
STRIP = $(ST)
MDNS_STRIP = $(STRIP)
endif
else

Expand Down Expand Up @@ -162,10 +176,9 @@ CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement \
-D__MAC_OS_X_VERSION_MIN_REQUIRED=__MAC_OS_X_VERSION_10_4 \
-DHAVE_STRLCPY=1 -DTARGET_OS_MAC \
-D__APPLE_USE_RFC_2292 #-Wunreachable-code
CC = gcc
LD = $(CC)
SOOPTS = -dynamiclib
LINKOPTS = -lSystem
LINKOPTS += -lSystem
LDSUFFIX = dylib
JDK = /System/Library/Frameworks/JavaVM.framework/Home
JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM
Expand Down Expand Up @@ -229,7 +242,7 @@ endif
endif
endif

MDNSCFLAGS = $(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUGGING)
MDNSCFLAGS = $(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUGGING) $(CPPFLAGS) $(CXXFLAGS)

#############################################################################

Expand Down Expand Up @@ -267,7 +280,7 @@ Daemon: setup $(BUILDDIR)/mdnsd

$(BUILDDIR)/mdnsd: $(DAEMONOBJS)
$(CC) -o $@ $+ $(LINKOPTS)
$(STRIP) $@
$(MDNS_STRIP) $@

# libdns_sd target builds the client library
libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
Expand All @@ -276,8 +289,8 @@ 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 $(OBJDIR)/dnssd_errstring.c.so.o

$(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
$(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+
$(STRIP) $@
$(LD) $(SOOPTS) $(LINKOPTS) -Wl,-soname,libdns_sd.$(LDSUFFIX).$(LIB_MAJOR_VER) -o $@ $+
$(MDNS_STRIP) $@

Clients: setup libdns_sd ../Clients/build/dns-sd
@echo "Clients done"
Expand All @@ -291,7 +304,7 @@ nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)

$(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
$(LD) $(SOOPTS) $(LINKOPTS) -o $@ $+
$(STRIP) $@
$(MDNS_STRIP) $@

#############################################################################

Expand Down Expand Up @@ -322,7 +335,8 @@ $(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAM

$(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
$(CP) $< $@
$(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
$(LN) libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIB_MAJOR_VER)
$(LN) libdns_sd.$(LDSUFFIX).$(LIB_MAJOR_VER) $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
ifdef LDCONFIG
# -m means 'merge into existing database', -R means 'rescan directories'
$(LDCONFIG) -mR
Expand Down
5 changes: 4 additions & 1 deletion mDNSPosix/Responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,18 +632,21 @@ static mStatus RegisterOurServices(void)
static void DeregisterOurServices(void)
{
PosixService *thisServ;
int thisServID;

while (gServiceList != NULL) {
thisServ = gServiceList;
gServiceList = thisServ->next;

thisServID = thisServ->serviceID;

mDNS_DeregisterService(&mDNSStorage, &thisServ->coreServ);

if (gMDNSPlatformPosixVerboseLevel > 0) {
fprintf(stderr,
"%s: Deregistered service %d\n",
gProgramName,
thisServ->serviceID);
thisServID);
}
}
}
Expand Down
Loading