[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r1420 - in /fsf/trunk/libc: ./ include/ nptl/ nptl/sysdeps/unix/sysv/linux/x86_64/ resolv/ sysdeps/unix/sysv/linux/x86_64/



Author: eglibc
Date: Sat Feb 10 00:01:29 2007
New Revision: 1420

Log:
Import glibc-mainline for 2007-02-10

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/include/resolv.h
    fsf/trunk/libc/nptl/ChangeLog
    fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
    fsf/trunk/libc/resolv/res_init.c
    fsf/trunk/libc/resolv/res_mkquery.c
    fsf/trunk/libc/resolv/res_query.c
    fsf/trunk/libc/resolv/res_send.c
    fsf/trunk/libc/resolv/resolv.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sat Feb 10 00:01:29 2007
@@ -1,3 +1,16 @@
+2007-02-09  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Remove incorrect comment.
+
+	* resolv/res_init.c (res_setoptions): Recognize edns0 option.
+	* resolv/res_mkquery.c: Define __res_nopt.
+	* resolv/res_query.c (__libc_res_nquery): If RES_USE_EDNS0 is set
+	try adding EDNS0 record.
+	* resolv/res_send.c (send_dg): If request failed with FORMERR and
+	EDNS0 record was send make sure we don't try it again.
+	* resolv/resolv.h: Define RES_F_EDNS0ERR and RES_USE_EDNS0.
+	* include/resolv.h: Declare __res_nopt.
+
 2007-02-08  Jakub Jelinek  <jakub@xxxxxxxxxx>
 
 	[BZ #3944]

Modified: fsf/trunk/libc/include/resolv.h
==============================================================================
--- fsf/trunk/libc/include/resolv.h (original)
+++ fsf/trunk/libc/include/resolv.h Sat Feb 10 00:01:29 2007
@@ -48,6 +48,8 @@
 extern int res_ourserver_p (const res_state __statp,
 			    const struct sockaddr_in6 *__inp);
 extern void __res_iclose (res_state statp, bool free_addr);
+extern int __res_nopt(res_state statp, int n0, u_char *buf, int buflen,
+		      int anslen);
 libc_hidden_proto (__res_ninit)
 libc_hidden_proto (__res_maybe_init)
 libc_hidden_proto (__res_nclose)
@@ -100,6 +102,7 @@
 libresolv_hidden_proto (__ns_name_unpack)
 libresolv_hidden_proto (__ns_get16)
 libresolv_hidden_proto (__ns_get32)
+libresolv_hidden_proto (__res_nopt)
 
 extern const char *_res_opcodes[];
 libresolv_hidden_proto (_res_opcodes)

Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Sat Feb 10 00:01:29 2007
@@ -1,3 +1,9 @@
+2007-02-09  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+	(__lll_mutex_timedlock_wait): Use correct pointer when we don't
+	call into the kernel to delay.
+
 2007-01-18  Ulrich Drepper  <drepper@xxxxxxxxxx>
 
 	* tst-initializers1.c: We want to test the initializers as seen

Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S Sat Feb 10 00:01:29 2007
@@ -164,7 +164,7 @@
 8:				/* NB: %edx == 2 */
 	xorl	%eax, %eax
 	LOCK
-	cmpxchgl %edx, (%rdi)
+	cmpxchgl %edx, (%r12)
 	jnz	7f
 
 6:	addq	$16, %rsp

Modified: fsf/trunk/libc/resolv/res_init.c
==============================================================================
--- fsf/trunk/libc/resolv/res_init.c (original)
+++ fsf/trunk/libc/resolv/res_init.c Sat Feb 10 00:01:29 2007
@@ -510,6 +510,8 @@
 		} else if (!strncmp(cp, "no-check-names",
 				    sizeof("no-check-names") - 1)) {
 			statp->options |= RES_NOCHECKNAME;
+                } else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
+			statp->options |= RES_USE_EDNS0;
 		} else {
 			/* XXX - print a warning here? */
 		}

Modified: fsf/trunk/libc/resolv/res_mkquery.c
==============================================================================
--- fsf/trunk/libc/resolv/res_mkquery.c (original)
+++ fsf/trunk/libc/resolv/res_mkquery.c Sat Feb 10 00:01:29 2007
@@ -208,3 +208,49 @@
 	return (cp - buf);
 }
 libresolv_hidden_def (res_nmkquery)
+
+
+/* attach OPT pseudo-RR, as documented in RFC2671 (EDNS0). */
+#ifndef T_OPT
+#define T_OPT   41
+#endif
+
+int
+__res_nopt(res_state statp,
+	   int n0,                /* current offset in buffer */
+	   u_char *buf,           /* buffer to put query */
+	   int buflen,            /* size of buffer */
+	   int anslen)            /* UDP answer buffer size */
+{
+	u_int16_t flags = 0;
+
+#ifdef DEBUG
+	if ((statp->options & RES_DEBUG) != 0U)
+		printf(";; res_nopt()\n");
+#endif
+
+	HEADER *hp = (HEADER *) buf;
+	u_char *cp = buf + n0;
+	u_char *ep = buf + buflen;
+
+	if ((ep - cp) < 1 + RRFIXEDSZ)
+		return -1;
+
+	*cp++ = 0;	/* "." */
+
+	ns_put16(T_OPT, cp);	/* TYPE */
+	cp += INT16SZ;
+	ns_put16(anslen & 0xffff, cp);	/* CLASS = UDP payload size */
+	cp += INT16SZ;
+	*cp++ = NOERROR;	/* extended RCODE */
+	*cp++ = 0;		/* EDNS version */
+	/* XXX Once we support DNSSEC we change the flag value here.  */
+	ns_put16(flags, cp);
+	cp += INT16SZ;
+	ns_put16(0, cp);	/* RDLEN */
+	cp += INT16SZ;
+	hp->arcount = htons(ntohs(hp->arcount) + 1);
+
+	return cp - buf;
+}
+libresolv_hidden_def (__res_nopt)

Modified: fsf/trunk/libc/resolv/res_query.c
==============================================================================
--- fsf/trunk/libc/resolv/res_query.c (original)
+++ fsf/trunk/libc/resolv/res_query.c Sat Feb 10 00:01:29 2007
@@ -120,10 +120,13 @@
 	u_char *buf;
 	HEADER *hp = (HEADER *) answer;
 	int n, use_malloc = 0;
-
+        u_int oflags = statp->_flags;
+
+	size_t bufsize = QUERYSIZE;
+	buf = alloca (bufsize);
+
+ again:
 	hp->rcode = NOERROR;	/* default */
-
-	buf = alloca (QUERYSIZE);
 
 #ifdef DEBUG
 	if (statp->options & RES_DEBUG)
@@ -131,18 +134,30 @@
 #endif
 
 	n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL,
-			 buf, QUERYSIZE);
-	if (__builtin_expect (n <= 0, 0)) {
+			 buf, bufsize);
+	if (n > 0
+	    && (oflags & RES_F_EDNS0ERR) == 0
+	    && (statp->options & RES_USE_EDNS0) != 0)
+		n = __res_nopt(statp, n, buf, bufsize, anslen);
+	if (__builtin_expect (n <= 0, 0) && !use_malloc) {
 		/* Retry just in case res_nmkquery failed because of too
 		   short buffer.  Shouldn't happen.  */
-		buf = malloc (MAXPACKET);
+		bufsize = MAXPACKET;
+		buf = malloc (bufsize);
 		if (buf != NULL) {
 			use_malloc = 1;
-			n = res_nmkquery(statp, QUERY, name, class, type, NULL,
-					 0, NULL, buf, MAXPACKET);
+			goto again;
 		}
 	}
 	if (__builtin_expect (n <= 0, 0)) {
+		/* If the query choked with EDNS0, retry without EDNS0.  */
+		if ((statp->options & RES_USE_EDNS0) != 0
+		    && ((oflags ^ statp->_flags) & RES_F_EDNS0ERR) != 0) {
+			statp->_flags |= RES_F_EDNS0ERR;
+			if (statp->options & RES_DEBUG)
+				printf(";; res_nquery: retry without EDNS0\n");
+                        goto again;
+		}
 #ifdef DEBUG
 		if (statp->options & RES_DEBUG)
 			printf(";; res_query: mkquery failed\n");

Modified: fsf/trunk/libc/resolv/res_send.c
==============================================================================
--- fsf/trunk/libc/resolv/res_send.c (original)
+++ fsf/trunk/libc/resolv/res_send.c Sat Feb 10 00:01:29 2007
@@ -986,6 +986,24 @@
 				ans, (resplen > anssiz) ? anssiz : resplen);
 			goto wait;
 		}
+#ifdef RES_USE_EDNS0
+		if (anhp->rcode == FORMERR
+		    && (statp->options & RES_USE_EDNS0) != 0U) {
+			/*
+			 * Do not retry if the server do not understand
+			 * EDNS0.  The case has to be captured here, as
+			 * FORMERR packet do not carry query section, hence
+			 * res_queriesmatch() returns 0.
+			 */
+			DprintQ(statp->options & RES_DEBUG,
+				(stdout,
+				 "server rejected query with EDNS0:\n"),
+				ans, (resplen > anssiz) ? anssiz : resplen);
+			/* record the error */
+			statp->_flags |= RES_F_EDNS0ERR;
+			goto err_out;
+        }
+#endif
 		if (!(statp->options & RES_INSECURE2) &&
 		    !res_queriesmatch(buf, buf + buflen,
 				      ans, ans + anssiz)) {

Modified: fsf/trunk/libc/resolv/resolv.h
==============================================================================
--- fsf/trunk/libc/resolv/resolv.h (original)
+++ fsf/trunk/libc/resolv/resolv.h Sat Feb 10 00:01:29 2007
@@ -180,6 +180,7 @@
  */
 #define	RES_F_VC	0x00000001	/* socket is TCP */
 #define	RES_F_CONN	0x00000002	/* socket is connected */
+#define RES_F_EDNS0ERR	0x00000004	/* EDNS0 caused errors */
 
 /* res_findzonecut() options */
 #define	RES_EXHAUSTIVE	0x00000001	/* always do all queries */
@@ -209,6 +210,7 @@
 					   strings */
 #define RES_NOIP6DOTINT	0x00080000	/* Do not use .ip6.int in IPv6
 					   reverse lookup */
+#define RES_USE_EDNS0	0x00100000	/* Use EDNS0.  */
 
 #define RES_DEFAULT	(RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
 

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h Sat Feb 10 00:01:29 2007
@@ -182,7 +182,6 @@
     The Linux kernel uses and destroys internally these registers:
     return address from
     syscall		rcx
-    additionally clobered: r12-r15,rbx,rbp
     eflags from syscall	r11
 
     Normal function call, including calls to the system call stub