netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] consolidate skb delivery
@ 2003-10-02 17:21 Stephen Hemminger
  2003-10-02 19:25 ` Andi Kleen
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2003-10-02 17:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

Several places all have the same code for delivering skb's to protocols.
Consolidate into one inline function and give preference to new protocols.

diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c	Thu Oct  2 10:01:13 2003
+++ b/net/core/dev.c	Thu Oct  2 10:01:13 2003
@@ -1489,6 +1489,18 @@
 	}
 }
 
+static __inline__ int deliver_skb(struct sk_buff *skb,
+				  struct packet_type *pt_prev, int last)
+{
+	if (unlikely(!pt_prev->data))
+		return deliver_to_old_ones(pt_prev, skb, last);
+	else {
+		atomic_inc(&skb->users);
+		return pt_prev->func(skb, skb->dev, pt_prev);
+	}
+}
+
+
 #if defined(CONFIG_BRIDGE) || defined (CONFIG_BRIDGE_MODULE)
 int (*br_handle_frame_hook)(struct sk_buff *skb);
 
@@ -1496,15 +1508,8 @@
 				     struct packet_type *pt_prev)
 {
 	int ret = NET_RX_DROP;
-
-	if (pt_prev) {
-		if (!pt_prev->data)
-			ret = deliver_to_old_ones(pt_prev, skb, 0);
-		else {
-			atomic_inc(&skb->users);
-			ret = pt_prev->func(skb, skb->dev, pt_prev);
-		}
-	}
+	if (pt_prev)
+		ret = deliver_skb(skb, pt_prev, 0);
 
 	return ret;
 }
@@ -1552,16 +1557,8 @@
 	rcu_read_lock();
 	list_for_each_entry_rcu(ptype, &ptype_all, list) {
 		if (!ptype->dev || ptype->dev == skb->dev) {
-			if (pt_prev) {
-				if (!pt_prev->data) {
-					ret = deliver_to_old_ones(pt_prev,
-								  skb, 0);
-				} else {
-					atomic_inc(&skb->users);
-					ret = pt_prev->func(skb, skb->dev,
-							    pt_prev);
-				}
-			}
+			if (pt_prev) 
+				ret = deliver_skb(skb, pt_prev, 0);
 			pt_prev = ptype;
 		}
 	}
@@ -1574,27 +1571,15 @@
 	list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) {
 		if (ptype->type == type &&
 		    (!ptype->dev || ptype->dev == skb->dev)) {
-			if (pt_prev) {
-				if (!pt_prev->data) {
-					ret = deliver_to_old_ones(pt_prev,
-								  skb, 0);
-				} else {
-					atomic_inc(&skb->users);
-					ret = pt_prev->func(skb, skb->dev,
-							    pt_prev);
-				}
-			}
+			if (pt_prev) 
+				ret = deliver_skb(skb, pt_prev, 0);
 			pt_prev = ptype;
 		}
 	}
 
-	if (pt_prev) {
-		if (!pt_prev->data) {
-			ret = deliver_to_old_ones(pt_prev, skb, 1);
-		} else {
-			ret = pt_prev->func(skb, skb->dev, pt_prev);
-		}
-	} else {
+	if (pt_prev)
+		ret = deliver_skb(skb, pt_prev, 1);
+	else {
 		kfree_skb(skb);
 		/* Jamal, now you will not able to escape explaining
 		 * me how you were going to use this. :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-07 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-02 17:21 [PATCH] consolidate skb delivery Stephen Hemminger
2003-10-02 19:25 ` Andi Kleen
2003-10-02 19:43   ` Stephen Hemminger
2003-10-03  7:11     ` David S. Miller
2003-10-07 10:40       ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).