summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2017-11-13 00:15:10 +0100
committerDavid S. Miller <davem@davemloft.net>2017-11-14 16:38:46 +0900
commit87c320e51519a83c496ab7bfb4e96c8f9c001e89 (patch)
treeb9ba9a9706210253ef272c349f8a70b10db5bc13 /net
parentd6f295e9def0bee85b37bdffb95153721935c342 (diff)
net: core: dev_get_valid_name is now the same as dev_alloc_name_ns
If name contains a %, it's easy to see that this patch doesn't change anything (other than eliminate the duplicate dev_valid_name call). Otherwise, we'll now just spend a little time in snprintf() copying name to the stack buffer allocated in dev_alloc_name_ns, and do the __dev_get_by_name using that buffer rather than name. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 1bb856eaed1c..ad5f90dacd92 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1146,19 +1146,7 @@ EXPORT_SYMBOL(dev_alloc_name);
int dev_get_valid_name(struct net *net, struct net_device *dev,
const char *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;
+ return dev_alloc_name_ns(net, dev, name);
}
EXPORT_SYMBOL(dev_get_valid_name);