Skip to contentSkip to conversation

virtio-net header alignment

PATCH Applied Herbert Xu 4 participants 6 messages Jun 10, 2009 – Jun 12, 2009 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): OF1B881599.F1B4A2EF-ON802575BB.0036EA40-802575BC.0041BFB5@au1.ibm.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 1243268223.32745.25.camel@blaa

Herbert Xu

author
#3 lore raw
Quoted 4 lines · Mark McLoughlin

Perhaps; would padding struct virtio_net_hdr_mrg_rxbuf have avoided it?

Cc-ing Herbert, he initially wrote the guest side of this.

Does this fix it?

virtio_net: Fix IP alignment on mergeable RX path

We need to enforce the IP alignment on the mergeable RX path just like the other RX path. Not doing so results in misaligned IP headers.

drivers/net/virtio_net.c +2 -1
index 4d1d479..52fba8e 100644
@@ -283,10 +283,11 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
 	for (;;) {
 		struct virtio_net_hdr *hdr;
 
-		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
+		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);
 		if (unlikely(!skb))
 			break;
 
+		skb_reserve(skb, NET_IP_ALIGN);
 		skb_put(skb, MAX_PACKET_LEN);
 
 		hdr = skb_vnet_hdr(skb);

Cheers,

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
maintainer
#4 lore raw

From: Herbert Xu <[email protected]>
Date: Wed, 10 Jun 2009 15:12:27 +1000

Quoted 8 lines · Mark McLoughlin
Quoted 4 lines

Perhaps; would padding struct virtio_net_hdr_mrg_rxbuf have avoided it?

Cc-ing Herbert, he initially wrote the guest side of this.

Does this fix it?

Quoted 7 lines

virtio_net: Fix IP alignment on mergeable RX path

We need to enforce the IP alignment on the mergeable RX path just like the other RX path. Not doing so results in misaligned IP headers.

I'll apply this as soon as I see some test reports.

Has anyone had a chance to try this out yet?

#5 lore raw
In reply to Herbert Xu
Quoted 6 lines · Herbert Xu
Quoted 4 lines · Mark McLoughlin

Perhaps; would padding struct virtio_net_hdr_mrg_rxbuf have avoided it?

Cc-ing Herbert, he initially wrote the guest side of this.

Quoted 7 lines

Does this fix it?

virtio_net: Fix IP alignment on mergeable RX path

We need to enforce the IP alignment on the mergeable RX path just like the other RX path. Not doing so results in misaligned IP headers.

I think this fixes the old RX path rather than the mergeable RX path. try_fill_recv_maxbufs() is called from try_fill_recv()

        if (!vi->mergeable_rx_bufs) {
                try_fill_recv_maxbufs(vi);
                return;
        }

-Sridhar

Quoted 22 lines
drivers/net/virtio_net.c +2 -1
index 4d1d479..52fba8e 100644
@@ -283,10 +283,11 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
 	for (;;) {
 		struct virtio_net_hdr *hdr;
 
-		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
+		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);
 		if (unlikely(!skb))
 			break;
 
+		skb_reserve(skb, NET_IP_ALIGN);
 		skb_put(skb, MAX_PACKET_LEN);
 
 		hdr = skb_vnet_hdr(skb);

Cheers,

author
#6 lore raw
Quoted 8 lines · Sridhar Samudrala

I think this fixes the old RX path rather than the mergeable RX path. try_fill_recv_maxbufs() is called from try_fill_recv()

        if (!vi->mergeable_rx_bufs) {
                try_fill_recv_maxbufs(vi);
                return;
        }

Yes you're right. We should do s/mergeable/non-mergeable/ in the changelog :)

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
#7 lore raw

PATCH 1/1 virtio_net: Fix IP alignment on non-mergeable RX path

From: Herbert Xu <[email protected]>

We need to enforce the IP alignment on the non-mergeable RX path just like the other RX path. Not doing so results in misaligned IP headers.

drivers/net/virtio_net.c +2 -1
index 4d1d479..52fba8e 100644
@@ -283,10 +283,11 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
 	for (;;) {
 		struct virtio_net_hdr *hdr;
 
-		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
+		skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);
 		if (unlikely(!skb))
 			break;
 
+		skb_reserve(skb, NET_IP_ALIGN);
 		skb_put(skb, MAX_PACKET_LEN);
 
 		hdr = skb_vnet_hdr(skb);
maintainer Applied
#8 lore raw

Re: [PATCH] virtio_net: Fix IP alignment on non-mergeable RX path

From: Rusty Russell <[email protected]>
Date: Fri, 12 Jun 2009 08:29:22 +0930

Quoted 8 lines

From: Herbert Xu <[email protected]>

We need to enforce the IP alignment on the non-mergeable RX path just like the other RX path. Not doing so results in misaligned IP headers.

Applied, thanks everyone.