diff options
author | Ben Pfaff <blp@ovn.org> | 2017-02-03 08:58:27 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-02-03 14:12:27 -0800 |
commit | 909153f143e97fd4d0404234bfa1d5a6fbd60f8b (patch) | |
tree | 4b894d60948da557033a5ce1070df60322f65508 | |
parent | 55f36be59122883afac2209d7cf12ddbd10a18ff (diff) | |
download | openvswitch-909153f143e97fd4d0404234bfa1d5a6fbd60f8b.tar.gz |
netdev: Reject empty names in netdev_open().
The empty string is not a valid name for a network device. I would have
expected that each of the netdev provider implementations would reject an
empty string, but there was a special case for Linux tap devices where they
instead caused unexpected behavior. This commit should fix the problem for
those devices and every other kind.
Reported-by: Gabor Locsei <gabor.locsei@ericsson.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2017-February/043613.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Girish Moodalbail <girish.moodalbail@oracle.com>
Acked-by: Andy Zhou <azhou@ovn.org>
-rw-r--r-- | lib/netdev.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/netdev.c b/lib/netdev.c index 1e6bb2b15..a8d8edad7 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -343,6 +343,14 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp) struct netdev *netdev; int error; + if (!name[0]) { + /* Reject empty names. This saves the providers having to do this. At + * least one screwed this up: the netdev-linux "tap" implementation + * passed the name directly to the Linux TUNSETIFF call, which treats + * an empty string as a request to generate a unique name. */ + return EINVAL; + } + netdev_initialize(); ovs_mutex_lock(&netdev_mutex); |