[PATCH v05 66/72] uapi icmp.h: glibc netinet/ip_icmp.h header file compatibility fixes

From: Mikko Rapeli
Date: Mon Aug 22 2016 - 14:59:51 EST


Fixes this userspace compile error when glibc netinet/ip_icmp.h is included
before linux/icmp.h:

linux/icmp.h:68:8: error: redefinition of âstruct icmphdrâ

Signed-off-by: Mikko Rapeli <mikko.rapeli@xxxxxx>
---
include/uapi/linux/icmp.h | 4 +++-
include/uapi/linux/libc-compat.h | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h
index fddd9d7..cd38005 100644
--- a/include/uapi/linux/icmp.h
+++ b/include/uapi/linux/icmp.h
@@ -17,6 +17,7 @@
#ifndef _UAPI_LINUX_ICMP_H
#define _UAPI_LINUX_ICMP_H

+#include <linux/libc-compat.h>
#include <linux/types.h>

#define ICMP_ECHOREPLY 0 /* Echo Reply */
@@ -64,7 +65,7 @@
#define ICMP_EXC_TTL 0 /* TTL count exceeded */
#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */

-
+#if __UAPI_DEF_ICMPHDR
struct icmphdr {
__u8 type;
__u8 code;
@@ -82,6 +83,7 @@ struct icmphdr {
__u8 reserved[4];
} un;
};
+#endif /* __UAPI_DEF_ICMPHDR */


/*
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 40190a4..8a5a7cc 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -154,6 +154,13 @@

#endif /* _NETINET_IN_H */

+/* Coordinate with glibc netinet/ip_icmp.h header. */
+#if defined(__NETINET_IP_ICMP_H)
+#define __UAPI_DEF_ICMPHDR 0
+#else /* defined(__NETINET_IP_ICMP_H) */
+#define __UAPI_DEF_ICMPHDR 1
+#endif /* defined(__NETINET_IP_ICMP_H) */
+
/* Coordinate with glibc netipx/ipx.h header. */
#if defined(__NETIPX_IPX_H)

@@ -218,6 +225,9 @@
#define __UAPI_DEF_IN6_PKTINFO 1
#define __UAPI_DEF_IP6_MTUINFO 1

+/* Definitions for icmp.h */
+#define __UAPI_DEF_ICMPHDR 1
+
/* Definitions for ipx.h */
#define __UAPI_DEF_SOCKADDR_IPX 1
#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
--
2.8.1