This patch fixes two things:

  When skb->ip_summed == CHECKSUM_PARTIAL, skb_checksum_help() should be
  called do the checksum, instead of gso_make_checksum(), which is used
  to do the checksum for current proto after calling skb_segment(), not
  after the inner proto's gso_segment().

  When offload_csum is disabled, the hardware will not do the checksum
  for the current proto, udp. So instead of calling gso_make_checksum(),
  it should calculate checksum for udp itself.

Signed-off-by: Xin Long <lucien....@gmail.com>
---
 net/ipv4/udp_offload.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index e67a66f..c0b010b 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -131,14 +131,15 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct 
sk_buff *skb,
                uh->check = ~csum_fold(csum_add(partial,
                                       (__force __wsum)htonl(len)));
 
-               if (skb->encapsulation || !offload_csum) {
-                       uh->check = gso_make_checksum(skb, ~uh->check);
-                       if (uh->check == 0)
-                               uh->check = CSUM_MANGLED_0;
-               } else {
+               if (skb->encapsulation)
+                       skb_checksum_help(skb);
+
+               if (offload_csum) {
                        skb->ip_summed = CHECKSUM_PARTIAL;
                        skb->csum_start = skb_transport_header(skb) - skb->head;
                        skb->csum_offset = offsetof(struct udphdr, check);
+               } else {
+                       uh->check = csum_fold(skb_checksum(skb, udp_offset, 
len, 0));
                }
        } while ((skb = skb->next));
 out:
-- 
2.1.0

Reply via email to