consolidate skb delivery
Subsystems (2)
PATCH 1/1 consolidate skb delivery
Several places all have the same code for delivering skb's to protocols. Consolidate into one inline function and give preference to new protocols.
net/core/dev.c +21 -36
@@ -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. :-)
net/core/dev.c line 1496
Quoted 5 lines
net/core/dev.c +5
-0+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
Quoted 9 lines · On Thu, 2 Oct 2003 21:25:46 +0200 Andi Kleen <[email protected]> wrote:
net/core/dev.c line 1496
Quoted 5 lines
net/core/dev.c +5
-0+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.
Quoted 8 lines · On Thu, 2 Oct 2003 12:43:45 -0700 Stephen Hemminger <[email protected]> wrote:
Quoted 3 lines · On Thu, 2 Oct 2003 21:25:46 +0200 Andi Kleen <[email protected]> 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.
Quoted 5 lines · On Fri, 3 Oct 2003 00:11:28 -0700 "David S. Miller" <[email protected]> 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.cfail 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.