about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/check_pf.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-07-25 21:19:13 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-07-25 21:19:13 +0000
commit89b4b02f421d2a6d24eb632d9c6977dbe786e6ee (patch)
treecfb4d8f06f24847cb5214a0bb2bc476085415706 /sysdeps/unix/sysv/linux/check_pf.c
parent842a39cd1ad9391af7a63a19c87f66a730e027a9 (diff)
downloadglibc-89b4b02f421d2a6d24eb632d9c6977dbe786e6ee.tar.gz
glibc-89b4b02f421d2a6d24eb632d9c6977dbe786e6ee.tar.xz
glibc-89b4b02f421d2a6d24eb632d9c6977dbe786e6ee.zip
Remove pre-2.4.21 Linux kernel support.
Diffstat (limited to 'sysdeps/unix/sysv/linux/check_pf.c')
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c127
1 files changed, 42 insertions, 85 deletions
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 793d27db4e..950498acd4 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-2012 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
@@ -289,16 +289,6 @@ out_fail:
 }
 
 
-/* We don't know if we have NETLINK support compiled into our
-   Kernel.  */
-#if __ASSUME_NETLINK_SUPPORT == 0
-/* Define in ifaddrs.h.  */
-extern int __no_netlink_support attribute_hidden;
-#else
-# define __no_netlink_support 0
-#endif
-
-
 void
 attribute_hidden
 __check_pf (bool *seen_ipv4, bool *seen_ipv6,
@@ -307,12 +297,10 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
   *in6ai = NULL;
   *in6ailen = 0;
 
-  if (! __no_netlink_support)
-    {
-      struct cached_data *olddata = NULL;
-      struct cached_data *data = NULL;
+  struct cached_data *olddata = NULL;
+  struct cached_data *data = NULL;
 
-      __libc_lock_lock (lock);
+  __libc_lock_lock (lock);
 
 #ifdef IS_IN_nscd
 # define cache_valid() nl_timestamp != 0 && cache->timestamp == nl_timestamp
@@ -321,90 +309,59 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
       ({ 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
-	{
-	  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;
+  if (cache != NULL && cache_valid ())
+    {
+      data = cache;
+      atomic_increment (&cache->usecnt);
+    }
+  else
+    {
+      int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
 
-	      socklen_t addr_len = sizeof (nladdr);
+      if (__builtin_expect (fd >= 0, 1))
+	{
+	  struct sockaddr_nl nladdr;
+	  memset (&nladdr, '\0', sizeof (nladdr));
+	  nladdr.nl_family = AF_NETLINK;
 
-	      if(__bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
-		 && __getsockname (fd, (struct sockaddr *) &nladdr,
-				   &addr_len) == 0)
-		data = make_request (fd, nladdr.nl_pid);
+	  socklen_t addr_len = sizeof (nladdr);
 
-	      close_not_cancel_no_status (fd);
-	    }
+	  if (__bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
+	      && __getsockname (fd, (struct sockaddr *) &nladdr,
+				&addr_len) == 0)
+	    data = make_request (fd, nladdr.nl_pid);
 
-	  if (data != NULL)
-	    {
-	      olddata = cache;
-	      cache = data;
-	    }
+	  close_not_cancel_no_status (fd);
 	}
 
-      __libc_lock_unlock (lock);
-
       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);
-
-	  return;
+	  olddata = cache;
+	  cache = data;
 	}
-
-#if __ASSUME_NETLINK_SUPPORT == 0
-      /* Remember that there is no netlink support.  */
-      __no_netlink_support = 1;
-#else
-      /* We cannot determine what interfaces are available.  Be
-	 pessimistic.  */
-      *seen_ipv4 = true;
-      *seen_ipv6 = true;
-#endif
     }
 
-#if __ASSUME_NETLINK_SUPPORT == 0
-  /* No netlink.  Get the interface list via getifaddrs.  */
-  struct ifaddrs *ifa = NULL;
-  if (getifaddrs (&ifa) != 0)
+  __libc_lock_unlock (lock);
+
+  if (data != NULL)
     {
-      /* We cannot determine what interfaces are available.  Be
-	 pessimistic.  */
-      *seen_ipv4 = true;
-      *seen_ipv6 = true;
+      /* 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);
+
       return;
     }
 
-  struct ifaddrs *runp;
-  for (runp = ifa; runp != NULL; runp = runp->ifa_next)
-    if (runp->ifa_addr != NULL)
-      {
-	if (runp->ifa_addr->sa_family == PF_INET)
-	  *seen_ipv4 = true;
-	else if (runp->ifa_addr->sa_family == PF_INET6)
-	  *seen_ipv6 = true;
-      }
-
-  (void) freeifaddrs (ifa);
-#endif
+  /* We cannot determine what interfaces are available.  Be
+     pessimistic.  */
+  *seen_ipv4 = true;
+  *seen_ipv6 = true;
 }