Don't allow spaces in network device names because it makes
it difficult to provide text interfaces via sysfs.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
---
 net/core/dev.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index d95e262..56c8afb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -79,6 +79,7 @@ #include <linux/capability.h>
 #include <linux/cpu.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/ctype.h>
 #include <linux/sched.h>
 #include <linux/mutex.h>
 #include <linux/string.h>
@@ -636,10 +637,25 @@ struct net_device * dev_get_by_flags(uns
  */
 int dev_valid_name(const char *name)
 {
-       return !(*name == '\0' 
-                || !strcmp(name, ".")
-                || !strcmp(name, "..")
-                || strchr(name, '/'));
+       if (*name == '\0')       /* null string */
+               return 0;
+
+       if (*name == '.') {
+               if (name[1] == '\0')    /* can't have . in directory */
+                       return 0;
+               if (name[1] == '.' && name[2] == '\0')
+                       return 0;       /* or .. */
+       }
+
+       /* Check for blanks and slash because it confuses sysfs interfaces */
+       do {
+               if (*name == '/')
+                       return 0;
+               if (isspace(*name))
+                       return 0;
+       } while (*++name);
+
+       return 1;
 }
 
 /**
-- 
1.4.0

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to