From: Tom Gundersen <teg@jklm.no>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org, Tom Gundersen <teg@jklm.no>
Subject: [PATCH v9 2/4] net: set name assign type for renamed devices
Date: Mon, 14 Jul 2014 16:37:23 +0200 [thread overview]
Message-ID: <1405348645-1995-2-git-send-email-teg@jklm.no> (raw)
In-Reply-To: <1405348645-1995-1-git-send-email-teg@jklm.no>
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>
---
net/core/dev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 30eedf6..80ae059 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",
--
1.9.3
next prev parent reply other threads:[~2014-07-14 14:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 14:37 [PATCH v9 1/4] net: add name_assign_type netdev attribute Tom Gundersen
2014-07-14 14:37 ` Tom Gundersen [this message]
2014-07-15 23:18 ` [PATCH v9 2/4] net: set name assign type for renamed devices David Miller
2014-07-14 14:37 ` [PATCH v9 3/4] net: set name_assign_type in alloc_netdev() Tom Gundersen
2014-07-15 23:18 ` David Miller
2014-07-17 18:20 ` Andrey Utkin
2014-07-14 14:37 ` [PATCH v9 4/4] net: rtnetlink - make create_link take name_assign_type Tom Gundersen
2014-07-15 23:19 ` David Miller
2014-07-15 23:18 ` [PATCH v9 1/4] net: add name_assign_type netdev attribute David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405348645-1995-2-git-send-email-teg@jklm.no \
--to=teg@jklm.no \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).