Re: [patch net-next-2.6 V3] net: convert bonding to use rx_handler
From: Nicolas de Pesloüan <hidden>
Date: 2011-02-19 14:32:49
Le 19/02/2011 14:46, Jiri Pirko a écrit :
Sat, Feb 19, 2011 at 02:18:00PM CET, nicolas.2p.debian@gmail.com wrote:
[snip]
quoted
Inside the loop, we should only do exact match delivery, for &ptype_all and for&ptype_base[ntohs(type)& PTYPE_HASH_MASK]: list_for_each_entry_rcu(ptype,&ptype_all, list) { - if (!ptype->dev || ptype->dev == dev) { + if (ptype->dev == dev) { if (pt_prev) ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = ptype; } } list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)& PTYPE_HASH_MASK], list) { if (ptype->type == type&& - (ptype->dev == null_or_dev || ptype->dev == skb->dev)) { + (ptype->dev == skb->dev)) { if (pt_prev) ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = ptype; } } After leaving the loop, we can do wilcard delivery, if skb is not NULL. list_for_each_entry_rcu(ptype,&ptype_all, list) { - if (!ptype->dev || ptype->dev == dev) { + if (!ptype->dev) { if (pt_prev) ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = ptype; } } list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)& PTYPE_HASH_MASK], list) { - if (ptype->type == type&& - (ptype->dev == null_or_dev || ptype->dev == skb->dev)) { + if (ptype->type == type&& !ptype->dev) { if (pt_prev) ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = ptype; } } This would reduce the number of tests inside the list_for_each_entry_rcu() loops. And because we match only ptype->dev == dev inside the loop and !ptype->dev outside the loop, this should avoid duplicate delivery.Would you care to put this into patch so I can see the whole picture? Thanks.
I will try. Nicolas.