[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <52D3E55B.8080401@huawei.com>
Date: Mon, 13 Jan 2014 21:08:43 +0800
From: Ding Tianhong <dingtianhong@...wei.com>
To: Jay Vosburgh <fubar@...ibm.com>,
Veaceslav Falico <vfalico@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Netdev <netdev@...r.kernel.org>
Subject: [PATCH net 2/2] bonding: rename the dev upper link if the master's,
name changed
The bond_maste_rename() will rename the links for slave dev's upper dev link,
if faild, it will rollback and rename the new name to old name for slave dev.
Add a new parameter called name to save the old bonding name in struct bonding.
Signed-off-by: Ding Tianhong <dingtianhong@...wei.com>
---
drivers/net/bonding/bond_main.c | 35 +++++++++++++++++++++++++++++++++++
drivers/net/bonding/bonding.h | 1 +
2 files changed, 36 insertions(+)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4b8c58b..8c044c0 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2799,11 +2799,41 @@ re_arm:
/*-------------------------- netdev event handling --------------------------*/
+static int bond_master_rename(struct bonding *bond)
+{
+ struct slave *slave;
+ struct list_head *iter;
+ char ori_linkname[IFNAMSIZ + 7], new_linkname[IFNAMSIZ + 7];
+ int err = 0;
+
+ sprintf(ori_linkname, "upper_%s", bond->name);
+ sprintf(new_linkname, "upper_%s", bond->dev->name);
+
+ bond_for_each_slave(bond, slave, iter) {
+
+ err = netdev_upper_dev_rename(slave->dev, bond->dev, ori_linkname,
+ new_linkname);
+ if (err) {
+ pr_err("slave %s unable to rename link %s to %s.\n",
+ slave->dev->name, bond->name, bond->dev->name);
+ break;
+ }
+ }
+ if (!err)
+ strlcpy(bond->name, bond->dev->name, IFNAMSIZ);
+ return err;
+}
/*
* Change device name
*/
static int bond_event_changename(struct bonding *bond)
{
+ /* If a rename fails, the rollback will cause another
+ * rename call with the existing name.
+ */
+ if (bond_master_rename(bond))
+ return NOTIFY_BAD;
+
bond_remove_proc_entry(bond);
bond_create_proc_entry(bond);
@@ -4418,6 +4448,7 @@ unsigned int bond_get_num_tx_queues(void)
int bond_create(struct net *net, const char *name)
{
struct net_device *bond_dev;
+ struct bonding *bond;
int res;
rtnl_lock();
@@ -4438,6 +4469,10 @@ int bond_create(struct net *net, const char *name)
netif_carrier_off(bond_dev);
+ bond = netdev_priv(bond_dev);
+
+ strlcpy(bond->name, bond_dev->name, IFNAMSIZ);
+
rtnl_unlock();
if (res < 0)
bond_destructor(bond_dev);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index a9f4f9f..d279f3a 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -232,6 +232,7 @@ struct bonding {
struct proc_dir_entry *proc_entry;
char proc_file_name[IFNAMSIZ];
#endif /* CONFIG_PROC_FS */
+ char name[IFNAMSIZ];
struct list_head bond_list;
u32 rr_tx_counter;
struct ad_bond_info ad_info;
--
1.8.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists