[ovs-dev] [PATCH] tunnel: Fix bug where misconfiguration persists.

Joe Stringer joestringer at nicira.com
Tue May 6 03:13:31 UTC 2014

Previously, misconfiguring a tunnel port to use the exact same settings
would cause the corresponding netdev to never be destroyed. When
attempting to re-use the port as a different type, this would fail and
result in a discrepancy between reported port type and actual netdev in

An example configuration that would previously give unexpected behaviour:

ovs-vsctl add-port br0 p0 -- set int p0 type=gre options:remote_ip=
ovs-vsctl add-port br0 p1 -- set int p1 type=internal
ovs-vsctl set int p1 type=gre options:remote_ip=
ovs-vsctl set int p1 type=internal

The final command would report in the ovs-vswitchd logs that it is
attempting to configure the port with the same gre settings as p0,
despite the command specifying the type as internal. Even after
deleting and re-adding the port, the message would reappear.

This patch fixes the bug by dereferencing the netdev in the failure
case of tnl_port_add__(), and ensures that the tnl_port structure is
freed in that case as well.

Bug #1198386.

Signed-off-by: Joe Stringer <joestringer at nicira.com>
This is a follow up to "netdev: Open devices as the type specified."
- Fixed root cause instead of avoiding symptoms.
- Removed a tests which didn't actually fail in absence of this patch.
 ofproto/tunnel.c               |    3 ++-
 tests/interface-reconfigure.at |   17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c
index d2e9584..2b5aa50 100644
--- a/ofproto/tunnel.c
+++ b/ofproto/tunnel.c
@@ -159,8 +159,9 @@ tnl_port_add__(const struct ofport_dpif *ofport, const struct netdev *netdev,
                       "port '%s' (%s)", tnl_port_get_name(tnl_port),
                       tnl_port_get_name(existing_port), ds_cstr(&ds));
-            free(tnl_port);
+        netdev_close(tnl_port->netdev);
+        free(tnl_port);
         return false;
diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at
index 26a77eb..63c62af 100644
--- a/tests/interface-reconfigure.at
+++ b/tests/interface-reconfigure.at
@@ -1028,3 +1028,20 @@ action_down: bring down physical devices - [u'eth0', u'eth1']
+dnl This test configures two tunnels, then deletes the second and re-uses its
+dnl name for different types of ports. This was introduced to detect errors
+dnl where port configuration persists even when the port is deleted and
+dnl readded.
+AT_SETUP([Re-create port with different types])
+  [add-port br0 p0 -- set int p0 type=gre options:remote_ip= -- \
+   add-port br0 p1 -- set int p1 type=dummy -- \
+   add-port br0 p2 -- set int p2 type=dummy])
+AT_CHECK([ovs-vsctl set int p1 type=gre options:remote_ip=])
+AT_CHECK([ovs-vsctl del-port p1])
+AT_CHECK([ovs-vsctl add-port br0 p1 -- set int p1 type=dummy])

More information about the dev mailing list