From patchwork Thu May 24 15:27:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 919945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="FC9pupFl"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="KYwW8izA"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sCw500v5z9s0x for ; Fri, 25 May 2018 01:28:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B225EBB3; Thu, 24 May 2018 15:28:25 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1F1AF958 for ; Thu, 24 May 2018 15:28:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D66966D6 for ; Thu, 24 May 2018 15:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1527175701; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f/r4bf1zk/fwbwZa8aKYOPvP48TGVP8eyzRiQiDhp+Q=; b=FC9pupFlFpn5Y736JekVVA1q1lzWVgk6We/pts4zYWXTqCVtSBJ6zjXirYiN2FTK X04DicxJ9j72JZqod1Nyc4s/4ZMC2W1pEoUZxquh5aiQOU0X2Waz6BELnCZihARp DIKxxNjSyYBYCcND47BgvGkO77ugOy5XPresiD57Kls=; X-AuditID: c1b4fb3a-3b5ff7000000451c-9e-5b06da143465 Received: from ESESSHC016.ericsson.se (Unknown_Domain [153.88.183.66]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 34.2E.17692.41AD60B5; Thu, 24 May 2018 17:28:21 +0200 (CEST) Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSHC016.ericsson.se (153.88.183.66) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 24 May 2018 17:28:20 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) 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.1466.3; Thu, 24 May 2018 17:28:20 +0200 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 24 May 2018 17:28:20 +0200 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=X8hbW76LqAMZggsATxWXXsLF7qBA72E5cC6nStNQvD4=; b=KYwW8izAaz/fBUwfspuh7SIggL6nzaU/5E8oD4naUwRHBm2S6EEaTrR75CIn+JyTzomCsr7NpfGL7YObvRWBgilQXOip7Z2ygPVFfiGsdDs6lAaVBI/A3SqoybiAS8mCuvlEmpk361YXzGn7z3I8K0sOotDK1IoIXtTNg0xYJK8= Received: from ubuntu.eed.ericsson.se (129.192.10.2) by AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.5; Thu, 24 May 2018 15:28:19 +0000 From: Jan Scheurich To: Date: Thu, 24 May 2018 17:27:59 +0200 Message-ID: <1527175681-14674-2-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> References: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: AM5PR0502CA0020.eurprd05.prod.outlook.com (2603:10a6:203:91::30) To AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB1780; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 3:H3LBvWh462PYnXw9OubuAUAkwj/qqA4yhNOrt6DNaI3BV1IyEOnRV45GA/a2KfJOPp3cyasH97//0XVbk8ly1M9VaUb3uqveL1Elnxm7h1ulcMVfvB8/Z3tPUnGue/NFpt6m0QW9wFNgnSiBaTITGXcEVJguqtp78XY2Z/0iHNw+fPm9DPipk02HoIjtzVLPPbopy9gTbsx4C9F8vs+NTvIhEL2QdJmUeCW1hb75EL/0kFtbBL/fXwtn3zTNpn4H; 25:2Asm8vZH5sD8anNvXit8ZaoNVpdGMQ7cZt4fzc/GbqRyQ0UAsoaWsOA5gqqS2BTzmyC7gjb+ApG4a8o/GqcbvN1po52zII3gsJziJCDEFYwQ/2JfNzRt/4Ke8GNZb6/nrAUm3IeSmDped6UMJKL7xQ54VBhBie54fpu63TKPjKn8Id11mWyU2bF41GGETUP8hBk+kpiZ3Km2ZLugip+Q+1RrfL1oY+3wINFShLFX8nXdS6AaHNnhOQ1JoyB6awIyk0vYGkZicGxOjZck8ia1edBJ9cROVWbd/NqyUXSMzgb3bhrr1+VGEAbXIoqR3HZHD2rc3/CXO/Nff3TD0kXs8Q==; 31:GoWyXfLQGX77YCwBAZU0ZORmVNVLRiRYCcinnMhHnoP3Q1Hu1Z0AG9S1UqdjZPqO+MZ6az1SL2AKeA3qW09dq1OZFMcx0UYcc8xs7Z0MT22bVisQcfVrM/zEK4aGrZAiuw1YGre0TqoVg6feiC91FMrYJuAzkhCJq2s/040m2v0dZz5wZlaZsd1wxFSB80P42BNLfxuwds8fJK8JzH9ugU99aLQyhjm/DVT/GHgACM0= X-MS-TrafficTypeDiagnostic: AM5PR0701MB1780: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 20:AMaqD9V6Dr4hqzLiBuo9K2lHsDGHOgx6uLOsvi8oK7KwRmxWx+8dM1eFm99I5lqeZCuKynypPV9cdP7L5uPAIeKV/vIblSY4zs4y0NZ2y8c2cRkizYjJ9rBX22YTV+JmELh5YIrhfPqcAKMz4tOWV9PGZYffzSf3mjg7ye9uyM2vEWYloob9fSk6g/It4SVzBySjcyaduXKavh6Fy+7+gq4thtD7oGA5N27Exp42ZQc/0+w6FaexVPI/4sZO8UpgLpZGerSPb4iPdycUcEmUOLXi+3kPv5w8VDK/I+JsH0mK4WhzvS6YhpKuw9Di3xXm+NGpbypZZTdHKbTBj0ntuOHVu2aJWp6F4p2NBTMFYj0NDz85y6ldgSqFQZWgmgdItOXZGMWMJmQTOY4qcCI035nz+JMWBzwVJ5ICBGYg31wRyLvGfCFxkiCe/nKylvkYZlo3n6Genc8Oy5wWJDowALKAEjB64WMHjPWG4yaJvVEdo6CVpAvELQrXPLFg02vv; 4:cWIr866Puwqd3xr6KVz3uq6ztYhBn0MAMH6oC03DgDBIWVFQYZC4BK1g2NZq/Vzh0hzZaFV10QJr4XUywvA/9b6tkCTDCZGtufSPZVuX/OlCHv5wFE0QETkpA15wAptX0XBtNshrZIgFzem63OdxzW1G3sKsF3uozgO/Fc0mEb0dzKO1TjLzbHyEDnQMV24oHrro9otJzTTrM48I38zl0/Hg+kXb/oN2IWG0M7IfAnsnCxD6OljQ45aKpafgJT8kdqKjrfhaygRbahsIrfIF/Q+py7GViIYsv7LqB0snNN/9GzYGbBSXvBhyi421UJE0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0701MB1780; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB1780; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39380400002)(366004)(39860400002)(199004)(189003)(25786009)(26005)(486006)(97736004)(86362001)(6512007)(476003)(44832011)(11346002)(446003)(956004)(2616005)(16526019)(186003)(478600001)(386003)(6506007)(305945005)(7736002)(51416003)(52116002)(76176011)(53936002)(4326008)(107886003)(6916009)(6666003)(6486002)(5660300001)(105586002)(106356001)(8676002)(81156014)(81166006)(316002)(16586007)(3846002)(6116002)(2906002)(15760500003)(50226002)(8936002)(2351001)(66066001)(36756003)(50466002)(48376002)(47776003)(2361001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0701MB1780; H:ubuntu.eed.ericsson.se; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0701MB1780; 23:Y0EhHgt+rAaArJ1p1TROxuBOthH2X0i7xRKYGCa?= obnsqWR9AJn1AEElnFBLvfz4iRv+5bX6z4m4Xq78oPQh1zA70QfCfwIrr6Z8Swhw4zSJPudGARuojLmUSSaKCtx+S2y2UUgvc8PVzRg0sRTWBi/4rnEwLst0O+T48gxI0VLj5eHLp+/9bMzJ31PFVo1Y+j9RQ55VkODmHACzPfQ4fojLceK3eJ63hyU58fXKqLc4OleNUMJ4Bjjtr3CufMN2y8+xGWPSQmo6ZEcv3NUgUsUKY2LUhjzbKUsdMCjyicaXKW07Oh/CTUIrNAQm2zFcUPuIyEREmVO2lQSZ7j7BgamN2nnxGICoJ2Hb5t4hdMUKEmswc1hfHSBD6+qrJBWVp04UmCWMecIVRQkLWUt9KvaHgRz5xRyc4p2OusbQRF7ovEuSp0vc+clVHcXJ2wg9gDlselsLSDZQD02QQayHCTenPGDV8/ok67oPRNy+OmsiAoA66tH2gHhzTCC1ZnhUlL0L5sjjk/wMxoLZ/yVeDanUWoTKkWy/lM5vvNuq39pt8IpLvqETy27gqydhuFZ6/rDtANSTEl3TgmufsLAI7jJHpwjTmTfFt+2YLSC0I0KCz6p3LeW3coSbB1EJmkfkBvcn6PnZNn+I+Jr3wNXiHALZuMZQXC3IAmEM94fOLZFMvEpl4BouWC6aLhIy13BaWjtGNMLYliHSB8KRXVhW9MyydKoc/yWAVcay/3ajfu4MnKZK+TaJdxhe/18qkR5oDfikW5eQospnPSCeBewuHJ9QT/iFpV1U+otKZdAg4iWW+n/9n/Lw+3RglJQZPcAjkOwnDU0N1yqbyFJ6/vszXpQXkaBYXHYVEkK3AL6mg44AUPHCiM5abCDARzwioiiqQjmOBxwS0DrHJt6Khccmn+xzBnPCy9Lk3Alh81+QyDAjLUr34KzZD5StGeJGhdUnR6oQf2mGVLxxEdSauqWDuVTH80KIAZSq3pcfggh106u/q51j7DJnF7PgJZ/rwdq5x0m0MABdvQXokL3v5wjYIkWaE0yP0nkRJE5+f0vqpPwYrNIB1W/A5Z5BkGRt5m9bXFlfaSgAbsLWbcl2E5h643cXXKk5O3ry9xHd6f1taUou1cBFtjyL34SIxLmjrcvX0wAWqhNfH8r1YUzL0l9DRGc5IPqaa2bgNBv7esXd+wd51WHDZ2aGxWLmLqEQKBbK9UL0PIWOfHcp0mBOuaY9iR0SjnoNwfYHNKBYBvdeBp0EmDmLRZ95ECggxzGfChnzWmx5OZAVh9wZulPcGmA10Gw== X-Microsoft-Antispam-Message-Info: 4XxnQjtX+kSQZ5xsEBKUU3H+sbWpDxs9R8gr9yDd43W0git8HLvDfO58g2DLaxmY2gNhu3n5wbZcornTmxTg6Iwi1Vg6GDix7iZ//o/pxOcPYyQolv0iq41OC4rvvE1O3D+mae7GlFGQEfqeb1WmaZaAPaiT2ndTE0U4IUL0R2rEvbcSDsGI2HIr5MC4Mv3T X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 6:h37KcP54/ETe9jrDcYltn0o/l13h/DpPP8gkTma6oeKpKowP3C0u0+Kpdnb3rF8F1sxXdIRd5u0r95YhPnNvsYUM31LYnH79TG+MsNcd1Pj1ksoKETHx/7HJPXO2VT84wdsk2VJHLjglROHKSfvmger9p81X5f2oCQfqwaYDsibcDL6QBTkP+avqxNlNN7HeLhgvPGfOJ4ZTdzx+LdBe+toDqFvOae+uL7wlpBP5GFblkTgsgEngkemECAe1FbGH5+cOQSAh7mSpbEA67ZLxxxcYAJzKIvpMeobea5JFeJ9kUPDEAmxctEUDse1sDWKZ78yavI0NzNRr3Cj2fWWgzIMNnTBeeUq1Y+ayEbRPqQhts8G7qvLpmPcgDM4/gtDho5Yw3YxNm+qeK2yhLgakVaDr+YD3UeiJrnNuNlfTjZ468Rcq6Vd/o4TPVaU1+klWKe7q3rLYd/X4nT4AWh697A==; 5:fH2oVohoTA6Acq/VED2K+BjdiZw7wIiQpN/n+xckBw6GlY7VAXsfkUL5bt8CiozDAC2psnVQLg5I5aax23VLhr/ooD5rphw/GAx/XCvIUK94HnufyV7reqBfi838hKKwFQhTR0eG1vB+1oDJVyB+4yUMGJs6mKE6cbIhskGSxOc=; 24:V51HztzA+EXSPF8DzIftz5ncj8wTBQfIWgDLZyZfT/tRDd2iKAc13ZiaRfyGGbrbQ78Exq4jA3rbxfP2VTkNJpkcfRyHgoFWJphEN8yoof4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 7:7PQf2M9rbzscEi5MWTtfxdQ9ITu6e7GrC68ItJGXwNdCm5UIRBI3uLV17hftSyDiio+O+D9iXK1/lYQG+qEharSDW+eanyyeZTkoczlN8Zr9XK6rknU38yK/IP9NYHtMTTv0KNfmTHLuTgIVo9VaZROhVMQuYhleEA+VTgAOqme86Vb4WbDTqZqc04gZYLQSCqKL7CMY4QsOBlbNEyD+cMunJu2zPyDjTbXwe5s+Ye85rbUUdTzMnUK5ZQjIZDEr X-MS-Office365-Filtering-Correlation-Id: f0e6c491-7193-4def-2d75-08d5c18afa74 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 15:28:19.2639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0e6c491-7193-4def-2d75-08d5c18afa74 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB1780 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRjm2znbjrPZ51J8M7UaRRDlDYkhFqZ/JH/Urwy18qjHW/PCzlra j5glhVpmXn5Mi0xFwkWiTbQ1w80WqalFLJgaSBMdukIll5fUtp0V/nue93me9wIvRUjWyGAq v0jJKIpouVQgIjWX+hJOBk4K0iJblnxlC/VqJDOPGgjZL30NiieS2p438JPmrDsoaf7rffIC kSqKy2bk+SpGEXEmQ5S3OF4nLBk5X7rwycFTo8FTVciHAhwDfywGQRUSURL8DsHKeiPJER2C yj4z4ogTgbNnjOBIOw96X697MiSuJaDRYvBmqngwaP/mUihKgCOh+U28e0gA3g/bbTqBGxNY BZ0TBg/eh1OgfdLqwSQ+CvbPlaQbi/E56H5oRdyCYTD8vp7vbumDk6F1aK+7LHFZdmqmhJzd H4Y1syTXHsBotxNc9BB06zSe1QA3I3j6Vo+48DHYMq2SnCkUzGOPvaZ+BIa5L15yWwgdG0Ok ezLgEzBh83UHEL4MFb2NPC68IQB9bxaHi0E7aPMuHQuLG7//HzDyYJzH9TQRoHdo+JwQAkbH Nr8WRTTtuqJp1xUtiNeJAlmGZQtzo6PDGUV+FssWF4UXMcoe5PoHo24zth8Z58+aEKaQdI/Y aBWkSfi0ii0rNCGgCGmAuCXTVRJn02U3GUXxVcV1OcOa0AGKlAaJE3JkqRKcSyuZawxTwij+ qTzKJ1iNCkaTNUsrkWmZXfwfH8Z6GmK2Uopb7xmjcma1IXFKvxcdwgj6SOiTWQeN5pwZM7YK Lf/l5nLiWkPfnRs5m1l3SxdXZyouqqrVzq5XOwen5IUDpyvLMWXWTut/FtSlWwbSD3/0L8m+ BfWrtMU2XL4cdOWZOSzBRiROVz/y6/wuJdk8Ouo4oWDpvwmlpSgLAwAA X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: nitin.katiyar@ericsson.com, ychen103103@163.com Subject: [ovs-dev] [PATCH v4 1/3] userspace datapath: Add OVS_HASH_L4_SYMMETRIC dp_hash algorithm X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This commit implements a new dp_hash algorithm OVS_HASH_L4_SYMMETRIC in the netdev datapath. It will be used as default hash algorithm for the dp_hash-based select groups in a subsequent commit to maintain compatibility with the symmetry property of the current default hash selection method. A new dpif_backer_support field 'max_hash_alg' is introduced to reflect the highest hash algorithm a datapath supports in the dp_hash action. Signed-off-by: Jan Scheurich Signed-off-by: Nitin Katiyar Co-authored-by: Nitin Katiyar --- datapath/linux/compat/include/linux/openvswitch.h | 4 ++ lib/flow.c | 43 +++++++++++++++++++++- lib/flow.h | 1 + lib/odp-execute.c | 23 ++++++++++-- ofproto/ofproto-dpif-xlate.c | 7 +++- ofproto/ofproto-dpif.c | 45 +++++++++++++++++++++++ ofproto/ofproto-dpif.h | 5 ++- 7 files changed, 121 insertions(+), 7 deletions(-) diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h index 6f4fa01..5c1e238 100644 --- a/datapath/linux/compat/include/linux/openvswitch.h +++ b/datapath/linux/compat/include/linux/openvswitch.h @@ -724,6 +724,10 @@ struct ovs_action_push_vlan { */ enum ovs_hash_alg { OVS_HASH_ALG_L4, +#ifndef __KERNEL__ + OVS_HASH_ALG_SYM_L4, +#endif + __OVS_HASH_MAX }; /* diff --git a/lib/flow.c b/lib/flow.c index 136f060..75ca456 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -2124,6 +2124,45 @@ flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis) return jhash_bytes(&fields, sizeof fields, basis); } +/* Symmetrically Hashes non-IP 'flow' based on its L2 headers. */ +uint32_t +flow_hash_symmetric_l2(const struct flow *flow, uint32_t basis) +{ + union { + struct { + ovs_be16 eth_type; + ovs_be16 vlan_tci; + struct eth_addr eth_addr; + ovs_be16 pad; + }; + uint32_t word[3]; + } fields; + + uint32_t hash = basis; + int i; + + if (flow->packet_type != htonl(PT_ETH)) { + /* Cannot hash non-Ethernet flows */ + return 0; + } + + for (i = 0; i < ARRAY_SIZE(fields.eth_addr.be16); i++) { + fields.eth_addr.be16[i] = + flow->dl_src.be16[i] ^ flow->dl_dst.be16[i]; + } + fields.vlan_tci = 0; + for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) { + fields.vlan_tci ^= flow->vlans[i].tci & htons(VLAN_VID_MASK); + } + fields.eth_type = flow->dl_type; + fields.pad = 0; + + hash = hash_add(hash, fields.word[0]); + hash = hash_add(hash, fields.word[1]); + hash = hash_add(hash, fields.word[2]); + return hash_finish(hash, basis); +} + /* Hashes 'flow' based on its L3 through L4 protocol information */ uint32_t flow_hash_symmetric_l3l4(const struct flow *flow, uint32_t basis, @@ -2144,8 +2183,8 @@ flow_hash_symmetric_l3l4(const struct flow *flow, uint32_t basis, hash = hash_add64(hash, a[i] ^ b[i]); } } else { - /* Cannot hash non-IP flows */ - return 0; + /* Revert to hashing L2 headers */ + return flow_hash_symmetric_l2(flow, basis); } hash = hash_add(hash, flow->nw_proto); diff --git a/lib/flow.h b/lib/flow.h index 7a9e7d0..9de94b2 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -236,6 +236,7 @@ hash_odp_port(odp_port_t odp_port) uint32_t flow_hash_5tuple(const struct flow *flow, uint32_t basis); uint32_t flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis); +uint32_t flow_hash_symmetric_l2(const struct flow *flow, uint32_t basis); uint32_t flow_hash_symmetric_l3l4(const struct flow *flow, uint32_t basis, bool inc_udp_ports ); diff --git a/lib/odp-execute.c b/lib/odp-execute.c index c5080ea..5831d1f 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -730,14 +730,16 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, } switch ((enum ovs_action_attr) type) { + case OVS_ACTION_ATTR_HASH: { const struct ovs_action_hash *hash_act = nl_attr_get(a); - /* Calculate a hash value directly. This might not match the + /* Calculate a hash value directly. This might not match the * value computed by the datapath, but it is much less expensive, * and the current use case (bonding) does not require a strict * match to work properly. */ - if (hash_act->hash_alg == OVS_HASH_ALG_L4) { + switch (hash_act->hash_alg) { + case OVS_HASH_ALG_L4: { struct flow flow; uint32_t hash; @@ -753,7 +755,22 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, } packet->md.dp_hash = hash; } - } else { + break; + } + case OVS_HASH_ALG_SYM_L4: { + struct flow flow; + uint32_t hash; + + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { + flow_extract(packet, &flow); + hash = flow_hash_symmetric_l3l4(&flow, + hash_act->hash_basis, + false); + packet->md.dp_hash = hash; + } + break; + } + default: /* Assert on unknown hash algorithm. */ OVS_NOT_REACHED(); } diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index c7c9df5..9f7fca7 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4005,10 +4005,15 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, struct ovs_action_hash *act_hash; /* Hash action. */ + enum ovs_hash_alg hash_alg = xr->hash_alg; + if (hash_alg > ctx->xbridge->support.max_hash_alg) { + /* Algorithm supported by all datapaths. */ + hash_alg = OVS_HASH_ALG_L4; + } act_hash = nl_msg_put_unspec_uninit(ctx->odp_actions, OVS_ACTION_ATTR_HASH, sizeof *act_hash); - act_hash->hash_alg = xr->hash_alg; + act_hash->hash_alg = hash_alg; act_hash->hash_basis = xr->hash_basis; /* Recirc action. */ diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 1ed82d0..7162811 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1291,6 +1291,50 @@ check_ct_clear(struct dpif_backer *backer) return supported; } +/* Probe the highest dp_hash algorithm supported by the datapath. */ +static size_t +check_max_dp_hash_alg(struct dpif_backer *backer) +{ + struct odputil_keybuf keybuf; + struct ofpbuf key; + struct flow flow; + struct ovs_action_hash *hash; + int max_alg = 0; + + struct odp_flow_key_parms odp_parms = { + .flow = &flow, + .probe = true, + }; + + memset(&flow, 0, sizeof flow); + ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); + odp_flow_key_from_flow(&odp_parms, &key); + + /* All datapaths support algortithm 0 (OVS_HASH_ALG_L4). */ + for (int alg = 1; alg < __OVS_HASH_MAX; alg++) { + struct ofpbuf actions; + bool ok; + + ofpbuf_init(&actions, 300); + hash = nl_msg_put_unspec_uninit(&actions, + OVS_ACTION_ATTR_HASH, sizeof *hash); + hash->hash_basis = 0; + hash->hash_alg = alg; + ok = dpif_probe_feature(backer->dpif, "Max dp_hash algorithm", &key, + &actions, NULL); + ofpbuf_uninit(&actions); + if (ok) { + max_alg = alg; + } else { + break; + } + } + + VLOG_INFO("%s: Max dp_hash algorithm probed to be %d", + dpif_name(backer->dpif), max_alg); + return max_alg; +} + #define CHECK_FEATURE__(NAME, SUPPORT, FIELD, VALUE, ETHTYPE) \ static bool \ check_##NAME(struct dpif_backer *backer) \ @@ -1353,6 +1397,7 @@ check_support(struct dpif_backer *backer) backer->rt_support.sample_nesting = check_max_sample_nesting(backer); backer->rt_support.ct_eventmask = check_ct_eventmask(backer); backer->rt_support.ct_clear = check_ct_clear(backer); + backer->rt_support.max_hash_alg = check_max_dp_hash_alg(backer); /* Flow fields. */ backer->rt_support.odp.ct_state = check_ct_state(backer); diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index 47bf7f9..d654947 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -175,7 +175,10 @@ struct group_dpif *group_dpif_lookup(struct ofproto_dpif *, DPIF_SUPPORT_FIELD(bool, ct_eventmask, "Conntrack eventmask") \ \ /* True if the datapath supports OVS_ACTION_ATTR_CT_CLEAR action. */ \ - DPIF_SUPPORT_FIELD(bool, ct_clear, "Conntrack clear") + DPIF_SUPPORT_FIELD(bool, ct_clear, "Conntrack clear") \ + \ + /* Highest supported dp_hash algorithm. */ \ + DPIF_SUPPORT_FIELD(size_t, max_hash_alg, "Max dp_hash algorithm") /* Stores the various features which the corresponding backer supports. */ struct dpif_backer_support { From patchwork Thu May 24 15:28:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 919947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="TP+FO5Wd"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="JELW+dKD"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sCxp11nQz9ry1 for ; Fri, 25 May 2018 01:30:22 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7154FBD7; Thu, 24 May 2018 15:28:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AE6E3BD8 for ; Thu, 24 May 2018 15:28:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CB165710 for ; Thu, 24 May 2018 15:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1527175707; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A1zUYpB+yLow+4tr+bTUHusspM3hpShLLU9CUtNDt8Y=; b=TP+FO5WddI7ehAPa++xNPTVH3K5G/SPKpv4NaskGbjz2nGnz2cDLcVIcbpBAhTgI OK1IaHjji5U13ER8rZiaiLI5urSUVETzNAjaUJ4EI3aGGgSkJYiGl4q158FVhCoQ /lfI1yq5RUKQ5gcCNbIntbwaNkafqiWfmQCuR6ZETPg=; X-AuditID: c1b4fb30-932519c0000065fb-a8-5b06da1a5ba2 Received: from ESESSHC010.ericsson.se (Unknown_Domain [153.88.183.48]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 54.5E.26107.A1AD60B5; Thu, 24 May 2018 17:28:27 +0200 (CEST) Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSHC010.ericsson.se (153.88.183.48) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 24 May 2018 17:28:21 +0200 Received: from ESESSMB503.ericsson.se (153.88.183.164) 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.1466.3; Thu, 24 May 2018 17:28:20 +0200 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 24 May 2018 17:28:21 +0200 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=4CGzo2zEO+EjD7skHzkY1yayQq6rmKctnSHjDEOkfks=; b=JELW+dKDAx62EhOTpKnKDM10g9x8/Eev2apfVubh/65eYXLAetRrwm0NO4qD1WabkRrksJdTWaaWSB7bDgJGQ4mLoXvAeuqUSsDtF/xT/LS75UZQf/EFegmYOhrxC0mxCx78uosGjVnlnsuWbCiQhYA9rrz/1De643G8EdIhfOQ= Received: from ubuntu.eed.ericsson.se (129.192.10.2) by AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.5; Thu, 24 May 2018 15:28:19 +0000 From: Jan Scheurich To: Date: Thu, 24 May 2018 17:28:00 +0200 Message-ID: <1527175681-14674-3-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> References: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: AM5PR0502CA0020.eurprd05.prod.outlook.com (2603:10a6:203:91::30) To AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB1780; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 3:IBOAjZ45AWbjV0K+8rPavM9ZfDXcXdHt/wlpNZXyVEbdeF3WNpKTLGcR/BPPseuHNyN4u0MYTGOJpy+pc8Iq9P/9IpqGRapgKdOv4kKlAy11EWvfWYNjZy0C6/f2p8E3Y+ajctV+g3VGGpGx/raKCuo+j7vAlveU4CUnZ8c+lk1UAQsKjP44UXxMrLqK/xLGwMnE2O6Q6DunwB+cBjvBuhSO5SXqk6yb0OYKIWD9a0YQpUuU20GEywzHJukz2A4H; 25:VVIoEmiGJljfuEpC244xhMZuJlvHNPhrqGdxLWnE+HBEvxckWt3hwx3FmEhTMKOMW8a+y4FfCPHGAOJMI+cPuZADAaMdoeMrzn+fMNZCQFlseZcpkyEl6J+FBDjnZWsSq6yNOsFiOlp8J/fwXor1+wztOKLKNqo9HcrO6TilQSTfolm0o9PNjWZl+QmG0VBLHGWcoCy/MisxuF60CFydrJHuZkVgrFu8oL2QgbrASCHqygroIzZG8SH6gLOUsUM/wo6+nyF50/yYiYy3jaEU8Oy5SX0KzZxuPlT1q/ohDCFfplrfwDeUpHIp9MGn9MFWdC37nSVonDGgsFx1XYlB7Q==; 31:J1FO2AJ5qzu8i9E6mTKaGiUpkekeXu8oFsCTSM45TrYfIA/faXUHQMcP114fIY+s77VvyGAA0BybGjDnZmh7EErKHr9qpTA6Xepzm9nKloyFmFEqLetW7syLAn4p3h5ToqU8vF6vdvAtNWaFEqxZJpIIk+xEDqsNk9uPBpdJ1UHMdmuqZVIEt/LhWUUCtyCRF5mhSFaXKOy68CPMmMOhByI0rQAeLcpyBsIynPFQiao= X-MS-TrafficTypeDiagnostic: AM5PR0701MB1780: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 20:GfWuKwq8j2VOY1xoSHgKlczLYwlLbtkVVJoVuXz4jARYG+r9ubR1V6jVQWHvi31KcPlG62j4APp5LZq2czSGNHlIQX+y7CDoeidBtSEQGf+oGiacRNSmZzF7lh45yE5qJZd4cYwRXuBECgMzm/91oUn5JuqBbBEdtKWfIa4610f2z6udPGuiYIl/kl9jrA2wcwfs5+/DIBc4LrNRkzUNIBNnhNE465W9tWD6HZadcVE2laaGOJ7mgMJOj7rPBE5B7fIopL7yFL3zn+sFvgTKm9Uch/cWdlTFH3AaRgM3Z2pMRMIbBOgbwq7yecvvaqCgopb8C9UmZN9iZ6PVMuYB2ZtPqVi2mypXM6M8mBF5pf5UACqE8zOJefvdKA9gGNyZgCO412GBPDK1I5DygK3/UrDP82F11jQrVDboZTL6ysAQXIk9MrR+cShsiWbnNIFrA57BfCSLzPm5OD/6QLoXLXyMQnXVv3riDZZSpUm0QmS7RzdcjGTK3ExTRAckHZAn; 4:JwXgtaYrGcMTZ7UYLi1n4LPZ7aneI1liTqHEeykvU2chQQqyODEgQQOtRUy4QarJqMcwimKVR/GCfezry0df42ZKlgNV/xwX7yBL6NrwFCEYm9SVD+AdCmjvaxgnTsXpH5ptpWNaLOptnxRXf3f8G3AkxLs5EbOMQ1gn5ktUZyWj4BU2YayWHl2zxCjP2c4OhNMY+2PngIeYuJM1NvbeCDt5H+4TAJNe8HilhJxRvadQdmxTo5ALeUKi7uOyVmbH+wk5Tv65Qp/qZA3kp/3uE1uD4F20yN36rdWMlakMp56oTtQ4vRg0346+Dcr+jhOp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0701MB1780; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB1780; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39380400002)(366004)(39860400002)(199004)(189003)(25786009)(26005)(486006)(97736004)(86362001)(6306002)(6512007)(476003)(44832011)(11346002)(446003)(956004)(2616005)(16526019)(186003)(478600001)(966005)(386003)(6506007)(59450400001)(305945005)(7736002)(51416003)(52116002)(76176011)(53936002)(4326008)(107886003)(6916009)(6666003)(6486002)(5660300001)(105586002)(106356001)(8676002)(81156014)(81166006)(316002)(16586007)(3846002)(6116002)(2906002)(50226002)(8936002)(2351001)(66066001)(36756003)(50466002)(48376002)(47776003)(2361001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0701MB1780; H:ubuntu.eed.ericsson.se; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0701MB1780; 23:HpFnq2wChIjvE8nTQGjdR+zsjDPW/gwvD2cNkCm?= JoXQtvyC/6YDDrIp4izYqpJvvIg5cIAvtOOwCtHDQnhqSkM9K/img8VbdNdKa+y11UCcRbDGtukDL5qfVpg04ea0i+j0y5piIS8I1VCgAWChCx6lzwI6XC90aDke0sWC7shRiaMQ1d+NoPcdLbXx5He5PLKcT6P5rXOnS7aJ6Sa/kAjiUaZ0y7snEVLkDfTJMW7gM1zt/vZXMnxgeM/0m7YvgRhCCsQSz8v0/mtyn5zoMnaAjgo33IrQOY1suWRPSvDo0rSIJ+LsaAY9M3KF5rin0D27ErEGaQfzY1HPs1weUM613i/mA0DOXr8PsLlpT7aftNm23R9D1NL+lEX8l+OgeXijHZtXce7twFqz1zNvw3v4qg5WXrPkTp7D/sKSAtnPtwzmY1sP/j4Ov3MUO+ZhZEV7BUiVdjeXgj2j5Ry/n66LbDlv4DBodl4nbmOhek1zLC9s5dgFM6yFHQObcItEodRKzWNt2zi2NhiJe4vlozjrj9J5jSguFc9eyMJw7+8LePwh1nSzSwlqK+fhpCXUy5grsD5LCeR+szk4GIS5NA4w5kclXf28+XKw3fUIgMcz2vXLUi+No+NxOCtIm+f4jZz1Opqwh6lUTkFR2gg3S3mBHHkS12NKzb4Ca+RTn4jiuGyadtdqjTFrHlV4R0uYwidl96PDfwRG3AqYSGQYDhcP1JhcmsFrk8KRidAgL60qilO2IJE4Fb8jJ9cX/AU+wJdpEm7Gr+C8UkJejH9/Nl2bwpIqFia9fP2iUfzVPLXXRiprdd1TXkXJQmGPZm8jf92Ll1XV+cynhQX8j6HlzFb1pprTSqoNgUeMdscPCdCwQvUAOP8HF5va6RyZU20WmRbVuALX69NOM9GcD9ui7AGC3CXPVeIAMog4hBy+WPXW5SCEN6Nm0+A8y5fK3T5x+4em2ZokPwR2FGB5nQGZmPl1pC6lCjjKR8rpnqFBS/LDkaB+QXunelxvZOEfQ/XQVeDJb1wjUVDq6Vi2WxpPOA0EWMTRvGb+oGOGn42B6U3AhhAFsCH0K55vGpqucD0h0Yri+M4o+4fW3duYj7meZRawWV4F13FmiLWflSo7xu3vj7N1XbdRM5nKacuIAh19uAptI/GRwyatk6Yj03+c9kC+A3ihfWwzp5+VeTXFdJT8hXPklf2itVQKuGGiskt2HnpBG9ghpKyGS+G+fP8MGJdzjeFfZBrVO1Ilgi98OVFq66ypcCEejwqEDlQPhL7+2LQhnbAkvqutibc45NSTh3XrRzc5Y2l/u+uCwOLs5vf0= X-Microsoft-Antispam-Message-Info: 9SMmheLHBdjlDyJ4NndJ69lUndrCXx6RiqEW/saBFT3YKDjXHUDWsLwgi8W+OXDuHghljxtg9lazdOseNVlVbCZcfu32ajwKmq966imuo2riEJ41IC9QQGI5J7e/Eq0YmrwkF1ekEiZ7zdEAM9CjzTqGV9OmIFJLv9Bafn/VbAMwftYHyYoC8ciGwsKGBnZg X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 6:gMojcpB1tta6Y2kxHOHdl0V4a3WbnBqMaQOClP2wUMjg9YK+JNq2v7w3wudZwnM3A85hZ/MpxzHx05DS9Oeau1akR/xRflTcCX8elz1HW1F0CIwHdpgdr8CBs3tcfwPeW4McS7ZhYFVqQQnj8YOWkiFoxSOMtsfxkZezxR7d4fduuTAW2jgiVQttJzW76lLehoxwVJ/S1VP7B2zWgykk5rlUm4/gq/43YN6xNzTPsvihG9w/mj5jF2MYPOOdJFWxjFaOtH5NCa1dlbNzBq2TZ77mGZ4o56YrvzDSFKgfmT+hfZz6VYKxvx4/e+XO/uqT3MBCEE3Lt1gp03dUqF745i2Y0ybcAMDVjlETp3NrqAzewUEynYY6qKeBy1svHf0yftqh2Dl8NJh8ODTw3WzM17QkyNIW5TsU/tb7RAs2y+rGEKuQ5XtnNAPKJAnxmlFNdSmVjB2hNxDSodOhAnrvxw==; 5:0nm/gikH4D+6326CUknjzeudeHISdD5YS12S3nBpjTBPqT3MiexXFLeKMK8L/I70jP1EFLfN34Vlyvev4B2hzehE7juVR2NCElEXTBmTaFVSaAhAcM6BOr4KXR5uzTun+v69Gu5hvJUne6blIlPdMgzE4EAaHqj5rZI0dU/q3cM=; 24:E6YftUxhHXLqMFp3kITMwSu/bvVB/E4mI/G7mkAHkCqgF6COD6HhzHBMzp93jKl2M8LtrG2kyNFoI14Bo2vII9SbSVCGbwFt0AyjX9ss+9M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 7:KpfamyEIYFBPmQmnpKTQuRNxnu4X1B4f0HN/meQKoWLyGk3ZQKd49q0eCYH1M7H0EYEKVSOF2BXLTazcfXDK7j+/HhCP7NQjcnco5CyxXhmMYh3GUcFrLi4wwlTZIHJSlOAJwBieTQV07omTyM5BdRt7BkvdaeDh2fUS1ZGFtgtY/V6b07hmymkwe858XeQkPZDFASpuTpDkZjKNbLY4VMDexEomCRkzWgDgHA9a9YkZsPalOx9ivnnYje6ClqnB X-MS-Office365-Filtering-Correlation-Id: 92118d9f-b6fc-4959-2b5b-08d5c18afab2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 15:28:19.6546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92118d9f-b6fc-4959-2b5b-08d5c18afab2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB1780 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsUyM2K7ga70LbZog5drOSxeTW5gtDh6eg+z xZddfYwOzB6LV0xh9Xh28z+jx/NrPSwBzFFcNimpOZllqUX6dglcGTPPPmEqONPDWPHu1S2m BsZp2V2MnBwSAiYS82fNYepi5OIQEjjCKHH9701GCGcLo0TjkS5GkCohgW+MEmsn+0AkljBJ PN1wFKyKRWACs8T2F9ug+ruYJA68uMvWxcjBwSZgIDF7twNIt4iApMS/xVvYQGxmgTKJVef3 gNnCAhESzSsbWEBsFgFVidWz/7CC2LwCXhLP/h1lhrhPTuLkscmsICM5BbwlFh3mhzjIS+J/ 3212iHJBiZMzn7BAjJeQOPjiBVSrgsTGLTNZQE6TEJjNKDF/3y6ob9Ql/h76ygJRJCtx9Owc qKIdjBJ7nl2GcprYJS7s7GAB2SwhoCNx/jE3SAOjQKxEy9apTBDNv9iAvi+CsPMlun+eYIWw rSRe//rOCPPAqd5zTBAzDzFL7HozE6pIRuLgm3+sExj1ZyH5YhaSLxYwMq1iFC1OLU7KTTcy 0kstykwuLs7P08tLLdnECEwPB7f8NtjB+PK54yFGAQ5GJR7e3TfYooVYE8uKK3MPMUpwMCuJ 8C5IAgrxpiRWVqUW5ccXleakFh9ilOZgURLntfDbHCUkkJ5YkpqdmlqQWgSTZeLglGpgjHv3 O0xC6nTry6UrZ8+cGSW/VtDqmcJxhn1LNlTcO/dkemL7+d8rzugvUvWzumuRyjcnJ1jYsiek 5Er+BbmjtvOSRP1DGfSqFdl3dS4NCJmydGNwJ1Ol1/Ji1x2N3RulbiTYPg353fYp6/S+zyqy W23/v27yPqyRNqvv15rTa/KnBCpuuLw1QYmlOCPRUIu5qDgRAMoyBz0LAwAA X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: nitin.katiyar@ericsson.com, ychen103103@163.com Subject: [ovs-dev] [PATCH v4 2/3] ofproto-dpif: Improve dp_hash selection method for select groups X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The current implementation of the "dp_hash" selection method suffers from two deficiences: 1. The hash mask and hence the number of dp_hash values is just large enough to cover the number of group buckets, but does not consider the case that buckets have different weights. 2. The xlate-time selection of best bucket from the masked dp_hash value often results in bucket load distributions that are quite different from the bucket weights because the number of available masked dp_hash values is too small (2-6 bits compared to 32 bits of a full hash in the default hash selection method). This commit provides a more accurate implementation of the dp_hash select group by applying the well known Webster method for distributing a small number of "seats" fairly over the weighted "parties" (see https://en.wikipedia.org/wiki/Webster/Sainte-Lagu%C3%AB_method). The dp_hash mask is autmatically chosen large enough to provide good enough accuracy even with widely differing weights. This distribution happens at group modification time and the resulting table is stored with the group-dpif struct. At xlation time, we use the masked dp_hash values as index to look up the assigned bucket. If the bucket should not be live, we do a circular search over the mapping table until we find the first live bucket. As the buckets in the table are by construction in pseudo-random order with a frequency according to their weight, this method maintains correct distribution even if one or more buckets are non-live. Xlation is further simplified by storing some derived select group state at group construction in struct group-dpif in a form better suited for xlation purposes. Adapted the unit test case for dp_hash select group accordingly. Signed-off-by: Jan Scheurich Signed-off-by: Nitin Katiyar Co-authored-by: Nitin Katiyar --- lib/odp-util.c | 4 +- ofproto/ofproto-dpif-xlate.c | 59 ++++++++++------- ofproto/ofproto-dpif.c | 150 +++++++++++++++++++++++++++++++++++++++++++ ofproto/ofproto-dpif.h | 13 ++++ tests/ofproto-dpif.at | 15 +++-- 5 files changed, 211 insertions(+), 30 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index 105ac80..8d4afa0 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -595,7 +595,9 @@ format_odp_hash_action(struct ds *ds, const struct ovs_action_hash *hash_act) ds_put_format(ds, "hash("); if (hash_act->hash_alg == OVS_HASH_ALG_L4) { - ds_put_format(ds, "hash_l4(%"PRIu32")", hash_act->hash_basis); + ds_put_format(ds, "l4(%"PRIu32")", hash_act->hash_basis); + } else if (hash_act->hash_alg == OVS_HASH_ALG_SYM_L4) { + ds_put_format(ds, "sym_l4(%"PRIu32")", hash_act->hash_basis); } else { ds_put_format(ds, "Unknown hash algorithm(%"PRIu32")", hash_act->hash_alg); diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9f7fca7..c990d8a 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4392,27 +4392,37 @@ pick_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group) static struct ofputil_bucket * pick_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group) { + uint32_t dp_hash = ctx->xin->flow.dp_hash; + /* dp_hash value 0 is special since it means that the dp_hash has not been * computed, as all computed dp_hash values are non-zero. Therefore * compare to zero can be used to decide if the dp_hash value is valid * without masking the dp_hash field. */ - if (!ctx->xin->flow.dp_hash) { - uint64_t param = group->up.props.selection_method_param; - - ctx_trigger_recirculate_with_hash(ctx, param >> 32, (uint32_t)param); + if (!dp_hash) { + enum ovs_hash_alg hash_alg = group->hash_alg; + if (hash_alg > ctx->xbridge->support.max_hash_alg) { + /* Algorithm supported by all datapaths. */ + hash_alg = OVS_HASH_ALG_L4; + } + ctx_trigger_recirculate_with_hash(ctx, hash_alg, group->hash_basis); return NULL; } else { - uint32_t n_buckets = group->up.n_buckets; - if (n_buckets) { - /* Minimal mask to cover the number of buckets. */ - uint32_t mask = (1 << log_2_ceil(n_buckets)) - 1; - /* Multiplier chosen to make the trivial 1 bit case to - * actually distribute amongst two equal weight buckets. */ - uint32_t basis = 0xc2b73583 * (ctx->xin->flow.dp_hash & mask); - - ctx->wc->masks.dp_hash |= mask; - return group_best_live_bucket(ctx, group, basis); + uint32_t hash_mask = group->hash_mask; + ctx->wc->masks.dp_hash |= hash_mask; + + /* Starting from the original masked dp_hash value iterate over the + * hash mapping table to find the first live bucket. As the buckets + * are quasi-randomly spread over the hash values, this maintains + * a distribution according to bucket weights even when some buckets + * are non-live. */ + for (int i = 0; i <= hash_mask; i++) { + struct ofputil_bucket *b = + group->hash_map[(dp_hash + i) & hash_mask]; + if (bucket_is_alive(ctx, b, 0)) { + return b; + } } + return NULL; } } @@ -4427,17 +4437,22 @@ pick_select_group(struct xlate_ctx *ctx, struct group_dpif *group) ctx_trigger_freeze(ctx); } - const char *selection_method = group->up.props.selection_method; - if (selection_method[0] == '\0') { + switch (group->selection_method) { + case SEL_METHOD_DEFAULT: return pick_default_select_group(ctx, group); - } else if (!strcasecmp("hash", selection_method)) { + break; + case SEL_METHOD_HASH: return pick_hash_fields_select_group(ctx, group); - } else if (!strcasecmp("dp_hash", selection_method)) { + break; + case SEL_METHOD_DP_HASH: return pick_dp_hash_select_group(ctx, group); - } else { - /* Parsing of groups should ensure this never happens */ + break; + default: + /* Parsing of groups ensures this never happens */ OVS_NOT_REACHED(); } + + return NULL; } static void @@ -4731,8 +4746,8 @@ finish_freezing__(struct xlate_ctx *ctx, uint8_t table) act_hash = nl_msg_put_unspec_uninit(ctx->odp_actions, OVS_ACTION_ATTR_HASH, sizeof *act_hash); - act_hash->hash_alg = OVS_HASH_ALG_L4; /* Make configurable. */ - act_hash->hash_basis = 0; /* Make configurable. */ + act_hash->hash_alg = ctx->dp_hash_alg; + act_hash->hash_basis = ctx->dp_hash_basis; } nl_msg_put_u32(ctx->odp_actions, OVS_ACTION_ATTR_RECIRC, recirc_id); } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 7162811..c9c2e51 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -32,6 +32,7 @@ #include "lacp.h" #include "learn.h" #include "mac-learning.h" +#include "math.h" #include "mcast-snooping.h" #include "multipath.h" #include "netdev-vport.h" @@ -4762,6 +4763,147 @@ group_dpif_credit_stats(struct group_dpif *group, ovs_mutex_unlock(&group->stats_mutex); } +/* Calculate the dp_hash mask needed to provide the least weighted bucket + * with at least one hash value and construct a mapping table from masked + * dp_hash value to group bucket using the Webster method. + * If the caller specifies a non-zero max_hash value, abort and return false + * if more hash values would be required. The absolute maximum number of + * hash values supported is 256. */ + +#define MAX_SELECT_GROUP_HASH_VALUES 256 + +static bool +group_setup_dp_hash_table(struct group_dpif *group, size_t max_hash) +{ + struct ofputil_bucket *bucket; + uint32_t n_buckets = group->up.n_buckets; + uint64_t total_weight = 0; + uint16_t min_weight = UINT16_MAX; + struct webster { + struct ofputil_bucket *bucket; + uint32_t divisor; + double value; + int hits; + } *webster; + + if (n_buckets == 0) { + VLOG_DBG(" Don't apply dp_hash method without buckets"); + return false; + } + + webster = xcalloc(n_buckets, sizeof(struct webster)); + int i = 0; + LIST_FOR_EACH (bucket, list_node, &group->up.buckets) { + if (bucket->weight > 0 && bucket->weight < min_weight) { + min_weight = bucket->weight; + } + total_weight += bucket->weight; + webster[i].bucket = bucket; + webster[i].divisor = 1; + webster[i].value = bucket->weight; + webster[i].hits = 0; + i++; + } + + if (total_weight == 0) { + VLOG_DBG(" Total weight is zero. No active buckets."); + free(webster); + return false; + } + VLOG_DBG(" Minimum weight: %d, total weight: %"PRIu64, + min_weight, total_weight); + + uint64_t min_slots = DIV_ROUND_UP(total_weight, min_weight); + uint64_t min_slots2 = ROUND_UP_POW2(min_slots); + uint64_t n_hash = MAX(16, min_slots2); + if (n_hash > MAX_SELECT_GROUP_HASH_VALUES || + (max_hash != 0 && n_hash > max_hash)) { + VLOG_DBG(" Too many hash values required: %"PRIu64, n_hash); + return false; + } + + VLOG_DBG(" Using %"PRIu64" hash values:", n_hash); + group->hash_mask = n_hash - 1; + if (group->hash_map) { + free(group->hash_map); + } + group->hash_map = xcalloc(n_hash, sizeof(struct ofputil_bucket *)); + + /* Use Webster method to distribute hash values over buckets. */ + for (int hash = 0; hash < n_hash; hash++) { + struct webster *winner = &webster[0]; + for (i = 1; i < n_buckets; i++) { + if (webster[i].value > winner->value) { + winner = &webster[i]; + } + } + winner->hits++; + winner->divisor += 2; + winner->value = (double) winner->bucket->weight / winner->divisor; + group->hash_map[hash] = winner->bucket; + } + + i = 0; + LIST_FOR_EACH (bucket, list_node, &group->up.buckets) { + double target = (n_hash * bucket->weight) / (double) total_weight; + VLOG_DBG(" Bucket %d: weight=%d, target=%.2f hits=%d", + bucket->bucket_id, bucket->weight, + target, webster[i].hits); + i++; + } + + free(webster); + return true; +} + +static void +group_set_selection_method(struct group_dpif *group) +{ + const struct ofputil_group_props *props = &group->up.props; + const char *selection_method = props->selection_method; + + if (selection_method[0] == '\0') { + VLOG_DBG("No selection method specified."); + group->selection_method = SEL_METHOD_DEFAULT; + } else if (!strcmp(selection_method, "dp_hash")) { + VLOG_DBG("Selection method specified: dp_hash."); + /* Try to use dp_hash if possible at all. */ + if (group_setup_dp_hash_table(group, 0)) { + group->selection_method = SEL_METHOD_DP_HASH; + group->hash_alg = props->selection_method_param >> 32; + if (group->hash_alg >= __OVS_HASH_MAX) { + VLOG_DBG(" Invalid dp_hash algorithm %d. " + "Defaulting to OVS_HASH_ALG_L4", group->hash_alg); + group->hash_alg = OVS_HASH_ALG_L4; + } + group->hash_basis = (uint32_t) props->selection_method_param; + VLOG_DBG("Use dp_hash with %d hash values using algorithm %d.", + group->hash_mask + 1, group->hash_alg); + } else { + /* Fall back to original default hashing in slow path. */ + VLOG_DBG(" Falling back to default hash method."); + group->selection_method = SEL_METHOD_DEFAULT; + } + } else if (!strcmp(selection_method, "hash")) { + VLOG_DBG("Selection method specified: hash."); + if (props->fields.values_size > 0) { + /* Controller has specified hash fields. */ + struct ds s = DS_EMPTY_INITIALIZER; + oxm_format_field_array(&s, &props->fields); + VLOG_DBG(" Hash fields: %s", ds_cstr(&s)); + ds_destroy(&s); + group->selection_method = SEL_METHOD_HASH; + } else { + /* No hash fields. Fall back to original default hashing. */ + VLOG_DBG(" No hash fields. Falling back to default hash method."); + group->selection_method = SEL_METHOD_DEFAULT; + } + } else { + /* Parsing of groups should ensure this never happens */ + OVS_NOT_REACHED(); + } +} + static enum ofperr group_construct(struct ofgroup *group_) { @@ -4770,6 +4912,10 @@ group_construct(struct ofgroup *group_) ovs_mutex_init_adaptive(&group->stats_mutex); ovs_mutex_lock(&group->stats_mutex); group_construct_stats(group); + group->hash_map = NULL; + if (group->up.type == OFPGT11_SELECT) { + group_set_selection_method(group); + } ovs_mutex_unlock(&group->stats_mutex); return 0; } @@ -4779,6 +4925,10 @@ group_destruct(struct ofgroup *group_) { struct group_dpif *group = group_dpif_cast(group_); ovs_mutex_destroy(&group->stats_mutex); + if (group->hash_map) { + free(group->hash_map); + group->hash_map = NULL; + } } static enum ofperr diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index d654947..e95fead 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -119,6 +119,12 @@ rule_dpif_is_internal(const struct rule_dpif *rule) /* Groups. */ +enum group_selection_method { + SEL_METHOD_DEFAULT, + SEL_METHOD_DP_HASH, + SEL_METHOD_HASH, +}; + struct group_dpif { struct ofgroup up; @@ -129,6 +135,12 @@ struct group_dpif { struct ovs_mutex stats_mutex; uint64_t packet_count OVS_GUARDED; /* Number of packets received. */ uint64_t byte_count OVS_GUARDED; /* Number of bytes received. */ + + enum group_selection_method selection_method; + enum ovs_hash_alg hash_alg; /* dp_hash algorithm to be applied. */ + uint32_t hash_basis; /* Basis for dp_hash. */ + uint32_t hash_mask; /* Used to mask dp_hash (2^N - 1).*/ + struct ofputil_bucket **hash_map; /* Map hash values to buckets. */ }; void group_dpif_credit_stats(struct group_dpif *, @@ -137,6 +149,7 @@ void group_dpif_credit_stats(struct group_dpif *, struct group_dpif *group_dpif_lookup(struct ofproto_dpif *, uint32_t group_id, ovs_version_t version, bool take_ref); + /* Backers. * diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index fe42a57..6d87951 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -500,11 +500,12 @@ for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) done -AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0x1)/dp_hash(0xXXXX\/0x1)/' | sed 's/packets.*actions:1/actions:1/' | strip_ufid | strip_used | sort], [0], [dnl +AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/packets.*actions:1/actions:1/' | \ + strip_ufid | strip_used | sort | uniq], [0], [dnl flow-dump from non-dpdk interfaces: -recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(hash_l4(0)),recirc(0x1) -recirc_id(0x1),dp_hash(0xXXXX/0x1),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:10 -recirc_id(0x1),dp_hash(0xXXXX/0x1),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(l4(0)),recirc(0x1) +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 ]) AT_CHECK([ovs-appctl revalidator/purge], [0]) @@ -516,10 +517,10 @@ for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) done -AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0x1)/dp_hash(0xXXXX\/0x1)/' | sed 's/\(actions:1\)[[01]]/\1X/' | strip_ufid | strip_used | sort], [0], [dnl +AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/\(actions:1\)[[01]]/\1X/' | strip_ufid | strip_used | sort], [0], [dnl flow-dump from non-dpdk interfaces: -recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(hash_l4(0)),recirc(0x2) -recirc_id(0x2),dp_hash(0xXXXX/0x1),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:15, bytes:1590, used:0.0s, actions:1X +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(l4(0)),recirc(0x2) +recirc_id(0x2),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:15, bytes:1590, used:0.0s, actions:1X ]) OVS_VSWITCHD_STOP From patchwork Thu May 24 15:28:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 919946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="UxNsmO0Z"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="c+igRv2G"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sCwr42xxz9ry1 for ; Fri, 25 May 2018 01:29:32 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 050A0AE0; Thu, 24 May 2018 15:28:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 07B509D0 for ; Thu, 24 May 2018 15:28:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg23.ericsson.net (sessmg23.ericsson.net [193.180.251.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DA8CC6D3 for ; Thu, 24 May 2018 15:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1527175702; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fIqLZmUeXccxdSeOEF398lAUWsTxTYuSnxyjrOv+yFE=; b=UxNsmO0ZUBbAFUnmnzINfxcPYVNAOfyq1EXq78yv3eautcqvwqiYcdV+VtqY3m+O eT26vs9r8ASwKkxjlpXp4Ohi5kwnny2DIiS75VNeyMrrE9uj7lGZE4Izus94ot5a TdFjDU5PF2yTBIMGd1+CZuaVVxY3ZtKMRy5UHtBCFfg=; X-AuditID: c1b4fb2d-1a3ff70000003162-73-5b06da167e8d Received: from ESESSHC020.ericsson.se (Unknown_Domain [153.88.183.78]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id D4.6D.12642.61AD60B5; Thu, 24 May 2018 17:28:22 +0200 (CEST) Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESSHC020.ericsson.se (153.88.183.78) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 24 May 2018 17:28:22 +0200 Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESBMB504.ericsson.se (153.88.183.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 24 May 2018 17:28:21 +0200 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB504.ericsson.se (153.88.183.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 24 May 2018 17:28:21 +0200 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=GamDHhGRKZojvvAL7DTf6gTNUHLFlTLRGj+qe4qQIEI=; b=c+igRv2GbV8hY82RQdH0Pl1mcePDhkZh7HhMyM8/WXL5dZE9C4Ct3/IeA1qe/ul6qsKiwegqR1lkZBt424kPG7g5KvOEInbVWjVJvs6Wa125B+El2GA3BAwMjglHe8FGZv1zlQA9ZbcvyMbySK7NZvAJI95ytMNSgw72yOc4zUY= Received: from ubuntu.eed.ericsson.se (129.192.10.2) by AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.5; Thu, 24 May 2018 15:28:20 +0000 From: Jan Scheurich To: Date: Thu, 24 May 2018 17:28:01 +0200 Message-ID: <1527175681-14674-4-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> References: <1527175681-14674-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: AM5PR0502CA0020.eurprd05.prod.outlook.com (2603:10a6:203:91::30) To AM5PR0701MB1780.eurprd07.prod.outlook.com (2603:10a6:203:1c::23) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB1780; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 3:UrPeQA6jftbTdFXaMNW6XMogkxQvKOsykHhdKsvl2iImhXaLlHixZbTZt4KJr6wcoO7zwDvYfiLWPeaxaIK9+tW7Y5JaASIs5HYLp4FRfUWMkoF8TVmfWuPJMEhXh/+qCcFtL0aMczLHVJ6MGnc4njFAfRYAOLHT2QtLH4j19tbPhHzB//W5Bi/HmfHfiSrbbOKc+9LB+XriFtdxX/CEn989FB6b4Vx/fi1lCr9/YMbKPevIQWHPhi/u+ck7tEES; 25:5pVYxxGZE1tyd5gSohFmwx+yb4/ZkA1AxjCz+g5XnTcNP5PgTX6uo6sGlNKmn6EN3/7YJm0x5FgJd4xFhAkq4Hl27pBfRJ8f3kTaol8LI3fi0XkxVezbwHPu/CXmqiu5C2NCV2uU/KeCV3Ek+NHBafHBWNGgS1TkLwk6Ik4oVuH3WqkhxyceRbIkPnDcKfhSXG54ICGS2aQAypjRgwg8MTg74wsnFOVx50zD8VT2hHNAiRsrpT7jxWUnujJ9hFzl1G/wnm3nkXpLCYsJCXhem/5I2c3kCvVnT7RdnWO19jpMWhcfRIrO6sTWN+Fa4uPqoaIAv+ex/s63CLkvCKLLFQ==; 31:nfkCBSlk2prg62Y2M3uEENNwYMxH1ptu8Ivx5GaSI7HKCzcdk+oQXoGB7O49NFhi6SxOuQy5oULxwQWu0UAinwFfFadZu+U+luB9dDi7krM/MkmJADfTIxG2esDfjtdLFju8P26285rD4BWxNQghpNuTojeFmpqlQFXXOB61koMF3yC8iv7EunVrWyf2iM/qQji9P3ZTcl2KRk/a9jbEOIU6uVB/xR83WDRX/koWjNA= X-MS-TrafficTypeDiagnostic: AM5PR0701MB1780: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 20:zWf8bdhTvmRN2X0ugKlxxzyfK1ydIql/gWiNaGJglvcQfaqpG9tjWJ0Bd6eYgFsHukKfk3YlwquTrtHAACzwVHIKAF2QHpGjY5WvsyxCY1NesyHdV+6hPQurgAD0x7m/aX9iTEaoHBwzycDCEDZg0pqrhauQHYDMj8BfJKa6pFzH6pMSckOFTgMot59Wwzen8VC9AQaBLR6DTe9s9rNUkqrRdrfjnruC6LmQD6yTpyhbE/DuAgTrqepKlmldhzlkLpLNxtK0+auyPmiLfKiRSv2LW5nLF7jn+d6TzWiSkzBiX0WyVqvXfeCi/wdPb1PfH4AlHdy53+w977/fi2tjLd3bfRyZZJnqgOpQM4rE73aFgvbzAMq5BtNCaEPyx7kg1cu3YeNI2PH/2zvv/gkGL1/+Mx7XLjGcn2entO04leoIsmVvWzgx/fQAXdpYXlZylr+HGEH0gU5IlbMEWJRq9hnqjvXll69liZQJ0M+ixlXP7rk6qWDPYobh3Io90V+7; 4:t+c2Mm0k1Wf7mwMI7XCmS9DVQwSErnpAHteRc2dv9Qx7BesT2dZTQ+UMTcLsogtvR/r5EIfhKLTtSHpj9TxnCaSvX8x0iEsMVDDpZNXZi0GLyg2fknP9gPsSAvqpAbNoVjMODSDq0FBrsB3HumiBSNUqkdjsZlmbJTO0Cy2LKwj8ZbxawR2ADxN86oXBcezPwwTknrb4CkCmB/ZT70xIakV95m2YcRwWNPRibLfMPLRGVIfbO8P2X3e8KMw1L5l3v9IfMf/zQ7KfQq8sSAzTyKCBurehZ5lh0MdDsAuJqfP4U/sQCOeJaJHG1j4Msbvx X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0701MB1780; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB1780; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(346002)(396003)(376002)(39380400002)(366004)(39860400002)(199004)(189003)(25786009)(26005)(486006)(97736004)(86362001)(575784001)(6512007)(53946003)(476003)(44832011)(11346002)(446003)(956004)(2616005)(16526019)(186003)(478600001)(386003)(6506007)(59450400001)(305945005)(7736002)(51416003)(52116002)(76176011)(53936002)(4326008)(107886003)(6916009)(6666003)(6486002)(5660300001)(105586002)(106356001)(8676002)(81156014)(81166006)(316002)(16586007)(3846002)(6116002)(2906002)(50226002)(8936002)(2351001)(66066001)(36756003)(50466002)(48376002)(47776003)(2361001)(68736007)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0701MB1780; H:ubuntu.eed.ericsson.se; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0701MB1780; 23:hZaUCbtnK6EMGYuk+j0EAf+aZfWrhSgNrhzJq18?= CeKH1mKKGOZ5cXuP294VS4QUOLKtBN85XGVQeenLfvjIqDeTHP26dF//EBdMCuU/u1cko8RKU12Pj67pFf2C+9HwRuby4Yp3gs5lK/P1M9x6RiJH4DOMEfrK+z5rMwvg1B/Dl4v2Sz23mVJoR4XzXfSK1Dxi2W5tjUGztNDBrKzVwTdd9EXuBmfxNtuyKo7wexiJ6855cPIHOJoe/j710TNvEm/eJC956t20bKpMTXFK6FMYMMqHHB5KBEgV+zVfXo2N7OulZBqa/0SAYrhFsNsbCk3XrOzJ7ms71N/P+kurCu0k1LQI61osowUdKexQlOHVhc1O1FtXXlwvdR9h730zmaa7rttZ2JCTfLdBmvQgRqikg8t3YVaGm+DEEu6Ctzfest1Y1eaZz0Po0kL7nxyyqqVKwUzh9wuyHlrE+oHf47KjTQleakt65m1H9oBwkhiWIhbFbOavn2bVIeMRIP2AKm16TPmwB0pue4b+moUITjWiI8kbjhpxgY/7Uh3m+1Of3MD2nA8BJk0x1hj1BfvvYRav3KTJczcB2mqFO6VBlFOn5A3JFC453EERzhHNrqP1eDu4rZ39t6YDJnYWQnKXmp+gnq5gTHqmkCrKXDCSLDuwx6cY1glPCQ6i3gScVV1Sl9F0NG7FoTz4UdPpatZ0WtcOfdkl0AaWsxV1SBPc+dFYucpX2CD+XzxsQb1zSZmolD3gf3uU7NRuueX+PO60BrH3TEQTcWSmCG35gR3Vp5GMOYStigDJ1QgEV4Mc2Z6XJwWIepxGV7lglx6uMsFytjaIo6bdtMrm28Nd4+CZ+U+4/MHS8ET8A0099a3WQW2sUQSt3Bry0t0efADwi4ZGzPE52w1AQik9InzvN0KztaJQRi9xwuSbBwHsRU1ZNi5cYjn/mhvD7fcKowwdYl2a4c/nPGv3GVsjgZh//ngV0wfwYpqRj/oPt3qJTAwAodzO66+uPnZVDuZlLViOSYn3JOvD2FbK3ydgm2Kc7Di6lk1yCZpoS99En8YQ9mlZysUmfg9tfWLtVp4oQJsHged92Jr3ELOAEIk6ZPp9dgv1lsRKnKPqbiWXWYEvtvFHtZNleIjux6USP0pgXirz76DcJ393Ye8YvOZuXDs98AbGP/ocGEhZSH+YCL9sz93YYNf4hlmIWrq0mt/qPa4tmKzciRGlYyGz0rs0zRjUIYZi4ZjPWGdcOQSE7mrTrtChinIz6kf0mv1bVyUtsB9pPBObFTLvbk5RVfPDnlPyXOJlqsp10Am3TuiKT0tHsTAQHWAUMMzMouv5qOVlZ+xo2QRI4GQDNVxiCygvghvAjlwersVVYkToDwNeQFE/peoih0zzzOz+wm+Po15kRvc3wUr/qV9xBL4iDQZhDNqv7tFrXHw== X-Microsoft-Antispam-Message-Info: J8VwlpdMY2C6raXF4p5HCuis/b5PlgWzP+ONvne7zzBamMR/66sbGvJMm4MplzR75lVW13D7NWTAXLBU0/bLELYMEAbENUH+2YPmW7gkFa5mYFPnS6IkqbTeGuKKueAe5CKsfWriJC4x5F5YJ3mFjTLs0yFlawprSZZ1rh6tlY43Bgd89CI9Fi3Y9lkyskGZ X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 6:7swcyBcSIV1vfNjPjdAwNXyUusAQzDVpGANaAM9commKDXzJ1rWi0fH79L9VezqoD++uxj2pA3rbw/mHVyDn5nWhmuAdgzQMAOMtaxF9elozIdLJlDrN3V7HwLnP8EnYZy7lnwGHXDmH0UMmRokaQv8KWdZeW76rhokRkSx+mCVG39Cw0Y7huyV8kInx8OLjsck0P1bJxXfLl9kSjNyNZPwtAcEg/d5Dsj2SlvwG4Rfvbt8hrFUN/kpyM8pThdxcKY941qOcuIbijQcrnEwsQCz0zYJA2LwAGRyAPTUx47/s5luLB6zTFzt7NdThOH2A9zf2jnSIlV2dP7vllmovCOFHFEqVZxKNmUNganLwJF4lU3aNpDriBHmgSUR7osZ9iXlNSdcW4/rYNdi9p6CktBktIcgrih0n5/srVE+2nrBCPy7dtHFZO0NCDDfxgp50q0IFO0s8d8jROSI4faZaaA==; 5:1t6vFfT6uJFDGFDP5L9yY332tYETCweZCIRJ+yvhbxLZKk1CAhg7GrIypR9VMSGKynvIwEgaIPJzlI3bmyQhY8hvqbsWeXmdMiqHm6jt2DNH97/x2LhIKdxI2FvF2F2IbLazUFsyWf/0ux5gUU/GFgAzXXg0Jwww/xMRua5SwQE=; 24:ULe45drAHZqjZyBoquJCEGu6mIVIR6/z5WfPI11KN7UuOBHEJ97pR0Fd7Ht4sDWWnW5//g4PIIsjjwpJmZ9dB33mJnW3yUOB45lyIAKZl2c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1780; 7:6awQBFM+/cLE9QGwzVvhazLe0Tu8yzX9kGlcP8NsYBO5J+aZmcV51GVq6cu/HkmTvs7nosif6JO/kR9TyZ9/B8y10/pAe/+Vm61TXd4H/U9l1v2wKOWWBs+8KWOwN4Jt+ZisJGbS9mwhqnNJa8fZvMo2gQO9kMJJHyiaS3sz+oD4eyankvkpStiat+iCq+uV2jfQTbN5LHH7GO590zmMKvtzof4MaK5EFk7fSeR0EAFRy/L+/b13YZnQ/kl6qhNC X-MS-Office365-Filtering-Correlation-Id: a61ce6bd-a7e7-4d9e-8ba1-08d5c18afaf2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 15:28:20.0765 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a61ce6bd-a7e7-4d9e-8ba1-08d5c18afaf2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB1780 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJIsWRmVeSWpSXmKPExsUyM2K7n67YLbZog49bLSxeTW5gtDh6eg+z xZddfYwOzB6LV0xh9Xh28z+jx/NrPSwBzFFcNimpOZllqUX6dglcGb/fbmAqeLuGqWLuXqkG xs+/GLsYOTkkBEwk+pZfY+pi5OIQEjjCKLHu3jx2CGcLo8SL+bdYIJxvjBLtd5YxQjhLmCS6 Dr8H62ERmMAssWvnMagBXUwSW7YcAerh4GATMJCYvdsBZImIgKTEv8Vb2EBsZoEyiVXn94DZ wgK+EsfmPGYCsVkEVCVW3r3KCmLzCnhJ3Fk3jw3iQDmJk8cms4KM5BTwllh0mB8kLARU8r/v NjtEuaDEyZlPWCDGS0gcfPGCGaJVQWLjlplgH0gIzGaUmL9vFyNEs7rE30NfWSCKZCWOnp0D VbSDUWLPs8tQiSZ2iVU3LUAWSwjoSJx/zA0SZhSIlWjZOpUJov4Xm8TbL69ZIerzJa7s2QYN VSuJ17++M8I8cKr3HFTDIWBovZkJ1SAjcfDNP9YJjPqzkHwxC8kXCxiZVjGKFqcWF+emGxnr pRZlJhcX5+fp5aWWbGIEJoiDW37r7mBc/drxEKMAB6MSD++dm2zRQqyJZcWVuYcYJTiYlUR4 FyQBhXhTEiurUovy44tKc1KLDzFKc7AoifPqrdoTJSSQnliSmp2aWpBaBJNl4uAEphCOHU/W 3VJ721DUZn78gHmEVb3v8cgZxWuTXv07Hcv3LiWG6/UtX6NU/dvBxz3cOf/IM7W0/Np5JyrU rM1J48qqPeePM4fXe96K+Bmre/ICY8iLIxPYZIoOBX1lnZ1Vf2epbgaHUNud1YrFNu/UL3Xr lCuvlvHU5LzkVXlLTlWtonDtrHO55kosxRmJhlrMRcWJAG3H40IMAwAA X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: nitin.katiyar@ericsson.com, ychen103103@163.com Subject: [ovs-dev] [PATCH v4 3/3] ofproto-dpif: Use dp_hash as default selection method X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The dp_hash selection method for select groups overcomes the scalability problems of the current default selection method which, due to L2-L4 hashing during xlation and un-wildcarding of the hashed fields, basically requires an upcall to the slow path to load-balance every L4 connection. The consequence are an explosion of datapath flows (megaflows degenerate to miniflows) and a limitation of connection setup rate OVS can handle. This commit changes the default selection method to dp_hash, provided the bucket configuration is such that the dp_hash method can accurately represent the bucket weights with up to 64 hash values. Otherwise we stick to original default hash method. We use the new dp_hash algorithm OVS_HASH_L4_SYMMETRIC to maintain the symmetry property of the old default hash method. A controller can explicitly request the old default hash selection method by specifying selection method "hash" with an empty list of fields in the Group properties of the OpenFlow 1.5 Group Mod message. Update the documentation about selection method in the ovs-ovctl man page. Revise and complete the ofproto-dpif unit tests cases for select groups. Signed-off-by: Jan Scheurich Signed-off-by: Nitin Katiyar Co-authored-by: Nitin Katiyar --- NEWS | 2 + lib/ofp-group.c | 15 ++- ofproto/ofproto-dpif.c | 30 +++-- ofproto/ofproto-dpif.h | 1 + ofproto/ofproto-provider.h | 2 +- tests/mpls-xlate.at | 26 ++-- tests/ofproto-dpif.at | 316 +++++++++++++++++++++++++++++++++++---------- tests/ofproto-macros.at | 7 +- utilities/ovs-ofctl.8.in | 47 ++++--- 9 files changed, 334 insertions(+), 112 deletions(-) diff --git a/NEWS b/NEWS index ec548b0..2b2be1e 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ Post-v2.9.0 * OFPT_ROLE_STATUS is now available in OpenFlow 1.3. * OpenFlow 1.5 extensible statistics (OXS) now implemented. * New OpenFlow 1.0 extensions for group support. + * Default selection method for select groups is now dp_hash with improved + accuracy. - Linux kernel 4.14 * Add support for compiling OVS with the latest Linux 4.14 kernel - ovn: diff --git a/lib/ofp-group.c b/lib/ofp-group.c index f5b0af8..697208f 100644 --- a/lib/ofp-group.c +++ b/lib/ofp-group.c @@ -1600,12 +1600,17 @@ parse_group_prop_ntr_selection_method(struct ofpbuf *payload, return OFPERR_OFPBPC_BAD_VALUE; } - error = oxm_pull_field_array(payload->data, fields_len, - &gp->fields); - if (error) { - OFPPROP_LOG(&rl, false, + if (fields_len > 0) { + error = oxm_pull_field_array(payload->data, fields_len, + &gp->fields); + if (error) { + OFPPROP_LOG(&rl, false, "ntr selection method fields are invalid"); - return error; + return error; + } + } else { + /* Selection_method "hash: w/o fields means default hash method. */ + gp->fields.values_size = 0; } return 0; diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index c9c2e51..a45d6ea 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1,5 +1,4 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -4787,7 +4786,7 @@ group_setup_dp_hash_table(struct group_dpif *group, size_t max_hash) } *webster; if (n_buckets == 0) { - VLOG_DBG(" Don't apply dp_hash method without buckets"); + VLOG_DBG(" Don't apply dp_hash method without buckets."); return false; } @@ -4862,9 +4861,24 @@ group_set_selection_method(struct group_dpif *group) const struct ofputil_group_props *props = &group->up.props; const char *selection_method = props->selection_method; + VLOG_DBG("Constructing select group %"PRIu32, group->up.group_id); if (selection_method[0] == '\0') { - VLOG_DBG("No selection method specified."); - group->selection_method = SEL_METHOD_DEFAULT; + VLOG_DBG("No selection method specified. Trying dp_hash."); + /* If the controller has not specified a selection method, check if + * the dp_hash selection method with max 64 hash values is appropriate + * for the given bucket configuration. */ + if (group_setup_dp_hash_table(group, 64)) { + /* Use dp_hash selection method with symmetric L4 hash. */ + group->selection_method = SEL_METHOD_DP_HASH; + group->hash_alg = OVS_HASH_ALG_SYM_L4; + group->hash_basis = 0; + VLOG_DBG("Use dp_hash with %d hash values using algorithm %d.", + group->hash_mask + 1, group->hash_alg); + } else { + /* Fall back to original default hashing in slow path. */ + VLOG_DBG("Falling back to default hash method."); + group->selection_method = SEL_METHOD_DEFAULT; + } } else if (!strcmp(selection_method, "dp_hash")) { VLOG_DBG("Selection method specified: dp_hash."); /* Try to use dp_hash if possible at all. */ @@ -4872,7 +4886,7 @@ group_set_selection_method(struct group_dpif *group) group->selection_method = SEL_METHOD_DP_HASH; group->hash_alg = props->selection_method_param >> 32; if (group->hash_alg >= __OVS_HASH_MAX) { - VLOG_DBG(" Invalid dp_hash algorithm %d. " + VLOG_DBG("Invalid dp_hash algorithm %d. " "Defaulting to OVS_HASH_ALG_L4", group->hash_alg); group->hash_alg = OVS_HASH_ALG_L4; } @@ -4881,7 +4895,7 @@ group_set_selection_method(struct group_dpif *group) group->hash_mask + 1, group->hash_alg); } else { /* Fall back to original default hashing in slow path. */ - VLOG_DBG(" Falling back to default hash method."); + VLOG_DBG("Falling back to default hash method."); group->selection_method = SEL_METHOD_DEFAULT; } } else if (!strcmp(selection_method, "hash")) { @@ -4890,12 +4904,12 @@ group_set_selection_method(struct group_dpif *group) /* Controller has specified hash fields. */ struct ds s = DS_EMPTY_INITIALIZER; oxm_format_field_array(&s, &props->fields); - VLOG_DBG(" Hash fields: %s", ds_cstr(&s)); + VLOG_DBG("Hash fields: %s", ds_cstr(&s)); ds_destroy(&s); group->selection_method = SEL_METHOD_HASH; } else { /* No hash fields. Fall back to original default hashing. */ - VLOG_DBG(" No hash fields. Falling back to default hash method."); + VLOG_DBG("No hash fields. Falling back to default hash method."); group->selection_method = SEL_METHOD_DEFAULT; } } else { diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index e95fead..1a404c8 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -61,6 +61,7 @@ struct ofproto_async_msg; struct ofproto_dpif; struct uuid; struct xlate_cache; +struct xlate_ctx; /* Number of implemented OpenFlow tables. */ enum { N_TABLES = 255 }; diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index d636fb3..2b77b89 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -572,7 +572,7 @@ struct ofgroup { const struct ovs_list buckets; /* Contains "struct ofputil_bucket"s. */ const uint32_t n_buckets; - const struct ofputil_group_props props; + struct ofputil_group_props props; struct rule_collection rules OVS_GUARDED; /* Referring rules. */ }; diff --git a/tests/mpls-xlate.at b/tests/mpls-xlate.at index 9bbf22a..34d82a3 100644 --- a/tests/mpls-xlate.at +++ b/tests/mpls-xlate.at @@ -25,7 +25,7 @@ dummy@ovs-dummy: hit:0 missed:0 ]) dnl Setup single MPLS tags. -AT_CHECK([ovs-ofctl -O OpenFlow13 add-group br0 group_id=1232,type=select,bucket=output:LOCAL]) +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 group_id=1232,type=select,selection_method=hash,bucket=output:LOCAL]) AT_CHECK([ovs-ofctl -O OpenFlow13 add-group br0 group_id=1233,type=all,bucket=output:LOCAL]) AT_CHECK([ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=dec_ttl,output:LOCAL]) AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 in_port=local,dl_type=0x0800,action=push_mpls:0x8847,set_field:10-\>mpls_label,output:1]) @@ -71,9 +71,15 @@ AT_CHECK([tail -1 stdout], [0], [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x2) ]) -AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(2),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) -AT_CHECK([tail -1 stdout], [0], - [Datapath actions: 100 +for d in 0 1 2 3; do + pkt="in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x8847),mpls(label=22,tc=0,ttl=64,bos=1)" + AT_CHECK([ovs-appctl netdev-dummy/receive p0 $pkt]) +done + +AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/packets.*actions:1/actions:1/' | strip_used | strip_ufid | sort], [0], [dnl +flow-dump from non-dpdk interfaces: +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x8847),mpls(label=22/0xfffff,tc=0/0,ttl=64/0x0,bos=1/1), packets:3, bytes:54, used:0.0s, actions:pop_mpls(eth_type=0x800),recirc(0x3) +recirc_id(0x3),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:100 ]) dnl Test MPLS pop then all group output (bucket actions do not trigger recirculation) @@ -85,10 +91,10 @@ AT_CHECK([tail -1 stdout], [0], dnl Test MPLS pop then all group output (bucket actions trigger recirculation) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x8847),mpls(label=24,tc=0,ttl=64,bos=1)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x3) + [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x4) ]) -AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(3),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(4),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], [Datapath actions: set(ipv4(ttl=63)),100 ]) @@ -96,10 +102,10 @@ AT_CHECK([tail -1 stdout], [0], dnl Test MPLS pop then all output to patch port AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x8847),mpls(label=25,tc=0,ttl=64,bos=1)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x4) + [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x5) ]) -AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(4),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(5),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], [Datapath actions: 101 ]) @@ -124,10 +130,10 @@ AT_CHECK([tail -1 stdout], [0], dnl Double MPLS pop AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x8847),mpls(label=60,tc=0,ttl=64,bos=0,label=50,tc=0,ttl=64,bos=1)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: pop_mpls(eth_type=0x8847),pop_mpls(eth_type=0x800),recirc(0x5) + [Datapath actions: pop_mpls(eth_type=0x8847),pop_mpls(eth_type=0x800),recirc(0x7) ]) -AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(5),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(7),in_port(1),eth(src=f8:bc:12:44:34:b6,dst=f8:bc:12:46:58:e0),eth_type(0x0800),ipv4(src=1.1.2.92,dst=1.1.2.88,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], [Datapath actions: set(ipv4(ttl=10)),100 ]) diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 6d87951..00ab97b 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -337,10 +337,18 @@ OVS_VSWITCHD_START add_of_ports br0 1 10 AT_CHECK([ovs-ofctl -O OpenFlow12 add-group br0 'group_id=1234,type=select,bucket=set_field:192.168.3.90->ip_src,output:10']) AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip actions=group:1234,output:10']) -AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0'], [0], [stdout]) -AT_CHECK([tail -1 stdout], [0], - [Datapath actions: set(ipv4(src=192.168.3.90,dst=192.168.0.2)),10,set(ipv4(src=192.168.0.1,dst=192.168.0.2)),10 + +for d in 0 1 2 3; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:1),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.1.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) +done + +AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/packets.*actions:/actions:/' | strip_ufid | strip_used | sort], [0], [dnl +flow-dump from non-dpdk interfaces: +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:hash(sym_l4(0)),recirc(0x1) +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), actions:set(ipv4(src=192.168.3.90)),10,set(ipv4(src=192.168.0.1)),10 ]) + OVS_VSWITCHD_STOP AT_CLEANUP @@ -397,81 +405,265 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - select group]) + +# Helper function to check the spread of dp_hash flows over buckets in the datapath +check_dpflow_stats () { + min_flows=$1 + min_buckets=$2 + read -d '' dpflows + hash_flow=`echo "$dpflows" | grep "actions:hash"` + n_flows=`echo "$dpflows" | grep -c dp_hash` + n_buckets=`echo "$dpflows" | grep dp_hash | grep -o "actions:[[0-9]]*" | sort | uniq -c | wc -l` + if [[ $n_flows -ge $min_flows ]]; then flows=ok; else flows=nok; fi + if [[ $n_buckets -ge $min_buckets ]]; then buckets=ok; else buckets=nok; fi + echo $hash_flow + echo "n_flows=$flows n_buckets=$buckets" +} + OVS_VSWITCHD_START add_of_ports br0 1 10 11 + +ovs-appctl vlog/set ofproto_dpif:file:dbg AT_CHECK([ovs-ofctl -O OpenFlow12 add-group br0 'group_id=1234,type=select,bucket=output:10,bucket=output:11']) +AT_CHECK([grep -A6 "Constructing select group 1234" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1234 +ofproto_dpif|DBG|No selection method specified. Trying dp_hash. +ofproto_dpif|DBG| Minimum weight: 1, total weight: 2 +ofproto_dpif|DBG| Using 16 hash values: +ofproto_dpif|DBG| Bucket 0: weight=1, target=8.00 hits=8 +ofproto_dpif|DBG| Bucket 1: weight=1, target=8.00 hits=8 +ofproto_dpif|DBG|Use dp_hash with 16 hash values using algorithm 1. +]) AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip actions=write_actions(group:1234)']) # Try a bunch of different flows and make sure that they get distributed -# at least somewhat. -for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_src=50:54:00:00:00:07,dl_dst=50:54:00:00:00:0$d,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0"], [0], [stdout]) - tail -1 stdout >> results +# # at least somewhat. +for d in 0 1 2 3; do + for s in 1 2 3 4 ; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:1),eth_type(0x0800),ipv4(src=192.168.0.$s,dst=192.168.1.$d,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) + done done -sort results | uniq -c -AT_CHECK([sort results | uniq], [0], - [Datapath actions: 10 -Datapath actions: 11 + +AT_CHECK([ovs-appctl dpctl/dump-flows | sort | strip_ufid | strip_used | check_dpflow_stats 5 2], [0], [dnl +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(sym_l4(0)),recirc(0x1) +n_flows=ok n_buckets=ok ]) + OVS_VSWITCHD_STOP AT_CLEANUP AT_SETUP([ofproto-dpif - select group with watch port]) + OVS_VSWITCHD_START add_of_ports br0 1 10 11 AT_CHECK([ovs-ofctl -O OpenFlow12 add-group br0 'group_id=1234,type=select,bucket=watch_port:10,output:10,bucket=output:11']) AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip actions=write_actions(group:1234)']) -AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:07,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0'], [0], [stdout]) -AT_CHECK([tail -1 stdout], [0], - [Datapath actions: 11 + +for d in 0 1 2 3; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:1),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) +done + +AT_CHECK([ovs-appctl dpctl/dump-flows | sort| sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | strip_ufid | strip_used], [0], [dnl +flow-dump from non-dpdk interfaces: +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:3, bytes:318, used:0.0s, actions:hash(sym_l4(0)),recirc(0x1) +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:3, bytes:318, used:0.0s, actions:11 ]) + OVS_VSWITCHD_STOP AT_CLEANUP -AT_SETUP([ofproto-dpif - select group with weight]) +AT_SETUP([ofproto-dpif - select group with weights]) + +# Helper function to check the spread of dp_hash flows over buckets in the datapath +check_dpflow_stats () { + min_flows=$1 + min_buckets=$2 + read -d '' dpflows + hash_flow=`echo "$dpflows" | grep "actions:hash"` + n_flows=`echo "$dpflows" | grep -c dp_hash` + n_buckets=`echo "$dpflows" | grep dp_hash | grep -o "actions:[[0-9]]*" | sort | uniq -c | wc -l` + if [[ $n_flows -ge $min_flows ]]; then flows=ok; else flows=nok; fi + if [[ $n_buckets -ge $min_buckets ]]; then buckets=ok; else buckets=nok; fi + echo $hash_flow + echo "n_flows=$flows n_buckets=$buckets" +} + +# Helper function to check the accuracy of distribution of packets over buckets +check_group_stats () { + min=($1 $2 $3 $4) + buckets=`grep -o 'packet_count=[[0-9]]*' | cut -d'=' -f2 | tail -n +2` + i=0 + for bucket in $buckets; do + if [[ $bucket -ge ${min[i]} ]]; then + echo "bucket$i >= ${min[[$i]]}" + else + echo "bucket$i < ${min[[$i]]}" + fi + (( i++ )) + if [[ $i -ge 4 ]]; then break; fi + done +} + OVS_VSWITCHD_START -add_of_ports br0 1 10 11 12 -AT_CHECK([ovs-ofctl -O OpenFlow12 add-group br0 'group_id=1234,type=select,bucket=output:10,bucket=output:11,weight=2000,bucket=output:12,weight=0']) +add_of_ports br0 1 10 11 12 13 14 + +ovs-appctl vlog/set ofproto_dpif:file:dbg +AT_CHECK([ovs-ofctl -O OpenFlow13 add-group br0 'group_id=1234,type=select,bucket=weight:5,output:10,bucket=weight:10,output:11,bucket=weight:25,output:12,bucket=weight:60,output:13,bucket=weight:0,output:14']) +AT_CHECK([grep -A9 "Constructing select group 1234" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1234 +ofproto_dpif|DBG|No selection method specified. Trying dp_hash. +ofproto_dpif|DBG| Minimum weight: 5, total weight: 100 +ofproto_dpif|DBG| Using 32 hash values: +ofproto_dpif|DBG| Bucket 0: weight=5, target=1.60 hits=2 +ofproto_dpif|DBG| Bucket 1: weight=10, target=3.20 hits=3 +ofproto_dpif|DBG| Bucket 2: weight=25, target=8.00 hits=8 +ofproto_dpif|DBG| Bucket 3: weight=60, target=19.20 hits=19 +ofproto_dpif|DBG| Bucket 4: weight=0, target=0.00 hits=0 +ofproto_dpif|DBG|Use dp_hash with 32 hash values using algorithm 1. +]) AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip actions=write_actions(group:1234)']) -AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:07,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0'], [0], [stdout]) -AT_CHECK([tail -1 stdout], [0], - [Datapath actions: 11 + +# Try 1000 different flows and make sure that they get distributed according to weights +for d1 in 0 1 2 3 4 5 6 7 8 9 ; do + for d2 in 0 1 2 3 4 5 6 7 8 9 ; do + for s in 0 1 2 3 4 5 6 7 8 9 ; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:1),eth_type(0x0800),ipv4(src=192.168.1.$s,dst=192.168.$d1.$d2,proto=6,tos=0,ttl=128,frag=no),tcp(src=1000$s,dst=1000)" + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) + done + done +done + +# Check balanced distribution over 32 dp_hash values +AT_CHECK([ovs-appctl dpctl/dump-flows | sort | strip_ufid | strip_used | check_dpflow_stats 32 4 ], [0], [dnl +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:117882, used:0.0s, actions:hash(sym_l4(0)),recirc(0x1) +n_flows=ok n_buckets=ok +]) + +# Check that actual distribution over the buckets is reasonably accurate: + ideal weights dp_hash values +# bucket0: 5%*1000 = 50 2/32*1000 = 63 +# bucket1: 10%*1000 = 100 3/32*1000 = 94 +# bucket2: 25%*1000 = 250 8/32*1000 = 250 +# bucket3: 60%*1000 = 600 19/32*1000 = 594 +# bucket4: 0 0 + +ovs-appctl time/warp 1000 +AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed 's/duration=[[0-9]]\.[[0-9]]*s,//' | check_group_stats 40 80 200 500], +[0], [dnl +bucket0 >= 40 +bucket1 >= 80 +bucket2 >= 200 +bucket3 >= 500 ]) + OVS_VSWITCHD_STOP AT_CLEANUP -AT_SETUP([ofproto-dpif - select group with hash selection method]) +AT_SETUP([ofproto-dpif - select group with explicit dp_hash selection method]) + OVS_VSWITCHD_START add_of_ports br0 1 10 11 -# Check that parse failures after 'fields' parsing work -AT_CHECK([ovs-ofctl -O OpenFlow10 add-group br0 'group_id=1,type=select,fields(eth_dst),bukket=output:10'], [1], ,[dnl -ovs-ofctl: unknown keyword bukket + +ovs-appctl vlog/set ofproto_dpif:file:dbg +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1234,type=select,selection_method=dp_hash,bucket=output:10,bucket=output:11']) +AT_CHECK([grep -A6 "Constructing select group 1234" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1234 +ofproto_dpif|DBG|Selection method specified: dp_hash. +ofproto_dpif|DBG| Minimum weight: 1, total weight: 2 +ofproto_dpif|DBG| Using 16 hash values: +ofproto_dpif|DBG| Bucket 0: weight=1, target=8.00 hits=8 +ofproto_dpif|DBG| Bucket 1: weight=1, target=8.00 hits=8 +ofproto_dpif|DBG|Use dp_hash with 16 hash values using algorithm 0. +]) + +# Fall back to legacy hash with zero buckets +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1235,type=select,selection_method=dp_hash']) +AT_CHECK([grep -A3 "Constructing select group 1235" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1235 +ofproto_dpif|DBG|Selection method specified: dp_hash. +ofproto_dpif|DBG| Don't apply dp_hash method without buckets. +ofproto_dpif|DBG|Falling back to default hash method. +]) + +# Fall back to legacy hash with zero buckets +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1236,type=select,selection_method=dp_hash,bucket=weight=1,output:10,bucket=weight=1000,output:11']) +AT_CHECK([grep -A4 "Constructing select group 1236" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1236 +ofproto_dpif|DBG|Selection method specified: dp_hash. +ofproto_dpif|DBG| Minimum weight: 1, total weight: 1001 +ofproto_dpif|DBG| Too many hash values required: 1024 +ofproto_dpif|DBG|Falling back to default hash method. +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + +AT_SETUP([ofproto-dpif - select group with legacy hash selection method]) + +# Helper function to check the spread of dp_hash flows over buckets in the datapath +check_dpflow_stats () { + min_flows=$1 + min_buckets=$2 + read -d '' dpflows + n_flows=`echo "$dpflows" | wc -l` + n_buckets=`echo "$dpflows" | grep -o "actions:[[0-9]]*" | sort | uniq -c | wc -l` + if [[ $n_flows -ge $min_flows ]]; then flows=ok; else flows=nok; fi + if [[ $n_buckets -ge $min_buckets ]]; then buckets=ok; else buckets=nok; fi + echo "n_flows=$flows n_buckets=$buckets" +} + +OVS_VSWITCHD_START +add_of_ports br0 1 10 11 + +ovs-appctl vlog/set ofproto_dpif:file:dbg +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1234,type=select,selection_method=hash,bucket=output:10,bucket=output:11']) +AT_CHECK([grep -A2 "Constructing select group 1234" ovs-vswitchd.log | sed 's/^.*ofproto_dpif/ofproto_dpif/'], [0], [dnl +ofproto_dpif|DBG|Constructing select group 1234 +ofproto_dpif|DBG|Selection method specified: hash. +ofproto_dpif|DBG|No hash fields. Falling back to default hash method. ]) -AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=output:10,bucket=output:11']) + AT_CHECK([ovs-ofctl -O OpenFlow15 add-flow br0 'ip actions=write_actions(group:1234)']) -# Try a bunch of different flows and make sure that they get distributed -# at least somewhat. -for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_src=50:54:00:00:00:07,dl_dst=50:54:00:00:00:0$d,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0"], [0], [stdout]) - tail -1 stdout >> results +# Try 16 flows with differing default hash values. +for d in 0 1 2 3; do + for s in 1 2 3 4 ; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:1),eth_type(0x0800),ipv4(src=192.168.0.$s,dst=192.168.1.$d,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) + done done -sort results | uniq -c -AT_CHECK([sort results | uniq], [0], - [Datapath actions: 10 -Datapath actions: 11 + +# Check that the packets installed 16 data path flows and each of the two +# buckets is hit at least once. +AT_CHECK([ovs-appctl dpctl/dump-flows | strip_ufid | strip_used | sort | check_dpflow_stats 16 2], [0], [dnl +n_flows=ok n_buckets=ok ]) -> results -# Try a bunch of different flows and make sure that they are not distributed -# as they only vary a field that is not hashed -for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do - AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_src=50:54:00:00:00:0$d,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=1,nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0"], [0], [stdout]) - tail -1 stdout >> results -done -sort results | uniq -c -AT_CHECK([sort results | uniq | sed 's/1[[01]]/1?/'], [0], - [Datapath actions: 1? +OVS_VSWITCHD_STOP +AT_CLEANUP + +AT_SETUP([ofproto-dpif - select group with custom hash selection method]) + +# Helper function to check the spread of dp_hash flows over buckets in the datapath +check_dpflow_stats () { + min_flows=$1 + min_buckets=$2 + read -d '' dpflows + n_flows=`echo "$dpflows" | wc -l` + n_buckets=`echo "$dpflows" | grep -o "actions:[[0-9]]*" | sort | uniq -c | wc -l` + if [[ $n_flows -ge $min_flows ]]; then flows=ok; else flows=nok; fi + if [[ $n_buckets -ge $min_buckets ]]; then buckets=ok; else buckets=nok; fi + echo "n_flows=$flows n_buckets=$buckets" +} + +OVS_VSWITCHD_START +add_of_ports br0 1 10 11 + +# Check that parse failures after 'fields' parsing work +AT_CHECK([ovs-ofctl -O OpenFlow10 add-group br0 'group_id=1,type=select,fields(eth_dst),bukket=output:10'], [1], ,[dnl +ovs-ofctl: unknown keyword bukket ]) # Check that fields are rejected without "selection_method=hash". @@ -484,43 +676,31 @@ AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1235,type=select,selec ovs-ofctl: selection_method_param is only allowed with "selection_method" ]) -OVS_VSWITCHD_STOP -AT_CLEANUP - -AT_SETUP([ofproto-dpif - select group with dp_hash selection method]) -OVS_VSWITCHD_START -add_of_ports br0 1 10 11 -AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1234,type=select,selection_method=dp_hash,bucket=output:10,bucket=output:11']) -AT_CHECK([ovs-ofctl -O OpenFlow15 add-flow br0 'ip,nw_src=192.168.0.1 actions=group:1234']) +AT_CHECK([ovs-ofctl -O OpenFlow15 add-group br0 'group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=output:10,bucket=output:11']) +AT_CHECK([ovs-ofctl -O OpenFlow15 add-flow br0 'ip actions=write_actions(group:1234)']) -# Try a bunch of different flows and make sure that they get distributed -# at least somewhat. -for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do - pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.1.$d,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" +# Try 16 flows with differing custom hash and check that they give rise to +# 16 data path flows and each of the two buckets is hit at least once +for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do + pkt="in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:$d),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) done -AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/packets.*actions:1/actions:1/' | \ - strip_ufid | strip_used | sort | uniq], [0], [dnl -flow-dump from non-dpdk interfaces: -recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(l4(0)),recirc(0x1) -recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:10 -recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 +AT_CHECK([ovs-appctl dpctl/dump-flows | strip_ufid | strip_used | sort | check_dpflow_stats 16 2], [0], [dnl +n_flows=ok n_buckets=ok ]) AT_CHECK([ovs-appctl revalidator/purge], [0]) -# Try a bunch of different flows and make sure that they are not distributed -# as they only vary a field that is not hashed +# Try 16 flows that differ only in fields that are not part of the custom +# hash and check that there is only a single datapath flow for d in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do pkt="in_port(1),eth(src=50:54:00:00:00:$d,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" AT_CHECK([ovs-appctl netdev-dummy/receive p1 $pkt]) done -AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/dp_hash(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/\(actions:1\)[[01]]/\1X/' | strip_ufid | strip_used | sort], [0], [dnl -flow-dump from non-dpdk interfaces: -recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(src=192.168.0.1,frag=no), packets:15, bytes:1590, used:0.0s, actions:hash(l4(0)),recirc(0x2) -recirc_id(0x2),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:15, bytes:1590, used:0.0s, actions:1X +AT_CHECK([ovs-appctl dpctl/dump-flows | grep -c recirc_id], [0], [dnl +1 ]) OVS_VSWITCHD_STOP diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 9a37464..8923ce0 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -300,6 +300,11 @@ strip_used () { sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/' } +# Removes all 'duration=...' to make output easier to compare. +strip_duration () { + sed 's/duration=[[0-9]]*\.[[0-9]]*s,//' +} + # Strips 'ufid:...' from output, to make it easier to compare. # (ufids are random.) strip_ufid () { @@ -318,7 +323,7 @@ m4_define([_OVS_VSWITCHD_START], [dnl Create database. touch .conf.db.~lock~ AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema]) - +q dnl Start ovsdb-server. AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr]) on_exit "kill `cat ovsdb-server.pid`" diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in index 2e2f696..4f8555a 100644 --- a/utilities/ovs-ofctl.8.in +++ b/utilities/ovs-ofctl.8.in @@ -2120,28 +2120,23 @@ The selection method used to select a bucket for a select group. This is a string of 1 to 15 bytes in length known to lower layers. This field is optional for \fBadd\-group\fR, \fBadd\-groups\fR and \fBmod\-group\fR commands on groups of type \fBselect\fR. Prohibited -otherwise. The default value is the empty string. +otherwise. If no selection method is specified, Open vSwitch up to +release 2.9 applies the \fBhash\fR method with default fields. From +2.10 onwards Open vSwitch defaults to the \fBdp_hash\fR method with symmetric +L3/L4 hash algorithm, unless the weighted group buckets cannot be mapped to +a maximum of 64 dp_hash values with sufficient accuracy. +In those rare cases Open vSwitch 2.10 and later fall back to the \fBhash\fR +method with the default set of hash fields. .RS -.IP \fBhash\fR -Use a hash computed over the fields specified with the \fBfields\fR -option, see below. \fBhash\fR uses the \fBselection_method_param\fR -as the hash basis. -.IP -Note that the hashed fields become exact matched by the datapath -flows. For example, if the TCP source port is hashed, the created -datapath flows will match the specific TCP source port value present -in the packet received. Since each TCP connection generally has a -different source port value, a separate datapath flow will be need to -be inserted for each TCP connection thus hashed to a select group -bucket. .IP \fBdp_hash\fR Use a datapath computed hash value. The hash algorithm varies accross different datapath implementations. \fBdp_hash\fR uses the upper 32 bits of the \fBselection_method_param\fR as the datapath hash -algorithm selector, which currently must always be 0, corresponding to -hash computation over the IP 5-tuple (selecting specific fields with -the \fBfields\fR option is not allowed with \fBdp_hash\fR). The lower -32 bits are used as the hash basis. +algorithm selector. The supported values are \fB0\fR (corresponding to +hash computation over the IP 5-tuple) and \fB1\fR (corresponding to a +\fIsymmetric\fR hash computation over the IP 5-tuple). Selecting specific +fields with the \fBfields\fR option is not supported with \fBdp_hash\fR). +The lower 32 bits are used as the hash basis. .IP Using \fBdp_hash\fR has the advantage that it does not require the generated datapath flows to exact match any additional packet header @@ -2155,9 +2150,23 @@ when needed, and a second match is required to match some bits of its value. This double-matching incurs a small additional latency cost for each packet, but this latency is orders of magnitude less than the latency of creating new datapath flows for new TCP connections. +.IP \fBhash\fR +Use a hash computed over the fields specified with the \fBfields\fR +option, see below. If no hash fields are specified, \fBhash\fR defaults +to a symmetric hash over the combination of MAC addresses, VLAN tags, +Ether type, IP addresses and L4 port numbers. \fBhash\fR uses the +\fBselection_method_param\fR as the hash basis. +.IP +Note that the hashed fields become exact matched by the datapath +flows. For example, if the TCP source port is hashed, the created +datapath flows will match the specific TCP source port value present +in the packet received. Since each TCP connection generally has a +different source port value, a separate datapath flow will be need to +be inserted for each TCP connection thus hashed to a select group +bucket. .RE .IP -This option will use a Netronome OpenFlow extension which is only supported +This option uses a Netronome OpenFlow extension which is only supported when using Open vSwitch 2.4 and later with OpenFlow 1.5 and later. .IP \fBselection_method_param\fR=\fIparam\fR @@ -2167,7 +2176,7 @@ lower-layer that implements the \fBselection_method\fR. It is optional if the \fBselection_method\fR field is specified as a non-empty string. Prohibited otherwise. The default value is zero. .IP -This option will use a Netronome OpenFlow extension which is only supported +This option uses a Netronome OpenFlow extension which is only supported when using Open vSwitch 2.4 and later with OpenFlow 1.5 and later. .IP \fBfields\fR=\fIfield\fR