libubox: fix mirror hash
[openwrt/openwrt.git] / target / linux / generic / pending-3.18 / 095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
1 From 279c6c7fa64f5763e6b9f05e7ab3840092e702e7 Mon Sep 17 00:00:00 2001
2 From: Stephen Hemminger <stephen@networkplumber.org>
3 Date: Mon, 29 Jun 2015 14:57:48 -1000
4 Subject: [PATCH] api: fix compatibility of linux/in.h with netinet/in.h
5
6 u
7 This fixes breakage to iproute2 build with recent kernel headers
8 caused by:
9 commit a263653ed798216c0069922d7b5237ca49436007
10 Author: Pablo Neira Ayuso <pablo@netfilter.org>
11 Date: Wed Jun 17 10:28:27 2015 -0500
12
13 netfilter: don't pull include/linux/netfilter.h from netns headers
14
15 The issue is that definitions in linux/in.h overlap with those
16 in netinet/in.h. This patch solves this by introducing the same
17 mechanism as was used to solve the same problem with linux/in6.h
18
19 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
21 ---
22 include/uapi/linux/in.h | 16 +++++++++++++---
23 include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
24 2 files changed, 35 insertions(+), 3 deletions(-)
25
26 --- a/include/uapi/linux/in.h
27 +++ b/include/uapi/linux/in.h
28 @@ -19,8 +19,10 @@
29 #define _UAPI_LINUX_IN_H
30
31 #include <linux/types.h>
32 +#include <linux/libc-compat.h>
33 #include <linux/socket.h>
34
35 +#if __UAPI_DEF_IN_IPPROTO
36 /* Standard well-defined IP protocols. */
37 enum {
38 IPPROTO_IP = 0, /* Dummy protocol for TCP */
39 @@ -73,12 +75,14 @@ enum {
40 #define IPPROTO_RAW IPPROTO_RAW
41 IPPROTO_MAX
42 };
43 +#endif
44
45 -
46 +#if __UAPI_DEF_IN_ADDR
47 /* Internet address. */
48 struct in_addr {
49 __be32 s_addr;
50 };
51 +#endif
52
53 #define IP_TOS 1
54 #define IP_TTL 2
55 @@ -154,6 +158,7 @@ struct in_addr {
56
57 /* Request struct for multicast socket ops */
58
59 +#if __UAPI_DEF_IP_MREQ
60 struct ip_mreq {
61 struct in_addr imr_multiaddr; /* IP multicast address of group */
62 struct in_addr imr_interface; /* local IP address of interface */
63 @@ -205,14 +210,18 @@ struct group_filter {
64 #define GROUP_FILTER_SIZE(numsrc) \
65 (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
66 + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
67 +#endif
68
69 +#if __UAPI_DEF_IN_PKTINFO
70 struct in_pktinfo {
71 int ipi_ifindex;
72 struct in_addr ipi_spec_dst;
73 struct in_addr ipi_addr;
74 };
75 +#endif
76
77 /* Structure describing an Internet (IP) socket address. */
78 +#if __UAPI_DEF_SOCKADDR_IN
79 #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
80 struct sockaddr_in {
81 __kernel_sa_family_t sin_family; /* Address family */
82 @@ -224,8 +233,9 @@ struct sockaddr_in {
83 sizeof(unsigned short int) - sizeof(struct in_addr)];
84 };
85 #define sin_zero __pad /* for BSD UNIX comp. -FvK */
86 +#endif
87
88 -
89 +#if __UAPI_DEF_IN_CLASS
90 /*
91 * Definitions of the bits in an Internet address integer.
92 * On subnets, host and network parts are found according
93 @@ -276,7 +286,7 @@ struct sockaddr_in {
94 #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
95 #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
96 #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
97 -
98 +#endif
99
100 /* <asm/byteorder.h> contains the htonl type stuff.. */
101 #include <asm/byteorder.h>
102 --- a/include/uapi/linux/libc-compat.h
103 +++ b/include/uapi/linux/libc-compat.h
104 @@ -56,6 +56,13 @@
105
106 /* GLIBC headers included first so don't define anything
107 * that would already be defined. */
108 +#define __UAPI_DEF_IN_ADDR 0
109 +#define __UAPI_DEF_IN_IPPROTO 0
110 +#define __UAPI_DEF_IN_PKTINFO 0
111 +#define __UAPI_DEF_IP_MREQ 0
112 +#define __UAPI_DEF_SOCKADDR_IN 0
113 +#define __UAPI_DEF_IN_CLASS 0
114 +
115 #define __UAPI_DEF_IN6_ADDR 0
116 /* The exception is the in6_addr macros which must be defined
117 * if the glibc code didn't define them. This guard matches
118 @@ -76,6 +83,13 @@
119 /* Linux headers included first, and we must define everything
120 * we need. The expectation is that glibc will check the
121 * __UAPI_DEF_* defines and adjust appropriately. */
122 +#define __UAPI_DEF_IN_ADDR 1
123 +#define __UAPI_DEF_IN_IPPROTO 1
124 +#define __UAPI_DEF_IN_PKTINFO 1
125 +#define __UAPI_DEF_IP_MREQ 1
126 +#define __UAPI_DEF_SOCKADDR_IN 1
127 +#define __UAPI_DEF_IN_CLASS 1
128 +
129 #define __UAPI_DEF_IN6_ADDR 1
130 /* We unconditionally define the in6_addr macros and glibc must
131 * coordinate. */
132 @@ -99,6 +113,14 @@
133 * that we need. */
134 #else /* !defined(__GLIBC__) */
135
136 +/* Definitions for in.h */
137 +#define __UAPI_DEF_IN_ADDR 1
138 +#define __UAPI_DEF_IN_IPPROTO 1
139 +#define __UAPI_DEF_IN_PKTINFO 1
140 +#define __UAPI_DEF_IP_MREQ 1
141 +#define __UAPI_DEF_SOCKADDR_IN 1
142 +#define __UAPI_DEF_IN_CLASS 1
143 +
144 /* Definitions for in6.h */
145 #define __UAPI_DEF_IN6_ADDR 1
146 #define __UAPI_DEF_IN6_ADDR_ALT 1