[ovs-dev] [PATCH 3/3] netdev: Warn on opening netdev as unexpected type.

Joe Stringer joestringer at nicira.com
Fri May 2 01:13:43 UTC 2014


Previously, it was possible to open a netdevice as one type, then
proceed to open it as a different type without first closing it. The
bridge code would expect it to be opened as the latter type and try to
apply configuration to it. This patch catches the problem earlier by
detecting the case in netdev_open() and logging a warning message.

Bug #1198386.

Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
I'm not sure if this case is meant to be possible, but I've observed it,
and this patch makes the error more obvious in the logs.
---
 lib/netdev.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/netdev.c b/lib/netdev.c
index e0b84bd..9e9a3a3 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -383,6 +383,10 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
                       name, type);
             error = EAFNOSUPPORT;
         }
+    } else if (strcmp(netdev_get_type(netdev), type)) {
+        VLOG_WARN("could not open netdev %s as type %s (is already type %s)",
+                  name, type, netdev_get_type(netdev));
+        error = EEXIST;
     } else {
         error = 0;
     }
-- 
1.7.10.4




More information about the dev mailing list