* [PATCH net 2/2] bonding: rename the dev upper link if the master's, name changed
@ 2014-01-13 13:08 Ding Tianhong
2014-01-13 17:54 ` Sergei Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: Ding Tianhong @ 2014-01-13 13:08 UTC (permalink / raw)
To: Jay Vosburgh, Veaceslav Falico, Eric Dumazet, David S. Miller,
Netdev
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@huawei.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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net 2/2] bonding: rename the dev upper link if the master's, name changed
2014-01-13 13:08 [PATCH net 2/2] bonding: rename the dev upper link if the master's, name changed Ding Tianhong
@ 2014-01-13 17:54 ` Sergei Shtylyov
2014-01-14 1:49 ` Ding Tianhong
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2014-01-13 17:54 UTC (permalink / raw)
To: Ding Tianhong, Jay Vosburgh, Veaceslav Falico, Eric Dumazet,
David S. Miller, Netdev
On 13-01-2014 17:08, Ding Tianhong wrote:
> The bond_maste_rename() will rename the links for slave dev's upper dev link,
s/maste/master/.
> if faild, it will rollback and rename the new name to old name for slave dev.
s/faild/failed/.
> Add a new parameter called name to save the old bonding name in struct bonding.
> Signed-off-by: Ding Tianhong <dingtianhong@huawei.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];
Perhaps s/ori/old/ is better?
> + 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) {
> +
No need for this empty line, I think.
> + err = netdev_upper_dev_rename(slave->dev, bond->dev, ori_linkname,
> + new_linkname);
The continuation line should start right under 'slave' on the broken up line.
WBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net 2/2] bonding: rename the dev upper link if the master's, name changed
2014-01-13 17:54 ` Sergei Shtylyov
@ 2014-01-14 1:49 ` Ding Tianhong
0 siblings, 0 replies; 3+ messages in thread
From: Ding Tianhong @ 2014-01-14 1:49 UTC (permalink / raw)
To: Sergei Shtylyov, Jay Vosburgh, Veaceslav Falico, Eric Dumazet,
David S. Miller, Netdev
On 2014/1/14 1:54, Sergei Shtylyov wrote:
> On 13-01-2014 17:08, Ding Tianhong wrote:
>
>> The bond_maste_rename() will rename the links for slave dev's upper dev link,
>
> s/maste/master/.
>
>> if faild, it will rollback and rename the new name to old name for slave dev.
>
> s/faild/failed/.
>
>> Add a new parameter called name to save the old bonding name in struct bonding.
>
>> Signed-off-by: Ding Tianhong <dingtianhong@huawei.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];
>
> Perhaps s/ori/old/ is better?
>
>> + 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) {
>> +
>
> No need for this empty line, I think.
>
>> + err = netdev_upper_dev_rename(slave->dev, bond->dev, ori_linkname,
>> + new_linkname);
>
> The continuation line should start right under 'slave' on the broken up line.
>
> WBR, Sergei
>
>
Yes, thanks.
Regards
Ding
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-14 1:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 13:08 [PATCH net 2/2] bonding: rename the dev upper link if the master's, name changed Ding Tianhong
2014-01-13 17:54 ` Sergei Shtylyov
2014-01-14 1:49 ` Ding Tianhong
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).