Skip to contentSkip to conversation

ndisc: use netdev_alloc_skb

PATCH In review Stephen Hemminger 2 participants 3 messages Jun 11, 2014

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

PATCH 1/1 ndisc: use netdev_alloc_skb

IPv6 neighbor discovery should use netdev_alloc_skb which adds extra space for headroom. The old code would allocate packet w/o any additional headroom and force drivers to reallocate and copy the packet in some cases.

net/ipv6/ndisc.c +1 -2
@@ -375,7 +375,7 @@ static struct sk_buff *ndisc_alloc_skb(s
 	struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
 	struct sk_buff *skb;
 
-	skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
+	skb = netdev_alloc_skb(dev, hlen + sizeof(struct ipv6hdr) + len + tlen);
 	if (!skb) {
 		ND_PRINTK(0, err, "ndisc: %s failed to allocate an skb\n",
 			  __func__);
@@ -383,7 +383,6 @@ static struct sk_buff *ndisc_alloc_skb(s
 	}
 
 	skb->protocol = htons(ETH_P_IPV6);
-	skb->dev = dev;
 
 	skb_reserve(skb, hlen + sizeof(struct ipv6hdr));
 	skb_reset_transport_header(skb);
#1 lore raw
Quoted 11 lines · Stephen Hemminger

IPv6 neighbor discovery should use netdev_alloc_skb which adds extra space for headroom. The old code would allocate packet w/o any additional headroom and force drivers to reallocate and copy the packet in some cases.

net/ipv6/ndisc.c static struct sk_buff *ndisc_alloc_skb(s · line 379

Quoted 6 lines
net/ipv6/ndisc.c +1 -1
@@ -375,7 +375,7 @@ static struct sk_buff *ndisc_alloc_skb(s
 	struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
 	struct sk_buff *skb;
 
-	skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
+	skb = netdev_alloc_skb(dev, hlen + sizeof(struct ipv6hdr) + len + tlen);
 	if (!skb) {

This looks strange.

netdev_alloc_skb() is mostly used for RX.

Perhaps you need to increase hlen with the needed room, because NET_SKB_PAD might be only 32, and its a bit hidden.

ie use LL_RESERVED_SPACE_EXTRA() instead of LL_RESERVED_SPACE(), to make clear what the intentions are.

#2 lore raw
Quoted 21 lines · On Wed, 11 Jun 2014 12:58:22 -0700 Eric Dumazet <[email protected]> wrote:
Quoted 11 lines · Stephen Hemminger

IPv6 neighbor discovery should use netdev_alloc_skb which adds extra space for headroom. The old code would allocate packet w/o any additional headroom and force drivers to reallocate and copy the packet in some cases.

net/ipv6/ndisc.c static struct sk_buff *ndisc_alloc_skb(s · line 379

Quoted 6 lines
net/ipv6/ndisc.c +1 -1
@@ -375,7 +375,7 @@ static struct sk_buff *ndisc_alloc_skb(s
 	struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
 	struct sk_buff *skb;
 
-	skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
+	skb = netdev_alloc_skb(dev, hlen + sizeof(struct ipv6hdr) + len + tlen);
 	if (!skb) {

This looks strange.

Quoted 7 lines

netdev_alloc_skb() is mostly used for RX.

Perhaps you need to increase hlen with the needed room, because NET_SKB_PAD might be only 32, and its a bit hidden.

ie use LL_RESERVED_SPACE_EXTRA() instead of LL_RESERVED_SPACE(), to make clear what the intentions are.

Never mind, I just saw a packet w/o space show up. It was because of bad driver hard header len