[ovs-dev] [PATCH] dpif-linux: Fix segfault when a port already exists.

Justin Pettit jpettit at nicira.com
Wed Jan 16 23:59:23 UTC 2013


Commit 78a2d59c (dpif-linux.c: Let the kernel pick a port number if one
not requested.) changed the logic for port assignment, but didn't
properly handle some error conditions.  An attempt to add a tunnel port
that already exists would lead to a segfault.  This commit fixes the
logic to stop processing and return an error.

Reported-by: Gurucharan Shetty <shettyg at nicira.com>
Signed-off-by: Justin Pettit <jpettit at nicira.com>
---
 lib/dpif-linux.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 63d7afb..a8544d7 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -475,9 +475,11 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
         *port_nop = reply.port_no;
         VLOG_DBG("%s: assigning port %"PRIu32" to netlink pid %"PRIu32,
                  dpif_name(dpif_), reply.port_no, upcall_pid);
-    } else if (error == EBUSY && *port_nop != UINT32_MAX) {
-        VLOG_INFO("%s: requested port %"PRIu32" is in use",
-                  dpif_name(dpif_), *port_nop);
+    } else {
+        if (error == EBUSY && *port_nop != UINT32_MAX) {
+            VLOG_INFO("%s: requested port %"PRIu32" is in use",
+                      dpif_name(dpif_), *port_nop);
+        }
         nl_sock_destroy(sock);
         ofpbuf_delete(buf);
         return error;
-- 
1.7.5.4




More information about the dev mailing list