From: Nikolay Aleksandrov <nikolay@redhat.com>
To: netdev@vger.kernel.org
Cc: andy@greyhouse.net, davem@davemloft.net, fubar@us.ibm.com
Subject: [PATCH net-next 3/5] bonding: simplify broadcast_xmit function
Date: Wed, 31 Jul 2013 17:12:31 +0200 [thread overview]
Message-ID: <1375283553-32070-4-git-send-email-nikolay@redhat.com> (raw)
In-Reply-To: <1375283553-32070-1-git-send-email-nikolay@redhat.com>
From: Nikolay Aleksandrov <razor@BlackWall.org>
We don't need to start from the curr_active_slave as the frame will be
sent to all eligible slaves anyway, so we remove the unnecessary local
variables, checks and comments, and make it use the standard list API.
This has the nice side-effect that later when it's converted to RCU
a race condition will be avoided which could lead to double packet tx.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
drivers/net/bonding/bond_main.c | 52 +++++++++++++----------------------------
1 file changed, 16 insertions(+), 36 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 92f8aed..5b58d08 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3916,52 +3916,32 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
return NETDEV_TX_OK;
}
-/*
- * in broadcast mode, we send everything to all usable interfaces.
- */
+/* in broadcast mode, we send everything to all usable interfaces. */
static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
- struct slave *slave, *start_at;
- struct net_device *tx_dev = NULL;
- int i;
- int res = 1;
-
- start_at = bond->curr_active_slave;
- if (!start_at)
- goto out;
+ struct slave *slave = NULL;
- bond_for_each_slave_from(bond, slave, i, start_at) {
- if (IS_UP(slave->dev) &&
- (slave->link == BOND_LINK_UP) &&
- bond_is_active_slave(slave)) {
- if (tx_dev) {
- struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
- if (!skb2) {
- pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
- bond_dev->name);
- continue;
- }
+ list_for_each_entry(slave, &bond->slave_list, list) {
+ if (slave->list.next == &bond->slave_list)
+ break;
+ if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP) {
+ struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
- res = bond_dev_queue_xmit(bond, skb2, tx_dev);
- if (res) {
- kfree_skb(skb2);
- continue;
- }
+ if (!skb2) {
+ pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
+ bond_dev->name);
+ continue;
}
- tx_dev = slave->dev;
+ /* bond_dev_queue_xmit always returns 0 */
+ bond_dev_queue_xmit(bond, skb2, slave->dev);
}
}
-
- if (tx_dev)
- res = bond_dev_queue_xmit(bond, skb, tx_dev);
-
-out:
- if (res)
- /* no suitable interface, frame not sent */
+ if (slave && IS_UP(slave->dev) && slave->link == BOND_LINK_UP)
+ bond_dev_queue_xmit(bond, skb, slave->dev);
+ else
kfree_skb(skb);
- /* frame sent to all suitable interfaces */
return NETDEV_TX_OK;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-07-31 15:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 15:12 [PATCH net-next 0/5] bonding: groundwork and initial conversion to RCU Nikolay Aleksandrov
2013-07-31 15:12 ` [PATCH net-next 1/5] bonding: convert to list API and replace bond's custom list Nikolay Aleksandrov
2013-07-31 18:28 ` Jay Vosburgh
2013-07-31 18:42 ` Nikolay Aleksandrov
2013-07-31 18:37 ` Stephen Hemminger
2013-07-31 18:44 ` Nikolay Aleksandrov
2013-07-31 18:56 ` Stephen Hemminger
2013-07-31 19:00 ` Nikolay Aleksandrov
2013-07-31 18:38 ` Stephen Hemminger
2013-07-31 18:49 ` Nikolay Aleksandrov
2013-07-31 15:12 ` [PATCH net-next 2/5] bonding: remove unnecessary read_locks of curr_slave_lock Nikolay Aleksandrov
2013-07-31 15:12 ` Nikolay Aleksandrov [this message]
2013-07-31 15:12 ` [PATCH net-next 4/5] bonding: factor out slave id tx code and simplify xmit paths Nikolay Aleksandrov
2013-07-31 15:12 ` [PATCH net-next 5/5] bonding: initial RCU conversion Nikolay Aleksandrov
2013-08-01 6:46 ` Ding Tianhong
2013-08-01 7:55 ` Nikolay Aleksandrov
2013-07-31 15:27 ` [PATCH net-next 0/5] bonding: groundwork and initial conversion to RCU Eric Dumazet
2013-07-31 15:39 ` Nikolay Aleksandrov
2013-07-31 18:03 ` Jiri Pirko
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=1375283553-32070-4-git-send-email-nikolay@redhat.com \
--to=nikolay@redhat.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
/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).