diff mbox series

[ovs-dev,1/2] ofproto.c: Fix port number leaking.

Message ID 1541658584-73372-1-git-send-email-hzhou8@ebay.com
State Accepted
Headers show
Series [ovs-dev,1/2] ofproto.c: Fix port number leaking. | expand

Commit Message

Han Zhou Nov. 8, 2018, 6:29 a.m. UTC
From: Han Zhou <hzhou8@ebay.com>

When there is an error in ofport_install(), the ofp port number is
not deallocated, which leads to port number leak. For example,
when there is an redundant tunnel port added in an OVS bridge,
ovs-vswitchd will try to add the port to ofproto whenever OVSDB
changes, which would trigger the port number leak, and over the
time there won't be any port available for valid requests.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 ofproto/ofproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Nov. 9, 2018, 9:35 p.m. UTC | #1
On Wed, Nov 07, 2018 at 10:29:43PM -0800, Han Zhou wrote:
> From: Han Zhou <hzhou8@ebay.com>
> 
> When there is an error in ofport_install(), the ofp port number is
> not deallocated, which leads to port number leak. For example,
> when there is an redundant tunnel port added in an OVS bridge,
> ovs-vswitchd will try to add the port to ofproto whenever OVSDB
> changes, which would trigger the port number leak, and over the
> time there won't be any port available for valid requests.
> 
> Signed-off-by: Han Zhou <hzhou8@ebay.com>

Thanks a lot for the fixes.  I applied these to master.
diff mbox series

Patch

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 222c749..bb020fe 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2516,6 +2516,7 @@  ofport_destroy__(struct ofport *port)
     struct ofproto *ofproto = port->ofproto;
     const char *name = netdev_get_name(port->netdev);
 
+    dealloc_ofp_port(port->ofproto, port->ofp_port);
     hmap_remove(&ofproto->ports, &port->hmap_node);
     shash_find_and_delete(&ofproto->port_by_name, name);
 
@@ -2527,7 +2528,6 @@  static void
 ofport_destroy(struct ofport *port, bool del)
 {
     if (port) {
-        dealloc_ofp_port(port->ofproto, port->ofp_port);
         port->ofproto->ofproto_class->port_destruct(port, del);
         ofport_destroy__(port);
      }