arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1331283.patch

147e83
commit 6c82a2f8d7c8e21e39237225c819f182ae438db3
147e83
Author: Carlos O'Donell <carlos@redhat.com>
147e83
Date:   Fri Sep 6 01:02:30 2013 -0400
147e83
147e83
    Coordinate IPv6 definitions for Linux and glibc
147e83
    
147e83
    This change synchronizes the glibc headers with the Linux kernel
147e83
    headers and arranges to coordinate the definition of structures
147e83
    already defined the Linux kernel UAPI headers.
147e83
    
147e83
    It is now safe to include glibc's netinet/in.h or Linux's linux/in6.h
147e83
    in any order in a userspace application and you will get the same
147e83
    ABI. The ABI is guaranteed by UAPI and glibc.
147e83
147e83
diff --git a/inet/netinet/in.h b/inet/netinet/in.h
147e83
index 89e3813..05c77e2 100644
147e83
--- a/inet/netinet/in.h
147e83
+++ b/inet/netinet/in.h
147e83
@@ -26,13 +26,21 @@
147e83
 
147e83
 __BEGIN_DECLS
147e83
 
147e83
+/* Internet address.  */
147e83
+typedef uint32_t in_addr_t;
147e83
+struct in_addr
147e83
+  {
147e83
+    in_addr_t s_addr;
147e83
+  };
147e83
+
147e83
+/* Get system-specific definitions.  */
147e83
+#include <bits/in.h>
147e83
+
147e83
 /* Standard well-defined IP protocols.  */
147e83
 enum
147e83
   {
147e83
     IPPROTO_IP = 0,	   /* Dummy protocol for TCP.  */
147e83
 #define IPPROTO_IP		IPPROTO_IP
147e83
-    IPPROTO_HOPOPTS = 0,   /* IPv6 Hop-by-Hop options.  */
147e83
-#define IPPROTO_HOPOPTS		IPPROTO_HOPOPTS
147e83
     IPPROTO_ICMP = 1,	   /* Internet Control Message Protocol.  */
147e83
 #define IPPROTO_ICMP		IPPROTO_ICMP
147e83
     IPPROTO_IGMP = 2,	   /* Internet Group Management Protocol. */
147e83
@@ -55,10 +63,6 @@ enum
147e83
 #define IPPROTO_DCCP		IPPROTO_DCCP
147e83
     IPPROTO_IPV6 = 41,     /* IPv6 header.  */
147e83
 #define IPPROTO_IPV6		IPPROTO_IPV6
147e83
-    IPPROTO_ROUTING = 43,  /* IPv6 routing header.  */
147e83
-#define IPPROTO_ROUTING		IPPROTO_ROUTING
147e83
-    IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header.  */
147e83
-#define IPPROTO_FRAGMENT	IPPROTO_FRAGMENT
147e83
     IPPROTO_RSVP = 46,	   /* Reservation Protocol.  */
147e83
 #define IPPROTO_RSVP		IPPROTO_RSVP
147e83
     IPPROTO_GRE = 47,	   /* General Routing Encapsulation.  */
147e83
@@ -67,14 +71,10 @@ enum
147e83
 #define IPPROTO_ESP		IPPROTO_ESP
147e83
     IPPROTO_AH = 51,       /* authentication header.  */
147e83
 #define IPPROTO_AH		IPPROTO_AH
147e83
-    IPPROTO_ICMPV6 = 58,   /* ICMPv6.  */
147e83
-#define IPPROTO_ICMPV6		IPPROTO_ICMPV6
147e83
-    IPPROTO_NONE = 59,     /* IPv6 no next header.  */
147e83
-#define IPPROTO_NONE		IPPROTO_NONE
147e83
-    IPPROTO_DSTOPTS = 60,  /* IPv6 destination options.  */
147e83
-#define IPPROTO_DSTOPTS		IPPROTO_DSTOPTS
147e83
     IPPROTO_MTP = 92,	   /* Multicast Transport Protocol.  */
147e83
 #define IPPROTO_MTP		IPPROTO_MTP
147e83
+    IPPROTO_BEETPH = 94,   /* IP option pseudo header for BEET.  */
147e83
+#define IPPROTO_BEETPH		IPPROTO_BEETPH
147e83
     IPPROTO_ENCAP = 98,	   /* Encapsulation Header.  */
147e83
 #define IPPROTO_ENCAP		IPPROTO_ENCAP
147e83
     IPPROTO_PIM = 103,	   /* Protocol Independent Multicast.  */
147e83
@@ -90,6 +90,28 @@ enum
147e83
     IPPROTO_MAX
147e83
   };
147e83
 
147e83
+/* If __USER_KERNEL_IPV6_DEFS is defined then the user has included the kernel
147e83
+   network headers first and we should use those ABI-identical definitions
147e83
+   instead of our own.  */
147e83
+#ifndef __USE_KERNEL_IPV6_DEFS
147e83
+enum
147e83
+  {
147e83
+    IPPROTO_HOPOPTS = 0,   /* IPv6 Hop-by-Hop options.  */
147e83
+#define IPPROTO_HOPOPTS		IPPROTO_HOPOPTS
147e83
+    IPPROTO_ROUTING = 43,  /* IPv6 routing header.  */
147e83
+#define IPPROTO_ROUTING		IPPROTO_ROUTING
147e83
+    IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header.  */
147e83
+#define IPPROTO_FRAGMENT	IPPROTO_FRAGMENT
147e83
+    IPPROTO_ICMPV6 = 58,   /* ICMPv6.  */
147e83
+#define IPPROTO_ICMPV6		IPPROTO_ICMPV6
147e83
+    IPPROTO_NONE = 59,     /* IPv6 no next header.  */
147e83
+#define IPPROTO_NONE		IPPROTO_NONE
147e83
+    IPPROTO_DSTOPTS = 60,  /* IPv6 destination options.  */
147e83
+#define IPPROTO_DSTOPTS		IPPROTO_DSTOPTS
147e83
+    IPPROTO_MH = 135,      /* IPv6 mobility header.  */
147e83
+#define IPPROTO_MH		IPPROTO_MH
147e83
+  };
147e83
+#endif /* !__USE_KERNEL_IPV6_DEFS */
147e83
 
147e83
 /* Type to represent a port.  */
147e83
 typedef uint16_t in_port_t;
147e83
@@ -134,15 +156,6 @@ enum
147e83
     IPPORT_USERRESERVED = 5000
147e83
   };
147e83
 
147e83
-
147e83
-/* Internet address.  */
147e83
-typedef uint32_t in_addr_t;
147e83
-struct in_addr
147e83
-  {
147e83
-    in_addr_t s_addr;
147e83
-  };
147e83
-
147e83
-
147e83
 /* Definitions of the bits in an Internet address integer.
147e83
 
147e83
    On subnets, host and network parts are found according to
147e83
@@ -191,7 +204,7 @@ struct in_addr
147e83
 #define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
147e83
 #define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
147e83
 
147e83
-
147e83
+#ifndef __USE_KERNEL_IPV6_DEFS
147e83
 /* IPv6 address */
147e83
 struct in6_addr
147e83
   {
147e83
@@ -209,6 +222,7 @@ struct in6_addr
147e83
 # define s6_addr32		__in6_u.__u6_addr32
147e83
 #endif
147e83
   };
147e83
+#endif /* !__USE_KERNEL_IPV6_DEFS */
147e83
 
147e83
 extern const struct in6_addr in6addr_any;        /* :: */
147e83
 extern const struct in6_addr in6addr_loopback;   /* ::1 */
147e83
@@ -233,6 +247,7 @@ struct sockaddr_in
147e83
 			   sizeof (struct in_addr)];
147e83
   };
147e83
 
147e83
+#ifndef __USE_KERNEL_IPV6_DEFS
147e83
 /* Ditto, for IPv6.  */
147e83
 struct sockaddr_in6
147e83
   {
147e83
@@ -242,7 +257,7 @@ struct sockaddr_in6
147e83
     struct in6_addr sin6_addr;	/* IPv6 address */
147e83
     uint32_t sin6_scope_id;	/* IPv6 scope-id */
147e83
   };
147e83
-
147e83
+#endif /* !__USE_KERNEL_IPV6_DEFS */
147e83
 
147e83
 #if defined __USE_MISC || defined __USE_GNU
147e83
 /* IPv4 multicast request.  */
147e83
@@ -268,7 +283,7 @@ struct ip_mreq_source
147e83
   };
147e83
 #endif
147e83
 
147e83
-
147e83
+#ifndef __USE_KERNEL_IPV6_DEFS
147e83
 /* Likewise, for IPv6.  */
147e83
 struct ipv6_mreq
147e83
   {
147e83
@@ -278,7 +293,7 @@ struct ipv6_mreq
147e83
     /* local interface */
147e83
     unsigned int ipv6mr_interface;
147e83
   };
147e83
-
147e83
+#endif /* !__USE_KERNEL_IPV6_DEFS */
147e83
 
147e83
 #if defined __USE_MISC || defined __USE_GNU
147e83
 /* Multicast group request.  */
147e83
@@ -349,10 +364,6 @@ struct group_filter
147e83
 				      * sizeof (struct sockaddr_storage)))
147e83
 #endif
147e83
 
147e83
-
147e83
-/* Get system-specific definitions.  */
147e83
-#include <bits/in.h>
147e83
-
147e83
 /* Functions to convert between host and network byte order.
147e83
 
147e83
    Please note that these functions normally take `unsigned long int' or
147e83
diff --git a/sysdeps/unix/sysv/linux/bits/in.h b/sysdeps/unix/sysv/linux/bits/in.h
147e83
index e959b33..d763ce9 100644
147e83
--- a/sysdeps/unix/sysv/linux/bits/in.h
147e83
+++ b/sysdeps/unix/sysv/linux/bits/in.h
147e83
@@ -21,6 +21,18 @@
147e83
 # error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
147e83
 #endif
147e83
 
147e83
+/* If the application has already included linux/in6.h from a linux-based
147e83
+   kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the
147e83
+   defines), sockaddr_in6, or ipv6_mreq.  The ABI used by the linux-kernel and
147e83
+   glibc match exactly.  Neither the linux kernel nor glibc should break this
147e83
+   ABI without coordination.  */
147e83
+#ifdef _UAPI_LINUX_IN6_H
147e83
+/* This is not quite the same API since the kernel always defines s6_addr16 and
147e83
+   s6_addr32. This is not a violation of POSIX since POSIX says "at least the
147e83
+   following member" and that holds true.  */
147e83
+# define __USE_KERNEL_IPV6_DEFS
147e83
+#endif
147e83
+
147e83
 /* Options for use with `getsockopt' and `setsockopt' at the IP level.
147e83
    The first word in the comment at the right is the data type used;
147e83
    "bool" means a boolean value stored in an `int'.  */