095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch 4.4 KB

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