summaryrefslogtreecommitdiff
path: root/cross/cross-mips64el-unknown-linux-gnu-glibc-headers/glibc-2.15-revert-netlink-cache.patch
blob: 87d04c7942fca82e2857079915196b87d45390c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
diff --git a/include/ifaddrs.h b/include/ifaddrs.h
index e1c6cac..50e4c48 100644
--- a/include/ifaddrs.h
+++ b/include/ifaddrs.h
@@ -21,13 +21,8 @@ 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 0fa34cc..b015432 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, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 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,19 +54,3 @@ __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 c741996..2b5c7ef 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -24,7 +24,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <grp.h>
-#include <ifaddrs.h>
 #include <libintl.h>
 #include <pthread.h>
 #include <pwd.h>
@@ -33,10 +32,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <arpa/inet.h>
-#ifdef HAVE_NETLINK
-# include <linux/netlink.h>
-# include <linux/rtnetlink.h>
-#endif
 #ifdef HAVE_EPOLL
 # include <sys/epoll.h>
 #endif
@@ -252,11 +247,6 @@ 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.  */
@@ -913,65 +903,6 @@ 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 ();
@@ -1895,18 +1826,6 @@ 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
@@ -2049,20 +1968,6 @@ 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)
 	      {
@@ -2141,17 +2046,6 @@ 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];
@@ -2268,18 +2162,6 @@ 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.  */
@@ -2303,7 +2185,6 @@ 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 b5cd2d2..caad26a 100644
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -260,17 +260,12 @@ struct hashentry
 
 
 /* Current persistent database version.  */
-#define DB_VERSION	2
+#define DB_VERSION	1
 
 /* 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
 {
@@ -279,8 +274,6 @@ 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;
@@ -329,12 +322,6 @@ 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,
@@ -384,7 +371,4 @@ 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 6ee142d..70631fa 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, 2011
+/* Copyright (C) 1998-2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -98,27 +98,6 @@ 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 365b599..fe63f9a 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.  */
-struct mapped_database *
-__nscd_get_mapping (request_type type, const char *key,
-		    struct mapped_database **mappedp)
+static struct mapped_database *
+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 = __nscd_get_mapping (type, name,
-				  (struct mapped_database **) &mapptr->mapped);
+	cur = 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 1a023f9..4979805 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 (in6ai);
+	  free (in6ai);
 	  return EAI_NONAME;
 	}
     }
@@ -2400,7 +2400,7 @@ getaddrinfo (const char *name, const char *service,
 	{
 	  if (hints->ai_flags & AI_NUMERICSERV)
 	    {
-	      __free_in6ai (in6ai);
+	      free (in6ai);
 	      return EAI_NONAME;
 	    }
 
@@ -2422,7 +2422,7 @@ getaddrinfo (const char *name, const char *service,
       if (last_i != 0)
 	{
 	  freeaddrinfo (p);
-	  __free_in6ai (in6ai);
+	  free (in6ai);
 
 	  return -(last_i & GAIH_EAI);
 	}
@@ -2434,7 +2434,7 @@ getaddrinfo (const char *name, const char *service,
     }
   else
     {
-      __free_in6ai (in6ai);
+      free (in6ai);
       return EAI_FAMILY;
     }
 
@@ -2622,7 +2622,7 @@ getaddrinfo (const char *name, const char *service,
       p->ai_canonname = canonname;
     }
 
-  __free_in6ai (in6ai);
+  free (in6ai);
 
   if (p)
     {
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index e684b16..c907af4 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -173,6 +173,6 @@ CFLAGS-mq_receive.c += -fexceptions
 endif
 
 ifeq ($(subdir),nscd)
-sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY -DHAVE_NETLINK
+sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY
 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 0738a70..d5ad7ea 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-2008, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006, 2007, 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,9 +33,6 @@
 
 #include <not-cancel.h>
 #include <kernel-features.h>
-#include <bits/libc-lock.h>
-#include <atomic.h>
-#include <nscd/nscd-client.h>
 
 
 #ifndef IFA_F_HOMEADDRESS
@@ -46,42 +43,9 @@
 #endif
 
 
-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 = 1,	/* 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)
+static int
+make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
+	      struct in6addrinfo **in6ai, size_t *in6ailen)
 {
   struct req
   {
@@ -135,6 +99,9 @@ make_request (int fd, pid_t pid)
 				    sizeof (nladdr))) < 0)
     goto out_fail;
 
+  *seen_ipv4 = false;
+  *seen_ipv6 = false;
+
   bool done = false;
   struct in6ailist
   {
@@ -142,8 +109,6 @@ make_request (int fd, pid_t pid)
     struct in6ailist *next;
   } *in6ailist = NULL;
   size_t in6ailistlen = 0;
-  bool seen_ipv4 = false;
-  bool seen_ipv6 = false;
 
   do
     {
@@ -207,12 +172,12 @@ make_request (int fd, pid_t pid)
 		    {
 		      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;
 		    }
 		}
 
@@ -246,47 +211,30 @@ make_request (int fd, pid_t pid)
     }
   while (! done);
 
-  struct cached_data *result;
-  if (seen_ipv6 && in6ailist != NULL)
+  if (*seen_ipv6 && in6ailist != NULL)
     {
-      result = malloc (sizeof (*result)
-		       + in6ailistlen * sizeof (struct in6addrinfo));
-      if (result == NULL)
+      *in6ai = malloc (in6ailistlen * sizeof (**in6ai));
+      if (*in6ai == NULL)
 	goto out_fail;
 
-#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;
+      *in6ailen = in6ailistlen;
 
       do
 	{
-	  result->in6ai[--in6ailistlen] = in6ailist->info;
+	  (*in6ai)[--in6ailistlen] = in6ailist->info;
 	  in6ailist = in6ailist->next;
 	}
       while (in6ailist != NULL);
     }
-  else
-    {
-      atomic_add (&noai6ai_cached.usecnt, 2);
-      noai6ai_cached.seen_ipv4 = seen_ipv4;
-      noai6ai_cached.seen_ipv6 = seen_ipv6;
-      result = &noai6ai_cached;
-    }
 
   if (use_malloc)
     free (buf);
-  return result;
+  return 0;
 
 out_fail:
   if (use_malloc)
     free (buf);
-  return NULL;
+  return -1;
 }
 
 
@@ -310,65 +258,28 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
 
   if (! __no_netlink_support)
     {
-      struct cached_data *olddata = NULL;
-      struct cached_data *data = NULL;
+      int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
 
-      __libc_lock_lock (lock);
-
-#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
+      if (__builtin_expect (fd >= 0, 1))
 	{
-	  int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+	  struct sockaddr_nl nladdr;
+	  memset (&nladdr, '\0', sizeof (nladdr));
+	  nladdr.nl_family = AF_NETLINK;
 
-	  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;
-
-	  if (olddata != NULL && olddata->usecnt > 0
-	      && atomic_add_zero (&olddata->usecnt, -1))
-	    free (olddata);
+	  close_not_cancel_no_status (fd);
 
-	  return;
+	  if (success)
+	    /* It worked.  */
+	    return;
 	}
 
 #if __ASSUME_NETLINK_SUPPORT == 0
@@ -407,26 +318,3 @@ __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);
-	}
-    }
-}