diff options
author | Tom Gundersen <teg@jklm.no> | 2014-07-14 16:37:23 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-15 16:12:01 -0700 |
commit | 238fa3623a5709d29673ed78ff8e714d040fbb89 (patch) | |
tree | febee5d08cba4e04e37cdc9cb1cbf57abbbfdc84 /net/core | |
parent | 685343fc3ba61a1f6eef361b786601123db16c28 (diff) | |
download | linux-stable-238fa3623a5709d29673ed78ff8e714d040fbb89.tar.gz linux-stable-238fa3623a5709d29673ed78ff8e714d040fbb89.tar.bz2 linux-stable-238fa3623a5709d29673ed78ff8e714d040fbb89.zip |
net: set name assign type for renamed devices
Based on a patch from David Herrmann.
This is the only place devices can be renamed.
v9: restore revers-christmas-tree order of local variables
Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 6e2a2cd82321..38793fb84a35 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1082,6 +1082,7 @@ static int dev_get_valid_name(struct net *net, */ int dev_change_name(struct net_device *dev, const char *newname) { + unsigned char old_assign_type; char oldname[IFNAMSIZ]; int err = 0; int ret; @@ -1109,10 +1110,14 @@ int dev_change_name(struct net_device *dev, const char *newname) return err; } + old_assign_type = dev->name_assign_type; + dev->name_assign_type = NET_NAME_RENAMED; + rollback: ret = device_rename(&dev->dev, dev->name); if (ret) { memcpy(dev->name, oldname, IFNAMSIZ); + dev->name_assign_type = old_assign_type; write_seqcount_end(&devnet_rename_seq); return ret; } @@ -1141,6 +1146,8 @@ rollback: write_seqcount_begin(&devnet_rename_seq); memcpy(dev->name, oldname, IFNAMSIZ); memcpy(oldname, newname, IFNAMSIZ); + dev->name_assign_type = old_assign_type; + old_assign_type = NET_NAME_RENAMED; goto rollback; } else { pr_err("%s: name change rollback failed: %d\n", |