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

* Re: [PATCH] consolidate skb delivery
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2003-10-02 19:25 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David S. Miller, netdev

> +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);

Are there even any old style protocols left? If not you could just make
it BUG() 

-Andi

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

* Re: [PATCH] consolidate skb delivery
  2003-10-02 19:25 ` Andi Kleen
@ 2003-10-02 19:43   ` Stephen Hemminger
  2003-10-03  7:11     ` David S. Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2003-10-02 19:43 UTC (permalink / raw)
  To: Andi Kleen; +Cc: David S. Miller, netdev

On Thu, 2 Oct 2003 21:25:46 +0200
Andi Kleen <ak@suse.de> wrote:

> > +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);
> 
> Are there even any old style protocols left? If not you could just make
> it BUG() 
> 

bpqether,lapbether,ipconfig, and econet are still old style.

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

* Re: [PATCH] consolidate skb delivery
  2003-10-02 19:43   ` Stephen Hemminger
@ 2003-10-03  7:11     ` David S. Miller
  2003-10-07 10:40       ` David S. Miller
  0 siblings, 1 reply; 5+ messages in thread
From: David S. Miller @ 2003-10-03  7:11 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: ak, netdev

On Thu, 2 Oct 2003 12:43:45 -0700
Stephen Hemminger <shemminger@osdl.org> wrote:

> On Thu, 2 Oct 2003 21:25:46 +0200
> Andi Kleen <ak@suse.de> wrote:
> 
> > Are there even any old style protocols left? If not you could just make
> > it BUG() 
> > 
> 
> bpqether,lapbether,ipconfig, and econet are still old style.

I would suggest we eliminate support for old style protocols
now.  We can do that by making the ptype registry in net/core/dev.c
fail if the thing being registered is old-style.

I'll code this up.

If we don't kill support for old-style protocols now, we can end up
being stuck supporting it throughout 2.6.x which I'd like to avoid.

I'll apply Stephen's patch here.

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

* Re: [PATCH] consolidate skb delivery
  2003-10-03  7:11     ` David S. Miller
@ 2003-10-07 10:40       ` David S. Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2003-10-07 10:40 UTC (permalink / raw)
  To: David S. Miller; +Cc: shemminger, ak, netdev

On Fri, 3 Oct 2003 00:11:28 -0700
"David S. Miller" <davem@redhat.com> wrote:

> I would suggest we eliminate support for old style protocols
> now.  We can do that by making the ptype registry in net/core/dev.c
> fail if the thing being registered is old-style.
> 
> I'll code this up.

Ok, as it turns out, instead I converted all the old-style
protocols.  When things seemed really complex or hard to
convert easily I just put:

	nskb = skb_copy(skb, GFP_ATOMIC);
	if (!nskb)
		goto drop;
	kfree_skb(skb);
	skb = nskb;

at the top of the input handler.  The only instance that I did
this for actually was x25.

^ 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).