From: Joe Stringer Date: Thu, 10 Aug 2017 00:18:22 +0000 (-0700) Subject: netdev: Free ifidx mapping in netdev_ports_remove(). X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=bed324c813587fa40aa767a01912a7d6e2794b4a;p=ovs.git netdev: Free ifidx mapping in netdev_ports_remove(). Previously, netdev_ports_insert() would allocate and insert an ifindex->odp_port mapping, but netdev_ports_remove() would never remove the mapping or free the mapping structure. This patch fixes these up. From master commit c8d0f32a6045af69aefd72c35b2eb92dd972288f. Fixes: 32b77c316d9982("dpif: Save added ports in a port map.") Reported-by: Andy Zhou Signed-off-by: Joe Stringer Acked-by: Andy Zhou --- diff --git a/lib/netdev.c b/lib/netdev.c index cb4d9f007..b4e570baf 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2266,6 +2266,27 @@ netdev_ports_remove(odp_port_t port_no, const struct dpif_class *dpif_class) data = netdev_ports_lookup(port_no, dpif_class); if (data) { + int ifindex = netdev_get_ifindex(data->netdev); + + if (ifindex > 0) { + struct ifindex_to_port_data *ifidx = NULL; + + HMAP_FOR_EACH_WITH_HASH (ifidx, node, ifindex, &ifindex_to_port) { + if (ifidx->port == port_no) { + hmap_remove(&ifindex_to_port, &ifidx->node); + free(ifidx); + break; + } + } + ovs_assert(ifidx); + } else { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + + VLOG_WARN_RL(&rl, "netdev ports map has dpif port %"PRIu32 + " but netdev has no ifindex: %s", port_no, + ovs_strerror(ifindex)); + } + dpif_port_destroy(&data->dpif_port); netdev_close(data->netdev); /* unref and possibly close */ hmap_remove(&port_to_netdev, &data->node);