diff options
author | David S. Miller <davem@davemloft.net> | 2018-01-02 11:45:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-02 11:50:12 -0500 |
commit | 55a5ec9b77106ffc05e8c40d7568432bf4696d7b (patch) | |
tree | aa0e60df83b27127833b587908be370d6a27fe42 /net/core/dev.c | |
parent | 2758b3e3e630ba304fc4aca434d591e70e528298 (diff) | |
download | linux-55a5ec9b77106ffc05e8c40d7568432bf4696d7b.tar.gz linux-55a5ec9b77106ffc05e8c40d7568432bf4696d7b.tar.bz2 linux-55a5ec9b77106ffc05e8c40d7568432bf4696d7b.zip |
Revert "net: core: dev_get_valid_name is now the same as dev_alloc_name_ns"
This reverts commit 87c320e51519a83c496ab7bfb4e96c8f9c001e89.
Changing the error return code in some situations turns out to
be harmful in practice. In particular Michael Ellerman reports
that DHCP fails on his powerpc machines, and this revert gets
things working again.
Johannes Berg agrees that this revert is the best course of
action for now.
Fixes: 029b6d140550 ("Revert "net: core: maybe return -EEXIST in __dev_alloc_name"")
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 01ee854454a8..0e0ba36eeac9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1146,7 +1146,19 @@ EXPORT_SYMBOL(dev_alloc_name); int dev_get_valid_name(struct net *net, struct net_device *dev, const char *name) { - return dev_alloc_name_ns(net, dev, name); + BUG_ON(!net); + + if (!dev_valid_name(name)) + return -EINVAL; + + if (strchr(name, '%')) + return dev_alloc_name_ns(net, dev, name); + else if (__dev_get_by_name(net, name)) + return -EEXIST; + else if (dev->name != name) + strlcpy(dev->name, name, IFNAMSIZ); + + return 0; } EXPORT_SYMBOL(dev_get_valid_name); |