From ab@purple.the-7.net  Tue Sep 23 20:15:24 2008
Return-Path: <ab@purple.the-7.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9FFFD1065688
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 23 Sep 2008 20:15:24 +0000 (UTC)
	(envelope-from ab@purple.the-7.net)
Received: from purple.the-7.net (purple.the-7.net [IPv6:2001:470:1f01:622:230:48ff:fe23:4c67])
	by mx1.freebsd.org (Postfix) with ESMTP id 83E6D8FC1B
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 23 Sep 2008 20:15:24 +0000 (UTC)
	(envelope-from ab@purple.the-7.net)
Received: from purple.the-7.net (ab@localhost.the-7.net [127.0.0.1])
	by purple.the-7.net (8.14.3/8.14.3) with ESMTP id m8NKFOmN035319
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=OK)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 23 Sep 2008 13:15:24 -0700 (PDT)
	(envelope-from ab@purple.the-7.net)
Received: (from ab@localhost)
	by purple.the-7.net (8.14.3/8.14.3/Submit) id m8NKFO1b035318;
	Tue, 23 Sep 2008 13:15:24 -0700 (PDT)
	(envelope-from ab)
Message-Id: <200809232015.m8NKFO1b035318@purple.the-7.net>
Date: Tue, 23 Sep 2008 13:15:24 -0700 (PDT)
From: "Eugene M. Kim" <20080111.freebsd.org@ab.ote.we.lv>
Reply-To: "Eugene M. Kim" <20080111.freebsd.org@ab.ote.we.lv>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] [libc/net] spurious warning against DNAME RRs in getaddrinfo() and gethostby*()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         127591
>Category:       bin
>Synopsis:       [patch] [libc] spurious warning against DNAME RRs in getaddrinfo() and gethostby*()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ume
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 23 20:20:01 UTC 2008
>Closed-Date:    Mon Feb 16 18:36:58 UTC 2009
>Last-Modified:  Mon Feb 16 18:40:06 UTC 2009
>Originator:     Eugene M. Kim
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD purple.the-7.net 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #4: Wed Sep 10 17:25:31 PDT 2008 ab@purple.the-7.net:/home/FreeBSD/build/RELENG_7/obj/home/FreeBSD/build/RELENG_7/src/sys/PURPLE i386

>Description:

DNS DNAME RRs (as defined in RFC 2672) provides a mechanism for
non-terminal name redirection.  For example, www.the-7.com does not
exist in DNS but the-7.com has a DNAME alias to the-7.net; looking up
www.the-7.com for an A record would return:

$ dig www.the-7.com IN A +noall +answer

; <<>> DiG 9.4.2-P1 <<>> www.the-7.com IN A +noall +answer
;; global options:  printcmd
the-7.com.		300	IN	DNAME	the-7.net.
www.the-7.com.		0	IN	CNAME	www.the-7.net.
www.the-7.net.		300	IN	CNAME	purple.the-7.net.
purple.the-7.net.	300	IN	A	64.71.156.34
$ 

(The nameserver, upon receiving a request that matches a DNAME,
returns the DNAME and a synthesized CNAME.)

When src/libc/net/{getaddrinfo,gethostbydns}.c examines this result,
they see the DNAME record and emits a warning over auth.notice syslog,
which shows up in /var/log/messages and /var/log/auth.log by default.

These warnings are benign (as the server returns a synthesized CNAME
that correctly leads to the targeted name), but on a heavy-loaded
server they add up quickly and bloats the log size.

>How-To-Repeat:

$ /sbin/ping www.the-7.com
...
^C
$ fgrep 'www.the-7.com' /var/log/messages | tail -1
Sep 23 12:18:43 purple ping: gethostby*.gethostanswer: asked for "www.the-7.com IN A", got type "DNAME"
$ 

>Fix:

$ patch -d /usr/src << 'ENDEND'
--- -	2008-09-23 12:53:26.119657584 -0700
+++ lib/libc/net/getaddrinfo.c	2008-09-23 12:23:00.143769940 -0700
@@ -1884,7 +1884,7 @@
 			}
 		} else if (type != qtype) {
 #ifdef DEBUG
-			if (type != T_KEY && type != T_SIG)
+			if (type != T_KEY && type != T_SIG && type != ns_t_dname)
 				syslog(LOG_NOTICE|LOG_AUTH,
 	       "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
 				       qname, p_class(C_IN), p_type(qtype),
--- -	2008-09-23 12:53:45.223733999 -0700
+++ lib/libc/net/gethostbydns.c	2008-09-23 12:22:03.243899560 -0700
@@ -294,7 +294,7 @@
 			continue;
 		}
 		if (type != qtype) {
-			if (type != T_SIG)
+			if (type != T_SIG && type != ns_t_dname)
 				syslog(LOG_NOTICE|LOG_AUTH,
 	"gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"",
 				       qname, p_class(C_IN), p_type(qtype),
ENDEND
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: ume 
State-Changed-When: Wed Jan 21 02:03:27 UTC 2009 
State-Changed-Why:  
I'll handle this. 


Responsible-Changed-From-To: freebsd-bugs->ume 
Responsible-Changed-By: ume 
Responsible-Changed-When: Wed Jan 21 02:03:27 UTC 2009 
Responsible-Changed-Why:  
I'll handle this. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127591: commit references a PR
Date: Sun,  8 Feb 2009 16:58:33 +0000 (UTC)

 Author: ume
 Date: Sun Feb  8 16:58:05 2009
 New Revision: 188316
 URL: http://svn.freebsd.org/changeset/base/188316
 
 Log:
   Shutup warning for DNAME RR.
   
   PR:		bin/127591
   Submitted by:	"Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv>
   MFC after:	1 week
 
 Modified:
   head/lib/libc/net/getaddrinfo.c
   head/lib/libc/net/gethostbydns.c
 
 Modified: head/lib/libc/net/getaddrinfo.c
 ==============================================================================
 --- head/lib/libc/net/getaddrinfo.c	Sun Feb  8 15:38:31 2009	(r188315)
 +++ head/lib/libc/net/getaddrinfo.c	Sun Feb  8 16:58:05 2009	(r188316)
 @@ -1863,7 +1863,8 @@ getanswer(const querybuf *answer, int an
  			}
  		} else if (type != qtype) {
  #ifdef DEBUG
 -			if (type != T_KEY && type != T_SIG)
 +			if (type != T_KEY && type != T_SIG &&
 +			    type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	       "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 
 Modified: head/lib/libc/net/gethostbydns.c
 ==============================================================================
 --- head/lib/libc/net/gethostbydns.c	Sun Feb  8 15:38:31 2009	(r188315)
 +++ head/lib/libc/net/gethostbydns.c	Sun Feb  8 16:58:05 2009	(r188316)
 @@ -294,7 +294,7 @@ gethostanswer(const querybuf *answer, in
  			continue;
  		}
  		if (type != qtype) {
 -			if (type != T_SIG)
 +			if (type != T_SIG && type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	"gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: ume 
State-Changed-When: Sun Feb 8 17:00:24 UTC 2009 
State-Changed-Why:  
I've committed it into HEAD.  I'll MFC it after 1 week. 
Thank you. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127591: commit references a PR
Date: Mon, 16 Feb 2009 18:25:00 +0000 (UTC)

 Author: ume
 Date: Mon Feb 16 18:24:48 2009
 New Revision: 188690
 URL: http://svn.freebsd.org/changeset/base/188690
 
 Log:
   MFH 188316: Shutup warning for DNAME RR.
   
   PR:		bin/127591
   Submitted by:	"Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv>
 
 Modified:
   stable/7/lib/libc/   (props changed)
   stable/7/lib/libc/net/getaddrinfo.c
   stable/7/lib/libc/net/gethostbydns.c
   stable/7/lib/libc/string/ffsll.c   (props changed)
   stable/7/lib/libc/string/flsll.c   (props changed)
 
 Modified: stable/7/lib/libc/net/getaddrinfo.c
 ==============================================================================
 --- stable/7/lib/libc/net/getaddrinfo.c	Mon Feb 16 18:07:23 2009	(r188689)
 +++ stable/7/lib/libc/net/getaddrinfo.c	Mon Feb 16 18:24:48 2009	(r188690)
 @@ -1884,7 +1884,8 @@ getanswer(const querybuf *answer, int an
  			}
  		} else if (type != qtype) {
  #ifdef DEBUG
 -			if (type != T_KEY && type != T_SIG)
 +			if (type != T_KEY && type != T_SIG &&
 +			    type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	       "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 
 Modified: stable/7/lib/libc/net/gethostbydns.c
 ==============================================================================
 --- stable/7/lib/libc/net/gethostbydns.c	Mon Feb 16 18:07:23 2009	(r188689)
 +++ stable/7/lib/libc/net/gethostbydns.c	Mon Feb 16 18:24:48 2009	(r188690)
 @@ -294,7 +294,7 @@ gethostanswer(const querybuf *answer, in
  			continue;
  		}
  		if (type != qtype) {
 -			if (type != T_SIG)
 +			if (type != T_SIG && type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	"gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: ume 
State-Changed-When: Mon Feb 16 18:35:36 UTC 2009 
State-Changed-Why:  
I've MFCed it into RELENG_7 and RELENG_6.  Thank you. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/127591: commit references a PR
Date: Mon, 16 Feb 2009 18:32:52 +0000 (UTC)

 Author: ume
 Date: Mon Feb 16 18:32:28 2009
 New Revision: 188691
 URL: http://svn.freebsd.org/changeset/base/188691
 
 Log:
   MFH 188316: Shutup warning for DNAME RR.
   
   PR:		bin/127591
   Submitted by:	"Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv>
 
 Modified:
   stable/6/lib/libc/   (props changed)
   stable/6/lib/libc/inet/inet_net_pton.c   (props changed)
   stable/6/lib/libc/net/getaddrinfo.c
   stable/6/lib/libc/net/gethostbydns.c
   stable/6/lib/libc/sys/   (props changed)
 
 Modified: stable/6/lib/libc/net/getaddrinfo.c
 ==============================================================================
 --- stable/6/lib/libc/net/getaddrinfo.c	Mon Feb 16 18:24:48 2009	(r188690)
 +++ stable/6/lib/libc/net/getaddrinfo.c	Mon Feb 16 18:32:28 2009	(r188691)
 @@ -1686,7 +1686,8 @@ getanswer(const querybuf *answer, int an
  			}
  		} else if (type != qtype) {
  #ifdef DEBUG
 -			if (type != T_KEY && type != T_SIG)
 +			if (type != T_KEY && type != T_SIG &&
 +			    type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	       "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 
 Modified: stable/6/lib/libc/net/gethostbydns.c
 ==============================================================================
 --- stable/6/lib/libc/net/gethostbydns.c	Mon Feb 16 18:24:48 2009	(r188690)
 +++ stable/6/lib/libc/net/gethostbydns.c	Mon Feb 16 18:32:28 2009	(r188691)
 @@ -298,7 +298,7 @@ gethostanswer(const querybuf *answer, in
  			continue;
  		}
  		if (type != qtype) {
 -			if (type != T_SIG)
 +			if (type != T_SIG && type != ns_t_dname)
  				syslog(LOG_NOTICE|LOG_AUTH,
  	"gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"",
  				       qname, p_class(C_IN), p_type(qtype),
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
