]> git.proxmox.com Git - mirror_ovs.git/commitdiff
dpif-netdev: Add check mark to avoid ovs-vswitchd crash.
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Tue, 9 Jun 2020 00:53:40 +0000 (08:53 +0800)
committerIlya Maximets <i.maximets@ovn.org>
Thu, 9 Jul 2020 09:34:26 +0000 (11:34 +0200)
When changing the pmd interfaces attribute, ovs-vswitchd will
reload pmd and flush offload flows. reload_affected_pmds may
be invoked twice or more. In that case, the flows may been
queued to "dp_netdev_flow_offload" thread again.

For example:
$ ovs-vsctl -- set interface <Interface> options:dpdk-lsc-interrupt=true

ovs-vswitchd main       flow-offload thread
append F to queue       ...
...
append F to queue
...                     del F
...                     del F (crash [1])

[1]:
ovs_assert_failure          lib/cmap.c:922
cmap_replace                lib/cmap.c:921
cmap_remove                 lib/cmap.h:295
mark_to_flow_disassociate   lib/dpif-netdev.c:2269
dp_netdev_flow_offload_del  lib/dpif-netdev.c:2369
dp_netdev_flow_offload_main lib/dpif-netdev.c:2492

Fixes: 02bb2824e51d ("dpif-netdev: do hw flow offload in a thread")
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
lib/dpif-netdev.c

index bd88e6d3f7d2160e5ef3b672bb2fe552d7e90bbc..83edfbd2fb1d9f024c8bc70d2e587cd1dd484866 100644 (file)
@@ -2264,6 +2264,12 @@ mark_to_flow_disassociate(struct dp_netdev_pmd_thread *pmd,
     struct cmap_node *mark_node = CONST_CAST(struct cmap_node *,
                                              &flow->mark_node);
 
+    /* INVALID_FLOW_MARK may mean that the flow has been disassociated or
+     * never associated. */
+    if (OVS_UNLIKELY(mark == INVALID_FLOW_MARK)) {
+        return EINVAL;
+    }
+
     cmap_remove(&flow_mark.mark_to_flow, mark_node, hash_int(mark, 0));
     flow->mark = INVALID_FLOW_MARK;