diff --git a/glibc-revert-netlink-cache.patch b/glibc-revert-netlink-cache.patch deleted file mode 100644 index d008a0d..0000000 --- a/glibc-revert-netlink-cache.patch +++ /dev/null @@ -1,801 +0,0 @@ -commit 432d41ceecf5df8cfbc5a1db0cee9190f07ec1ca -Author: Ulrich Drepper -Date: Tue Nov 1 08:43:33 2011 -0400 - - Use kernel headers for netlink definitions - -2011-11-01 Ulrich Drepper - - * nscd/connections.c: Use kernel headers instead of . - -diff --git a/nscd/connections.c b/nscd/connections.c -index 1b8a9bd..c741996 100644 ---- a/nscd/connections.c -+++ b/nscd/connections.c -@@ -34,7 +34,8 @@ - #include - #include - #ifdef HAVE_NETLINK --# include -+# include -+# include - #endif - #ifdef HAVE_EPOLL - # include - -commit a501a01e069619676990454abd43c4d2bf4527f4 -Author: Ulrich Drepper -Date: Tue Nov 15 07:18:15 2011 -0500 - - Pretty printing - -diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c -index 895dc2a..0738a70 100644 ---- a/sysdeps/unix/sysv/linux/check_pf.c -+++ b/sysdeps/unix/sysv/linux/check_pf.c -@@ -273,7 +273,7 @@ make_request (int fd, pid_t pid) - } - else - { -- atomic_add(&noai6ai_cached.usecnt, 2); -+ atomic_add (&noai6ai_cached.usecnt, 2); - noai6ai_cached.seen_ipv4 = seen_ipv4; - noai6ai_cached.seen_ipv6 = seen_ipv6; - result = &noai6ai_cached; - - -commit 09f93bd3d6b1c41370432e6b7a3c88d0fc482881 -Author: Andreas Schwab -Date: Tue Nov 15 10:32:18 2011 +0100 - - Fix reference counting in network interface information cache - -2011-11-15 Andreas Schwab - - * sysdeps/unix/sysv/linux/check_pf.c (make_request): Properly - count references to noai6ai_cached. - -diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c -index 1f66684..895dc2a 100644 ---- a/sysdeps/unix/sysv/linux/check_pf.c -+++ b/sysdeps/unix/sysv/linux/check_pf.c -@@ -58,7 +58,7 @@ struct cached_data - - static struct cached_data noai6ai_cached = - { -- .usecnt = 3, /* Make sure we never try to delete this entry. */ -+ .usecnt = 1, /* Make sure we never try to delete this entry. */ - .in6ailen = 0 - }; - -@@ -273,6 +273,7 @@ make_request (int fd, pid_t pid) - } - else - { -+ atomic_add(&noai6ai_cached.usecnt, 2); - noai6ai_cached.seen_ipv4 = seen_ipv4; - noai6ai_cached.seen_ipv6 = seen_ipv6; - result = &noai6ai_cached; - -commit 3a2c02424d9824f5cdea4ebd32ff929b2b1f49c6 -Author: Ulrich Drepper -Date: Mon Oct 31 01:51:16 2011 -0400 - - Cache network interface information - - Whenever getaddrinfo needed network interface information it used the - netlink interface to read the information every single time. The - problem is that this information can change at any time. - - The patch implements monitoring of the network interfaces through - nscd. If no change is detected the previously read information can - be reused (which is the norm). This timestamp information is also - made available to other processes using the shared memory segment - between nscd and those processes. - -2011-10-31 Ulrich Drepper - - * include/ifaddrs.h: Declare __free_in6ai and __bump_nl_timestamp. - * inet/check_pf.c: Provide dummy versions of __free_in6ai and - __bump_nl_timestamp. - * nscd/connections (nscd_init): When host database is served open - netlink socket and request notification about configuration changes. - (main_loop_poll): Track netlink file descriptor and bump timestamp - in case data becomes available. - (main_loop_epoll): Likewise. - * nscd/nscd-client.h (DB_VERSION): Bump to 2. - (database_pers_head): Add extra_data fileds. - Declare __nscd_get_mapping and __nscd_get_nl_timestamp. - * nscd/nscd_gethst_r.c (__nscd_get_nl_timestamp): New function. - * nscd/nscd_helper.c (__nscd_get_mapping): Renamed from get_mapping. - Adjust caller. - * sysdeps/posix/getaddrinfo.c (getaddrinfo): Don't call free on - in6ai data, call __free_in6ai. - * sysdeps/unix/sysv/linux/Makefile [subdir=nscd] (sysdep-CFLAGS): - Add -DHAVE_NETLINK. - * sysdeps/unix/sysv/linux/check_pf.c: Major rewrite. Cache the - interface information. Reuse previous data if netlink timestamp - is not changed. - (__bump_nl_timestamp): New function. - (__free_in6ai): New function. - - * sysdeps/unix/sysv/linux/check_pf.c (make_request): Don't call - -diff --git a/include/ifaddrs.h b/include/ifaddrs.h -index 50e4c48..e1c6cac 100644 ---- a/include/ifaddrs.h -+++ b/include/ifaddrs.h -@@ -21,8 +21,13 @@ struct in6addrinfo - extern void __check_pf (bool *seen_ipv4, bool *seen_ipv6, - struct in6addrinfo **in6ai, size_t *in6ailen) - attribute_hidden; -+extern void __free_in6ai (struct in6addrinfo *in6ai) attribute_hidden; - extern void __check_native (uint32_t a1_index, int *a1_native, - uint32_t a2_index, int *a2_native) - attribute_hidden; - -+#ifdef IS_IN_nscd -+extern uint32_t __bump_nl_timestamp (void) attribute_hidden; -+#endif -+ - #endif /* ifaddrs.h */ -diff --git a/inet/check_pf.c b/inet/check_pf.c -index b015432..0fa34cc 100644 ---- a/inet/check_pf.c -+++ b/inet/check_pf.c -@@ -1,5 +1,5 @@ - /* Determine protocol families for which interfaces exist. Generic version. -- Copyright (C) 2003, 2006 Free Software Foundation, Inc. -+ Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or -@@ -54,3 +54,19 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, - - (void) freeifaddrs (ifa); - } -+ -+ -+void -+__free_in6ai (struct in6addrinfo *in6ai) -+{ -+ /* Nothing to do. */ -+} -+ -+ -+#ifdef IS_IN_nscd -+uint32_t -+__bump_nl_timestamp (void) -+{ -+ return 0; -+} -+#endif -diff --git a/nscd/connections.c b/nscd/connections.c -index 2b5c7ef..1b8a9bd 100644 ---- a/nscd/connections.c -+++ b/nscd/connections.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -32,6 +33,9 @@ - #include - #include - #include -+#ifdef HAVE_NETLINK -+# include -+#endif - #ifdef HAVE_EPOLL - # include - #endif -@@ -247,6 +251,11 @@ static int sock; - int inotify_fd = -1; - #endif - -+#ifdef HAVE_NETLINK -+/* Descriptor for netlink status updates. */ -+static int nl_status_fd = -1; -+#endif -+ - #ifndef __ASSUME_SOCK_CLOEXEC - /* Negative if SOCK_CLOEXEC is not supported, positive if it is, zero - before be know the result. */ -@@ -903,6 +912,65 @@ cannot set socket to close on exec: %s; disabling paranoia mode"), - exit (1); - } - -+#ifdef HAVE_NETLINK -+ if (dbs[hstdb].enabled) -+ { -+ /* Try to open netlink socket to monitor network setting changes. */ -+ nl_status_fd = socket (AF_NETLINK, -+ SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, -+ NETLINK_ROUTE); -+ if (nl_status_fd != -1) -+ { -+ struct sockaddr_nl snl; -+ memset (&snl, '\0', sizeof (snl)); -+ snl.nl_family = AF_NETLINK; -+ /* XXX Is this the best set to use? */ -+ snl.nl_groups = (RTMGRP_IPV4_IFADDR | RTMGRP_TC | RTMGRP_IPV4_MROUTE -+ | RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_RULE -+ | RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_MROUTE -+ | RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFINFO -+ | RTMGRP_IPV6_PREFIX); -+ -+ if (bind (nl_status_fd, (struct sockaddr *) &snl, sizeof (snl)) != 0) -+ { -+ close (nl_status_fd); -+ nl_status_fd = -1; -+ } -+ else -+ { -+ /* Start the timestamp process. */ -+ dbs[hstdb].head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP] -+ = __bump_nl_timestamp (); -+ -+# ifndef __ASSUME_SOCK_CLOEXEC -+ if (have_sock_cloexec < 0) -+ { -+ /* We don't want to get stuck on accept. */ -+ int fl = fcntl (nl_status_fd, F_GETFL); -+ if (fl == -1 -+ || fcntl (nl_status_fd, F_SETFL, fl | O_NONBLOCK) == -1) -+ { -+ dbg_log (_("\ -+cannot change socket to nonblocking mode: %s"), -+ strerror (errno)); -+ exit (1); -+ } -+ -+ /* The descriptor needs to be closed on exec. */ -+ if (paranoia -+ && fcntl (nl_status_fd, F_SETFD, FD_CLOEXEC) == -1) -+ { -+ dbg_log (_("cannot set socket to close on exec: %s"), -+ strerror (errno)); -+ exit (1); -+ } -+ } -+# endif -+ } -+ } -+ } -+#endif -+ - /* Change to unprivileged uid/gid/groups if specified in config file */ - if (server_user != NULL) - finish_drop_privileges (); -@@ -1826,6 +1894,18 @@ main_loop_poll (void) - } - #endif - -+#ifdef HAVE_NETLINK -+ size_t idx_nl_status_fd = 0; -+ if (nl_status_fd != -1) -+ { -+ idx_nl_status_fd = nused; -+ conns[nused].fd = nl_status_fd; -+ conns[nused].events = POLLRDNORM; -+ ++nused; -+ firstfree = nused; -+ } -+#endif -+ - while (1) - { - /* Wait for any event. We wait at most a couple of seconds so -@@ -1968,6 +2048,20 @@ disabled inotify after read error %d"), - } - #endif - -+#ifdef HAVE_NETLINK -+ if (idx_nl_status_fd != 0 && conns[idx_nl_status_fd].revents != 0) -+ { -+ char buf[4096]; -+ /* Read all the data. We do not interpret it here. */ -+ while (TEMP_FAILURE_RETRY (read (nl_status_fd, buf, -+ sizeof (buf))) != -1) -+ ; -+ -+ dbs[hstdb].head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP] -+ = __bump_nl_timestamp (); -+ } -+#endif -+ - for (size_t cnt = first; cnt < nused && n > 0; ++cnt) - if (conns[cnt].revents != 0) - { -@@ -2046,6 +2140,17 @@ main_loop_epoll (int efd) - } - # endif - -+# ifdef HAVE_NETLINK -+ if (nl_status_fd != -1) -+ { -+ ev.events = EPOLLRDNORM; -+ ev.data.fd = nl_status_fd; -+ if (epoll_ctl (efd, EPOLL_CTL_ADD, nl_status_fd, &ev) == -1) -+ /* We cannot use epoll. */ -+ return; -+ } -+# endif -+ - while (1) - { - struct epoll_event revs[100]; -@@ -2162,6 +2267,18 @@ main_loop_epoll (int efd) - } - } - # endif -+# ifdef HAVE_NETLINK -+ else if (revs[cnt].data.fd == nl_status_fd) -+ { -+ char buf[4096]; -+ /* Read all the data. We do not interpret it here. */ -+ while (TEMP_FAILURE_RETRY (read (nl_status_fd, buf, -+ sizeof (buf))) != -1) -+ ; -+ -+ __bump_nl_timestamp (); -+ } -+# endif - else - { - /* Remove the descriptor from the epoll descriptor. */ -@@ -2185,6 +2302,7 @@ main_loop_epoll (int efd) - time_t laststart = now - ACCEPT_TIMEOUT; - assert (starttime[sock] == 0); - assert (inotify_fd == -1 || starttime[inotify_fd] == 0); -+ assert (nl_status_fd == -1 || starttime[nl_status_fd] == 0); - for (int cnt = highest; cnt > STDERR_FILENO; --cnt) - if (starttime[cnt] != 0 && starttime[cnt] < laststart) - { -diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h -index caad26a..b5cd2d2 100644 ---- a/nscd/nscd-client.h -+++ b/nscd/nscd-client.h -@@ -260,12 +260,17 @@ struct hashentry - - - /* Current persistent database version. */ --#define DB_VERSION 1 -+#define DB_VERSION 2 - - /* Maximum time allowed between updates of the timestamp. */ - #define MAPPING_TIMEOUT (5 * 60) - - -+/* Used indices for the EXTRA_DATA element of 'database_pers_head'. -+ Each database has its own indices. */ -+#define NSCD_HST_IDX_CONF_TIMESTAMP 0 -+ -+ - /* Header of persistent database file. */ - struct database_pers_head - { -@@ -274,6 +279,8 @@ struct database_pers_head - volatile int32_t gc_cycle; - volatile int32_t nscd_certainly_running; - volatile nscd_time_t timestamp; -+ /* Room for extensions. */ -+ volatile uint32_t extra_data[4]; - - nscd_ssize_t module; - nscd_ssize_t data_size; -@@ -322,6 +329,12 @@ extern int __nscd_open_socket (const char *key, size_t keylen, - request_type type, void *response, - size_t responselen) attribute_hidden; - -+/* Try to get a file descriptor for the shared meory segment -+ containing the database. */ -+extern struct mapped_database *__nscd_get_mapping (request_type type, -+ const char *key, -+ struct mapped_database **mappedp) attribute_hidden; -+ - /* Get reference of mapping. */ - extern struct mapped_database *__nscd_get_map_ref (request_type type, - const char *name, -@@ -371,4 +384,7 @@ extern ssize_t writeall (int fd, const void *buf, size_t len) - extern ssize_t sendfileall (int tofd, int fromfd, off_t off, size_t len) - attribute_hidden; - -+/* Get netlink timestamp counter from mapped area or zero. */ -+extern uint32_t __nscd_get_nl_timestamp (void); -+ - #endif /* nscd.h */ -diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c -index 70631fa..6ee142d 100644 ---- a/nscd/nscd_gethst_r.c -+++ b/nscd/nscd_gethst_r.c -@@ -1,4 +1,4 @@ --/* Copyright (C) 1998-2005, 2006, 2007, 2008, 2009 -+/* Copyright (C) 1998-2005, 2006, 2007, 2008, 2009, 2011 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1998. -@@ -98,6 +98,27 @@ libc_freeres_fn (hst_map_free) - } - - -+uint32_t -+__nscd_get_nl_timestamp (void) -+{ -+ if (__nss_not_use_nscd_hosts != 0) -+ return 0; -+ -+ struct mapped_database *map = __hst_map_handle.mapped; -+ -+ if (map == NULL -+ || (map != NO_MAPPING -+ && map->head->nscd_certainly_running == 0 -+ && map->head->timestamp + MAPPING_TIMEOUT < time (NULL))) -+ map = __nscd_get_mapping (GETFDHST, "hosts", &__hst_map_handle.mapped); -+ -+ if (map == NO_MAPPING) -+ return 0; -+ -+ return map->head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP]; -+} -+ -+ - int __nss_have_localdomain attribute_hidden; - - static int -diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c -index fe63f9a..365b599 100644 ---- a/nscd/nscd_helper.c -+++ b/nscd/nscd_helper.c -@@ -277,9 +277,9 @@ __nscd_unmap (struct mapped_database *mapped) - - /* Try to get a file descriptor for the shared meory segment - containing the database. */ --static struct mapped_database * --get_mapping (request_type type, const char *key, -- struct mapped_database **mappedp) -+struct mapped_database * -+__nscd_get_mapping (request_type type, const char *key, -+ struct mapped_database **mappedp) - { - struct mapped_database *result = NO_MAPPING; - #ifdef SCM_RIGHTS -@@ -449,8 +449,8 @@ __nscd_get_map_ref (request_type type, const char *name, - || (cur->head->nscd_certainly_running == 0 - && cur->head->timestamp + MAPPING_TIMEOUT < time (NULL)) - || cur->head->data_size > cur->datasize) -- cur = get_mapping (type, name, -- (struct mapped_database **) &mapptr->mapped); -+ cur = __nscd_get_mapping (type, name, -+ (struct mapped_database **) &mapptr->mapped); - - if (__builtin_expect (cur != NO_MAPPING, 1)) - { -diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c -index a5aafe9..216c9cc 100644 ---- a/sysdeps/posix/getaddrinfo.c -+++ b/sysdeps/posix/getaddrinfo.c -@@ -2386,7 +2386,7 @@ getaddrinfo (const char *name, const char *service, - || (hints->ai_family == PF_INET6 && ! seen_ipv6)) - { - /* We cannot possibly return a valid answer. */ -- free (in6ai); -+ __free_in6ai (in6ai); - return EAI_NONAME; - } - } -@@ -2400,7 +2400,7 @@ getaddrinfo (const char *name, const char *service, - { - if (hints->ai_flags & AI_NUMERICSERV) - { -- free (in6ai); -+ __free_in6ai (in6ai); - return EAI_NONAME; - } - -@@ -2422,7 +2422,7 @@ getaddrinfo (const char *name, const char *service, - if (last_i != 0) - { - freeaddrinfo (p); -- free (in6ai); -+ __free_in6ai (in6ai); - - return -(last_i & GAIH_EAI); - } -@@ -2434,7 +2434,7 @@ getaddrinfo (const char *name, const char *service, - } - else - { -- free (in6ai); -+ __free_in6ai (in6ai); - return EAI_FAMILY; - } - -@@ -2622,7 +2622,7 @@ getaddrinfo (const char *name, const char *service, - p->ai_canonname = canonname; - } - -- free (in6ai); -+ __free_in6ai (in6ai); - - if (p) - { -diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile -index af53f70..3032026 100644 ---- a/sysdeps/unix/sysv/linux/Makefile -+++ b/sysdeps/unix/sysv/linux/Makefile -@@ -161,6 +161,6 @@ CFLAGS-mq_receive.c += -fexceptions - endif - - ifeq ($(subdir),nscd) --sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY -+sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY -DHAVE_NETLINK - CFLAGS-gai.c += -DNEED_NETLINK - endif -diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c -index d5ad7ea..1f66684 100644 ---- a/sysdeps/unix/sysv/linux/check_pf.c -+++ b/sysdeps/unix/sysv/linux/check_pf.c -@@ -1,5 +1,5 @@ - /* Determine protocol families for which interfaces exist. Linux version. -- Copyright (C) 2003, 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. -+ Copyright (C) 2003, 2006-2008, 2010, 2011 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or -@@ -33,6 +33,9 @@ - - #include - #include -+#include -+#include -+#include - - - #ifndef IFA_F_HOMEADDRESS -@@ -43,9 +46,42 @@ - #endif - - --static int --make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, -- struct in6addrinfo **in6ai, size_t *in6ailen) -+struct cached_data -+{ -+ uint32_t timestamp; -+ uint32_t usecnt; -+ bool seen_ipv4; -+ bool seen_ipv6; -+ size_t in6ailen; -+ struct in6addrinfo in6ai[0]; -+}; -+ -+static struct cached_data noai6ai_cached = -+ { -+ .usecnt = 3, /* Make sure we never try to delete this entry. */ -+ .in6ailen = 0 -+ }; -+ -+static struct cached_data *cache; -+__libc_lock_define_initialized (static, lock); -+ -+ -+#ifdef IS_IN_nscd -+static uint32_t nl_timestamp; -+ -+uint32_t -+__bump_nl_timestamp (void) -+{ -+ if (atomic_increment_val (&nl_timestamp) == 0) -+ atomic_increment (&nl_timestamp); -+ -+ return nl_timestamp; -+} -+#endif -+ -+ -+static struct cached_data * -+make_request (int fd, pid_t pid) - { - struct req - { -@@ -99,9 +135,6 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, - sizeof (nladdr))) < 0) - goto out_fail; - -- *seen_ipv4 = false; -- *seen_ipv6 = false; -- - bool done = false; - struct in6ailist - { -@@ -109,6 +142,8 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, - struct in6ailist *next; - } *in6ailist = NULL; - size_t in6ailistlen = 0; -+ bool seen_ipv4 = false; -+ bool seen_ipv6 = false; - - do - { -@@ -172,12 +207,12 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, - { - if (*(const in_addr_t *) address - != htonl (INADDR_LOOPBACK)) -- *seen_ipv4 = true; -+ seen_ipv4 = true; - } - else - { - if (!IN6_IS_ADDR_LOOPBACK (address)) -- *seen_ipv6 = true; -+ seen_ipv6 = true; - } - } - -@@ -211,30 +246,46 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, - } - while (! done); - -- if (*seen_ipv6 && in6ailist != NULL) -+ struct cached_data *result; -+ if (seen_ipv6 && in6ailist != NULL) - { -- *in6ai = malloc (in6ailistlen * sizeof (**in6ai)); -- if (*in6ai == NULL) -+ result = malloc (sizeof (*result) -+ + in6ailistlen * sizeof (struct in6addrinfo)); -+ if (result == NULL) - goto out_fail; - -- *in6ailen = in6ailistlen; -+#ifdef IS_IN_nscd -+ result->timestamp = nl_timestamp; -+#else -+ result->timestamp = __nscd_get_nl_timestamp (); -+#endif -+ result->usecnt = 2; -+ result->seen_ipv4 = seen_ipv4; -+ result->seen_ipv6 = true; -+ result->in6ailen = in6ailistlen; - - do - { -- (*in6ai)[--in6ailistlen] = in6ailist->info; -+ result->in6ai[--in6ailistlen] = in6ailist->info; - in6ailist = in6ailist->next; - } - while (in6ailist != NULL); - } -+ else -+ { -+ noai6ai_cached.seen_ipv4 = seen_ipv4; -+ noai6ai_cached.seen_ipv6 = seen_ipv6; -+ result = &noai6ai_cached; -+ } - - if (use_malloc) - free (buf); -- return 0; -+ return result; - - out_fail: - if (use_malloc) - free (buf); -- return -1; -+ return NULL; - } - - -@@ -258,28 +309,65 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, - - if (! __no_netlink_support) - { -- int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ struct cached_data *olddata = NULL; -+ struct cached_data *data = NULL; -+ -+ __libc_lock_lock (lock); - -- if (__builtin_expect (fd >= 0, 1)) -+#ifdef IS_IN_nscd -+# define cache_valid() nl_timestamp != 0 && cache->timestamp == nl_timestamp -+#else -+# define cache_valid() \ -+ ({ uint32_t val = __nscd_get_nl_timestamp (); \ -+ val != 0 && cache->timestamp == val; }) -+#endif -+ if (cache != NULL && cache_valid ()) -+ { -+ data = cache; -+ atomic_increment (&cache->usecnt); -+ } -+ else - { -- struct sockaddr_nl nladdr; -- memset (&nladdr, '\0', sizeof (nladdr)); -- nladdr.nl_family = AF_NETLINK; -+ int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ -+ if (__builtin_expect (fd >= 0, 1)) -+ { -+ struct sockaddr_nl nladdr; -+ memset (&nladdr, '\0', sizeof (nladdr)); -+ nladdr.nl_family = AF_NETLINK; -+ -+ socklen_t addr_len = sizeof (nladdr); -+ -+ if(__bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0 -+ && __getsockname (fd, (struct sockaddr *) &nladdr, -+ &addr_len) == 0) -+ data = make_request (fd, nladdr.nl_pid); -+ -+ close_not_cancel_no_status (fd); -+ } -+ -+ if (data != NULL) -+ { -+ olddata = cache; -+ cache = data; -+ } -+ } - -- socklen_t addr_len = sizeof (nladdr); -+ __libc_lock_unlock (lock); - -- bool success -- = (__bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0 -- && __getsockname (fd, (struct sockaddr *) &nladdr, -- &addr_len) == 0 -- && make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6, -- in6ai, in6ailen) == 0); -+ if (data != NULL) -+ { -+ /* It worked. */ -+ *seen_ipv4 = data->seen_ipv4; -+ *seen_ipv6 = data->seen_ipv6; -+ *in6ailen = data->in6ailen; -+ *in6ai = data->in6ai; - -- close_not_cancel_no_status (fd); -+ if (olddata != NULL && olddata->usecnt > 0 -+ && atomic_add_zero (&olddata->usecnt, -1)) -+ free (olddata); - -- if (success) -- /* It worked. */ -- return; -+ return; - } - - #if __ASSUME_NETLINK_SUPPORT == 0 -@@ -318,3 +406,26 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, - (void) freeifaddrs (ifa); - #endif - } -+ -+ -+void -+__free_in6ai (struct in6addrinfo *ai) -+{ -+ if (ai != NULL) -+ { -+ struct cached_data *data = -+ (struct cached_data *) ((char *) ai -+ - offsetof (struct cached_data, in6ai)); -+ -+ if (atomic_add_zero (&data->usecnt, -1)) -+ { -+ __libc_lock_lock (lock); -+ -+ if (data->usecnt == 0) -+ /* Still unused. */ -+ free (data); -+ -+ __libc_lock_unlock (lock); -+ } -+ } -+} diff --git a/glibc.changes b/glibc.changes index a6dfede..4f0ed0f 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,8 +1,14 @@ +------------------------------------------------------------------- +Tue Apr 17 08:29:21 UTC 2012 - aj@suse.de + +- Build for power4 only, don't support power3 anymore. +- Add option to build glibc a bit more quickly for testing purposes. +- Remove disabled patch glibc-revert-netlink-cache.patch. +- Start renumbering patches. + ------------------------------------------------------------------- Mon Apr 16 14:31:38 UTC 2012 - aj@suse.de -- The dynamic linker for armv7 hardware float is called - /lib/ld-linux-armhf.so.3. Provide compatibility symlink. - Do not build locales and profile for i686 since we only ship the base and glibc-devel packages. diff --git a/glibc.spec b/glibc.spec index 3e25917..21fd5b9 100644 --- a/glibc.spec +++ b/glibc.spec @@ -16,7 +16,12 @@ # +# The full testsuite is only run with osc --with=glibc_run_testsuite %bcond_with glibc_run_testsuite +# Run with osc --with=fast_build to have a shorter turnaround +# It will avoid building some parts of glibc and will not run the +# testsuite +%bcond_with fast_build %define crypt_bf_version 1.2 @@ -36,30 +41,41 @@ BuildRequires: libstdc++-devel %define build_locales 0 %define build_html 0 %else +%if %{with fast_build} +%define build_profile 0 +%define build_locales 0 +%define build_html 0 +%else +# Default: %define build_profile 1 %define build_locales 1 %define build_html 1 %endif +%endif # Enable testsuite runs for local builds +%if %{with fast_build} +%define run_testsuite 0 +%else %if %{with glibc_run_testsuite} %define run_testsuite 1 %else %define run_testsuite 0 %endif +%endif + %define disable_assert 0 %define enable_stackguard_randomization 1 %ifarch ppc ppc64 %define optimize_power 1 %ifarch ppc - %define powerpc_optimize_base power3 - %define powerpc_optimize_tune power3 - %define powerpc_optimize_cpu_power4 1 + %define powerpc_optimize_base power4 + %define powerpc_optimize_tune power4 %else %define powerpc_optimize_base power4 %define powerpc_optimize_tune power5 - %define powerpc_optimize_cpu_power4 0 %endif # We are not building Power CPU specific optimizations for openSUSE. + %define powerpc_optimize_cpu_power4 0 %define powerpc_optimize_cpu_power6 0 %define powerpc_optimize_cpu_power7 0 %define powerpc_optimize_cpu_cell 0 @@ -128,6 +144,17 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build NoSource: 0 %endif # + +### +# Patches are ordered as: +# Patches that we will never upstream or which have not been looked at: 0000-0999 +# Patches taken from upstream: 1000-2000 +# Patches that are going upstream, waiting approval: 2000-3000 +### + +### +# Patches that upstream will not accept +### # PATCH-FIX-OPENSUSE remove lfs test from testsuite aj@suse.de Patch0: glibc-testsuite.patch # PATCH-FIX-OPENSUSE handle glibc binaries @@ -166,14 +193,12 @@ Patch28: glibc-2.2-sunrpc.diff Patch29: glibc-2.8-getconf.diff # PATCH-FIX-OPENSUSE only use ipv6 if real ipv6 address exists bnc#361697, bnc#684534 Patch30: getaddrinfo-ipv6-sanity.diff -# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines +# PATCH-FIX-OPENSUSE add option --enable-runbinaries to disable running of compiled binaries Patch33: glibc-compiled-binaries.diff # PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines Patch36: glibc-no-unwind-tables.diff # PATCH-FEATURE-SLE increase cpusetsize to 4096, needs to be kept for compatibility kukuk@suse.de Patch38: glibc-cpusetsize.diff -# PATCH-FIX-OPENSUSE - Allow compilation with -altivec aj@suse.de -Patch41: glibc-uio-cell.diff # PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines Patch45: glibc-gai-private4.diff # PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines @@ -198,12 +223,8 @@ Patch68: glibc-fix-lookup-crash.patch Patch69: glibc-fix-noload.patch # PATCH-FIX-OPENSUSE Do not trigger an abort when an i586 Intel CPU is running the i686 library, as valgrind does. bnc#681398 aj@suse.de Patch71: x86-cpuid-level2.patch -# PATCH-FIX-UPSTREAM Fix assertion error in res_query.c (bso#13013) -Patch73: glibc-resolv-assert.diff # PATCH-FIX-OPENSUSE Run ctors (bnc#717671) aj@suse.de Patch74: glibc-2.14-fix-ctors.patch -# PATCH-FIX-OPENSUSE Fix missing declarations -Patch75: glibc-2.15-nss_db-declarations.patch # PATCH-FEATURE-OPENSUSE -- add sha support to crypt_blowfish lnussel@suse.de Patch80: crypt_blowfish-1.2-sha.diff # PATCH-FEATURE-OPENSUSE -- use separate symbol version for Owl extensions - lnussel@suse.de @@ -216,36 +237,48 @@ Patch84: nscd-avoid-gcc-warning.diff Patch87: glibc-nodate.patch # PATCH-FIX-OPENSUSE revert pthread-cond-wait change since it causes hangs - aj@suse.de Patch88: pthread-cond-wait-revert.patch -# PATCH-FIX-UPSTREAM Fix realloc usage in vfscanf - aj@suse.de -Patch89: glibc-2.16-scanf.patch -# PATCH-FIX-UPSTREAM Fix getcontext on 32-bit powerpc - aj@suse.de -Patch90: glibc-ppc-getcontext.patch -# PATCH-FIX-UPSTREAM Fix ifunc relocations (bnc#740109) - aj@suse.de -Patch91: glibc-ifunc-2.16.patch -# PATCH-FIX-OPENSUSE Remove netlink optimization (bnc#741021) - aj@suse.de -Patch92: glibc-revert-netlink-cache.patch -# PATCH-FIX-UPSTREAM Fix tests for AVX features - aj@suse.de -Patch93: glibc-2.16-avx.patch -# PATCH-FIX-UPSTREAM vfprintf: validate nargs and maybe allocate from heap bnc#747768 - aj@suse.de -Patch94: vfprintf-nargs.patch # PATCH-FIX-OPENSUSE Fix cycle detection - aj@suse.de Patch95: cycle-detection.patch # PATCH-FIX-OPENSUSE Fix LD_PROFILE (glibc bug#13818) - aj@suse.de Patch96: glibc-ld-profile.patch # PATCH-FIX-OPENSUSE Fix path for nss_db (bnc#753657) - aj@suse.de Patch97: nss-db-path.patch -# PATCH-FIX-OPENSUSE Fix crash when nscd is not running (bso#135949) - aj@suse.de -Patch98: glibc-nscd-crash-bso13594.patch -# PATCH-FIX-UPSTREAM Add Arm dependency on libmemusage - bwiedemann@suse.de -Patch99: glibc-add-arm-dependency-libmemusage.patch -# PATCH-FIX-OPENSUSE Fix cycle detection (from Fedora) - aj@suse.de +# PATCH-FIX-OPENSUSE Fix cycle detection 2 (from Fedora) - aj@suse.de Patch100: glibc-sw13618-2.patch + +### +# Patches from upstream +### +# PATCH-FIX-UPSTREAM Fix missing declarations +Patch1000: glibc-2.15-nss_db-declarations.patch +# PATCH-FIX-UPSTREAM Fix realloc usage in vfscanf - aj@suse.de +Patch1001: glibc-2.16-scanf.patch +# PATCH-FIX-UPSTREAM Fix getcontext on 32-bit powerpc - aj@suse.de +Patch1002: glibc-ppc-getcontext.patch +# PATCH-FIX-UPSTREAM Fix ifunc relocations (bnc#740109) - aj@suse.de +Patch1003: glibc-ifunc-2.16.patch +# PATCH-FIX-UPSTREAM Fix tests for AVX features - aj@suse.de +Patch1004: glibc-2.16-avx.patch +# PATCH-FIX-UPSTREAM vfprintf: validate nargs and maybe allocate from heap bnc#747768 - aj@suse.de +Patch1005: vfprintf-nargs.patch +# PATCH-FIX-UPSTREAM Add Arm dependency on libmemusage - bwiedemann@suse.de +Patch1006: glibc-add-arm-dependency-libmemusage.patch # PATCH-FIX-UPSTREAM Fix check abi - aj@suse.de -Patch101: glibc-2.16-fix-check-abi.patch +Patch1007: glibc-2.16-fix-check-abi.patch # PATCH-FIX-UPSTREAM Fix check-localelfplt - aj@suse.de -Patch102: glibc-2.16-fix-check-localplt.patch -# PATCH-FIX-OPENSUSE Use new common path for ARMv7 hardware float linker - aj@suse.de -Patch103: armhf-ld-so.patch +Patch1008: glibc-2.16-fix-check-localplt.patch +# PATCH-FIX-UPSTREAM - Allow compilation with -altivec aj@suse.de +Patch1009: glibc-uio-cell.diff + +### +# Patches awaiting upstream approval +### +# PATCH-FIX-UPSTREAM Fix assertion error in res_query.c (bso#13013) +Patch2001: glibc-resolv-assert.diff +# PATCH-FIX-UPSTREAM Use new common path for ARMv7 hardware float linker - aj@suse.de +Patch2002: armhf-ld-so.patch +# PATCH-FIX-UPSTREAM Fix crash when nscd is not running (bso#135949) - aj@suse.de +Patch2003: glibc-nscd-crash-bso13594.patch %description The GNU C Library provides the most important standard libraries used @@ -462,7 +495,7 @@ rm nscd/s-stamp %patch33 -p1 %patch36 -p1 %patch38 -%patch41 -p1 +%patch1009 -p1 %patch45 %patch46 -p1 %patch47 -p1 @@ -477,30 +510,29 @@ rm nscd/s-stamp #%patch68 -p1 %patch69 -p1 %patch71 -p1 -%patch73 -p1 +%patch2001 -p1 %patch74 -p1 -%patch75 -p1 +%patch1000 -p1 %patch84 -p1 %patch87 -p1 %patch88 -p1 -R -%patch89 -p1 -%patch90 -p1 -%patch91 -p1 -# XXX Should be fixed properly now, remove soon -#%patch92 -p1 -R -%patch93 -p1 -%patch94 -p1 +%patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch1005 -p1 %patch95 -p1 # XXX Disable, it breaks the testsuite, test elf/tst-audit2 # %patch96 -p1 %patch97 -p1 -%patch98 -p1 -%patch99 -p1 +%patch2003 -p1 +%patch1006 -p1 %patch100 -p1 -%patch101 -p1 -%patch102 -p1 +%patch1007 -p1 +%patch1008 -p1 %ifarch armv7l -%patch103 -p1 +# Disable for now +#%patch2002 -p1 %endif # @@ -757,9 +789,11 @@ export SUSE_ASNEEDED=0 %endif # File was not created as empty file by patch 101 touch abilist/libnss_dns.abilist abilist/libnss_db.abilist -# This has to pass. Exceptions: -# ARM: There's no check-abi data for arm -%ifnarch %arm +# This has to pass on x86 and x86-64 +# Exceptions: +# ARM: There's no check-abi data for arm at all +# s390, s390x, ppc, ppc64: Outdated check-abi data +%ifnarch %arm s390 s390x ppc ppc64 make -C cc-base check-abi #%else #make -C cc-base check-abi || echo check-abi failed @@ -964,7 +998,7 @@ install -m 644 %{SOURCE22} %{buildroot}/lib/systemd/system %ifarch armv7l # Provide compatibility link -ln -s ld-%{version}.so %{buildroot}/lib/ld-linux.so.3 +# XXX ln -s ld-%{version}.so %{buildroot}/lib/ld-linux.so.3 %endif ####################################################################### @@ -1043,13 +1077,13 @@ exit 0 # Each architecture has a different name for the dynamic linker: %ifarch %arm %ifarch armv7l -/%{_lib}/ld-linux-armhf.so.3 +#XXX /%{_lib}/ld-linux-armhf.so.3 # Keep compatibility link /%{_lib}/ld-linux.so.3 -%endif %else /%{_lib}/ld-linux.so.2 %endif +%endif %ifarch ia64 /%{_lib}/ld-linux-ia64.so.2 %endif