From nobody@FreeBSD.org  Thu Oct 31 05:59:05 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 66E34E8E
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Oct 2013 05:59:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 35C522172
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Oct 2013 05:59:05 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r9V5x4nt006206
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 31 Oct 2013 05:59:04 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r9V5x4q8006201;
	Thu, 31 Oct 2013 05:59:04 GMT
	(envelope-from nobody)
Message-Id: <201310310559.r9V5x4q8006201@oldred.freebsd.org>
Date: Thu, 31 Oct 2013 05:59:04 GMT
From: "Bradley T. Hughes" <bradleythughes@fastmail.fm>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mdnsd from net/mDNSResponder wakes up every 976us
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183512
>Category:       ports
>Synopsis:       mdnsd from net/mDNSResponder wakes up every 976us
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sunpoet
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 31 06:00:03 UTC 2013
>Closed-Date:    Tue Nov 05 12:49:25 UTC 2013
>Last-Modified:  Tue Nov 05 12:49:25 UTC 2013
>Originator:     Bradley T. Hughes
>Release:        10.0-BETA2
>Organization:
>Environment:
FreeBSD freebsd10.local 10.0-BETA2 FreeBSD 10.0-BETA2 #0 r257166: Sat Oct 26 19:23:22 UTC 2013     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The mdnsd daemon from net/mDNSResponder, once started, works correctly, but never idles. This can be seen as constant load on the machine, with constant wake ups. After examining and tracing the code, in particular mDNSPosix/mDNSPosix.c and mDNSPosix/PosixDaemon.c, I noticed that most of the load comes from very load timeout values passed to select(), but once select() returned and mDNS_Execute(), from mDNSCore/mDNS.c, never actually did any work. Using the ShowTaskSchedulingError() method from mDNSCore/DNSCommon.c, I noticed that the m->clearIgnoreNA flag was never cleared. After finding the relevant code in mDNS_Execute(), I noticed that the flag is cleared inside an #ifdef APPLE_OSX_mDNSResponder/#endif block. A small oversight, I think. I've attached a patch that moves the #ifdef to just around the OSX specific function, allowing the clearIgnoreNA flag to be properly set, and mdnsd now idles when there is nothing more to do.
>How-To-Repeat:
1. Install net/mDNSResponder
2. # echo 'mdnsd_enable="YES"' >> /etc/rc.conf
3. # service mdnsd start
4. Observe system activity, CPU and load rises, 
>Fix:
See the attached patch. FYI, I have not reported this upstream. I am unsure if my patch is the correct fix or not. An alternative would be to only set the clearIgnoreNA flag inside a similar #ifdef APPLE_OSX_mDNSResponder block.

Patch attached with submission follows:

--- mDNSCore/mDNS.c.orig	2013-10-31 06:41:04.868158806 +0100
+++ mDNSCore/mDNS.c	2013-10-31 06:41:21.089955155 +0100
@@ -4508,13 +4508,13 @@
 
         // After two seconds after the owner option is set, call the ioctl to clear the
         // ignore neighbor advertisement flag.
-#if APPLE_OSX_mDNSResponder
         if (m->clearIgnoreNA &&  m->timenow - m->clearIgnoreNA >= 0)
         {
+#if APPLE_OSX_mDNSResponder
             mDNSPlatformToggleInterfaceAdvt(m, mDNSfalse);
+#endif
             m->clearIgnoreNA = 0;
         }
-#endif
         // Clear AnnounceOwner if necessary. (Do this *before* SendQueries() and SendResponses().)
         if (m->AnnounceOwner && m->timenow - m->AnnounceOwner >= 0)
         {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sunpoet 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Oct 31 06:00:12 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183512 

From: "Bradley T. Hughes" <bradleythughes@fastmail.fm>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/183512: mdnsd from net/mDNSResponder wakes up every 976us
Date: Tue, 5 Nov 2013 10:06:29 +0100

 This problem doesn=92t exist anymore after upgrading to =
 mDNSResponder-541.
 
 --
 Bradley T. Hughes
 bradleythughes@fastmail.fm
 
State-Changed-From-To: open->closed 
State-Changed-By: sunpoet 
State-Changed-When: Tue Nov 5 12:49:23 UTC 2013 
State-Changed-Why:  
Submitter confirmed that the problem is solved in current ports tree. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183512 
>Unformatted:
