Skip to contentSkip to conversation

small loopback.c cleanups

PATCH In review Mitchell Blank Jr 2 participants 2 messages Aug 17, 2003

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

PATCH 1/1 small loopback.c cleanups

Few trivial cleanups/improvements to drivers/net/loopback.c Seems to work fine for me, although I don't know how to stress all of the code paths.

Patch is versus 2.6.0-test3 (should apply to current BK fine)

-Mitch

drivers/net/loopback.c +6 -14
@@ -128,17 +128,13 @@
 	 *	instead are lobbed from tx queue to rx queue 
 	 */
 
-	if(atomic_read(&skb->users) != 1)
-	{
+	if (skb_shared(skb)) {
 	  	struct sk_buff *skb2=skb;
 	  	skb=skb_clone(skb, GFP_ATOMIC);		/* Clone the buffer */
-	  	if(skb==NULL) {
-			kfree_skb(skb2);
+		kfree_skb(skb2);
+	  	if (unlikely(skb==NULL))
 			return 0;
-		}
-	  	kfree_skb(skb2);
-	}
-	else
+	} else
 		skb_orphan(skb);
 
 	skb->protocol=eth_type_trans(skb,dev);
@@ -148,12 +144,8 @@
 #endif
 
 	if (skb_shinfo(skb)->tso_size) {
-		struct iphdr *iph = skb->nh.iph;
-
-		if (skb->protocol != htons(ETH_P_IP))
-			BUG();
-		if (iph->protocol != IPPROTO_TCP)
-			BUG();
+		BUG_ON(skb->protocol != htons(ETH_P_IP));
+		BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
 
 		emulate_large_send_offload(skb);
 		return 0;
#1 lore raw
Quoted 4 lines · On Sat, 16 Aug 2003 17:57:06 -0700 Mitchell Blank Jr <[email protected]> wrote:

Few trivial cleanups/improvements to drivers/net/loopback.c Seems to work fine for me, although I don't know how to stress all of the code paths.

Patch is versus 2.6.0-test3 (should apply to current BK fine)

Patch applied, thank you.