Skip to contentSkip to conversation

kvm-guest-drivers-linux: Fix GSO/partial csum support on older kernels

PATCH Applied Mark McLoughlin 3 participants 8 messages May 27, 2008 – Jun 20, 2008 KVM

lore
Share & tools
lore
#0 lore raw

cover kvm-guest-drivers-linux: Fix GSO/partial csum support on older kernels

Hi,
Here's a few patches to fix virtio_net GSO
and partial csum support under older kernels.

Cheers,
Mark.

#1 lore raw

PATCH 1/3 Fix partial csum rx handling

When we receive a packet with a partial csum,
just set ip_summed to CHECKSUM_UNNECESSARY.

---
 hack-module.awk |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
hack-module.awk +5 -1
index 4bad1e7..b687951 100644
@@ -114,7 +114,11 @@
 }
 
 /flags \& VIRTIO_NET_HDR_F_NEEDS_CSUM\)/ {
-    print "#ifndef COMPAT_csum_offset";
+    print "#ifdef COMPAT_csum_offset";
+    print "\tif (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {";
+    print "\t\tskb->ip_summed = CHECKSUM_UNNECESSARY;";
+    print "\t}";
+    print "#else"
     need_endif_indent_brace = 1
 }
 
Signature · 1 line
1.5.5.1
#2 lore raw

PATCH 2/3 Fix partial csum tx handling

Older kernels didn't have the csum_start/csum_offset skb members, but skb->csum did contain the offset into the transport header of the csum field and csum->h contained a pointer to the transport layer header.

---
 hack-module.awk |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
hack-module.awk +10 -3
index b687951..d04c3b6 100644
@@ -124,10 +124,17 @@
 
 /ip_summed == CHECKSUM_PARTIAL\)/ {
     print "#ifdef COMPAT_csum_offset";
-    print "\thdr->flags = 0;"
-    print "\thdr->csum_offset = hdr->csum_start = 0;"
+    print "\tif (skb->ip_summed == CHECKSUM_HW) {"
     print "#else"
-    need_endif_indent_brace = 1;
+    need_endif = 1;
+}
+
+/hdr->csum_start = skb->csum_start/ {
+    print "#ifdef COMPAT_csum_offset";
+    print "\t\thdr->csum_start = skb->h.raw - skb->data;";
+    print "\t\thdr->csum_offset = skb->csum;";
+    print "#else"
+    need_endif = 1;
 }
 
 /skb_transport_header/ {
Signature · 1 line
1.5.5.1
#3 lore raw

PATCH 3/3 Fix GSO tx handling

Use skb->h instead of skb->transport_header

skb->transport_header was introduced in 2.6.22

---
 hack-module.awk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hack-module.awk +1 -1
index d04c3b6..a3275fa 100644
@@ -139,7 +139,7 @@
 
 /skb_transport_header/ {
     print "#ifdef COMPAT_transport_header";
-    print "BUG();";
+    print "\t\thdr->hdr_len = skb->h.raw - skb->data;";
     print "#else";
     need_endif = 1;
 }
Signature · 1 line
1.5.5.1
#4 lore raw

Re: [PATCH 1/3] Fix partial csum rx handling

In reply to Mark McLoughlin
Quoted 5 lines · Mark McLoughlin

When we receive a packet with a partial csum,
just set ip_summed to CHECKSUM_UNNECESSARY.

I'm not sure I follow the context of this patch. Could you explain what it's for?

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw

Re: [PATCH 1/3] Fix partial csum rx handling

Quoted 9 lines · Herbert Xu
Quoted 5 lines · Mark McLoughlin

When we receive a packet with a partial csum,
just set ip_summed to CHECKSUM_UNNECESSARY.

I'm not sure I follow the context of this patch. Could you explain what it's for?

Yeah, sorry. These three patches are to kvm-guest-driver-linux's awk script which munges the virtio drivers so that they can be built for older kernels.

So, the three patches are what I needed to make csum/GSO handling work correctly on the RHEL5 2.6.18 based kernel.

Cheers,
Mark.

#6 lore raw

Re: [PATCH 1/3] Fix partial csum rx handling

Hi Mark:

Quoted 3 lines · Mark McLoughlin

So, the three patches are what I needed to make csum/GSO handling work correctly on the RHEL5 2.6.18 based kernel.

Thanks for the explanation.

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Applied
#7 lore raw
In reply to Mark McLoughlin
Quoted 5 lines · Mark McLoughlin

Hi,
Here's a few patches to fix virtio_net GSO
and partial csum support under older kernels.

Applied all, thanks. Sorry for the virtio-like latency in processing.

I don't much like the intense hackery involved in this. The way I think it could be done is:

- hack virtio to use an API which is specific to kvm, but matches the current upstream API:

s/net_func/virtio_compat_net_func/

including data structures.

- define this API on top of the host kernel's real API. For a recent enough kernel, that's a one-to-one mapping:

virtio_compat_net_func() { return net_func(); }

for older ones there's a more trickery involved.

For kvm, this is a fairly successful strategy, but I imagine that for
virtio-net this will be much, much, more difficult.

- write Documentation/stable_api_nonsense_nonsense.txt.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.