Skip to contentSkip to conversation

netpoll: don't send packets to detached device

PATCH New Stephen Hemminger 1 participant 2 messages Oct 18, 2006

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

PATCH 1/1 netpoll: don't send packets to detached device

Netpoll shouldn't send packets to devices that have detached themselves. This can happen during shutdown or suspend.

net/core/netpoll.c +1 -1
@@ -273,7 +273,7 @@
 	int status;
 	struct netpoll_info *npinfo;
 
-	if (!np || !np->dev || !netif_running(np->dev)) {
+	if (!np || !np->dev || !netif_device_present(np->dev) || !netif_running(np->dev)) {
 		__kfree_skb(skb);
 		return;
 	}
#1 lore raw

PATCH 1/1 netpoll: netpoll_send_skb local optimization

This cleans up netpoll_send_skb:
* np and np->dev are always non-null given the local callers
* get device into a local variable

net/core/netpoll.c +8 -8
@@ -270,19 +270,19 @@
 
 static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
+	struct net_device *dev = np->dev;
+	struct netpoll_info *npinfo = dev->npinfo;
 	int status;
-	struct netpoll_info *npinfo;
 
-	if (!np || !np->dev || !netif_device_present(np->dev) || !netif_running(np->dev)) {
+	if (!netif_device_present(dev) || !netif_running(dev)) {
 		__kfree_skb(skb);
 		return;
 	}
 
-	npinfo = np->dev->npinfo;
 
 	/* avoid recursion */
 	if (npinfo->poll_owner == smp_processor_id() ||
-	    np->dev->xmit_lock_owner == smp_processor_id()) {
+	    dev->xmit_lock_owner == smp_processor_id()) {
 		if (np->drop)
 			np->drop(skb);
 		else
@@ -292,17 +292,17 @@
 
 	do {
 		npinfo->tries--;
-		netif_tx_lock(np->dev);
+		netif_tx_lock(dev);
 
 		/*
 		 * network drivers do not expect to be called if the queue is
 		 * stopped.
 		 */
 		status = NETDEV_TX_BUSY;
-		if (!netif_queue_stopped(np->dev))
-			status = np->dev->hard_start_xmit(skb, np->dev);
+		if (!netif_queue_stopped(dev))
+			status = dev->hard_start_xmit(skb, dev);
 
-		netif_tx_unlock(np->dev);
+		netif_tx_unlock(dev);
 
 		/* success */
 		if(!status) {