summaryrefslogtreecommitdiff
path: root/lib/dpif.c
diff options
context:
space:
mode:
authorAshish Varma <ashishvarma.ovs@gmail.com>2017-11-06 12:17:45 -0800
committerBen Pfaff <blp@ovn.org>2017-11-13 11:05:31 -0800
commit97459c2f011341d6f8376b84af52dd34fed629ba (patch)
tree1595c02c653b027a659d163c11c1a38d7f6e2085 /lib/dpif.c
parentb4027b17e890915472d568619ea9f3ae675d4ac8 (diff)
downloadopenvswitch-97459c2f011341d6f8376b84af52dd34fed629ba.tar.gz
netdev, dpif: fix the crash/assert on port delete
a crash is seen in "netdev_ports_remove" when an interface is deleted and added back in the system and when the interface is part of a bridge configuration. e.g. steps: create a tap0 interface using "ip tuntap add.." add the tap0 interface to br0 using "ovs-vsctl add-port.." delete the tap0 interface from system using "ip tuntap del.." add the tap0 interface back in system using "ip tuntap add.." (this changes the ifindex of the interface) delete tap0 from br0 using "ovs-vsctl del-port.." In the function "netdev_ports_insert", two hmap entries were created for mapping "portnum -> netdev" and "ifindex -> portnum". When the interface is deleted from the system, the "netdev_ports_remove" function is not getting called and the old ifindex entry is not getting cleaned up from the "ifindex_to_port" hmap. As part of the fix, added function "dpif_port_remove" which will call "netdev_ports_remove" in the path where the interface deletion from the system is detected. Also, in "netdev_ports_remove", added the code where the "ifindex_to_port_data" (ifindex -> portnum map node) is getting freed when the ifindex is not available any more. (as the interface is already deleted.) VMware-BZ: #1975788 Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/dpif.c')
-rw-r--r--lib/dpif.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/dpif.c b/lib/dpif.c
index 3233bc8d6..3f0742d38 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -605,21 +605,23 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, odp_port_t *port_nop)
/* Attempts to remove 'dpif''s port number 'port_no'. Returns 0 if successful,
* otherwise a positive errno value. */
int
-dpif_port_del(struct dpif *dpif, odp_port_t port_no)
+dpif_port_del(struct dpif *dpif, odp_port_t port_no, bool local_delete)
{
- int error;
+ int error = 0;
COVERAGE_INC(dpif_port_del);
- error = dpif->dpif_class->port_del(dpif, port_no);
- if (!error) {
- VLOG_DBG_RL(&dpmsg_rl, "%s: port_del(%"PRIu32")",
- dpif_name(dpif), port_no);
-
- netdev_ports_remove(port_no, dpif->dpif_class);
- } else {
- log_operation(dpif, "port_del", error);
+ if (!local_delete) {
+ error = dpif->dpif_class->port_del(dpif, port_no);
+ if (!error) {
+ VLOG_DBG_RL(&dpmsg_rl, "%s: port_del(%"PRIu32")",
+ dpif_name(dpif), port_no);
+ } else {
+ log_operation(dpif, "port_del", error);
+ }
}
+
+ netdev_ports_remove(port_no, dpif->dpif_class);
return error;
}