1
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. @@ -135,11 +136,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. @@ -85,6 +85,14 @@
  36. #endif /* _NET_IF_H */
  37. +/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
  38. + * Glibc just includes the kernel header and uses a different guard. */
  39. +#if defined(_NETINET_IF_ETHER_H)
  40. +#define __UAPI_DEF_ETHHDR 0
  41. +#else
  42. +#define __UAPI_DEF_ETHHDR 1
  43. +#endif
  44. +
  45. /* Coordinate with libc netinet/in.h header. */
  46. #if defined(_NETINET_IN_H)
  47. @@ -161,6 +169,9 @@
  48. /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
  49. #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
  50. +/* Definitions for if_ether.h */
  51. +#define __UAPI_DEF_ETHHDR 1
  52. +
  53. /* Definitions for in.h */
  54. #define __UAPI_DEF_IN_ADDR 1
  55. #define __UAPI_DEF_IN_IPPROTO 1