netdev: do not allow devices to be opened with conflicting types netdev
authorThadeu Lima de Souza Cascardo <cascardo@redhat.com>
Tue, 5 Jul 2016 14:41:24 +0000 (11:41 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@redhat.com>
Wed, 27 Jul 2016 14:59:01 +0000 (11:59 -0300)
commitf52bb90626b3c21e382285e82ec7471e67077df6
treec29296860f6d39d7685eb0802676b9b672b1e7e9
parentf674583bea85d3a9914b94732e15ed5dfeeb9389
netdev: do not allow devices to be opened with conflicting types

When a device is already opened, netdev_open should verify that the types match,
or else return an error.

Otherwise, users might expect to open a device with a certain type and get a
handle belonging to a different type.

This also prevents certain conflicting configurations that would have a port of
a certain type in the database and one of a different type on the system.

For example, when adding an interface with a type other than system, and there
is already a system interface with the same name, as the routing table will hold
a reference to that system interface, some conflicts will arise. The netdev will
be opened with the incorrect type and that will make vswitchd remove it, but
adding it again will fail as it already exists. Failing earlier prevents some
vswitchd loops in reconfiguring the interface.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
lib/netdev.c