kvm-guest-drivers-linux: Fix GSO/partial csum support on older kernels
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.
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
@@ -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
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
@@ -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
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
@@ -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
Re: [PATCH 1/3] Fix partial csum rx handling
In reply to Mark McLoughlinQuoted 5 lines · Mark McLoughlin
When we receive a packet with a partial csum,
just setip_summedtoCHECKSUM_UNNECESSARY.Signed-off-by Mark McLoughlin <[email protected]>Cc Herbert Xu <[email protected]>
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.txtRe: [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 setip_summedtoCHECKSUM_UNNECESSARY.Signed-off-by Mark McLoughlin <[email protected]>Cc Herbert Xu <[email protected]>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.
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.txtAvi Kivity
AppliedQuoted 5 lines · Mark McLoughlin
Hi,
Here's a few patches to fixvirtio_netGSO
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.