0001-iptunnel.c-do-not-include-netinet-ip.h.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From eec38a200357b195efbb23bb645ab721c040f246 Mon Sep 17 00:00:00 2001
  2. From: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
  3. Date: Thu, 3 Nov 2016 12:59:39 +0000
  4. Subject: [PATCH] iptunnel.c: do not include netinet/ip.h
  5. This fixes a struct redefinition problem like this one:
  6. ================================
  7. In file included from /usr/include/linux/if_tunnel.h:6:0,
  8. from iptunnel.c:34:
  9. /usr/include/linux/ip.h:85:8: error: redefinition of 'struct iphdr'
  10. struct iphdr {
  11. ^
  12. In file included from iptunnel.c:29:0:
  13. /usr/include/netinet/ip.h:45:8: note: originally defined here
  14. struct iphdr
  15. ^
  16. ================================
  17. iptunnel.c includes netinet/ip.h which contains a definition of the
  18. iphdr struct.
  19. iptunnel.c also includes linux/if_tunnel.h which includes linux/ip.h
  20. which contains a definition of the iphdr struct.
  21. So, both netinet/ip.h and linux/ip.h define the iphdr struct, and both
  22. of them have been included directly or indirectly by iptunnel.c. Because
  23. of that the compilation fails due to a struct redefinition.
  24. The problem can be solved by just not including netinet/ip.h.
  25. However, some Linux headers included in certain toolchains may not have
  26. an updated linux/if_tunnel.h which includes linux/ip.h, so we need to
  27. include it unconditionally otherwise linux/if_tunnel.h will use the
  28. struct iphdr before being defined and the compilation will also fail in
  29. this way:
  30. ================================
  31. In file included from iptunnel.c:33:0:
  32. /usr/include/linux/if_tunnel.h:37:16: error: field 'iph' has incomplete type
  33. struct iphdr iph;
  34. ^
  35. ================================
  36. Upstream status: merge request sent
  37. https://sourceforge.net/p/net-tools/code/merge-requests/4/
  38. Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
  39. ---
  40. iptunnel.c | 2 +-
  41. 1 file changed, 1 insertion(+), 1 deletion(-)
  42. diff --git a/iptunnel.c b/iptunnel.c
  43. index 3fe1b84..e2ec2d8 100644
  44. --- a/iptunnel.c
  45. +++ b/iptunnel.c
  46. @@ -26,11 +26,11 @@
  47. #include <sys/socket.h>
  48. #include <sys/ioctl.h>
  49. #include <netinet/in.h>
  50. -#include <netinet/ip.h>
  51. #include <arpa/inet.h>
  52. #include <net/if.h>
  53. #include <net/if_arp.h>
  54. #include <linux/types.h>
  55. +#include <linux/ip.h>
  56. #include <linux/if_tunnel.h>
  57. #include "config.h"
  58. --
  59. 2.10.1