From patchwork Mon Oct 3 04:02:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng He X-Patchwork-Id: 1685541 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.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=20210112 header.b=ZUSfSuTy; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mh0p71Xzzz1ypH for ; Mon, 3 Oct 2022 23:41:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4F18C415DC; Mon, 3 Oct 2022 12:41:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4F18C415DC Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ZUSfSuTy X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cXvLLICnK5qx; Mon, 3 Oct 2022 12:41:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id C32FA415E9; Mon, 3 Oct 2022 12:41:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C32FA415E9 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2DA5FC0032; Mon, 3 Oct 2022 12:41:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28289C0035 for ; Mon, 3 Oct 2022 12:41:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 38849415CB for ; Mon, 3 Oct 2022 12:41:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 38849415CB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3I4jFDuYUAJU for ; Mon, 3 Oct 2022 12:41:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 13747415AE Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by smtp4.osuosl.org (Postfix) with ESMTPS id 13747415AE for ; Mon, 3 Oct 2022 12:41:39 +0000 (UTC) Received: by mail-pf1-x42a.google.com with SMTP id a26so1091348pfg.7 for ; Mon, 03 Oct 2022 05:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9qzSWnywehD6turLpoex3ifk+j4rOro8W6h3KpAFec4=; b=ZUSfSuTyTGYb+d7HlxcxMpjWKNytXouzlZeWrpsNtF/x+oG+O9FZB3t5Bh65oduOrw 6hbmWbR8dSMw8dQ9T2PWb9QyrqAoG7KLdpDZW0b3tV3fRKLoYo3LUcEcI7No5u80DQDE otffRBX/5ZsMqtf2UkwcBFkjMkvX4GGg0oOqjHZgeEdY5BTxaH4NXQve1V9hRAz9W4oA m/aqd5+E0KZkd3OZgZ5xH4unF/fCtlgKgLrXyrjhJVK8DP1qBCuRFc0kOuGXyeERCPrS G0G6blXWydAbq1LATIPV0a4VPW6lMMBr7IHSoknbAQ4J+FWlcHEPChjSFewQH78jdIOa ugSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9qzSWnywehD6turLpoex3ifk+j4rOro8W6h3KpAFec4=; b=7xfi447aKRdL2crmf8b/LdVAy3DoZONIyTrmNC68RLGpREGQn8fMFLcX6hfkSkTpT2 TRFUEvjwwGTrZSdkiXoxTI5WGXAxuLiSSqVF9XnDeJLDE5/QtmUNbdXrXpti7RyHRySN u/eIDcgCJ7JWj5KhjGThnvZHPjDY9VWbBTcm/WZiFjuBtdvvNtcG7vb8Nj3eFvCIq9yt 472B6IuGyGLCyBP7DzULsAR+9Lh++8CGnZOAz9jk4w1Q0gn6yms0uEB08xwN6QaCItem Wbkzgim3H90CH4M8ne4U6jKpN0lP2r0Ym1fN7jYg+5+/Qor5nC5X2SstXg4f7sdkEVXu 66SA== X-Gm-Message-State: ACrzQf0hsBV1uR5lwvFO1LmeYD4f0dDBSd0p+d7wFPw7W9hKUGe5KAnV bJePnwxMQ8/rQWK+21KNdw4nPcWtJj9pMA== X-Google-Smtp-Source: AMsMyM7ihK4gOByfF3YySz14sHuaR6L1e0GeDAOa9/YUmxnppJriBA6uZ78qrWOz1yjlqJelB5+mbw== X-Received: by 2002:a05:6a00:1892:b0:540:acee:29e8 with SMTP id x18-20020a056a00189200b00540acee29e8mr22543024pfh.1.1664800899264; Mon, 03 Oct 2022 05:41:39 -0700 (PDT) Received: from localhost ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id p3-20020a170902e74300b00176b0dec886sm7201650plf.58.2022.10.03.05.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 05:41:39 -0700 (PDT) From: Peng He X-Google-Original-From: Peng He To: dev@openvswitch.org Date: Mon, 3 Oct 2022 04:02:20 +0000 Message-Id: <20221003040220.1153222-4-hepeng.0320@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003040220.1153222-1-hepeng.0320@bytedance.com> References: <20221003040220.1153222-1-hepeng.0320@bytedance.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 3/3] dpif-netdev: fix inconsistent processing between ukey and megaflow 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When PMDs perform upcalls, the newly generated ukey will replace the old, however, the newly generated mageflow will be discard to reuse the old one without checking if the actions of new and old are equal. This code prevents in case someone runs dpctl/add-flow to add a dp flow with inconsistent actions with the actions of ukey, and causes more confusion. Signed-off-by: Peng He --- lib/dpif-netdev.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a45b46014..b316e59ef 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -8304,7 +8304,22 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, * to be locking revalidators out of making flow modifications. */ ovs_mutex_lock(&pmd->flow_mutex); netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL); - if (OVS_LIKELY(!netdev_flow)) { + if (OVS_UNLIKELY(netdev_flow)) { + struct dp_netdev_actions *old_act = + dp_netdev_flow_get_actions(netdev_flow); + + if ((add_actions->size != old_act->size) || + memcmp(old_act->actions, add_actions->data, + add_actions->size)) { + + struct dp_netdev_actions *new_act = + dp_netdev_actions_create(add_actions->data, + add_actions->size); + + ovsrcu_set(&netdev_flow->actions, new_act); + ovsrcu_postpone(dp_netdev_actions_free, old_act); + } + } else { netdev_flow = dp_netdev_flow_add(pmd, &match, &ufid, add_actions->data, add_actions->size, orig_in_port);