virtio-net: restrict build_skb() use to some arches
Subsystems (4)
PATCH 1/1 virtio-net: restrict build_skb() use to some arches
From: Eric Dumazet <[email protected]>
build_skb() is supposed to be followed byskb_reserve(skb, NET_IP_ALIGN), so that IP headers are word-aligned. (Best practice is to reserve NET_IP_ALIGN+NET_SKB_PAD, but the NET_SKB_PAD part is only a performance optimization if tunnel encaps are added.)
Unfortunately virtio_net has not provisioned this reserve. We can only use build_skb() for arches where NET_IP_ALIGN == 0
We might refine this later, with enough testing.
--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
@@ -416,7 +416,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, shinfo_size =SKB_DATA_ALIGN (sizeof (struct skb_shared_info )); -if (len >GOOD_COPY_LEN && tailroom >= shinfo_size) { +if (!NET_IP_ALIGN && len >GOOD_COPY_LEN && tailroom >= shinfo_size) { skb =build_skb (p, truesize);if (unlikely (!skb))return NULL ;
Signature · 1 line
2.31.1.368.gbe11c130af-goog
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Tue, 20 Apr 2021 13:01:44 -0700 you wrote:
From: Eric Dumazet <[email protected]>
build_skb()is supposed to be followed byskb_reserve(skb, NET_IP_ALIGN), so that IP headers are word-aligned. (Best practice is to reserve NET_IP_ALIGN+NET_SKB_PAD, but theNET_SKB_PADpart is only a performance optimization if tunnel encaps are added.)[...]
Here is the summary with links:
- [net-next] virtio-net: restrict build_skb() use to some arches
https://git.kernel.org/netdev/net-next/c/f5d7872a8b8a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 12 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
build_skb()is supposed to be followed byskb_reserve(skb, NET_IP_ALIGN), so that IP headers are word-aligned. (Best practice is to reserve NET_IP_ALIGN+NET_SKB_PAD, but theNET_SKB_PADpart is only a performance optimization if tunnel encaps are added.)Unfortunately
virtio_nethas not provisioned this reserve. We can only usebuild_skb()for arches whereNET_IP_ALIGN== 0We might refine this later, with enough testing.
Quoted 7 lines
Fixes fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom")Signed-off-by Eric Dumazet <[email protected]>Reported-by Guenter Roeck <[email protected]>Cc Xuan Zhuo <[email protected]>Cc Jason Wang <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>
Quoted 17 lines
--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/virtio_net.c +1
-1@@ -416,7 +416,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, shinfo_size =SKB_DATA_ALIGN (sizeof (struct skb_shared_info )); -if (len >GOOD_COPY_LEN && tailroom >= shinfo_size) { +if (!NET_IP_ALIGN && len >GOOD_COPY_LEN && tailroom >= shinfo_size) { skb =build_skb (p, truesize);if (unlikely (!skb))return NULL ;