2
0

272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
  2. From: David Heidelberger <david.heidelberger@ixit.cz>
  3. Date: Mon, 29 Jun 2015 16:53:03 +0200
  4. Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
  5. Musl provides its own ethhdr struct definition. Add a guard to prevent
  6. its definition of the appropriate musl header has already been included.
  7. Signed-off-by: John Spencer <maillist-linux@barfooze.de>
  8. Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
  9. Signed-off-by: Jonas Gorski <jogo@openwrt.org>
  10. ---
  11. include/uapi/linux/if_ether.h | 3 +++
  12. include/uapi/linux/libc-compat.h | 11 +++++++++++
  13. 2 files changed, 14 insertions(+)
  14. --- a/include/uapi/linux/if_ether.h
  15. +++ b/include/uapi/linux/if_ether.h
  16. @@ -22,6 +22,7 @@
  17. #define _UAPI_LINUX_IF_ETHER_H
  18. #include <linux/types.h>
  19. +#include <linux/libc-compat.h>
  20. /*
  21. * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
  22. @@ -134,11 +135,13 @@
  23. * This is an Ethernet frame header.
  24. */
  25. +#if __UAPI_DEF_ETHHDR
  26. struct ethhdr {
  27. unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
  28. unsigned char h_source[ETH_ALEN]; /* source ether addr */
  29. __be16 h_proto; /* packet type ID field */
  30. } __attribute__((packed));
  31. +#endif
  32. #endif /* _UAPI_LINUX_IF_ETHER_H */
  33. --- a/include/uapi/linux/libc-compat.h
  34. +++ b/include/uapi/linux/libc-compat.h
  35. @@ -51,6 +51,14 @@
  36. /* We have included libc headers... */
  37. #if !defined(__KERNEL__)
  38. +/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
  39. + * Glibc just includes the kernel header and uses a different guard. */
  40. +#if defined(_NETINET_IF_ETHER_H)
  41. +#define __UAPI_DEF_ETHHDR 0
  42. +#else
  43. +#define __UAPI_DEF_ETHHDR 1
  44. +#endif
  45. +
  46. /* Coordinate with libc netinet/in.h header. */
  47. #if defined(_NETINET_IN_H)
  48. @@ -113,6 +121,9 @@
  49. * that we need. */
  50. #else /* defined(__KERNEL__) */
  51. +/* Definitions for if_ether.h */
  52. +#define __UAPI_DEF_ETHHDR 1
  53. +
  54. /* Definitions for in.h */
  55. #define __UAPI_DEF_IN_ADDR 1
  56. #define __UAPI_DEF_IN_IPPROTO 1