0002-xtables-monitor-fix-build-with-older-glibc.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 7c8791edac3e74f6ce0bf21f98bc820db8e55e62 Mon Sep 17 00:00:00 2001
  2. From: Baruch Siach <baruch@tkos.co.il>
  3. Date: Fri, 16 Nov 2018 07:23:32 +0200
  4. Subject: [PATCH] xtables-monitor: fix build with older glibc
  5. glibc older than 2.19 only expose BSD style fields of struct tcphdr when
  6. _BSD_SOURCE is define. Current glibc however, warn that _BSD_SOURCE is
  7. deprecated. Migrate to the GNU style of tcphdr fields to make the code
  8. compatible with any glibc version.
  9. Fix the following build failure:
  10. xtables-monitor.c: In function 'trace_print_packet':
  11. xtables-monitor.c:406:43: error: 'const struct tcphdr' has no member named 'th_sport'
  12. printf("SPORT=%d DPORT=%d ", ntohs(tcph->th_sport), ntohs(tcph->th_dport));
  13. ^
  14. xtables-monitor.c:406:66: error: 'const struct tcphdr' has no member named 'th_dport'
  15. printf("SPORT=%d DPORT=%d ", ntohs(tcph->th_sport), ntohs(tcph->th_dport));
  16. ^
  17. ...
  18. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  19. Signed-off-by: Florian Westphal <fw@strlen.de>
  20. ---
  21. Upstream status: commit 7c8791edac3e74
  22. iptables/xtables-monitor.c | 30 ++++++++++++++----------------
  23. 1 file changed, 14 insertions(+), 16 deletions(-)
  24. diff --git a/iptables/xtables-monitor.c b/iptables/xtables-monitor.c
  25. index 3b1ca777a28a..5d1611122df5 100644
  26. --- a/iptables/xtables-monitor.c
  27. +++ b/iptables/xtables-monitor.c
  28. @@ -403,26 +403,24 @@ static void trace_print_packet(const struct nftnl_trace *nlt, struct cb_arg *arg
  29. case IPPROTO_UDP:
  30. if (len < 4)
  31. break;
  32. - printf("SPORT=%d DPORT=%d ", ntohs(tcph->th_sport), ntohs(tcph->th_dport));
  33. + printf("SPORT=%d DPORT=%d ", ntohs(tcph->source), ntohs(tcph->dest));
  34. break;
  35. case IPPROTO_TCP:
  36. if (len < sizeof(*tcph))
  37. break;
  38. - printf("SPORT=%d DPORT=%d ", ntohs(tcph->th_sport), ntohs(tcph->th_dport));
  39. - if (tcph->th_flags & (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG)) {
  40. - if (tcph->th_flags & TH_SYN)
  41. - printf("SYN ");
  42. - if (tcph->th_flags & TH_ACK)
  43. - printf("ACK ");
  44. - if (tcph->th_flags & TH_FIN)
  45. - printf("FIN ");
  46. - if (tcph->th_flags & TH_RST)
  47. - printf("RST ");
  48. - if (tcph->th_flags & TH_PUSH)
  49. - printf("PSH ");
  50. - if (tcph->th_flags & TH_URG)
  51. - printf("URG ");
  52. - }
  53. + printf("SPORT=%d DPORT=%d ", ntohs(tcph->source), ntohs(tcph->dest));
  54. + if (tcph->syn)
  55. + printf("SYN ");
  56. + if (tcph->ack)
  57. + printf("ACK ");
  58. + if (tcph->fin)
  59. + printf("FIN ");
  60. + if (tcph->rst)
  61. + printf("RST ");
  62. + if (tcph->psh)
  63. + printf("PSH ");
  64. + if (tcph->urg)
  65. + printf("URG ");
  66. break;
  67. default:
  68. break;
  69. --
  70. 2.19.1