From patchwork Mon Apr 16 14:26:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 898647 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="TH1EHdlR"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="aUBC66yV"; 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 40PrM31swGz9s1l for ; Tue, 17 Apr 2018 00:27:43 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 881DFDE3; Mon, 16 Apr 2018 14:26:58 +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 573CFDBB for ; Mon, 16 Apr 2018 14:26:56 +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 43BE4473 for ; Mon, 16 Apr 2018 14:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1523888813; 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=xA/La+oE/Ea2RfbOHyi4IqmYDRVXkjAN9IF/Ncu+1aI=; b=TH1EHdlRKcrRQa0zrLS6OaBJTXNUs6iP+6s5f9/bQuSSkpAaAjNkFAVX39cELMVe qxqHarQVupXF3Kj+WmngOnrN18NonCz6XEqV07H5MgdEalOVVaJZcPHea3RGDa4i W8LNxOSVbG3Tmj0CqrCDVTFwS31tHkK42Gn6OXKJEFo=; X-AuditID: c1b4fb30-1ebff70000005970-62-5ad4b2adf613 Received: from ESESSHC007.ericsson.se (Unknown_Domain [153.88.183.39]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 5D.44.22896.DA2B4DA5; Mon, 16 Apr 2018 16:26:53 +0200 (CEST) Received: from ESESSMB505.ericsson.se (153.88.183.166) by ESESSHC007.ericsson.se (153.88.183.39) with Microsoft SMTP Server (TLS) id 14.3.382.0; Mon, 16 Apr 2018 16:26:52 +0200 Received: from ESESSMB505.ericsson.se (153.88.183.166) by ESESSMB505.ericsson.se (153.88.183.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Mon, 16 Apr 2018 16:26:52 +0200 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB505.ericsson.se (153.88.183.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26 via Frontend Transport; Mon, 16 Apr 2018 16:26:52 +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; bh=1dSfEkm73OGDRzZdhH/9JoY53U1tZ5DzM4+2Bn6+YTg=; b=aUBC66yVZl8Ihf8AMMnDqwwNgJuVBC6NtBTuKQaoNl79ke1gQDnpKWC8+3NXs3ib1ReTt/NR0yzLSK1pqj8qiZVuxnlcTgydaMb9IxHFkigJWCdxUVwO92eO/jcWklaLZsXCXcxw6X0ZgW2VJQnAPdpZhvYwRsmaTfJjgdt1Uo4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; Received: from ubuntu.eed.ericsson.se (129.192.10.2) by DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.8; Mon, 16 Apr 2018 14:26:47 +0000 From: Jan Scheurich To: Date: Mon, 16 Apr 2018 16:26:26 +0200 Message-ID: <1523888788-20288-2-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> References: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: PR2P264CA0035.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101:1::23) To DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB3PR07MB0650; X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 3:oOg2u0d20h/dLgH0Ethp6uC3Nr4GXeogD90fLYIgyPjCoKVl48gQ+t9PRJg7/xYkijURi6WED7dsJW7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t6pkubIZqsg7Z8SgljLUyCQK14V2dKctICuM1fWIMSyHQKZnz5E9YosIKCWI4f2whRNZKddaGWs+wi4dnnVzV7K3SQMIqeJ2ktLAeRMAJ7Niz6rJ1PBziD0LZigEjugg4yb9GHD+5mayfho72s8UYhlyPgvP7wSYqEhXBXP5iEIjktRPWyPrByie4c3yf3D040HbwgH09qiVfJlfwkhGaZkj1CAn7ttb8dFtVPOjRORR8+QTis1ActVjnrnxX/wWzkcKnSEA2yRW; 4:E510kOcN3mraAlMdEQhMN2WS7rMArGJF4XYxOnCAdoxW7AFBYPbBtNPH1HZyep6VUn/PhuB8SUTwt2u7B4GcgCWY7bqJKO094uZ6qRl7D5eezLltaUZ6MwAMPIIBPzGf23jmuXDjQf1hY1rntOBlODJaC1JK/ThdA2K+kv5/e6Keh4L42EAI7OvnmmU1w/Q55oEfcXT5asCGDi1f3tYsgi//bx2Nl6mcXMk6l7gVkpXy9qrK6Yr1tnAFXpBzgMNZLesOpkMOpxflWKN1zmz77q/fwbF4STqlqOyPS+Hvqmb7amtIIHUtQZ5YZAZ5MwqC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:DB3PR07MB0650; BCL:0; PCL:0; RULEID:; SRVR:DB3PR07MB0650; X-Forefront-PRVS: 0644578634 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(396003)(39860400002)(346002)(199004)(189003)(186003)(16526019)(8676002)(6486002)(81156014)(50226002)(97736004)(81166006)(15760500003)(11346002)(478600001)(446003)(44832011)(68736007)(6506007)(66066001)(51416003)(316002)(52116002)(36756003)(76176011)(106356001)(105586002)(956004)(2616005)(50466002)(26005)(2351001)(107886003)(16586007)(386003)(2361001)(305945005)(86362001)(3846002)(5660300001)(2906002)(4326008)(53936002)(25786009)(7736002)(6116002)(6512007)(476003)(47776003)(486006)(8936002)(48376002)(6666003)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR07MB0650; 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; DB3PR07MB0650; 23:cbCDrSDgwR06C4qP7VEelhM3xiF9U6uUY0OhL1vLn?= e2RYK5mD53UAKR4drJJqcRnhm4qWkzlxhrGqGDejqsheyKETkzmB6qrwgGJsMWEDOGZnfZ25D8zxzo2Iia48mNrNn7ZvhTDX++739qnMgQIZxiweget/8Kq15qAhSlSCMH1wDDLdrA6kZoVQRKegGScY7CsrNaaAv0H829RCskYL0ZEGLZ/Y1OF8mzr9isoAaCHjwhi1guErtyPn0hE99FPzPvJpPxhUaeBN4xLJJzEbx3Xyw1R34L9KMFBYsfNC8uzxyrNpTxmM1YNLwgq+3BnM3AEiq/9gRBJd4mM9Z8PP9Z87kz0nC5ELDtEiObT4SfkvCWHNlcPggrgK+B2HyO8QuH9TBZDC2s/wRQiJK9We1pDBpfYlwB/vu/LBmfqW2kYfM45Su4MYJsSP2K7M/Z136z2cVr3GJuZfWH9jlx3hLcwXmK29nOE2HMUmDV4+r1U5bnM4kchdErBWL+5iBNU9sJKlkeO3/G4ii5iWIXp/gbAyWTq3V0brfp4Ge7+xPgbDEGJnSyw8MD+40mL8T3AL/zykIMroTMo6CU9USI+irVFKLkkrFpi/DW9gOfCHrYLVl/OPKmGRwDicIVaXku9BfhaNJQfI2mN+PrLbnv+1IcABFVrtOiGrHEqHPXFJJMsLUdviXeBcsMpkB3XlZ3mmEqz3x0PGqdii8T564wqlKWpVebu+4ut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gF5OOZ5nLqLhrEX3253PMf/bs8J+LlCUrE1bkZ+CxMRW1yg4V5RYe+BPUpRWQZBkcry2PPXmsKRrZDgPYPy+czqGjTp0I+sY1C3hXiqY041q+7Lk2JCXZoaZ20tztSOpr9I3Lvg31O6zRKOCemxakkBuGNDGIKkx17aNDY6BfAUpKcPPYMdg0v9PYYHx6U0rRu5cT4eKu3hwyXszjCA==; 5:1XiYOyPnkFaGIhEqNhGUV0OoWvkeidNVtlf2QAS9vyvdDLiwQjXzGQ4kuhwN3Io77UJ2Nl/4MGRcGZTHIZu3Va9qqIKMy3pK+xCUj0kMj7JEXnXrzXQCXJMVSPwrUBMWEZDYaWTJ33+rKZ03L2/PapT9A2FyyQ7E8amb6yGPHRc=; 24:hjRY+bedDm2YCP8zhGVwcljAvbqN/JvCOz5ty56RpIKPrCWXWZA6teS+fZwShBB/oblUo0AHwyDIBVEMCls/raUlHZp2E/+CuZurifpiDBA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 7:NyuWhTugh361dSUNIJ+c3p97EkwGxv6EIp+OvUeU08lkpPUlSJ+KivPHdHBdNTW/KiCsho2OESJGJ6pgrzZaTVCTaUpY6k31alYmT9dmETHFJ3xXkBAHMKIdV5K4RKWFbmKqj4A2ifFFADL/J9xzNKppMf4tToa6GKHE12ZMQNjwCV4pEUsocwXRtWYB4OS4pnmrtb4ctIY/ru/nZf0lf1uXgvP0kSmGmWuONjTfq73x0r0jSRaljFIiT4EguPRJ X-MS-Office365-Filtering-Correlation-Id: 07827a4a-4cf5-4136-884a-08d5a3a61689 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2018 14:26:47.7421 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07827a4a-4cf5-4136-884a-08d5a3a61689 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR07MB0650 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsUyM2K7uu7aTVeiDJrmqVu8mtzAaHH09B5m iy+7+hgdmD0Wr5jC6vHs5n9Gj+fXelgCmKO4bFJSczLLUov07RK4Mnbc+8NUcFC74vdnmQbG DrkuRk4OCQETiR8HP7KC2EICRxglfvSadzFyAdlbGCU+bDzHCOF8Z5R4OHk/C4SzlEli7fsG MIdF4BOTxIKdvYwg/YwCsRItW6cyQVR1MUksX/EFaDAHB5uAgcTs3Q4gNSICkhL/Fm9hA7GZ BcokVp3fwwZSIiwQLjHzgg1ImEVAVeLv17MsIDavgJfEwruvWCFOlZM4eWwymM0p4C1x/fQ9 RoizvSSmb17FBlEvKHFy5hMWiPESEgdfvGCG6FWQ2LhlJtjNEgLTGSW+7VnODtGsLvH30FcW iCJZiaNn50AVbWOU6L62jx3CaWCXOPJ0H9QZWhKXJ96DSvxgk5jWvJEJIpEt8W1yGxuEbSXx +td3RoiipcwST/afhkrISFxvb4CadJFV4tlj3QmMerOQ3D4Lye0LGJlWMYoWpxYn5aYbGeml FmUmFxfn5+nlpZZsYgSmh4NbfhvsYHz53PEQowAHoxIPL9PiK1FCrIllxZW5hxglOJiVRHiX JV6OEuJNSaysSi3Kjy8qzUktPsQozcGiJM5r4bc5SkggPbEkNTs1tSC1CCbLxMEp1cBofv+Z +04v4TBVo/j31zZXFX2fyHlC4bOVzH6BybNlyz8m1gX3rPderyDS6tiwUGfCYr3waWIhXKFC RrZrmLNWcVtU7bJelr1FoH/Zl2/iebNTs6amHGpk/3XWPVKB9erku6/c38/mip7x/taJenX+ yimbGfKes3QXPta6kV259MXq/Zx9NeJKLMUZiYZazEXFiQBPS07zCwMAAA== 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 v2 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. 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 | 42 +++++++++++++++++++++-- lib/flow.h | 1 + lib/odp-execute.c | 23 +++++++++++-- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h index 84ebcaf..2bb3cb2 100644 --- a/datapath/linux/compat/include/linux/openvswitch.h +++ b/datapath/linux/compat/include/linux/openvswitch.h @@ -720,6 +720,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 09b66b8..9d8c1ca 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -2108,6 +2108,44 @@ 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 != htons(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]; + } + 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, @@ -2128,8 +2166,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 af82931..900e8f8 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 1969f02..c716c41 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -726,14 +726,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; @@ -749,7 +751,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(); } From patchwork Mon Apr 16 14:26:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 898648 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="aLfj9lDT"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="dVAXJm86"; 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 40PrMt4FXLz9s1l for ; Tue, 17 Apr 2018 00:28:26 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5D675E42; Mon, 16 Apr 2018 14:27:07 +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 734CADF6 for ; Mon, 16 Apr 2018 14:27:05 +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 62953625 for ; Mon, 16 Apr 2018 14:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1523888821; 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=wStoGpLwWxpTmJfkW9olFykvOJPFh/htH7kUyedwg5I=; b=aLfj9lDTJl4GhHr9ZEvXzr6iwf2KDfRPJlAuhdY5igBVbaFde2tEdrb17s/R0og9 CA88oNU6z9YlJuuHXy4bmr9sn+Z1oD6gF6HDOhLoUyFSY0Jc3CQyNfBaJqL/Ht2K LNOZzSoZQfLqgufwMu+FA+jdleQIi+uxv6bJxkDOaSc=; X-AuditID: c1b4fb2d-815ff70000003563-f3-5ad4b2b5b06c Received: from ESESSHC012.ericsson.se (Unknown_Domain [153.88.183.54]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 87.74.13667.5B2B4DA5; Mon, 16 Apr 2018 16:27:01 +0200 (CEST) Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSHC012.ericsson.se (153.88.183.54) with Microsoft SMTP Server (TLS) id 14.3.382.0; Mon, 16 Apr 2018 16:27:01 +0200 Received: from ESESSMB502.ericsson.se (153.88.183.163) 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.1034.26; Mon, 16 Apr 2018 16:27:00 +0200 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26 via Frontend Transport; Mon, 16 Apr 2018 16:27:00 +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; bh=fvphxf2wKkwFJp1YNP5qq1BUxmH9vN1KhR2fryxfSNY=; b=dVAXJm86TCWtd4mWB2ADGUfr9ef//3ksbIsaPkH2CGkL6BUkJNSngUYORQ/oi16txPfbjvP41al7x0WLmyErKM0EG1cd+0/WhFlF1dm1i2ZaVSRSRP87M9OtcW3vN6lvSqRPMUnF+53uObb+8nmY87zPAp5qr+OVWJQCbbRIYj8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; Received: from ubuntu.eed.ericsson.se (129.192.10.2) by DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.8; Mon, 16 Apr 2018 14:26:50 +0000 From: Jan Scheurich To: Date: Mon, 16 Apr 2018 16:26:27 +0200 Message-ID: <1523888788-20288-3-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> References: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: PR2P264CA0035.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101:1::23) To DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB3PR07MB0650; X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 3:Z4RL2cBJwWEYkmAmTaSlt2wRmSWIouIULuE0jzEZ0xci4He+1nYFFws1cpI1C6R/zhjbO8xIgLrInwtXV9sEZCOsz5GGQ+yORNQMW4wgjztHrAkAsArBs12WNQsaf/Mr4tJW2MOVa+LM8TK14BE4brt/fqStjNjaFm0Ro0FWDKyOj/j5AVWhqpSulPFqZfN7bm9sRM4EiWngyuYvdJSMrSQlipQAq1mTekJ4nHhFLNbwuXfflbAIjdzFMD1d4ALv; 25:1ubj2HTK8SFeoH+utPNBaSj2k4ehraTZc+PJB3iWE+qbPRLo66qPvcfxKbRgijme+AJbKvGVioo2DPj7FCh24wA2jp2Gz6qHluMv9rnaGr/GBmw0AIKkCuIs8PwNhrvMVZhKuTO5KH0OXBRG6F37nnEWQR+7+zTLR33sg6jtXHkAUvj3LsN5K/JYGMTpWbHQ6E1jtjN/MyPRq+ZBiSr5HygWsTJCf2l/HHUgOEKc78j/R7nXNKXXIM+oPFGhKjVfA3VfNFj3Nsmc3fjQmdHmW78j2qKcKLI1mfIXnnG7D3vM2+uf6t/UevHkGM8T4xnL4KInbUOdHt6dEEZp9+gJLQ==; 31:qqN+AU6U7GMpw+XRIulghKYbe3JK/Eqeqx0DjA/7LKokF59jKqVUT98hB9Bv+mYZ4vE+ZY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B67T1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:DB3PR07MB0650; BCL:0; PCL:0; RULEID:; SRVR:DB3PR07MB0650; X-Forefront-PRVS: 0644578634 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(396003)(39860400002)(346002)(199004)(189003)(186003)(16526019)(8676002)(6486002)(81156014)(50226002)(59450400001)(97736004)(966005)(81166006)(11346002)(478600001)(446003)(44832011)(68736007)(6506007)(66066001)(51416003)(316002)(52116002)(36756003)(76176011)(106356001)(105586002)(956004)(2616005)(50466002)(26005)(2351001)(107886003)(16586007)(386003)(2361001)(305945005)(86362001)(3846002)(5660300001)(2906002)(4326008)(6306002)(53936002)(25786009)(7736002)(6116002)(6512007)(476003)(47776003)(486006)(8936002)(48376002)(6666003)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR07MB0650; 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; DB3PR07MB0650; 23:icp2te56/a5wp+qgKSDsO0d+mOKpyk+UvMpQI6HqI?= APuiqKbmKc58vgJ7zY0IVraLX5l0OjtOkKcseSDqymj9xgIMWE7vxrCkSmkHXvdlWTKI2oBB/ZzTMDjquJbxtXwtq9k7jfBTBZVn4+Fa++ffGBNWUeVqvfgMqgV0jsSrXWK/CRMcWDcsjwd9ViCgfYc/jZPcy9QVCsziviz19SqC3VX2KUNv0WgpT7Ak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Nse8BJipvwbWyDESVb334ouuA= X-Microsoft-Antispam-Message-Info: xYRTFhiy8sQMP3rVpHcfzVJr9lL03CR1ydxhmUGVs/LJ55p/Z57vyGxLxXb8seh74EAh9je5A28UTAHtWWVhnqYh9PcThd0EAsmvQYjgFiPBVtcHNY3QZsO/2GajEQaRLRy4JOloogw+z/IX+vUQoqr6cwg8GwI7c4A4JNxvsjpQrDaWq9fUn2EWbUNTdZ9h X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 6:cDI29SE7ZSkoIfNXQHnnThrWMShNSx9DnYQraM0/relCTr9zDJ5GAVa8iEElIiKq81U4qrIjgePv7AnCpaXSj+k//m2ib1y2+pxPl4R/X6JFALP5Wr9jUTIoCMRW+n41/vLD0aVa676Tm0UmGjTxyiGCtAseZQhTIklxaL7yf/6+cOP2LiTgr7OiYFp2XUgL86lmITFVr4YcdeMP4YZz5DVmTSNPt7u4VZJu5negNbEcKDT1A+VEGdMkO703mTiuUTLf1f1nJuw9ktfrZ1rYV6JLzSmB//s1Mo9Ti4te19LdS+A1socJDEfkZPI1OKoTtGRJcj8s5dTZ9jcmCTplSDXhgqt3sFhhfR0454FH+aeD3Q/bBbMCeZspGWt20+RaocWHE5YY5NNm7021NnSDY/I1CzYVi8zJErHILdr1MhiWB2b74KWEqTvVNcw2LRyCNhNAtotJbdDmVQqUi0kz9Q==; 5:TXV108JmwsBtj9DfP7aSYtVNwbefrmreogGhdkHHS8LJlR8cDR/zVimXekGtroTR7gMG/nQWZD7irXVX/VJVKQlIaXeBFn/F5rZVBg5hGSgyZUJwITCoaRZnNiteQAIpWf99AL17iv7DZIRePlmDn/BPlnL9Ji+jeqlurEmoke4=; 24:aTa9PArfOUwBVdbPJCi4owhpBO5TsgiecHqFcVWEfmShPoO6y9ROg8Kc/BUjhi7pOd+jOnzhwJu//c6NDETCVdcWtSLoygJdkIg/9U0796A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 7:wpNmjwCI9WQOYT+bY9tAQ3A5RSKQ5vCPntfIXogwjLHej/g6W+L9VvME1mWSuMgQkE7Ij2pVUSfGqjcIIRgNBd4yGZH8Z/HZar7VR1Cnqwtx06grMvoqI0cZBKhzr5s3FjBUcc+wWBRJU+vEaZmWGeW1c0nMjcZErYBWyMurswrmCfQ9/oh6qsZExWMD9sY/007odpe9eU68PhGtFwaBBlU/068D2RT9p7HYVRP5d5ndhYCuHpbPvNMRJ6IchU3k X-MS-Office365-Filtering-Correlation-Id: c3f49f28-1041-44dd-421a-08d5a3a61837 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2018 14:26:50.5803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3f49f28-1041-44dd-421a-08d5a3a61837 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR07MB0650 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTYRjG+845247DweeyevMSMShLcFmJjG7YBdIiulBkg6yhhynqNna8 lskEIZohiYXMVJSxzGmCa96XbisNWWGmeAnRSDEvf5jhJbM0t7PA/56H5/c+PB98NCn+QwXQ Sao0RqtSpEj4QsoQ2xwZ1mgZkId3th2UzRbrkKzLZSNli22FKIqMNr58youeGtlA0d8HH1NX SLnwRAKTkpTBaA+duitM/FK3QGheFaEse0cBqUPzaj3yoQFHQLejhNAjIS3G7xBY7HkCzlgR fG5uQpxZQdDzdYzPGRMBnwyVHozCPwlYrGkh3GUI34b8xmfeMj0BM7MzmxRN83E4PG+PcjP+ eDesG618tyZxBph7bR69HceCw97Kc2sK74OJ+RlPpwhfgClHNcmN3QM93cUexgdfhCHXGHJr 8SZT8trM53g/6DFMUlw/gGN62nu7FxqsBsq9DXAJgmVbtYA7DoG/ziWKg4Kh62OZF2pCUDDY IeCMTgATZcteKhT6i8a8wS8+mHSFlPuZgJNBP6jkmGMw93sFcYyJhMlOF58LgmDooY7HBd94 ULVgIJ4gaemW7aVbtlciwox2sAzLpiqPHJUy2qR4llWrpComzYI2/4TDuhbWgmrnTjsRppHE V+SoGpCLeYoMNjvViYAmJf6iF4p+uViUoMi+x2jVd7TpKQzrRIE0JdklkpptcjFWKtKYZIbR MNr/KUH7BOhQcP39miGXzLgu8jv53rka/0AjuVQfaTqfGdKOAnOVGmL6TJZpRLMUh2/mWmKC +iMz08uv5sUYzmrLz6mvt+4f/rHtckVFLym6sWE8ELea05wvz4n13effanz0VuiAqbrh6r6u tQ+TS7beN1nj430NOZitPX6NtI+O3tqZH8GXUGyi4nAoqWUV/wB3nUEADwMAAA== 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 v2 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 --- include/openvswitch/ofp-group.h | 1 + ofproto/ofproto-dpif-xlate.c | 74 +++++++++++++------- ofproto/ofproto-dpif.c | 146 ++++++++++++++++++++++++++++++++++++++++ ofproto/ofproto-dpif.h | 13 ++++ tests/ofproto-dpif.at | 18 +++-- 5 files changed, 221 insertions(+), 31 deletions(-) diff --git a/include/openvswitch/ofp-group.h b/include/openvswitch/ofp-group.h index 8d893a5..af4033d 100644 --- a/include/openvswitch/ofp-group.h +++ b/include/openvswitch/ofp-group.h @@ -47,6 +47,7 @@ struct bucket_counter { /* Bucket for use in groups. */ struct ofputil_bucket { struct ovs_list list_node; + uint16_t aux; /* Padding. Also used for temporary data. */ uint16_t weight; /* Relative weight, for "select" groups. */ ofp_port_t watch_port; /* Port whose state affects whether this bucket * is live. Only required for fast failover diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index c8baba1..df245c5 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4235,35 +4235,55 @@ xlate_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group, } } +static struct ofputil_bucket * +group_dp_hash_best_bucket(struct xlate_ctx *ctx, + const struct group_dpif *group, + uint32_t dp_hash) +{ + struct ofputil_bucket *bucket, *best_bucket = NULL; + uint32_t n_hash = group->hash_mask + 1; + + uint32_t hash = dp_hash &= group->hash_mask; + ctx->wc->masks.dp_hash |= group->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 < n_hash; i++) { + bucket = group->hash_map[(hash + i) % n_hash]; + if (bucket_is_alive(ctx, bucket, 0)) { + best_bucket = bucket; + break; + } + } + + return best_bucket; +} + static void xlate_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group, bool is_last_action) { - struct ofputil_bucket *bucket; - /* 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); + ctx_trigger_recirculate_with_hash(ctx, group->hash_alg, + group->hash_basis); + if (ctx->xin->xcache) { + ofproto_group_unref(&group->up); + } } 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; - bucket = group_best_live_bucket(ctx, group, basis); - if (bucket) { - xlate_group_bucket(ctx, bucket, is_last_action); - xlate_group_stats(ctx, group, bucket); - } + struct ofputil_bucket *bucket = + group_dp_hash_best_bucket(ctx, group, ctx->xin->flow.dp_hash); + if (bucket) { + xlate_group_bucket(ctx, bucket, is_last_action); + xlate_group_stats(ctx, group, bucket); + } else if (ctx->xin->xcache) { + ofproto_group_unref(&group->up); } } } @@ -4272,8 +4292,6 @@ static void xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group, bool is_last_action) { - const char *selection_method = group->up.props.selection_method; - /* Select groups may access flow keys beyond L2 in order to * select a bucket. Recirculate as appropriate to make this possible. */ @@ -4281,15 +4299,19 @@ xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group, ctx_trigger_freeze(ctx); } - if (selection_method[0] == '\0') { + switch (group->selection_method) { + case SEL_METHOD_DEFAULT: xlate_default_select_group(ctx, group, is_last_action); - } else if (!strcasecmp("hash", selection_method)) { + break; + case SEL_METHOD_HASH: xlate_hash_fields_select_group(ctx, group, is_last_action); - } else if (!strcasecmp("dp_hash", selection_method)) { + break; + case SEL_METHOD_DP_HASH: xlate_dp_hash_select_group(ctx, group, is_last_action); - } else { - /* Parsing of groups should ensure this never happens */ + break; + default: OVS_NOT_REACHED(); + break; } } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 1ed82d0..e1a5c09 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" @@ -4717,6 +4718,143 @@ 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; + double total_weight = 0.0; + uint16_t min_weight = UINT16_MAX; + uint32_t n_hash; + struct webster { + struct ofputil_bucket *bucket; + uint32_t divisor; + double value; + } webster[group->up.n_buckets]; + + if (n_buckets == 0) { + VLOG_DBG(" Don't apply dp_hash method without buckets"); + return false; + } + + int i = 0; + LIST_FOR_EACH (bucket, list_node, &group->up.buckets) { + bucket->aux = 0; + 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; + i++; + } + + VLOG_DBG(" Minimum weight: %d, total weight: %.0f", + min_weight, total_weight); + + uint32_t min_slots = ceil(total_weight / min_weight); + n_hash = MAX(16, 1L << log_2_ceil(min_slots)); + + if (n_hash > MAX_SELECT_GROUP_HASH_VALUES || + (max_hash != 0 && n_hash > max_hash)) { + VLOG_DBG(" Too many hash values required: %d", n_hash); + return false; + } + + VLOG_DBG(" Using %d 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++) { + double max_val = 0.0; + struct webster *winner; + for (i = 0; i < n_buckets; i++) { + if (webster[i].value > max_val) { + max_val = webster[i].value; + winner = &webster[i]; + } + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + /* winner is a reference to a webster[] element initialized above. */ + winner->divisor += 2; + winner->value = (double) winner->bucket->weight / winner->divisor; + group->hash_map[hash] = winner->bucket; + winner->bucket->aux++; +#pragma GCC diagnostic pop + } + + LIST_FOR_EACH (bucket, list_node, &group->up.buckets) { + double target = (n_hash * bucket->weight) / total_weight; + VLOG_DBG(" Bucket %d: weight=%d, target=%.2f hits=%d", + bucket->bucket_id, bucket->weight, + target, bucket->aux); + } + + return true; +} + +static void +group_set_selection_method(struct group_dpif *group) +{ + struct ofputil_group_props *props = &group->up.props; + char *selection_method = props->selection_method; + + if (selection_method[0] == '\0') { + VLOG_INFO("No selection method specified."); + group->selection_method = SEL_METHOD_DEFAULT; + + } else if (!strcmp(selection_method, "dp_hash")) { + VLOG_INFO("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_INFO(" 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; + } else { + /* Fall back to original default hashing in slow path. */ + VLOG_INFO(" Falling back to default hash method."); + group->selection_method = SEL_METHOD_DEFAULT; + } + } else if (!strcmp(selection_method, "hash")) { + VLOG_INFO("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_INFO(" 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_INFO(" 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_) { @@ -4725,6 +4863,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; } @@ -4734,6 +4876,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 47bf7f9..880dd3d 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 60f28e2..6c20208 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -500,11 +500,19 @@ 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], [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(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:10 +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:10 +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: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 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 +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 +524,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(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 Mon Apr 16 14:26:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 898649 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="YfHnsF6c"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="W3gOvY6Y"; 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 40PrNx5D8cz9s1l for ; Tue, 17 Apr 2018 00:29:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A535BE54; Mon, 16 Apr 2018 14:27:11 +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 076C2E35 for ; Mon, 16 Apr 2018 14:27:10 +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 CDE6D625 for ; Mon, 16 Apr 2018 14:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1523888824; 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=sVx0fuVzxdxqZpfi3dj1nDVN5rBNshvRECJtFFlCXG4=; b=YfHnsF6cveipjL6xc+0fuAXXIEJjYkJ9GcK5xuVj2CW16udF57a8q9RIY3VQxsy6 Tgoci3BoPstGQu+UBHYXCetgBqVScmDZuqE+glfG1iqfhMeZKAW8+B5MxIsv/miP rt+1OQi14rep6xy6BXoj3bl3tDjbpMrG6SxnD0SIRK4=; X-AuditID: c1b4fb2d-82dff70000003563-05-5ad4b2b87b84 Received: from ESESSHC007.ericsson.se (Unknown_Domain [153.88.183.39]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 4A.74.13667.8B2B4DA5; Mon, 16 Apr 2018 16:27:04 +0200 (CEST) Received: from ESESBMR506.ericsson.se (153.88.183.202) by ESESSHC007.ericsson.se (153.88.183.39) with Microsoft SMTP Server (TLS) id 14.3.382.0; Mon, 16 Apr 2018 16:27:04 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESBMR506.ericsson.se (153.88.183.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Mon, 16 Apr 2018 16:27:04 +0200 Received: from EUR03-VE1-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.1034.26 via Frontend Transport; Mon, 16 Apr 2018 16:27:03 +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; bh=Xo7qEAiQaCUEIVmYZvzC7xxXm4uu1i3U68qXJ9vb1nk=; b=W3gOvY6Ya8VSuU+JxsFDexakFshdc+Khait4kvR9U/mzizG9xibJu0w4QkzxT3A1CCdpqIpB6Z5l2CI2b17VvfN7KsrThgyjYLIBXJkfQiYV7oulYD7lfQjYxfaO4tS9d5wtF7vlbBu9zH6kZjodC6sh5vPWz807MKr6JGdQPrg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jan.scheurich@ericsson.com; Received: from ubuntu.eed.ericsson.se (129.192.10.2) by DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.8; Mon, 16 Apr 2018 14:26:58 +0000 From: Jan Scheurich To: Date: Mon, 16 Apr 2018 16:26:28 +0200 Message-ID: <1523888788-20288-4-git-send-email-jan.scheurich@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> References: <1523888788-20288-1-git-send-email-jan.scheurich@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [129.192.10.2] X-ClientProxiedBy: PR2P264CA0035.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101:1::23) To DB3PR07MB0650.eurprd07.prod.outlook.com (2a01:111:e400:943d::16) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB3PR07MB0650; X-Microsoft-Exchange-Diagnostics: 1; DB3PR07MB0650; 3:hTCsOz5ICBB7RGi/KWKRtJ/8whrhBMrNWzfsigIj8tS4ggTMx6tkp2Q5BckMwN9h8NF6YjOdUCDCFiWoR4X4J6URHj4dwGTRBNUKZh82zkYWxh8fCsAktNErO5xayBhW79tVjoJTciVS8zu0yTEcSs5FHYaQLu8ghzL3rsA6f4C+PlC0S2cfC9QvyT4GF6rca/Bjf3/dXlkOzjWRo4/skecYfBS9y607k6fD00A/Y56u65Ku4z21RiB1khnPitrk; 25:3xwWnHkSYWKeRQGnhr/9IbJx5ahYKn9u8qlJoKyDss7rcFo9m4wbWaluPwa6awi58EQYaV9jxmmbG3lkKDGLQQsx3urHJtgjAMUXQn5gPtJ1r7PUASv8KcECTguMigg86+902GwaMIi23tZNAcszXVru6k4xT/T3q+yK08EvCGtdLaKp9vGWhpvsc1oj3s0zkWk1c1rKYe17iJKHU4JbbPbmdUt9EJUTBQWJPHZWuws1tnNHqp6y8UpC0vMkXa2WNtk1XCJ8SH43u1vn+HNVjaFRFHfYyp1BW3T8dzg/bZB5jrdXsFIxpz5toPkWjEm1ciC86VHqE6ywIWRIzLldOg==; 31:nhZq3XSrcL6s/sO4YNUDvq4pcq7khpa4jUJpCrOonLVMXKzaGvRarnceLkpTxiX8E4riHkSAvcQFD+z0LRNwSkfiSV7uuMDueuLp7cOGB0n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change-Antispam-Report-Test: UriScan:(37575265505322); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:DB3PR07MB0650; BCL:0; PCL:0; RULEID:; SRVR:DB3PR07MB0650; X-Forefront-PRVS: 0644578634 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(396003)(39860400002)(346002)(199004)(189003)(186003)(16526019)(8676002)(6486002)(81156014)(50226002)(59450400001)(97736004)(81166006)(11346002)(478600001)(446003)(44832011)(68736007)(6506007)(66066001)(51416003)(316002)(52116002)(36756003)(76176011)(106356001)(105586002)(956004)(2616005)(50466002)(26005)(2351001)(107886003)(16586007)(386003)(2361001)(53946003)(305945005)(86362001)(3846002)(5660300001)(2906002)(4326008)(53936002)(25786009)(7736002)(6116002)(6512007)(476003)(47776003)(486006)(8936002)(48376002)(6666003)(6916009)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR07MB0650; 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; DB3PR07MB0650; 23:AkJ4aMG8hHRIeUaNb2tlVnGuW0h9APu2xOmVut846?= FIdpVVTa2laHISBn2alZBpDdWEKCr7rKcn26dS/ZxJU1mB+lZsHOwzxEwwT+6xgGxfDrCzlGnK3YA2oaKgTkZ7TwNGYkS3SiVVtM4EEO4cfOT7YeWELI4OTE+tX9fdSiE7PxoTtjQ9JPJZbKOXRcqGdk/+sn3MOSgOC57MrQ1axZDhQ0EvC/X34TR3IERECjeFIjlFLq/DqzfA9vqJAZP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lh+cy7sV5i+Rw5x+OLNC+uGhj+/SNX6KYGlBGf0H3lYl7H1JzvY5728j/g9/oVJyGIiUYbN1/HK/w0jEosBJ4mhfcEaM/zAQU8D08obKV+22Lkz5x5GcrO2d0q0DVCbH3B4o4aT/q7ISF2em6MvE5EpjN5tog6umcXwhDCweHDJous9AH4ZGwMZgYry9vAOWky634nXx7pmRiZBHseE0COqpmeX0MxRPTPThNntrLtclqCnNuAWShnmYQep69/H X-MS-Office365-Filtering-Correlation-Id: 2965f9fd-1e9d-4764-4938-08d5a3a61cf7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2018 14:26:58.5417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2965f9fd-1e9d-4764-4938-08d5a3a61cf7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR07MB0650 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUhTYRTHe+69u7sOR7fly2mV1CAEyWUmNEzD+jSyqA/Ry6Bs6UVNnXLv krSwhaG0SjMT0YosXYtJ4Mt8wUa2i8ampZVL88tImro0QiUzfMnc7gK//f7P+Z3DOfBQuGyF kFOZOj3D6rTZClJC1JzpiIzubHFpYqYq9qumKg1I1dtvw1W/uspQEq6uf/FApJ4YXUXqyeE7 xAlcI0lIY7Iz8xl2z8ELkoympTcob3gBuzIzZiENaK4PM6IgCug4sNuXcSOSUDK6B4HH1YCE YEUw5igmhLCAYNnZEaiYMCi5P+sPBD2Hganvln8Yos/BzbYqTLCMGJRZzKQRURRJx8DDV0k+ J4TeAn/rraSPcTofLIM2P2+mj8FAySLyMUHvgi8eg9jHUvoIlDjKA8tGgPNtpcjHQXQyjPS7 /b5szalutZCCvwmcNR5CmA9g93pxoXcHNFtr/OcAXY3gt80sFpojYYWfJwRpO/S+fxSQ2hHc Hn4tFoJBDNaBJiRYUTBU4RYL/IcEUz0pcBYUVzcH3uNhenEBCc0mHDzd/QFpG4yUGkRC4ZsI VsuXiHtIWbtu99p1u9chzIJCOYbjctJj9ykZNjOV43J1Sh2jb0Frn8JuXYruRI3Th3hEU0gR LLU/dWlkIm0+V5DDI6BwRYj0uXZII5OmaQsKGTY3hb2czXA82koRinCp0mLTyOh0rZ7JYpg8 hv1fxagguQFZniR+Hj1NO3bu1l0MS/eijV2hTnWb65rqQ/Fhufzx8bm4r88a5stk8UXmnhvP fnaPfcw1j5vvXsVKN9SljQ+6pxrNolZ5Skg4//1s4fWiCLf3U/hR6bvlyeBTqG2C5xN+VLXP 6B2XqFn+5dCB2NhkYyK0eFOz+DBX7flVdFJBcBnavVE4y2n/AQvUrA4QAwAA 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 v2 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 | 35 +++-- ofproto/ofproto-dpif.h | 1 + ofproto/ofproto-provider.h | 2 +- tests/mpls-xlate.at | 26 ++-- tests/ofproto-dpif.at | 322 +++++++++++++++++++++++++++++++++++---------- utilities/ovs-ofctl.8.in | 47 ++++--- 8 files changed, 336 insertions(+), 114 deletions(-) diff --git a/NEWS b/NEWS index 58a7b58..4ea03bf 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ Post-v2.9.0 - ovs-vsctl: New commands "add-bond-iface" and "del-bond-iface". - OpenFlow: * OFPT_ROLE_STATUS is now available in OpenFlow 1.3. + * 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 31b0437..c5ddc65 100644 --- a/lib/ofp-group.c +++ b/lib/ofp-group.c @@ -1518,12 +1518,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 e1a5c09..8f71083 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4814,39 +4814,54 @@ group_set_selection_method(struct group_dpif *group) struct ofputil_group_props *props = &group->up.props; char *selection_method = props->selection_method; + VLOG_DBG("Constructing select group %"PRIu32, group->up.group_id); if (selection_method[0] == '\0') { - VLOG_INFO("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. */ + VLOG_DBG("Use dp_hash with %d hash values.", + group->hash_mask + 1); + group->selection_method = SEL_METHOD_DP_HASH; + group->hash_alg = OVS_HASH_ALG_SYM_L4; + group->hash_basis = 0xdeadbeef; + } 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_INFO("Selection method specified: 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_INFO(" Invalid dp_hash algorithm %d. " - "Defaulting to OVS_HASH_ALG_L4", group->hash_alg); + 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; } else { /* Fall back to original default hashing in slow path. */ - VLOG_INFO(" 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")) { - VLOG_INFO("Selection method specified: 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_INFO(" 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_INFO(" 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 880dd3d..c101109 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..686fa35 100644 --- a/tests/mpls-xlate.at +++ b/tests/mpls-xlate.at @@ -68,12 +68,18 @@ AT_CHECK([tail -1 stdout], [0], dnl Test MPLS pop then select group output (group type triggers 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=22,tc=0,ttl=64,bos=1)'], [0], [stdout]) AT_CHECK([tail -1 stdout], [0], - [Datapath actions: pop_mpls(eth_type=0x800),recirc(0x2) + [Datapath actions: pop_mpls(eth_type=0x800),hash(hash_l4(0)),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/dp_hash(.*\/0xf)/dp_hash(0XXXX\/0xf)/' | 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_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),hash(hash_l4(0)),recirc(0x3) +recirc_id(0x3),dp_hash(0XXXX/0xf),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 6c20208..e1a4039 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(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(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,245 @@ AT_CLEANUP AT_SETUP([ofproto-dpif - select group]) + 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. +]) 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| 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:15, bytes:1590, used:0.0s, actions:hash(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), packets:0, bytes:0, used:never, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:212, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:1, bytes:106, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:2, bytes:212, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:1, bytes:106, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:10 ]) + 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(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), 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]) + 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. +]) 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,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| sed 's/dp_hash(.*\/0x1f)/dp_hash(0xXXXX\/0x1f)/' | 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:999, bytes:117882, used:0.0s, actions:hash(hash_l4(0)),recirc(0x1) +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:36, bytes:4248, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:33, bytes:3894, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:30, bytes:3540, used:0.0s, actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:28, bytes:3304, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:36, bytes:4248, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:32, bytes:3776, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:31, bytes:3658, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:25, bytes:2950, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:36, bytes:4248, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:30, bytes:3540, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:25, bytes:2950, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:39, bytes:4602, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:26, bytes:3068, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:35, bytes:4130, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:29, bytes:3422, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:28, bytes:3304, used:0.0s, actions:10 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:35, bytes:4130, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:31, bytes:3658, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:29, bytes:3422, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:16, bytes:1888, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:32, bytes:3776, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:32, bytes:3776, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:27, bytes:3186, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:31, bytes:3658, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:22, bytes:2596, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:33, bytes:3894, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:27, bytes:3186, used:0.0s, actions:11 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:33, bytes:3894, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:35, bytes:4130, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:33, bytes:3894, used:0.0s, actions:13 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:25, bytes:2950, used:0.0s, actions:12 +recirc_id(0x1),dp_hash(0xXXXX/0x1f),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:28, bytes:3304, used:0.0s, actions:12 +]) + +# Check that actual distribution over the buckets is reasonably accurate: +# weights: bucket0: 5%*1000 = 50, bucket1: 10%*1000 = 100, bucket2: 25%*1000 = 250, bucket3: 60%*1000 = 600, bucket4: 0 +# dp_hash: bucket0: 2/32*1000 = 63, bucket1: 3/32*1000 = 94, bucket2: 8/32*1000 = 250, bucket3: 19/32*1000 = 594, bucket4: 0 +ovs-appctl time/warp 1000 +AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed 's/duration=[[0-9]]\.[[0-9]]*s,//'], [0], [dnl +OFPST_GROUP reply (OF1.3) (xid=0x6): + group_id=1234,ref_count=1,packet_count=1000,byte_count=118000,bucket0:packet_count=60,byte_count=7080,bucket1:packet_count=86,byte_count=10148,bucket2:packet_count=258,byte_count=30444,bucket3:packet_count=596,byte_count=70328,bucket4:packet_count=0,byte_count=0 ]) + 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 -A5 "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 ]) -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']) + +# 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]) + +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-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 +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 | 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(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.0,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),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.1,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),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.2,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),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.3,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.1.0,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.1.1,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.1.2,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.1.3,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.3,dst=192.168.1.0,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.3,dst=192.168.1.1,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.3,dst=192.168.1.2,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.3,dst=192.168.1.3,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.4,dst=192.168.1.0,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.4,dst=192.168.1.1,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.4,dst=192.168.1.2,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(src=192.168.0.4,dst=192.168.1.3,proto=1,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions:10 ]) -> 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]) + +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,35 +656,41 @@ 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 a bunch of flows with differing custom hash 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 + 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], [0], [dnl +AT_CHECK([ovs-appctl dpctl/dump-flows | 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(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:10 -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:10 -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: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 -recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 -recirc_id(0x1),dp_hash(0xXXXX/0xf),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:11 -recirc_id(0x1),dp_hash(0xXXXX/0xf),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(dst=50:54:00:00:00:00),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:01),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:02),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:03),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:04),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:06),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:08),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:09),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0b),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0d),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0e),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:10 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:0f),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:0, bytes:0, used:never, actions:11 +]) + +ovs-appctl time/warp 1000 +ovs-appctl time/warp 1000 +AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed 's/duration=[[0-9]]\.[[0-9]]*s,//'], [0], [dnl +OFPST_GROUP reply (OF1.3) (xid=0x6): + group_id=1234,ref_count=1,packet_count=16,byte_count=1696,bucket0:packet_count=8,byte_count=848,bucket1:packet_count=8,byte_count=848 ]) AT_CHECK([ovs-appctl revalidator/purge], [0]) @@ -524,10 +702,16 @@ 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(.*\/0xf)/dp_hash(0xXXXX\/0xf)/' | sed 's/\(actions:1\)[[01]]/\1X/' | strip_ufid | strip_used | sort], [0], [dnl +AT_CHECK([ovs-appctl dpctl/dump-flows | 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/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 +recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(dst=192.168.0.2,proto=1,frag=no), packets:15, bytes:1590, used:0.0s, actions:10 +]) + +ovs-appctl time/warp 1000 +ovs-appctl time/warp 1000 +AT_CHECK([ovs-ofctl -O OpenFlow13 dump-group-stats br0 | sed 's/duration=[[0-9]]\.[[0-9]]*s,//'], [0], [dnl +OFPST_GROUP reply (OF1.3) (xid=0x6): + group_id=1234,ref_count=1,packet_count=32,byte_count=3392,bucket0:packet_count=24,byte_count=2544,bucket1:packet_count=8,byte_count=848 ]) OVS_VSWITCHD_STOP diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in index 1211829..17fadf4 100644 --- a/utilities/ovs-ofctl.8.in +++ b/utilities/ovs-ofctl.8.in @@ -2122,28 +2122,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 @@ -2157,9 +2152,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 @@ -2169,7 +2178,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