mirror of
https://github.com/openvswitch/ovs
synced 2025-10-21 14:49:41 +00:00
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.
This commit is contained in:
@@ -251,6 +251,7 @@ static int
|
|||||||
create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
|
create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
|
||||||
{
|
{
|
||||||
struct netdev_class *netdev_class;
|
struct netdev_class *netdev_class;
|
||||||
|
int error;
|
||||||
|
|
||||||
if (!options->type || strlen(options->type) == 0) {
|
if (!options->type || strlen(options->type) == 0) {
|
||||||
/* Default to system. */
|
/* Default to system. */
|
||||||
@@ -262,8 +263,10 @@ create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
|
|||||||
return EAFNOSUPPORT;
|
return EAFNOSUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return netdev_class->create(netdev_class, options->name, options->args,
|
error = netdev_class->create(netdev_class, options->name, options->args,
|
||||||
netdev_devp);
|
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
|
/* Opens the network device named 'name' (e.g. "eth0") and returns zero if
|
||||||
|
Reference in New Issue
Block a user