Skip to contentSkip to conversation

xen-netfront: reset skb network header before checksum

PATCH Applied Wei Liu 3 participants 5 messages Feb 19, 2014

Subsystems (3)
lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 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.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Paul Durrant <[email protected]>
---
 drivers/net/xen-netfront.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/xen-netfront.c +1 -0
index ff04d4f..95041b6 100644
@@ -907,6 +907,7 @@ static int handle_incoming_queue(struct net_device *dev,
 
 		/* Ethernet work: Delayed to here as it peeks the header. */
 		skb->protocol = eth_type_trans(skb, dev);
+		skb_reset_network_header(skb);
 
 		if (checksum_setup(dev, skb)) {
 			kfree_skb(skb);
Signature · 1 line
1.7.10.4
Tested-by on v1 1/1
#1 lore raw
Quoted 29 lines · you

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.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Paul Durrant <[email protected]>
---
 drivers/net/xen-netfront.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/xen-netfront.c +0 -0
index ff04d4f..95041b6 100644

drivers/net/xen-netfront.c static int handle_incoming_queue(struct net_device *dev, · line 913

Quoted 7 lines
drivers/net/xen-netfront.c +1 -0
@@ -907,6 +907,7 @@ static int handle_incoming_queue(struct net_device *dev,
 
                /* Ethernet work: Delayed to here as it peeks the header. */
                skb->protocol = eth_type_trans(skb, dev);
+               skb_reset_network_header(skb);
 
                if (checksum_setup(dev, skb)) {
                        kfree_skb(skb);

Ah that also explains why ICMP was not affected :-) Just tested and this patch indeed fixes my problem, so:

Thanks Wei !

--
Sander

Tested-by on v1 1/1
#2 lore raw
In reply to Wei Liu
Quoted 29 lines · you

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.

Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Paul Durrant <[email protected]>
---
 drivers/net/xen-netfront.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/xen-netfront.c +0 -0
index ff04d4f..95041b6 100644

drivers/net/xen-netfront.c static int handle_incoming_queue(struct net_device *dev, · line 913

Quoted 7 lines
drivers/net/xen-netfront.c +1 -0
@@ -907,6 +907,7 @@ static int handle_incoming_queue(struct net_device *dev,
 
                /* Ethernet work: Delayed to here as it peeks the header. */
                skb->protocol = eth_type_trans(skb, dev);
+               skb_reset_network_header(skb);
 
                if (checksum_setup(dev, skb)) {
                        kfree_skb(skb);

Ah that also explains why ICMP was not affected :-) Just tested and this patch indeed fixes my problem, so:

Thanks Wei !

--
Sander

maintainer Applied
#3 lore raw
In reply to Wei Liu

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

Quoted 12 lines

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.

Quoted 6 lines

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.

Applied, thanks.

maintainer Applied
#4 lore raw
In reply to Wei Liu

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

Quoted 12 lines

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.

Quoted 6 lines

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.

Applied, thanks.