From patchwork Thu Jan 16 16:17:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li,Rongqing via dev" X-Patchwork-Id: 1224325 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.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.a=rsa-sha256 header.s=selector1 header.b=Dxn7n6Li; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47z8jT00BVz9sNx for ; Fri, 17 Jan 2020 03:27:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9FE3986463; Thu, 16 Jan 2020 16:27:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UNMdK1ZI-WgQ; Thu, 16 Jan 2020 16:27:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7F93486356; Thu, 16 Jan 2020 16:27:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 62B84C1D81; Thu, 16 Jan 2020 16:27:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0ECA5C077D for ; Thu, 16 Jan 2020 16:27:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id F08BB863CD for ; Thu, 16 Jan 2020 16:27:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z_KDOESlIc5w for ; Thu, 16 Jan 2020 16:26:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70089.outbound.protection.outlook.com [40.107.7.89]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DA8EF86356 for ; Thu, 16 Jan 2020 16:26:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qf+zuRhc7mFNB28S1QQq4vypU60W8QqRYOhK1fdqmDIfvTKF4fHcLLO3h1xyNMZe0OHuraxcnxJxYdXM7ejxERDCE2E+lmsXqF2jGLrSy1VBmhAvRitv64CGAHtluyDwkpPvcFQFATMl/+yfBvnLS0vhbdSBe1jdVaHNHSr8nm2Qc4Zmw8GINBY34rM58CqMQ/GoiAO+7p03O5qB+8XVqh1aOQqdhPHY1wGirCTZO+M4dgVUr4keoJT65+XTstwyPACC7FNl/HWhkeIRFCtsFRquuCZx/lBIJw5tvpd4NrvS/YG5f//d+QYFrxMpq4MQL06w5bEVxFuTKa/bKSFa3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1KrsG/P8dfzwRSWs3+xxRAj4hNIUwJsa1szOWG614ls=; b=ZiDGltHA9r4P8MHoSsKO0g+vXBki3B9tGPQhY4159GpXYu93NsBFmJFe/oWoCeBTYBFOfO0OCFQiQLrHBF1sghy234sOMS+5OPLdFLz9/zN+lM9thXO5+x+08e55nWlHtgm80EpfzJ7a5odP5+awA9K4HN+CLOknfIs6npyR+Kr6HNQYlcuK5zLI03J4stRSnr5IntQCFA1W9hlAsWKPdYw0WTdUiK29wOuGuENDQ3onwx+0kot2dk7VysND+m6j5jfZem7uMcS0d6fYgMVmUcn1sreH+GPi7G3OPJaowzI/dWoZFRLUN7o0lBJmpJKCOGq/qpjQGTf0Ikm+QBgnYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=none pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1KrsG/P8dfzwRSWs3+xxRAj4hNIUwJsa1szOWG614ls=; b=Dxn7n6LiwYuDo9i67bhN9v4SXgsVZ2UT3CocZjgciECD7mmjE2BT5eRo8Iecvhx774BXBIHH2sVgLZyiv1R5jkdP8NznV4TppMkNlpy4oBsVMhYB+F5NXzI0GPt47szVuXcfOfArdFzBL840TT/Rhc3vJl76IA/JM3vAXnDCOtc= Received: from DB6PR07CA0111.eurprd07.prod.outlook.com (2603:10a6:6:2c::25) by AM4PR07MB3106.eurprd07.prod.outlook.com (2603:10a6:205:d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.11; Thu, 16 Jan 2020 16:26:54 +0000 Received: from AM5EUR02FT054.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::205) by DB6PR07CA0111.outlook.office365.com (2603:10a6:6:2c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.7 via Frontend Transport; Thu, 16 Jan 2020 16:26:54 +0000 Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; openvswitch.org; dkim=none (message not signed) header.d=none;openvswitch.org; dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by AM5EUR02FT054.mail.protection.outlook.com (10.152.8.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2644.19 via Frontend Transport; Thu, 16 Jan 2020 16:26:53 +0000 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESBMR503.ericsson.se (153.88.183.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 16 Jan 2020 17:26:52 +0100 Received: from localhost.localdomain (153.88.183.153) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 16 Jan 2020 17:26:52 +0100 To: Date: Thu, 16 Jan 2020 21:47:23 +0530 Message-ID: <1579191443-27484-1-git-send-email-vishal.deep.ajmera@ericsson.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [153.88.183.153] X-ClientProxiedBy: ESESBMB501.ericsson.se (153.88.183.168) To ESESSMB501.ericsson.se (153.88.183.162) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.176.1.74; IPV:; CTRY:SE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(346002)(396003)(136003)(189003)(199004)(70586007)(8936002)(478600001)(2616005)(5660300002)(2906002)(956004)(336012)(70206006)(107886003)(356004)(8676002)(36756003)(54906003)(26005)(246002)(4326008)(316002)(7636002)(16526019)(86362001)(6666004)(6916009)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR07MB3106; H:oa.msg.ericsson.com; FPR:; SPF:Pass; LANG:en; PTR:office365.se.ericsson.net; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df9e4f48-f1fc-48c7-b30c-08d79aa0e58e X-MS-TrafficTypeDiagnostic: AM4PR07MB3106: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 02843AA9E0 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 51ZEhrVIf5WtRSjvGa1aTLos3C0vRDaM4NBwZjrh7aQjGC2MNYS6ehQe7VvQ6ejCfKyWTJz4JSB/X5WqMFm/xJ53/LNsiwy9xiY5fp5oQJsOqZVAyXjFjnfuAYoYDU3k9j0KbQTkJkoBMBRTNM2ExlswzB0pvi58z8v/KfxpMvuYSn3D6Q4kWHlx3BWriGIUHVybY/x4RHZfvS95Ki96kO3tre8UhSOqJCBS33RqQkMGmJBuLL0SXhplTpiYxzO6iBrt9eMpcgLPaAHIbTPw1F/2lRVvxud2kzlGZSFoquz5mUM40feNP3rIFEEBIOCtDWy9jdvkaVIdzFUGg5HUzpF9WYa7tOtQmLZVJdoBs0WlpRFfNsa+aH4XfpQ/97z3fDwMcSpJ2Fis/FmwmObfrdJoITpGGddWpLhql1K0hbTT3OZpdL5K3rfyadxnb6l/ X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2020 16:26:53.2413 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df9e4f48-f1fc-48c7-b30c-08d79aa0e58e X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR07MB3106 Subject: [ovs-dev] [PATCH] ofproto: Fix for frequent invalidation of flows due to mismatch in mask bits 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: , X-Patchwork-Original-From: Vishal Deep Ajmera via dev From: "Li,Rongqing via dev" Reply-To: Vishal Deep Ajmera Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The wildcard bits in the installed megaflow entry could be different from the bits originally generated by the ofproto layer. Datapath implementation wildcards those match fields which are not present in the incoming packet before installing the flow. When the revalidator thread validates a megaflow, it will first query the ofproto layer to get the wildcard bits and then compare it against the wildcard bits in the megaflow. If the bits are different the entry will be removed. A subsequent packet will again result in the same megaflow entry being installed only for it to be removed by the revalidator thread. This cycle will continue and will significantly degrade performance. An earlier patch fixing the issue for MPLS and VLAN was sent. However similar problem now appears for IPv6 datapath flows. This patch addresses the issue in a generic way. Signed-off-by: Vishal Deep Ajmera --- ofproto/ofproto-dpif-upcall.c | 14 +++++++++++++- ofproto/ofproto-dpif-xlate.c | 20 -------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 409286a..1371486 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -2169,7 +2169,7 @@ revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey, { struct xlate_out *xoutp; struct netflow *netflow; - struct flow_wildcards dp_mask, wc; + struct flow_wildcards dp_mask, wc, wc_from_flow; enum reval_result result; struct reval_context ctx = { .odp_actions = odp_actions, @@ -2215,6 +2215,18 @@ revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey, goto exit; } + /* Clear flow wildcard bits for fields which are not present + * in the original packet header. These wildcards may get set + * due to push/set_field actions. This results into frequent + * invalidation of datapath flows by revalidator thread. */ + + /* Create wc mask based on incoming packet. */ + flow_wildcards_init_for_packet(&wc_from_flow, + &ctx.flow); + + /* Clear mask fields in ctx which are not relevant for packet. */ + flow_wildcards_and(ctx.wc, &wc_from_flow, ctx.wc); + /* Do not modify if any bit is wildcarded by the installed datapath flow, * but not the newly revalidated wildcard mask (wc), i.e., if revalidation * tells that the datapath flow is now too generic and must be narrowed diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 4407f9c..42fdb9f 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -7363,26 +7363,6 @@ xlate_wc_finish(struct xlate_ctx *ctx) ctx->wc->masks.tp_src = 0; ctx->wc->masks.tp_dst = 0; } - - /* Clear flow wildcard bits for fields which are not present - * in the original packet header. These wildcards may get set - * due to push/set_field actions. This results into frequent - * invalidation of datapath flows by revalidator thread. */ - - /* Clear mpls label wc bits if original packet is non-mpls. */ - if (!eth_type_mpls(ctx->xin->upcall_flow->dl_type)) { - for (i = 0; i < FLOW_MAX_MPLS_LABELS; i++) { - ctx->wc->masks.mpls_lse[i] = 0; - } - } - /* Clear vlan header wc bits if original packet does not have - * vlan header. */ - for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) { - if (!eth_type_vlan(ctx->xin->upcall_flow->vlans[i].tpid)) { - ctx->wc->masks.vlans[i].tpid = 0; - ctx->wc->masks.vlans[i].tci = 0; - } - } } /* Translates the flow, actions, or rule in 'xin' into datapath actions in