Skip to content

Commit

Permalink
netdev: Reject empty names in netdev_open().
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2017-February/043613.html
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Girish Moodalbail <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
blp committed Feb 3, 2017
1 parent 55f36be commit 909153f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/netdev.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 909153f

Please sign in to comment.