0002-batman-adv-add-fixes-for-packet-checksum-handling.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Mon, 22 Jan 2018 20:41:41 +0100
  3. Subject: batman-adv: add fixes for packet checksum handling
  4. diff --git a/batman-adv/patches/0001-batman-adv-fix-packet-checksum-in-receive-path.patch b/batman-adv/patches/0001-batman-adv-fix-packet-checksum-in-receive-path.patch
  5. new file mode 100644
  6. index 0000000000000000000000000000000000000000..ce1a5345be1405ccf034ab948b2061be46cda090
  7. --- /dev/null
  8. +++ b/batman-adv/patches/0001-batman-adv-fix-packet-checksum-in-receive-path.patch
  9. @@ -0,0 +1,44 @@
  10. +From 05cee97344804ffb2a8df87603663a098fd0cb36 Mon Sep 17 00:00:00 2001
  11. +Message-Id: <05cee97344804ffb2a8df87603663a098fd0cb36.1516705934.git.mschiffer@universe-factory.net>
  12. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  13. +Date: Mon, 22 Jan 2018 20:06:51 +0100
  14. +Subject: [PATCH 1/2] batman-adv: fix packet checksum in receive path
  15. +
  16. +eth_type_trans() internally calls skb_pull(), which does not adjust the
  17. +skb checksum; skb_postpull_rcsum() is necessary to avoid log spam of the
  18. +form "bat0: hw csum failure" when packets with CHECKSUM_COMPLETE are
  19. +received.
  20. +
  21. +Note that in usual setups, packets don't reach batman-adv with
  22. +CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
  23. +batadv's ethtype?), which is why the log messages do nor occur on every
  24. +system using batman-adv. I could reproduce this issue by stacking
  25. +batman-adv on top of a VXLAN interface.
  26. +
  27. +Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  28. +---
  29. + net/batman-adv/soft-interface.c | 8 +-------
  30. + 1 file changed, 1 insertion(+), 7 deletions(-)
  31. +
  32. +diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
  33. +index 9f673cdf..6f7ce7a6 100644
  34. +--- a/net/batman-adv/soft-interface.c
  35. ++++ b/net/batman-adv/soft-interface.c
  36. +@@ -451,13 +451,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
  37. +
  38. + /* skb->dev & skb->pkt_type are set here */
  39. + skb->protocol = eth_type_trans(skb, soft_iface);
  40. +-
  41. +- /* should not be necessary anymore as we use skb_pull_rcsum()
  42. +- * TODO: please verify this and remove this TODO
  43. +- * -- Dec 21st 2009, Simon Wunderlich
  44. +- */
  45. +-
  46. +- /* skb->ip_summed = CHECKSUM_UNNECESSARY; */
  47. ++ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
  48. +
  49. + batadv_inc_counter(bat_priv, BATADV_CNT_RX);
  50. + batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
  51. +--
  52. +2.16.1
  53. +
  54. diff --git a/batman-adv/patches/0002-batman-adv-invalidate-checksum-on-fragment-reassembl.patch b/batman-adv/patches/0002-batman-adv-invalidate-checksum-on-fragment-reassembl.patch
  55. new file mode 100644
  56. index 0000000000000000000000000000000000000000..957fc345846acde05345963bcd66eed47b167358
  57. --- /dev/null
  58. +++ b/batman-adv/patches/0002-batman-adv-invalidate-checksum-on-fragment-reassembl.patch
  59. @@ -0,0 +1,42 @@
  60. +From 3f5713999a5f61ed7221944276393b4ff40a9416 Mon Sep 17 00:00:00 2001
  61. +Message-Id: <3f5713999a5f61ed7221944276393b4ff40a9416.1516705934.git.mschiffer@universe-factory.net>
  62. +In-Reply-To: <05cee97344804ffb2a8df87603663a098fd0cb36.1516705934.git.mschiffer@universe-factory.net>
  63. +References: <05cee97344804ffb2a8df87603663a098fd0cb36.1516705934.git.mschiffer@universe-factory.net>
  64. +From: Matthias Schiffer <mschiffer@universe-factory.net>
  65. +Date: Tue, 23 Jan 2018 10:24:45 +0100
  66. +Subject: [PATCH 2/2] batman-adv: invalidate checksum on fragment reassembly
  67. +
  68. +A more sophisticated implementation could try to combine fragment checksums
  69. +when all fragments have CHECKSUM_COMPLETE and are split at even offsets.
  70. +For now, we just set ip_summed to CHECKSUM_NONE to avoid "hw csum failure"
  71. +warnings in the kernel log when fragmented frames are received. In
  72. +consequence, skb_pull_rcsum() can be replaced with skb_pull().
  73. +
  74. +Note that in usual setups, packets don't reach batman-adv with
  75. +CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
  76. +batadv's ethtype?), which is why the log messages do nor occur on every
  77. +system using batman-adv. I could reproduce this issue by stacking
  78. +batman-adv on top of a VXLAN interface.
  79. +
  80. +Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  81. +---
  82. + net/batman-adv/fragmentation.c | 3 ++-
  83. + 1 file changed, 2 insertions(+), 1 deletion(-)
  84. +
  85. +diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
  86. +index ebe6e389..1bb2b43f 100644
  87. +--- a/net/batman-adv/fragmentation.c
  88. ++++ b/net/batman-adv/fragmentation.c
  89. +@@ -287,7 +287,8 @@ batadv_frag_merge_packets(struct hlist_head *chain)
  90. + /* Move the existing MAC header to just before the payload. (Override
  91. + * the fragment header.)
  92. + */
  93. +- skb_pull_rcsum(skb_out, hdr_size);
  94. ++ skb_pull(skb_out, hdr_size);
  95. ++ skb_out->ip_summed = CHECKSUM_NONE;
  96. + memmove(skb_out->data - ETH_HLEN, skb_mac_header(skb_out), ETH_HLEN);
  97. + skb_set_mac_header(skb_out, -ETH_HLEN);
  98. + skb_reset_network_header(skb_out);
  99. +--
  100. +2.16.1
  101. +