bonding: rename the dev upper link if the master's, name changed
Subsystems (3)
PATCH 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.
--- drivers/net/bonding/bond_main.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/bonding/bonding.h | 1 + 2 files changed, 36 insertions(+)
drivers/net/bonding/bond_main.c +35 -0
@@ -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);
drivers/net/bonding/bonding.h +1 -0
@@ -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;
Signature · 1 line
1.8.0
Quoted 1 line · Ding Tianhong
The
bond_maste_rename()will rename the links for slave dev's upper dev link,
s/maste/master/.
Quoted 1 line
if faild, it will rollback and rename the new name to old name for slave dev.
s/faild/failed/.
Quoted 13 lines
Add a new parameter called name to save the old bonding name in struct bonding.
Signed-off-by Ding Tianhong <[email protected]>--- drivers/net/bonding/bond_main.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/bonding/bonding.h | 1 + 2 files changed, 36 insertions(+)drivers/net/bonding/bond_main.c +0
-0
drivers/net/bonding/bond_main.c re_arm: · line 2806
Quoted 8 lines
drivers/net/bonding/bond_main.c +5
-0@@ -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?
drivers/net/bonding/bond_main.c re_arm: · line 2813
Quoted 7 lines
drivers/net/bonding/bond_main.c +7
-0+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.
drivers/net/bonding/bond_main.c re_arm: · line 2815
Quoted 2 lines
drivers/net/bonding/bond_main.c +2
-0+ 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
Quoted 44 lines · Sergei Shtylyov
Quoted 1 line · Ding Tianhong
The
bond_maste_rename()will rename the links for slave dev's upper dev link,s/maste/master/.
Quoted 1 line
if faild, it will rollback and rename the new name to old name for slave dev.
s/faild/failed/.
Quoted 13 lines
Add a new parameter called name to save the old bonding name in struct bonding.
Signed-off-by Ding Tianhong <[email protected]>--- drivers/net/bonding/bond_main.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/bonding/bonding.h | 1 + 2 files changed, 36 insertions(+)drivers/net/bonding/bond_main.c +0
-0drivers/net/bonding/bond_main.c re_arm: · line 2806
Quoted 8 lines
drivers/net/bonding/bond_main.c +5
-0@@ -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?
drivers/net/bonding/bond_main.c re_arm: · line 2813
Quoted 7 lines
drivers/net/bonding/bond_main.c +7
-0+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.
Quoted 8 lines
drivers/net/bonding/bond_main.c re_arm: · line 2815
Quoted 2 lines
drivers/net/bonding/bond_main.c +2
-0+ 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