Staging: hv: handle skb allocation failure
Some fixes to receive handling: * Dieing with assertion failure when running out of memory is not ok * Use newer alloc function to get aligned skb * Dropped statistic is supposed to be incremented only by driver it was responsible for the drop. Compile tested only. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Cc: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b852fdcefc
commit
9495c282ba
@@ -294,7 +294,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
|
|||||||
struct net_device_context *net_device_ctx;
|
struct net_device_context *net_device_ctx;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
void *data;
|
void *data;
|
||||||
int ret;
|
|
||||||
int i;
|
int i;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
@@ -308,12 +307,12 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
|
|||||||
|
|
||||||
net_device_ctx = netdev_priv(net);
|
net_device_ctx = netdev_priv(net);
|
||||||
|
|
||||||
/* Allocate a skb - TODO preallocate this */
|
/* Allocate a skb - TODO direct I/O to pages? */
|
||||||
/* Pad 2-bytes to align IP header to 16 bytes */
|
skb = netdev_alloc_skb_ip_align(net, packet->TotalDataBufferLength);
|
||||||
skb = dev_alloc_skb(packet->TotalDataBufferLength + 2);
|
if (unlikely(!skb)) {
|
||||||
ASSERT(skb);
|
++net->stats.rx_dropped;
|
||||||
skb_reserve(skb, 2);
|
return 0;
|
||||||
skb->dev = net;
|
}
|
||||||
|
|
||||||
/* for kmap_atomic */
|
/* for kmap_atomic */
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
@@ -338,25 +337,18 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
|
|||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
|
|
||||||
skb->protocol = eth_type_trans(skb, net);
|
skb->protocol = eth_type_trans(skb, net);
|
||||||
|
|
||||||
skb->ip_summed = CHECKSUM_NONE;
|
skb->ip_summed = CHECKSUM_NONE;
|
||||||
|
|
||||||
|
net->stats.rx_packets++;
|
||||||
|
net->stats.rx_bytes += skb->len;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass the skb back up. Network stack will deallocate the skb when it
|
* Pass the skb back up. Network stack will deallocate the skb when it
|
||||||
* is done
|
* is done.
|
||||||
|
* TODO - use NAPI?
|
||||||
*/
|
*/
|
||||||
ret = netif_rx(skb);
|
netif_rx(skb);
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case NET_RX_DROP:
|
|
||||||
net->stats.rx_dropped++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
net->stats.rx_packets++;
|
|
||||||
net->stats.rx_bytes += skb->len;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
|
DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
|
||||||
net->stats.rx_packets, net->stats.rx_bytes);
|
net->stats.rx_packets, net->stats.rx_bytes);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user