From: Andrejs Hanins <ahanins@gmail.com>
To: wireguard@lists.zx2c4.com
Subject: [PATCH 1/1] Calculate inner checksums for all L4 protocols (was for TCP/UDP only).
Date: Fri, 10 Aug 2018 11:06:17 +0300 [thread overview]
Message-ID: <20180810080617.20283-2-ahanins@gmail.com> (raw)
In-Reply-To: <20180810080617.20283-1-ahanins@gmail.com>
- skb_checksum_setup can only handle TCP/UDP protocols under top level
IP header, packets with other protocols (like GRE) are sent out by
Wireguard with unfinished partial checksums which causes problems on
receiving side (bad checksums).
- skb_encrypt gets skb prepared by network stack, so there is no need to
setup the checksum from scratch, but just perform hw checksum offload
using software helper skb_checksum_help for packet which explicitly
require it as denoted by CHECKSUM_PARTIAL.
Signed-off-by: Andrejs Hanins <ahanins@gmail.com>
---
src/send.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/send.c b/src/send.c
index 3af7ef3..1d021ae 100644
--- a/src/send.c
+++ b/src/send.c
@@ -151,9 +151,9 @@ static inline bool skb_encrypt(struct sk_buff *skb, struct noise_keypair *keypai
if (unlikely(skb_cow_head(skb, DATA_PACKET_HEAD_ROOM) < 0))
return false;
- /* We have to remember to add the checksum to the innerpacket, in case the receiver forwards it. */
- if (likely(!skb_checksum_setup(skb, true)))
- skb_checksum_help(skb);
+ /* Finalize checksum calculation for the inner packet, if required. */
+ if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb))
+ return false;
/* Only after checksumming can we safely add on the padding at the end and the header. */
skb_set_inner_network_header(skb, 0);
--
2.17.1
next prev parent reply other threads:[~2018-08-10 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 8:06 [PATCH 0/1] Fix broken inner checksums for non TCP/UDP protocols Andrejs Hanins
2018-08-10 8:06 ` Andrejs Hanins [this message]
2018-08-12 8:13 ` Jason A. Donenfeld
2018-08-13 11:11 ` Andrey H.
2018-10-18 16:36 ` Jason A. Donenfeld
[not found] ` <0d8cad17-593a-9e96-eb4e-dc01c87743fe@gmail.com>
[not found] ` <be9f1e51-6ed4-3d21-2c20-c7ed6d31aadb@gmail.com>
2018-10-27 1:23 ` Jason A. Donenfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180810080617.20283-2-ahanins@gmail.com \
--to=ahanins@gmail.com \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).