r2854 - in glibc-package/trunk/debian: . patches/all patches/any
Author: aurel32
Date: 2008-03-05 11:25:12 +0000 (Wed, 05 Mar 2008)
New Revision: 2854
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/patches/all/cvs-gai_conf.diff
glibc-package/trunk/debian/patches/any/cvs-rfc3484.diff
Log:
* patches/any/cvs-rfc3484.diff: update from CVS to allow the definition of
IPv4 scopes in /etc/gai.conf.
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2008-03-05 11:09:17 UTC (rev 2853)
+++ glibc-package/trunk/debian/changelog 2008-03-05 11:25:12 UTC (rev 2854)
@@ -16,8 +16,10 @@
from "A.M/P.M.".
* Remove uk_UA from patches/localedata/first_weekday.diff: merged upstream
in a different way. Closes: bug#469439.
+ * patches/any/cvs-rfc3484.diff: update from CVS to allow the definition of
+ IPv4 scopes in /etc/gai.conf.
* patches/all/cvs-gai_conf.diff: update gai.conf from CVS to also mention
- Teredo tunnels.
+ Teredo tunnels and scopev4 defaults.
-- Aurelien Jarno <aurel32@debian.org> Wed, 05 Mar 2008 12:08:44 +0100
Modified: glibc-package/trunk/debian/patches/all/cvs-gai_conf.diff
===================================================================
--- glibc-package/trunk/debian/patches/all/cvs-gai_conf.diff 2008-03-05 11:09:17 UTC (rev 2853)
+++ glibc-package/trunk/debian/patches/all/cvs-gai_conf.diff 2008-03-05 11:25:12 UTC (rev 2854)
@@ -1,5 +1,9 @@
2007-11-19 Ulrich Drepper <drepper@redhat.com>
+ * posix/gai.conf: Document scopev4 defaults.
+
+2007-11-19 Ulrich Drepper <drepper@redhat.com>
+
* posix/gai.conf: Update for current default tables.
===================================================================
@@ -45,3 +49,21 @@
# and 10.3 in RFC 3484. The default is:
#
#precedence ::1/128 50
+@@ -52,3 +52,17 @@
+ # For sites which prefer IPv4 connections change the last line to
+ #
+ #precedence ::ffff:0:0/96 100
++
++#
++# scopev4 <mask> <value>
++# Add another rule to the RFC 3484 scope table for IPv4 addresses.
++# By default the scope IDs described in section 3.2 in RFC 3484 are
++# used. Changing these defaults should hardly ever be necessary.
++# The defaults are equivalent to:
++#
++#scopev4 ::ffff:169.254.0.0/112 2
++#scopev4 ::ffff:127.0.0.0/104 2
++#scopev4 ::ffff:10.0.0.0/104 5
++#scopev4 ::ffff:172.16.0.0/108 5
++#scopev4 ::ffff:192.168.0.0/112 5
++#scopev4 ::ffff:0.0.0.0 14
Modified: glibc-package/trunk/debian/patches/any/cvs-rfc3484.diff
===================================================================
--- glibc-package/trunk/debian/patches/any/cvs-rfc3484.diff 2008-03-05 11:09:17 UTC (rev 2853)
+++ glibc-package/trunk/debian/patches/any/cvs-rfc3484.diff 2008-03-05 11:25:12 UTC (rev 2854)
@@ -3,7 +3,15 @@
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Fix
recognition of interface family.
+2007-11-19 Ulrich Drepper <drepper@redhat.com>
+ * sysdeps/posix/getaddrinfo.c (defaults_scopes, scopes): New variables.
+ (get_scope): For IPv4 scope, use scopes table.
+ (fini): Free scopes table if necessary.
+ (free_scopelist): New function.
+ (scopecmp): New function.
+ (gaiconf_init): Also handle scopev4 entries.
+
2007-11-12 Ulrich Drepper <drepper@redhat.com>
* include/ifaddrs.c (struct in6addrinfo): Add prefixlen field.
@@ -437,3 +445,312 @@
}
else if (nlmh->nlmsg_type == NLMSG_DONE)
/* We found the end, leave the loop. */
+===================================================================
+RCS file: /cvs/glibc/libc/sysdeps/posix/getaddrinfo.c,v
+retrieving revision 1.120
+retrieving revision 1.121
+diff -u -r1.120 -r1.121
+--- libc/sysdeps/posix/getaddrinfo.c 2007/11/19 17:31:28 1.120
++++ libc/sysdeps/posix/getaddrinfo.c 2007/11/20 00:40:41 1.121
+@@ -1014,6 +1014,38 @@
+ };
+
+
++#if __BYTE_ORDER == __BIG_ENDIAN
++# define htonl_c(n) n
++#else
++# define htonl_c(n) __bswap_constant_32 (n)
++#endif
++
++static const struct scopeentry
++{
++ union
++ {
++ char addr[4];
++ uint32_t addr32;
++ };
++ uint32_t netmask;
++ int32_t scope;
++} default_scopes[] =
++ {
++ /* Link-local addresses: scope 2. */
++ { { { 169, 254, 0, 0 } }, htonl_c (0xffff0000), 2 },
++ { { { 127, 0, 0, 0 } }, htonl_c (0xff000000), 2 },
++ /* Site-local addresses: scope 5. */
++ { { { 10, 0, 0, 0 } }, htonl_c (0xff000000), 5 },
++ { { { 172, 16, 0, 0 } }, htonl_c (0xfff00000), 5 },
++ { { { 192, 168, 0, 0 } }, htonl_c (0xffff0000), 5 },
++ /* Default: scope 14. */
++ { { { 0, 0, 0, 0 } }, htonl_c (0x00000000), 14 }
++ };
++
++/* The label table. */
++static const struct scopeentry *scopes;
++
++
+ static int
+ get_scope (const struct sockaddr_storage *ss)
+ {
+@@ -1038,17 +1070,17 @@
+ else if (ss->ss_family == PF_INET)
+ {
+ const struct sockaddr_in *in = (const struct sockaddr_in *) ss;
+- const uint8_t *addr = (const uint8_t *) &in->sin_addr;
+
+- /* RFC 3484 specifies how to map IPv6 addresses to scopes.
+- 169.254/16 and 127/8 are link-local. */
+- if ((addr[0] == 169 && addr[1] == 254) || addr[0] == 127)
+- scope = 2;
+- else if (addr[0] == 10 || (addr[0] == 172 && (addr[1] & 0xf0) == 16)
+- || (addr[0] == 192 && addr[1] == 168))
+- scope = 5;
+- else
+- scope = 14;
++ size_t cnt = 0;
++ while (1)
++ {
++ if ((in->sin_addr.s_addr & scopes[cnt].netmask)
++ == scopes[cnt].addr32)
++ return scopes[cnt].scope;
++
++ ++cnt;
++ }
++ /* NOTREACHED */
+ }
+ else
+ /* XXX What is a good default? */
+@@ -1490,6 +1522,13 @@
+ precedence = default_precedence;
+ free ((void *) old);
+ }
++
++ if (scopes != default_scopes)
++ {
++ const struct scopeentry *old = scopes;
++ scopes = default_scopes;
++ free ((void *) old);
++ }
+ }
+
+
+@@ -1500,6 +1539,13 @@
+ };
+
+
++struct scopelist
++{
++ struct scopeentry entry;
++ struct scopelist *next;
++};
++
++
+ static void
+ free_prefixlist (struct prefixlist *list)
+ {
+@@ -1512,6 +1558,18 @@
+ }
+
+
++static void
++free_scopelist (struct scopelist *list)
++{
++ while (list != NULL)
++ {
++ struct scopelist *oldp = list;
++ list = list->next;
++ free (oldp);
++ }
++}
++
++
+ static int
+ prefixcmp (const void *p1, const void *p2)
+ {
+@@ -1526,6 +1584,20 @@
+ }
+
+
++static int
++scopecmp (const void *p1, const void *p2)
++{
++ const struct scopeentry *e1 = (const struct scopeentry *) p1;
++ const struct scopeentry *e2 = (const struct scopeentry *) p2;
++
++ if (e1->netmask > e2->netmask)
++ return -1;
++ if (e1->netmask == e2->netmask)
++ return 0;
++ return 1;
++}
++
++
+ static void
+ gaiconf_init (void)
+ {
+@@ -1535,6 +1607,9 @@
+ struct prefixlist *precedencelist = NULL;
+ size_t nprecedencelist = 0;
+ bool precedencelist_nullbits = false;
++ struct scopelist *scopelist = NULL;
++ size_t nscopelist = 0;
++ bool scopelist_nullbits = false;
+
+ FILE *fp = fopen (GAICONF_FNAME, "rc");
+ if (fp != NULL)
+@@ -1625,7 +1700,7 @@
+ || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+- && bits <= INT_MAX
++ && bits <= 128
+ && ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+@@ -1659,6 +1734,73 @@
+ }
+ break;
+
++ case 7:
++ if (strcmp (cmd, "scopev4") == 0)
++ {
++ struct in6_addr prefix;
++ unsigned long int bits;
++ unsigned long int val;
++ char *endp;
++
++ bits = 32;
++ __set_errno (0);
++ cp = strchr (val1, '/');
++ if (cp != NULL)
++ *cp++ = '\0';
++ if (inet_pton (AF_INET6, val1, &prefix))
++ {
++ if (IN6_IS_ADDR_V4MAPPED (&prefix)
++ && (cp == NULL
++ || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
++ || errno != ERANGE)
++ && *endp == '\0'
++ && bits >= 96
++ && bits <= 128
++ && ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
++ || errno != ERANGE)
++ && *endp == '\0'
++ && val <= INT_MAX)
++ {
++ struct scopelist *newp;
++ new_scope:
++ newp = malloc (sizeof (*newp));
++ if (newp == NULL)
++ {
++ free (line);
++ fclose (fp);
++ goto no_file;
++ }
++
++ newp->entry.netmask = htonl (bits != 96
++ ? (0xffffffff
++ << (128 - bits))
++ : 0);
++ newp->entry.addr32 = (prefix.s6_addr32[3]
++ & newp->entry.netmask);
++ newp->entry.scope = val;
++ newp->next = scopelist;
++ scopelist = newp;
++ ++nscopelist;
++ scopelist_nullbits |= bits == 96;
++ }
++ }
++ else if (inet_pton (AF_INET, val1, &prefix.s6_addr32[3])
++ && (cp == NULL
++ || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
++ || errno != ERANGE)
++ && *endp == '\0'
++ && bits <= 32
++ && ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
++ || errno != ERANGE)
++ && *endp == '\0'
++ && val <= INT_MAX)
++ {
++ bits += 96;
++ goto new_scope;
++ }
++ }
++ break;
++
+ case 10:
+ if (strcmp (cmd, "precedence") == 0)
+ {
+@@ -1742,12 +1884,52 @@
+
+ /* Sort the entries so that the most specific ones are at
+ the beginning. */
+- qsort (new_precedence, nprecedencelist, sizeof (*new_labels),
++ qsort (new_precedence, nprecedencelist, sizeof (*new_precedence),
+ prefixcmp);
+ }
+ else
+ new_precedence = (struct prefixentry *) default_precedence;
+
++ struct scopeentry *new_scopes;
++ if (nscopelist > 0)
++ {
++ if (!scopelist_nullbits)
++ ++nscopelist;
++ new_scopes = malloc (nscopelist * sizeof (*new_scopes));
++ if (new_scopes == NULL)
++ {
++ if (new_labels != default_labels)
++ free (new_labels);
++ if (new_precedence != default_precedence)
++ free (new_precedence);
++ goto no_file;
++ }
++
++ int i = nscopelist;
++ if (!scopelist_nullbits)
++ {
++ --i;
++ new_scopes[i].addr32 = 0;
++ new_scopes[i].netmask = 0;
++ new_scopes[i].scope = 14;
++ }
++
++ struct scopelist *l = scopelist;
++ while (i-- > 0)
++ {
++ new_scopes[i] = l->entry;
++ l = l->next;
++ }
++ free_scopelist (scopelist);
++
++ /* Sort the entries so that the most specific ones are at
++ the beginning. */
++ qsort (new_scopes, nscopelist, sizeof (*new_scopes),
++ scopecmp);
++ }
++ else
++ new_scopes = (struct scopeentry *) default_scopes;
++
+ /* Now we are ready to replace the values. */
+ const struct prefixentry *old = labels;
+ labels = new_labels;
+@@ -1759,6 +1941,11 @@
+ if (old != default_precedence)
+ free ((void *) old);
+
++ const struct scopeentry *oldscope = scopes;
++ scopes = new_scopes;
++ if (oldscope != default_scopes)
++ free ((void *) oldscope);
++
+ gaiconf_mtime = st.st_mtim;
+ }
+ else
+@@ -1766,6 +1953,7 @@
+ no_file:
+ free_prefixlist (labellist);
+ free_prefixlist (precedencelist);
++ free_scopelist (scopelist);
+
+ /* If we previously read the file but it is gone now, free the
+ old data and use the builtin one. Leave the reload flag
Reply to: