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
7 This fixes breakage to iproute2 build with recent kernel headers
9 commit a263653ed798216c0069922d7b5237ca49436007
10 Author: Pablo Neira Ayuso <pablo@netfilter.org>
11 Date: Wed Jun 17 10:28:27 2015 -0500
13 netfilter: don't pull include/linux/netfilter.h from netns headers
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
19 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
22 include/uapi/linux/in.h | 16 +++++++++++++---
23 include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
24 2 files changed, 35 insertions(+), 3 deletions(-)
26 --- a/include/uapi/linux/in.h
27 +++ b/include/uapi/linux/in.h
29 #define _UAPI_LINUX_IN_H
31 #include <linux/types.h>
32 +#include <linux/libc-compat.h>
33 #include <linux/socket.h>
35 +#if __UAPI_DEF_IN_IPPROTO
36 /* Standard well-defined IP protocols. */
38 IPPROTO_IP = 0, /* Dummy protocol for TCP */
39 @@ -73,12 +75,14 @@ enum {
40 #define IPPROTO_RAW IPPROTO_RAW
46 +#if __UAPI_DEF_IN_ADDR
47 /* Internet address. */
55 @@ -154,6 +158,7 @@ struct in_addr {
57 /* Request struct for multicast socket ops */
59 +#if __UAPI_DEF_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))
69 +#if __UAPI_DEF_IN_PKTINFO
72 struct in_addr ipi_spec_dst;
73 struct in_addr ipi_addr;
77 /* Structure describing an Internet (IP) socket address. */
78 +#if __UAPI_DEF_SOCKADDR_IN
79 #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
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)];
85 #define sin_zero __pad /* for BSD UNIX comp. -FvK */
89 +#if __UAPI_DEF_IN_CLASS
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 */
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
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
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
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
129 #define __UAPI_DEF_IN6_ADDR 1
130 /* We unconditionally define the in6_addr macros and glibc must
134 #else /* !defined(__GLIBC__) */
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
144 /* Definitions for in6.h */
145 #define __UAPI_DEF_IN6_ADDR 1
146 #define __UAPI_DEF_IN6_ADDR_ALT 1