0003-remove-kernel-headers-include-musl-fix.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Remove kernel header includes causing issues with musl
  2. Include the kernel headers from netfilter causes a conflict with the
  3. <netinet/in.h> way of defining the IPPROTO_* constants, resulting in
  4. the following build failure:
  5. In file included from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/netdb.h:9:0,
  6. from /home/peko/autobuild/instance-0/output/build/norm-1.5r6/protolib/include/protoAddress.h:13,
  7. from /home/peko/autobuild/instance-0/output/build/norm-1.5r6/protolib/include/protoDetour.h:5,
  8. from ../protolib/src/linux/linuxDetour.cpp:3:
  9. /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected identifier before numeric constant
  10. IPPROTO_IP = 0, /* Dummy protocol for TCP */
  11. ^
  12. /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected '}' before numeric constant
  13. /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected unqualified-id before numeric constant
  14. In file included from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/netfilter.h:7:0,
  15. from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/netfilter_ipv4.h:8,
  16. from ../protolib/src/linux/linuxDetour.cpp:10:
  17. /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:79:1: error: expected declaration before '}' token
  18. };
  19. ^
  20. Since from musl's developers perspective including kernel headers is
  21. seen as being unsafe, we simply duplicate the necessary netfilter
  22. definitions (there are just a few) instead of including some kernel
  23. headers.
  24. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  25. Index: b/protolib/src/linux/linuxDetour.cpp
  26. ===================================================================
  27. --- a/protolib/src/linux/linuxDetour.cpp
  28. +++ b/protolib/src/linux/linuxDetour.cpp
  29. @@ -7,15 +7,18 @@
  30. #include <stdlib.h> // for atoi(), getenv()
  31. #include <stdio.h>
  32. #include <unistd.h> // for close()
  33. -#include <linux/netfilter_ipv4.h> // for NF_IP_LOCAL_OUT, etc
  34. -#include <linux/netfilter_ipv6.h> // for NF_IP6_LOCAL_OUT, etc
  35. -#include <linux/netfilter.h> // for NF_ACCEPT, etc
  36. #include <libnetfilter_queue/libnetfilter_queue.h>
  37. #include <fcntl.h> // for fcntl(), etc
  38. #include <linux/if_ether.h> // for ETH_P_IP
  39. #include <net/if_arp.h> // for ARPHRD_ETHER
  40. +/* From netfilter kernel headers */
  41. +#define NF_IP_LOCAL_OUT 3
  42. +
  43. +#define NF_DROP 0
  44. +#define NF_ACCEPT 1
  45. +
  46. /** NOTES:
  47. *
  48. * 1) This newer implementation of LinuxDetour uses netfilter_queue