diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-12-12 18:13:35 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-12-12 18:13:35 +0000 |
commit | 574e283890a6ca92325a06dafa76ff307a8019a2 (patch) | |
tree | 055e44e24a55fb4863e5d9cdc04e320cde52ffe9 /posix | |
parent | a162e5955f7e324be82d9318bbcbe869c66ffb86 (diff) | |
download | glibc-574e283890a6ca92325a06dafa76ff307a8019a2.tar glibc-574e283890a6ca92325a06dafa76ff307a8019a2.tar.gz glibc-574e283890a6ca92325a06dafa76ff307a8019a2.tar.bz2 glibc-574e283890a6ca92325a06dafa76ff307a8019a2.zip |
Updated to fedora-glibc-20071212T1051
Diffstat (limited to 'posix')
-rw-r--r-- | posix/Makefile | 1 | ||||
-rw-r--r-- | posix/gai.conf | 34 | ||||
-rw-r--r-- | posix/regex.h | 2 | ||||
-rw-r--r-- | posix/tst-rfc3484-2.c | 20 | ||||
-rw-r--r-- | posix/tst-rfc3484-3.c | 137 | ||||
-rw-r--r-- | posix/tst-rfc3484.c | 12 | ||||
-rw-r--r-- | posix/unistd.h | 4 |
7 files changed, 195 insertions, 15 deletions
diff --git a/posix/Makefile b/posix/Makefile index c9b61bb4e9..c0edce4d62 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -90,6 +90,7 @@ tests := tstgetopt testfnm runtests runptests \ tst-execv1 tst-execv2 tst-execl1 tst-execl2 \ tst-execve1 tst-execve2 tst-execle1 tst-execle2 \ tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \ + tst-rfc3484-3 \ tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset xtests := bug-ga2 ifeq (yes,$(build-shared)) diff --git a/posix/gai.conf b/posix/gai.conf index 0e334ac2c5..b4abfc1f90 100644 --- a/posix/gai.conf +++ b/posix/gai.conf @@ -19,13 +19,14 @@ # Add another rule to the RFC 3484 label table. See section 2.1 in # RFC 3484. The default is: # -#label ::1/128 0 -#label ::/0 1 -#label 2002::/16 2 -#label ::/96 3 -#label ::ffff:0:0/96 4 -#label fec0::/10 5 -#label fc00::/7 6 +#label ::1/128 0 +#label ::/0 1 +#label 2002::/16 2 +#label ::/96 3 +#label ::ffff:0:0/96 4 +#label fec0::/10 5 +#label fc00::/7 6 +#label 2001:0::/32 7 # # This default differs from the tables given in RFC 3484 by handling # (now obsolete) site-local IPv6 addresses and Unique Local Addresses. @@ -35,10 +36,11 @@ # site-local IPv4 and IPv6 addresses a lookup for a global address would # see the IPv6 be preferred. The result is a long delay because the # site-local IPv6 addresses cannot be used while the IPv4 address is -# (at least for the foreseeable future) NATed. +# (at least for the foreseeable future) NATed. We also treat Teredo +# tunnels special. # # precedence <mask> <value> -# Add another rule the to RFC 3484 precedence table. See section 2.1 +# Add another rule to the RFC 3484 precedence table. See section 2.1 # and 10.3 in RFC 3484. The default is: # #precedence ::1/128 50 @@ -50,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 diff --git a/posix/regex.h b/posix/regex.h index 807c404ec2..66f566e7b7 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -302,7 +302,7 @@ extern reg_syntax_t re_syntax_options; `re_error_msg' table in regex.c. */ typedef enum { -#ifdef _XOPEN_SOURCE +#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K REG_ENOSYS = -1, /* This will never happen for this implementation. */ #endif diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c index f318523ed5..d29f0725cc 100644 --- a/posix/tst-rfc3484-2.c +++ b/posix/tst-rfc3484-2.c @@ -18,6 +18,12 @@ __check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen) *in6ai = NULL; *in6ailen = 0; } +void +attribute_hidden +__check_native (uint32_t a1_index, int *a1_native, + uint32_t a2_index, int *a2_native) +{ +} int __idna_to_ascii_lz (const char *input, char **output, int flags) { @@ -60,6 +66,7 @@ do_test (void) { labels = default_labels; precedence = default_precedence; + scopes = default_scopes; struct sockaddr_in so1; so1.sin_family = AF_INET; @@ -99,6 +106,8 @@ do_test (void) results[0].source_addr_len = sizeof (so1); results[0].source_addr_flags = 0; results[0].service_order = 0; + results[0].prefixlen = 16; + results[0].index = 0; memcpy (&results[0].source_addr, &so1, sizeof (so1)); results[1].dest_addr = &ai2; @@ -106,10 +115,13 @@ do_test (void) results[1].source_addr_len = sizeof (so2); results[1].source_addr_flags = 0; results[1].service_order = 1; + results[1].prefixlen = 16; + results[1].index = 0; memcpy (&results[1].source_addr, &so2, sizeof (so2)); - qsort (results, 2, sizeof (results[0]), rfc3484_sort); + struct sort_result_combo combo = { .results = results, .nresults = 2 }; + qsort_r (results, 2, sizeof (results[0]), rfc3484_sort, &combo); int result = 0; if (results[0].dest_addr->ai_family == AF_INET6) @@ -125,6 +137,8 @@ do_test (void) results[1].source_addr_len = sizeof (so1); results[1].source_addr_flags = 0; results[1].service_order = 1; + results[1].prefixlen = 16; + results[1].index = 0; memcpy (&results[1].source_addr, &so1, sizeof (so1)); results[0].dest_addr = &ai2; @@ -132,10 +146,12 @@ do_test (void) results[0].source_addr_len = sizeof (so2); results[0].source_addr_flags = 0; results[0].service_order = 0; + results[0].prefixlen = 16; + results[0].index = 0; memcpy (&results[0].source_addr, &so2, sizeof (so2)); - qsort (results, 2, sizeof (results[0]), rfc3484_sort); + qsort_r (results, 2, sizeof (results[0]), rfc3484_sort, &combo); if (results[0].dest_addr->ai_family == AF_INET6) { diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c new file mode 100644 index 0000000000..4aede81ee3 --- /dev/null +++ b/posix/tst-rfc3484-3.c @@ -0,0 +1,137 @@ +#include <stdbool.h> +#include <stdio.h> +#include <ifaddrs.h> + +/* Internal definitions used in the libc code. */ +#define __getservbyname_r getservbyname_r +#define __socket socket +#define __getsockname getsockname +#define __inet_aton inet_aton +#define __gethostbyaddr_r gethostbyaddr_r +#define __gethostbyname2_r gethostbyname2_r + +void +attribute_hidden +__check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen) +{ + *p1 = *p2 = true; + *in6ai = NULL; + *in6ailen = 0; +} +void +attribute_hidden +__check_native (uint32_t a1_index, int *a1_native, + uint32_t a2_index, int *a2_native) +{ +} +int +__idna_to_ascii_lz (const char *input, char **output, int flags) +{ + return 0; +} +int +__idna_to_unicode_lzlz (const char *input, char **output, int flags) +{ + *output = NULL; + return 0; +} + +#include "../sysdeps/posix/getaddrinfo.c" + +service_user *__nss_hosts_database attribute_hidden; + + +/* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ + + +#if __BYTE_ORDER == __BIG_ENDIAN +# define h(n) n +#else +# define h(n) __bswap_constant_32 (n) +#endif + +struct sockaddr_in addrs[] = +{ + { .sin_family = AF_INET, .sin_addr = { h (0xa0a86d1d) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a85d03) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a82c3d) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a86002) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a802f3) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a80810) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xa0a85e02) } }, + { .sin_family = AF_INET, .sin_addr = { h (0xac162311) } }, + { .sin_family = AF_INET, .sin_addr = { h (0x0a324572) } } +}; +#define naddrs (sizeof (addrs) / sizeof (addrs[0])) +static struct addrinfo ais[naddrs]; +static struct sort_result results[naddrs]; + +static const int expected[naddrs] = + { + 8, 0, 1, 2, 3, 4, 5, 6, 7 + }; + +static const struct scopeentry new_scopes[] = + { + { { { 169, 254, 0, 0 } }, h (0xffff0000), 2 }, + { { { 127, 0, 0, 0 } }, h (0xff000000), 2 }, + { { { 10, 0, 0, 0 } }, h (0xff000000), 5 }, + { { { 192, 168, 0, 0 } }, h(0xffff0000), 5 }, + { { { 0, 0, 0, 0 } }, h (0x00000000), 14 } + }; + + +ssize_t +__getline (char **lineptr, size_t *n, FILE *s) +{ + *lineptr = NULL; + *n = 0; + return 0; +} + + +static int +do_test (void) +{ + labels = default_labels; + precedence = default_precedence; + scopes= new_scopes; + + struct sockaddr_in so; + so.sin_family = AF_INET; + so.sin_addr.s_addr = h (0x0aa85f19); + + for (int i = 0; i < naddrs; ++i) + { + ais[i].ai_family = AF_INET; + ais[i].ai_addr = (struct sockaddr *) &addrs[i]; + results[i].dest_addr = &ais[i]; + results[i].got_source_addr = true; + memcpy(&results[i].source_addr, &so, sizeof (so)); + results[i].source_addr_len = sizeof (so); + results[i].source_addr_flags = 0; + results[i].service_order = i; + results[i].prefixlen = 8; + results[i].index = 0; + } + + struct sort_result_combo combo = { .results = results, .nresults = naddrs }; + qsort_r (results, naddrs, sizeof (results[0]), rfc3484_sort, &combo); + + int result = 0; + for (int i = 0; i < naddrs; ++i) + { + struct in_addr addr = ((struct sockaddr_in *) (results[i].dest_addr->ai_addr))->sin_addr; + + int here = memcmp (&addr, &addrs[expected[i]].sin_addr, + sizeof (struct in_addr)); + printf ("[%d] = %s: %s\n", i, inet_ntoa (addr), here ? "FAIL" : "OK"); + result |= here; + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c index 08d57a66ee..fe06255759 100644 --- a/posix/tst-rfc3484.c +++ b/posix/tst-rfc3484.c @@ -18,6 +18,12 @@ __check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen) *in6ai = NULL; *in6ailen = 0; } +void +attribute_hidden +__check_native (uint32_t a1_index, int *a1_native, + uint32_t a2_index, int *a2_native) +{ +} int __idna_to_ascii_lz (const char *input, char **output, int flags) { @@ -79,6 +85,7 @@ do_test (void) { labels = default_labels; precedence = default_precedence; + scopes= default_scopes; struct sockaddr_in so; so.sin_family = AF_INET; @@ -94,9 +101,12 @@ do_test (void) results[i].source_addr_len = sizeof (so); results[i].source_addr_flags = 0; results[i].service_order = i; + results[i].prefixlen = 8; + results[i].index = 0; } - qsort (results, naddrs, sizeof (results[0]), rfc3484_sort); + struct sort_result_combo combo = { .results = results, .nresults = naddrs }; + qsort_r (results, naddrs, sizeof (results[0]), rfc3484_sort, &combo); int result = 0; for (int i = 0; i < naddrs; ++i) diff --git a/posix/unistd.h b/posix/unistd.h index 476c1f3cbc..01ac3f8b41 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -915,13 +915,13 @@ extern char *getpass (__const char *__prompt) __nonnull ((1)); #endif /* Use BSD || X/Open. */ -#if defined __USE_BSD || defined __USE_XOPEN +#if defined __USE_BSD || defined __USE_XOPEN || defined __USE_XOPEN2K /* Make all changes done to FD actually appear on disk. This function is a cancellation point and therefore not marked with __THROW. */ extern int fsync (int __fd); -#endif /* Use BSD || X/Open. */ +#endif /* Use BSD || X/Open || Unix98. */ #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |