]> git.proxmox.com Git - mirror_ovs.git/commitdiff
netdev: Free ifidx mapping in netdev_ports_remove().
authorJoe Stringer <joe@ovn.org>
Thu, 10 Aug 2017 00:18:22 +0000 (17:18 -0700)
committerJoe Stringer <joe@ovn.org>
Fri, 11 Aug 2017 16:46:54 +0000 (09:46 -0700)
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.

Fixes: 32b77c316d9982("dpif: Save added ports in a port map.")
Reported-by: Andy Zhou <azhou@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Andy Zhou <azhou@ovn.org>
lib/netdev.c

index cb4d9f007b85a94d2ec7b92c198c7b409794042d..b4e570bafd08533d22d4f61f1af8bbeadff4bea1 100644 (file)
@@ -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);