Skip to contentSkip to conversation

xen-netfront sets partial checksum at wrong offset

DISCUSSION Venkat Venkatsubra 4 participants 11 messages May 7, 2015 – May 29, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello All,

When handle_incoming_queue (xen-netfront.c) calls checksum_setup() the transport header didn't seem to be initialized yet. skb_checksum_setup_ipv4 ends up initializing the checksum at incorrect offset.

        if (recalculate)
                *csum = ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
                                           ip_hdr(skb)->daddr,
                                           skb->len - off,
                                           ip_hdr(skb)->protocol, 0);

where csum is &tcp_hdr(skb)->check.

This problem got exposed when LRO was ON on the host.
It hits this case in checksum_setup().
/*
* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
* peers can fail to set NETRXF_csum_blank when sending a GSO
* frame. In this case force the SKB to CHECKSUM_PARTIAL and
* recalculate the partial checksum.
*/

skb->ip_summed was CHECKSUM_UNNECESSARY.
The guest was at 3.8.13 kernel.

I can send a patch if you think the problem exists in current releases too.

Thanks.

Venkat

#1 lore raw
Quoted 22 lines · Venkat Venkatsubra

Hello All,

When handle_incoming_queue (xen-netfront.c) calls checksum_setup() the transport header didn't seem to be initialized yet. skb_checksum_setup_ipv4 ends up initializing the checksum at incorrect offset.

        if (recalculate)
                *csum = ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
                                           ip_hdr(skb)->daddr,
                                           skb->len - off,
                                           ip_hdr(skb)->protocol, 0);

where csum is &tcp_hdr(skb)->check.

This problem got exposed when LRO was ON on the host.
It hits this case in checksum_setup().
/*
* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
* peers can fail to set NETRXF_csum_blank when sending a GSO
* frame. In this case force the SKB to CHECKSUM_PARTIAL and
* recalculate the partial checksum.
*/

Quoted 4 lines

skb->ip_summed was CHECKSUM_UNNECESSARY.
The guest was at 3.8.13 kernel.

I can send a patch if you think the problem exists in current releases too.

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Quoted 9 lines

Thanks.

Venkat

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author Tested-by Sander Eikelenboom
#2 lore raw
Quoted 5 lines

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

In ed1f50c3a ("net: add skb_checksum_setup") we introduced some checksum functions in core driver. Subsequent change b5cf66cd1 ("xen-netfront:
use new skb_checksum_setup function") made use of those functions to replace its own implementation.

However with that change netfront is broken. It sees a lot of checksum error. That's because its own implementation of checksum function was a bit hacky (dereferencing skb->data directly) while the new function was implemented using ip_hdr(). The network header is not reset before skb is passed to the new function. When the new function tries to do its job, it's confused and reports error.

The fix is simple, we need to reset network header before passing skb to checksum function. Netback is not affected as it already does the right thing.

Thanks.

Venkat

#3 lore raw
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

(In either case netback's xenvif_tx_submit() calling skb_probe_transport_header() would seem pointless, as skb_checksum_setup() - with or without a fix - ought to be taking care of this anyway.)

Jan

#4 lore raw
Quoted 18 lines · Jan Beulich
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

Quoted 9 lines

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

I think this is the follow-up thread <[email protected]>

And the conclusion is 3.8 is too old so the fix is not there.

Quoted 5 lines

(In either case netback's xenvif_tx_submit() calling skb_probe_transport_header() would seem pointless, as skb_checksum_setup() - with or without a fix - ought to be taking care of this anyway.)

Patches welcome. :-)

Wei.

Quoted 1 line

Jan

#5 lore raw
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 12:39, <[email protected]> wrote:
Quoted 18 lines · Jan Beulich
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

Quoted 9 lines

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

Quoted 3 lines

I think this is the follow-up thread <[email protected]>

And the conclusion is 3.8 is too old so the fix is not there.

Ah, right. Seems like I failed to remove the earlier mail from my list of things to look at when this came through. Sorry for the noise then.

Jan

#6 lore raw
In reply to Wei Liu
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 12:39, <[email protected]> wrote:
Quoted 18 lines · Jan Beulich
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

Quoted 9 lines

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

Quoted 3 lines

I think this is the follow-up thread <[email protected]>

And the conclusion is 3.8 is too old so the fix is not there.

Ah, right. Seems like I failed to remove the earlier mail from my list of things to look at when this came through. Sorry for the noise then.

Jan

#7 lore raw
In reply to Jan Beulich
Quoted 18 lines · Jan Beulich
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

Quoted 9 lines

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

I think this is the follow-up thread <[email protected]>

And the conclusion is 3.8 is too old so the fix is not there.

Quoted 5 lines

(In either case netback's xenvif_tx_submit() calling skb_probe_transport_header() would seem pointless, as skb_checksum_setup() - with or without a fix - ought to be taking care of this anyway.)

Patches welcome. :-)

Wei.

Quoted 1 line

Jan

#8 lore raw
In reply to Venkat Venkatsubra
Quoted 9 lines
Quoted 6 lines
Quoted 1 line · On 11.05.15 at 19:25, <[email protected]> wrote:

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

Quoted 8 lines

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

So no response at all so far from the maintainers made me look into
this: I first thought what we need would be calls to skb_probe_transport_header() in skb_checksum_setup_ip() after each of the skb_maybe_pull_tail() functions. But skb_partial_csum_set() already calls skb_set_transport_header(), so I now think things ought to be fine without any change. Can you clarify what you think is missing? Or is this an issue in just the old (3.8.x) kernel you're using?

(In either case netback's xenvif_tx_submit() calling skb_probe_transport_header() would seem pointless, as skb_checksum_setup() - with or without a fix - ought to be taking care of this anyway.)

Jan

author Tested-by Sander Eikelenboom
#9 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 5 lines

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Thanks, Konrad.

I am copying Wei too who had fixed the below problem earlier. It fixed the incorrect ip_hdr(). tcp_hdr() still needs to fixed.

commit d554f73df6bc35ac8f6a65e5560bf1d31dfebed9

Author: Wei Liu <[email protected]>
Date:   Wed Feb 19 18:48:34 2014 +0000

xen-netfront: reset skb network header before checksum

In ed1f50c3a ("net: add skb_checksum_setup") we introduced some checksum functions in core driver. Subsequent change b5cf66cd1 ("xen-netfront:
use new skb_checksum_setup function") made use of those functions to replace its own implementation.

However with that change netfront is broken. It sees a lot of checksum error. That's because its own implementation of checksum function was a bit hacky (dereferencing skb->data directly) while the new function was implemented using ip_hdr(). The network header is not reset before skb is passed to the new function. When the new function tries to do its job, it's confused and reports error.

The fix is simple, we need to reset network header before passing skb to checksum function. Netback is not affected as it already does the right thing.

Thanks.

Venkat

#10 lore raw
In reply to Venkat Venkatsubra
Quoted 22 lines · Venkat Venkatsubra

Hello All,

When handle_incoming_queue (xen-netfront.c) calls checksum_setup() the transport header didn't seem to be initialized yet. skb_checksum_setup_ipv4 ends up initializing the checksum at incorrect offset.

        if (recalculate)
                *csum = ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
                                           ip_hdr(skb)->daddr,
                                           skb->len - off,
                                           ip_hdr(skb)->protocol, 0);

where csum is &tcp_hdr(skb)->check.

This problem got exposed when LRO was ON on the host.
It hits this case in checksum_setup().
/*
* A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
* peers can fail to set NETRXF_csum_blank when sending a GSO
* frame. In this case force the SKB to CHECKSUM_PARTIAL and
* recalculate the partial checksum.
*/

Quoted 4 lines

skb->ip_summed was CHECKSUM_UNNECESSARY.
The guest was at 3.8.13 kernel.

I can send a patch if you think the problem exists in current releases too.

Please CC the maintainers of the driver. You can get that from 'scripts/get_maintainer.pl'

I've done that for you.

Quoted 9 lines

Thanks.

Venkat

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel