aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-08-05 14:18:06 -0700
committerBen Pfaff <blp@nicira.com>2011-08-08 12:55:43 -0700
commit18812dff32ce650440b9f1eac1bb00afe08c621a (patch)
tree1abd453fbc096d8eb300a0f6d514c4d24360e040 /lib/netdev.c
parentde5cdb90f7c02d22b0595c7dc311c5306291b02f (diff)
netdev: Get rid of struct netdev_options and netdev_open_default().
Now that netdev_options only has two members, we might as well pass them directly as parameters.
Diffstat (limited to 'lib/netdev.c')
-rw-r--r--lib/netdev.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index ec8ae4fc..cd824f84 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -192,14 +192,15 @@ netdev_enumerate_types(struct sset *types)
}
}
-/* Opens the network device named 'name' (e.g. "eth0") and returns zero if
- * successful, otherwise a positive errno value. On success, sets '*netdevp'
- * to the new network device, otherwise to null.
+/* Opens the network device named 'name' (e.g. "eth0") of the specified 'type'
+ * (e.g. "system") and returns zero if successful, otherwise a positive errno
+ * value. On success, sets '*netdevp' to the new network device, otherwise to
+ * null.
*
* Some network devices may need to be configured (with netdev_set_config())
* before they can be used. */
int
-netdev_open(struct netdev_options *options, struct netdev **netdevp)
+netdev_open(const char *name, const char *type, struct netdev **netdevp)
{
struct netdev_dev *netdev_dev;
int error;
@@ -207,18 +208,18 @@ netdev_open(struct netdev_options *options, struct netdev **netdevp)
*netdevp = NULL;
netdev_initialize();
- netdev_dev = shash_find_data(&netdev_dev_shash, options->name);
+ netdev_dev = shash_find_data(&netdev_dev_shash, name);
if (!netdev_dev) {
const struct netdev_class *class;
- class = netdev_lookup_provider(options->type);
+ class = netdev_lookup_provider(type);
if (!class) {
VLOG_WARN("could not create netdev %s of unknown type %s",
- options->name, options->type);
+ name, type);
return EAFNOSUPPORT;
}
- error = class->create(class, options->name, &netdev_dev);
+ error = class->create(class, name, &netdev_dev);
if (error) {
return error;
}
@@ -239,17 +240,6 @@ netdev_open(struct netdev_options *options, struct netdev **netdevp)
return error;
}
-int
-netdev_open_default(const char *name, struct netdev **netdevp)
-{
- struct netdev_options options;
-
- memset(&options, 0, sizeof options);
- options.name = name;
-
- return netdev_open(&options, netdevp);
-}
-
/* Reconfigures the device 'netdev' with 'args'. 'args' may be empty
* or NULL if none are needed. */
int
@@ -321,7 +311,7 @@ netdev_exists(const char *name)
struct netdev *netdev;
int error;
- error = netdev_open_default(name, &netdev);
+ error = netdev_open(name, "system", &netdev);
if (!error) {
netdev_close(netdev);
return true;
@@ -1265,7 +1255,7 @@ netdev_find_dev_by_in4(const struct in_addr *in4)
SSET_FOR_EACH (name, &dev_list) {
struct in_addr dev_in4;
- if (!netdev_open_default(name, &netdev)
+ if (!netdev_open(name, "system", &netdev)
&& !netdev_get_in4(netdev, &dev_in4, NULL)
&& dev_in4.s_addr == in4->s_addr) {
goto exit;