From: Nikolay Aleksandrov <nikolay@redhat.com>
To: Veaceslav Falico <vfalico@redhat.com>
Cc: netdev@vger.kernel.org, Jay Vosburgh <fubar@us.ibm.com>,
Andy Gospodarek <andy@greyhouse.net>
Subject: Re: [PATCH v2 net-next 5/6] bonding: convert bond_arp_send_all to use bond->dev->vlan_info
Date: Fri, 09 Aug 2013 13:42:39 +0200 [thread overview]
Message-ID: <5204D5AF.9080702@redhat.com> (raw)
In-Reply-To: <1375981079-2936-6-git-send-email-vfalico@redhat.com>
On 08/08/2013 06:57 PM, Veaceslav Falico wrote:
> RFC -> v1: use the new __vlan_find_dev_next(), also release rcu_read_lock()
> only after we stop using the vlan_dev.
> v1 -> v2: no change.
>
> Instead of looping through bond->vlan_list, loop through
> bond->dev->vlan_info via __vlan_find_dev_next() under rcu_read_lock().
>
> CC: Jay Vosburgh <fubar@us.ibm.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> ---
> drivers/net/bonding/bond_main.c | 29 +++++++++++++----------------
> 1 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index e52e2d5..f536d05 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2440,11 +2440,10 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
>
> static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
> {
> - int i, vlan_id;
> - __be32 *targets = bond->params.arp_targets;
> - struct vlan_entry *vlan;
> - struct net_device *vlan_dev = NULL;
> + struct net_device *vlan_dev;
> struct rtable *rt;
> + __be32 *targets = bond->params.arp_targets;
> + int i;
>
Style nitpick: maybe move them longest -> shortest.
> for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
> __be32 addr;
> @@ -2486,28 +2485,26 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
> continue;
> }
>
> - vlan_id = 0;
> - list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
> - rcu_read_lock();
> - vlan_dev = __vlan_find_dev_deep(bond->dev,
> - htons(ETH_P_8021Q),
> - vlan->vlan_id);
> - rcu_read_unlock();
> + vlan_dev = NULL;
> +
> + rcu_read_lock();
> + while ((vlan_dev = __vlan_find_dev_next(bond->dev, vlan_dev)))
> if (vlan_dev == rt->dst.dev) {
> - vlan_id = vlan->vlan_id;
> pr_debug("basa: vlan match on %s %d\n",
> - vlan_dev->name, vlan_id);
> + vlan_dev->name,
> + vlan_dev_vlan_id(vlan_dev));
> break;
> }
> - }
>
> - if (vlan_id && vlan_dev) {
> + if (vlan_dev) {
> ip_rt_put(rt);
> addr = bond_confirm_addr(vlan_dev, targets[i], 0);
> bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
> - addr, vlan_id);
> + addr, vlan_dev_vlan_id(vlan_dev));
> + rcu_read_unlock();
> continue;
> }
> + rcu_read_unlock();
>
I think these lines can be re-arranged to something shorter like:
rcu_read_lock();
vlan_dev = NULL;
while ((vlan_dev = __vlan_find_dev_next(bond->dev, vlan_dev)))
if (vlan_dev == rt->dst.dev) {
pr_debug("basa: vlan match on %s %d\n",
vlan_dev->name,
vlan_dev_vlan_id(vlan_dev));
break;
}
if (vlan_dev) {
ip_rt_put(rt);
addr = bond_confirm_addr(vlan_dev, targets[i], 0);
bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
addr, vlan_dev_vlan_id(vlan_dev));
} else {
if (net_ratelimit())
pr_warning("%s: no path to arp_ip_target %pI4 via
rt.dev %s\n",
bond->dev->name, &targets[i],
rt->dst.dev ? rt->dst.dev->name : "NULL");
ip_rt_put(rt);
}
rcu_read_unlock();
But either way is fine, I just think this one is more readable.
Cheers,
Nik
next prev parent reply other threads:[~2013-08-09 11:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 16:57 [PATCH net-next v2 0/6] bonding: remove bond->vlan_list Veaceslav Falico
2013-08-08 16:57 ` [PATCH v2 net-next 1/6] bonding: add rcu to vlan_uses_dev() and make bond_vlan_used() use it Veaceslav Falico
2013-08-09 11:06 ` Nikolay Aleksandrov
2013-08-09 11:11 ` Veaceslav Falico
2013-08-08 16:57 ` [PATCH v2 net-next 2/6] vlan: add __vlan_find_dev_next() Veaceslav Falico
2013-08-09 7:30 ` Veaceslav Falico
2013-08-09 11:07 ` Nikolay Aleksandrov
2013-08-14 15:28 ` Veaceslav Falico
2013-08-08 16:57 ` [PATCH v2 net-next 3/6] bonding: make bond_alb use 8021q's dev->vlan_info instead of vlan_list Veaceslav Falico
2013-08-09 11:13 ` Nikolay Aleksandrov
2013-08-09 11:24 ` Veaceslav Falico
2013-08-08 16:57 ` [PATCH v2 net-next 4/6] bonding: convert bond_has_this_ip to use bond->dev->vlan_info Veaceslav Falico
2013-08-08 16:57 ` [PATCH v2 net-next 5/6] bonding: convert bond_arp_send_all " Veaceslav Falico
2013-08-09 11:42 ` Nikolay Aleksandrov [this message]
2013-08-08 16:57 ` [PATCH v2 net-next 6/6] bonding: remove unused bond->vlan_list Veaceslav Falico
2013-08-09 11:44 ` Nikolay Aleksandrov
2013-08-26 16:31 ` [PATCH net-next v2 0/6] bonding: remove bond->vlan_list Veaceslav Falico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5204D5AF.9080702@redhat.com \
--to=nikolay@redhat.com \
--cc=andy@greyhouse.net \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=vfalico@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).