From f7fc8a30f9fe5f92a8897bc71f64d7c47d298ee1 Mon Sep 17 00:00:00 2001 From: Han Zhou Date: Wed, 7 Nov 2018 22:29:43 -0800 Subject: [PATCH] ofproto.c: Fix port number leaking. 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 Signed-off-by: Ben Pfaff --- ofproto/ofproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 222c74994..bb020fee0 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); }