summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@redhat.com>2014-01-14 21:58:51 +0100
committerDavid S. Miller <davem@davemloft.net>2014-01-16 00:16:20 +0100
commit5bb025fae53889cc99a21058c5dd369bf8cce820 (patch)
treecc80601cdb7096b9dc4d9d5f14eb477c4dd82322 /net/core
parentnet: add sysfs helpers for netdev_adjacent logic (diff)
downloadlinux-5bb025fae53889cc99a21058c5dd369bf8cce820.tar.xz
linux-5bb025fae53889cc99a21058c5dd369bf8cce820.zip
net: rename sysfs symlinks on device name change
Currently, we don't rename the upper/lower_ifc symlinks in /sys/class/net/*/ , which might result stale/duplicate links/names. Fix this by adding netdev_adjacent_rename_links(dev, oldname) which renames all the upper/lower interface's links to dev from the upper/lower_oldname to the new name. We don't need a rollback because only we control these symlinks and if we fail to rename them - sysfs will anyway complain. Reported-by: Ding Tianhong <dingtianhong@huawei.com> CC: Ding Tianhong <dingtianhong@huawei.com> CC: "David S. Miller" <davem@davemloft.net> CC: Eric Dumazet <edumazet@google.com> CC: Nicolas Dichtel <nicolas.dichtel@6wind.com> CC: Cong Wang <amwang@redhat.com> Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 130d3bd0ce6f..995755733997 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1119,6 +1119,8 @@ rollback:
write_seqcount_end(&devnet_rename_seq);
+ netdev_adjacent_rename_links(dev, oldname);
+
write_lock_bh(&dev_base_lock);
hlist_del_rcu(&dev->name_hlist);
write_unlock_bh(&dev_base_lock);
@@ -1138,6 +1140,7 @@ rollback:
err = ret;
write_seqcount_begin(&devnet_rename_seq);
memcpy(dev->name, oldname, IFNAMSIZ);
+ memcpy(oldname, newname, IFNAMSIZ);
goto rollback;
} else {
pr_err("%s: name change rollback failed: %d\n",
@@ -4999,6 +5002,25 @@ void netdev_upper_dev_unlink(struct net_device *dev,
}
EXPORT_SYMBOL(netdev_upper_dev_unlink);
+void netdev_adjacent_rename_links(struct net_device *dev, char *oldname)
+{
+ struct netdev_adjacent *iter;
+
+ list_for_each_entry(iter, &dev->adj_list.upper, list) {
+ netdev_adjacent_sysfs_del(iter->dev, oldname,
+ &iter->dev->adj_list.lower);
+ netdev_adjacent_sysfs_add(iter->dev, dev,
+ &iter->dev->adj_list.lower);
+ }
+
+ list_for_each_entry(iter, &dev->adj_list.lower, list) {
+ netdev_adjacent_sysfs_del(iter->dev, oldname,
+ &iter->dev->adj_list.upper);
+ netdev_adjacent_sysfs_add(iter->dev, dev,
+ &iter->dev->adj_list.upper);
+ }
+}
+
void *netdev_lower_dev_get_private(struct net_device *dev,
struct net_device *lower_dev)
{