Skip to content

Commit 279c6c7

Browse files
shemmingerdavem330
authored andcommitted
api: fix compatibility of linux/in.h with netinet/in.h
u This fixes breakage to iproute2 build with recent kernel headers caused by: commit a263653 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Wed Jun 17 10:28:27 2015 -0500 netfilter: don't pull include/linux/netfilter.h from netns headers The issue is that definitions in linux/in.h overlap with those in netinet/in.h. This patch solves this by introducing the same mechanism as was used to solve the same problem with linux/in6.h Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1625fec commit 279c6c7

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

include/uapi/linux/in.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
#define _UAPI_LINUX_IN_H
2020

2121
#include <linux/types.h>
22+
#include <linux/libc-compat.h>
2223
#include <linux/socket.h>
2324

25+
#if __UAPI_DEF_IN_IPPROTO
2426
/* Standard well-defined IP protocols. */
2527
enum {
2628
IPPROTO_IP = 0, /* Dummy protocol for TCP */
@@ -75,12 +77,14 @@ enum {
7577
#define IPPROTO_RAW IPPROTO_RAW
7678
IPPROTO_MAX
7779
};
80+
#endif
7881

79-
82+
#if __UAPI_DEF_IN_ADDR
8083
/* Internet address. */
8184
struct in_addr {
8285
__be32 s_addr;
8386
};
87+
#endif
8488

8589
#define IP_TOS 1
8690
#define IP_TTL 2
@@ -158,6 +162,7 @@ struct in_addr {
158162

159163
/* Request struct for multicast socket ops */
160164

165+
#if __UAPI_DEF_IP_MREQ
161166
struct ip_mreq {
162167
struct in_addr imr_multiaddr; /* IP multicast address of group */
163168
struct in_addr imr_interface; /* local IP address of interface */
@@ -209,14 +214,18 @@ struct group_filter {
209214
#define GROUP_FILTER_SIZE(numsrc) \
210215
(sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
211216
+ (numsrc) * sizeof(struct __kernel_sockaddr_storage))
217+
#endif
212218

219+
#if __UAPI_DEF_IN_PKTINFO
213220
struct in_pktinfo {
214221
int ipi_ifindex;
215222
struct in_addr ipi_spec_dst;
216223
struct in_addr ipi_addr;
217224
};
225+
#endif
218226

219227
/* Structure describing an Internet (IP) socket address. */
228+
#if __UAPI_DEF_SOCKADDR_IN
220229
#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
221230
struct sockaddr_in {
222231
__kernel_sa_family_t sin_family; /* Address family */
@@ -228,8 +237,9 @@ struct sockaddr_in {
228237
sizeof(unsigned short int) - sizeof(struct in_addr)];
229238
};
230239
#define sin_zero __pad /* for BSD UNIX comp. -FvK */
240+
#endif
231241

232-
242+
#if __UAPI_DEF_IN_CLASS
233243
/*
234244
* Definitions of the bits in an Internet address integer.
235245
* On subnets, host and network parts are found according
@@ -280,7 +290,7 @@ struct sockaddr_in {
280290
#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
281291
#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
282292
#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
283-
293+
#endif
284294

285295
/* <asm/byteorder.h> contains the htonl type stuff.. */
286296
#include <asm/byteorder.h>

include/uapi/linux/libc-compat.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656

5757
/* GLIBC headers included first so don't define anything
5858
* that would already be defined. */
59+
#define __UAPI_DEF_IN_ADDR 0
60+
#define __UAPI_DEF_IN_IPPROTO 0
61+
#define __UAPI_DEF_IN_PKTINFO 0
62+
#define __UAPI_DEF_IP_MREQ 0
63+
#define __UAPI_DEF_SOCKADDR_IN 0
64+
#define __UAPI_DEF_IN_CLASS 0
65+
5966
#define __UAPI_DEF_IN6_ADDR 0
6067
/* The exception is the in6_addr macros which must be defined
6168
* if the glibc code didn't define them. This guard matches
@@ -78,6 +85,13 @@
7885
/* Linux headers included first, and we must define everything
7986
* we need. The expectation is that glibc will check the
8087
* __UAPI_DEF_* defines and adjust appropriately. */
88+
#define __UAPI_DEF_IN_ADDR 1
89+
#define __UAPI_DEF_IN_IPPROTO 1
90+
#define __UAPI_DEF_IN_PKTINFO 1
91+
#define __UAPI_DEF_IP_MREQ 1
92+
#define __UAPI_DEF_SOCKADDR_IN 1
93+
#define __UAPI_DEF_IN_CLASS 1
94+
8195
#define __UAPI_DEF_IN6_ADDR 1
8296
/* We unconditionally define the in6_addr macros and glibc must
8397
* coordinate. */
@@ -103,6 +117,14 @@
103117
* that we need. */
104118
#else /* !defined(__GLIBC__) */
105119

120+
/* Definitions for in.h */
121+
#define __UAPI_DEF_IN_ADDR 1
122+
#define __UAPI_DEF_IN_IPPROTO 1
123+
#define __UAPI_DEF_IN_PKTINFO 1
124+
#define __UAPI_DEF_IP_MREQ 1
125+
#define __UAPI_DEF_SOCKADDR_IN 1
126+
#define __UAPI_DEF_IN_CLASS 1
127+
106128
/* Definitions for in6.h */
107129
#define __UAPI_DEF_IN6_ADDR 1
108130
#define __UAPI_DEF_IN6_ADDR_ALT 1

0 commit comments

Comments
 (0)