Message ID | 4ACD585B.5080106@gmail.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On 10/08/2009 11:11 AM, Eric Dumazet wrote: > Thomas Chou a écrit : > You should do : > > size -= 4; /* strip the CRC */ > skb = netdev_alloc_skb(dev, size + NET_IP_ALIGN); > if (skb) { > skb_reserve(skb, NET_IP_ALIGN); > ... > } > > > Please check other implementations... > > David, maybe we should add following helper : > > [PATCH] net: Add netdev_alloc_skb_ip_align() helper Hi Eric, Thanks for the suggestion. I will follow your commit and send revised patch. - Thomas -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Thu, 08 Oct 2009 05:11:23 +0200 > David, maybe we should add following helper : > > [PATCH] net: Add netdev_alloc_skb_ip_align() helper > > Instead of hardcoding NET_IP_ALIGN stuff in various network drivers, we can > add a helper around netdev_alloc_skb() > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Looks ok, but I want to look at how often this exact sequence would match. If it applies to a lot of cases, I'll add this but I know of many exceptions in my head already :-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller a écrit : > Looks ok, but I want to look at how often this exact sequence > would match. If it applies to a lot of cases, I'll add this > but I know of many exceptions in my head already :-) Well, it was more as a reference. I believe about 20-30 call sites could use it. Do you want me to provide a combo patch ? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Fri, 9 Oct 2009 18:31:30 +0200 > David Miller a écrit : > >> Looks ok, but I want to look at how often this exact sequence >> would match. If it applies to a lot of cases, I'll add this >> but I know of many exceptions in my head already :-) > > Well, it was more as a reference. I believe about 20-30 call sites > could use it. Do you want me to provide a combo patch ? No, that's not necessary. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Thu, 08 Oct 2009 05:11:23 +0200 > [PATCH] net: Add netdev_alloc_skb_ip_align() helper > > Instead of hardcoding NET_IP_ALIGN stuff in various network drivers, we can > add a helper around netdev_alloc_skb() > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Applied to net-next-2.6 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index df7b23a..fed788e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1489,6 +1489,16 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev, return __netdev_alloc_skb(dev, length, GFP_ATOMIC); } +static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length) +{ + struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN); + + if (NET_IP_ALIGN && skb) + skb_reserve(skb, NET_IP_ALIGN); + return skb; +} + extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask); /**