From patchwork Sat May 23 12:28:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1296691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=CDFlUeNC; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49TjMK5KHjz9sRf for ; Sat, 23 May 2020 22:28:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 598B620354; Sat, 23 May 2020 12:28:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fsTIy8Jmak4t; Sat, 23 May 2020 12:28:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 5CE6A20377; Sat, 23 May 2020 12:28:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 40E96C0178; Sat, 23 May 2020 12:28:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6C670C0176 for ; Sat, 23 May 2020 12:28:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 53ADC883F1 for ; Sat, 23 May 2020 12:28:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wf4pdCW2zIzx for ; Sat, 23 May 2020 12:28:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id B5BD3883F0 for ; Sat, 23 May 2020 12:28:37 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id q24so6227236pjd.1 for ; Sat, 23 May 2020 05:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DC6YGNauXTTnHnWjhH2P7IsTQxxEIq8uxEYzuf9/Z+I=; b=CDFlUeNC+jeMNyUjK9N6gTkCzuWHj4jq95tIrEh1fxctL6SwdFf/AAiQQrM02S8VCd 2vMKlObhA6wUabFARuCHR33QhS9vWWGqdmh9eQNcJCuz4XAvzvgDKf+8QATHMtxEgaes ftS92E5vEg6B5R+IeRWaOTdFNl4pxDPJ+sagIxbWqzL9lUK4EhHbCpC3gKkDPgGOxxFW /a5ipfl+/YVHzUF31cK7FDNBVps6O1BL6qz0zZeYlF49Y2crkckR5EXfDEx7MnQ/ldA2 aYI1zbAyvmYA5I4wrVeya8gohRA351Zhi+Jw/q7KEVpT+xXoGDaz6tcslRWloadck1Qe mjvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DC6YGNauXTTnHnWjhH2P7IsTQxxEIq8uxEYzuf9/Z+I=; b=rijl4CxNNCb2459ERq+mt7DvbXBPbXEkKN5lp5eej+MvL4j0NaZv5Jssm9fdFXRwZP rqsAKqJxdj4YrwaJJ/ISuR6UzyVOQzbBmuxrJg/kqXcWRWJrZQtk4P6mkAITlYb1Pwhp dknC5w4x36+J24GCVSqCUqAVoYVKUNRnEvhYW2HdCp/VCBhUWCPrYA+m9Xnqa+uRGWD+ QDXd7yqNHwJC/iKitLrLvw2FpwbPN7bofNSelyd+N+zfu5+uzQZ6X94wKeuVADSj2qcl d5nnAPEB/b+enrYX9cw5HPxrcRo0R8ma4mzV7mDPV8Whh85RQP6xqdyXlwyMqUkAaSZQ Kx2g== X-Gm-Message-State: AOAM530ZF/eVe+E7MmO8dfC+wklRjWuK9wmYWyaBvgxlvmuREx+nMbJ9 +uSBNv83UBtL+Re875uCrqrTB0OAe6XzAg== X-Google-Smtp-Source: ABdhPJx/kigIJAVI9bfXPJOvc1M34bJgaaWMgLiNB3igmqEfwA0W16BSZZ6AWpsPywwlsB0l5bDPoQ== X-Received: by 2002:a17:90a:db0f:: with SMTP id g15mr10642466pjv.8.1590236917267; Sat, 23 May 2020 05:28:37 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id e5sm9072665pfe.121.2020.05.23.05.28.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 May 2020 05:28:36 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: yliu@fridaylinux.org, i.maximets@ovn.org, blp@ovn.org, u9012063@gmail.com Date: Sat, 23 May 2020 20:28:27 +0800 Message-Id: <20200523122828.54627-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH 1/2] dpif-netdev: Add check mark to avoid ovs-vswitchd crash. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang 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 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 Cc: Yuanhan Liu Cc: Ian Stokes Cc: Ben Pfaff Cc: William Tu Signed-off-by: Tonghao Zhang --- lib/dpif-netdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 46eb1e3d97c9..25c4b960857a 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2265,6 +2265,13 @@ mark_to_flow_disassociate(struct dp_netdev_pmd_thread *pmd, uint32_t mark = flow->mark; struct cmap_node *mark_node = CONST_CAST(struct cmap_node *, &flow->mark_node); + /* Check the mark if avoidable, INVALID_FLOW_MARK may + * mean that the flow has been disassociated or never + * associated. + */ + if (OVS_UNLIKELY(mark == INVALID_FLOW_MARK)) { + return -1; + } cmap_remove(&flow_mark.mark_to_flow, mark_node, hash_int(mark, 0)); flow->mark = INVALID_FLOW_MARK; From patchwork Sat May 23 12:28:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1296692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=tKr65kuc; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49TjMN2RSJz9sSF for ; Sat, 23 May 2020 22:28:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A50D22076E; Sat, 23 May 2020 12:28:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N0qU6K-OeqLF; Sat, 23 May 2020 12:28:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 426B4204F9; Sat, 23 May 2020 12:28:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 12D02C0178; Sat, 23 May 2020 12:28:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5E1FEC0178 for ; Sat, 23 May 2020 12:28:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 5827B88402 for ; Sat, 23 May 2020 12:28:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QEimrcSXtkso for ; Sat, 23 May 2020 12:28:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by hemlock.osuosl.org (Postfix) with ESMTPS id C1954883F5 for ; Sat, 23 May 2020 12:28:40 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id 5so6225473pjd.0 for ; Sat, 23 May 2020 05:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EX9yKn4oBNOiekerYi7DGaGEcNZzT2yRJ/DrBUfULsE=; b=tKr65kuc/s4r+VPseG+NgK2/itfmC7g27lPT3kXBO5Nd1JbMpZeN7KL7+z9izjBdbC WIn/liItWLox6PQGcq9aiJTMO8d++7eGoKWztEDbzvdKOfpGFwJkd/OeJNREUTMymr+h zfCVCW/+X6DtijUtnpA6/5AXsylUIsgrG1wIveQzzt9oL5trSrsm7/N8O4ZZ3O+kMyl4 SzZNBfs7ePt18MIcYaU79boc4Txl8mQtzUXCsvypSuhOTfDxBGK61YoCjoRp4vL74sxm gvwdpP9TeJV2kAFr2q5//lwXNyWX0xru+buhGine5QTAOIgNT/5QwsbBciqelzZEcuOB 3Gng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EX9yKn4oBNOiekerYi7DGaGEcNZzT2yRJ/DrBUfULsE=; b=CA/QVSxL/4o9v0xfAcBoXDsFE0UdrXCL8liccHM2J8uNyeEU7xE5Bb8FbhJah9ce/O YfwJwNV5Pyr1kqcu/oCtrFvtwoYmzMzUHGYrD9EIVtIkWG5RrtVUJb6tEuiosiQf4Rlp KLivrZf9B4n5ElSdZoxfJcNNfOMhJfi0zg77tfUzq/AbTYpcDXgeOyjeeM5jPqYd8fbq sXkO/T3u2Ik9QxpymqQNTLH6WqcKMZmHlldlIwq+bl62+R7GCpsUbht/7v9qzGYqXHtD D5LswQxY5VBUmMQ165AXVzcKun058QkSP/Zx0PoWXl/vQ0da+50NKfXX1ZgYxYGQoUIu 4A7Q== X-Gm-Message-State: AOAM530q85csNis1VOK60NVdYPEoEc/GkDog0hNTreqpXybibPDlE3DR TCmgcPw6Ld7Egcj/xmYcaJE= X-Google-Smtp-Source: ABdhPJyCUgCwmOk2RRjQcY64xPK/Px+5gEab9b6T77uGPjFLNQFyBycDeKl5zz1yo95Imw0FrZIbAw== X-Received: by 2002:a17:90a:49c5:: with SMTP id l5mr10046454pjm.73.1590236920471; Sat, 23 May 2020 05:28:40 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id e5sm9072665pfe.121.2020.05.23.05.28.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 May 2020 05:28:39 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: yliu@fridaylinux.org, i.maximets@ovn.org, blp@ovn.org, u9012063@gmail.com Date: Sat, 23 May 2020 20:28:28 +0800 Message-Id: <20200523122828.54627-2-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200523122828.54627-1-xiangxia.m.yue@gmail.com> References: <20200523122828.54627-1-xiangxia.m.yue@gmail.com> Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH 2/2] dpif-netdev: Return error code when no mark available. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang The max number of mark is (UINT32_MAX - 1), that is enough to be used. But theoretically, if there are no mark available, the later different flows will shared the mark INVALID_FLOW_MARK, that may break the function. If there are no available mark to be used, return error code. Cc: Yuanhan Liu Cc: Ian Stokes Cc: Ben Pfaff Cc: William Tu Signed-off-by: Tonghao Zhang --- lib/dpif-netdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 25c4b960857a..a001e5b4ea4a 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2426,6 +2426,7 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) mark = flow_mark_alloc(); if (mark == INVALID_FLOW_MARK) { VLOG_ERR("Failed to allocate flow mark!\n"); + return -1; } } info.flow_mark = mark;