summaryrefslogtreecommitdiff
path: root/lib/netdev.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-11-03 17:00:57 -0700
committerBen Pfaff <blp@nicira.com>2010-11-04 13:47:26 -0700
commita8f86734614d584ff72ffe34938bb3e9cf05394c (patch)
tree544eb1c72b84d21e715134b7957ece9f5c76bbb2 /lib/netdev.c
parent59348dba2c4c8cc43a70b1c0265e536ef177c1ab (diff)
downloadopenvswitch-a8f86734614d584ff72ffe34938bb3e9cf05394c.tar.gz
netdev: Assert that the type of a new network device is correct.
This would have found a bug that I accidentally inserted while working on netdev-linux.
Diffstat (limited to 'lib/netdev.c')
-rw-r--r--lib/netdev.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index 5cd252c3a..34cb1e9b5 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -251,6 +251,7 @@ static int
create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
{
struct netdev_class *netdev_class;
+ int error;
if (!options->type || strlen(options->type) == 0) {
/* Default to system. */
@@ -262,8 +263,10 @@ create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
return EAFNOSUPPORT;
}
- return netdev_class->create(netdev_class, options->name, options->args,
- netdev_devp);
+ error = netdev_class->create(netdev_class, options->name, options->args,
+ netdev_devp);
+ assert(error || (*netdev_devp)->netdev_class == netdev_class);
+ return error;
}
/* Opens the network device named 'name' (e.g. "eth0") and returns zero if