From patchwork Fri Jun 9 13:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 105667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp983680vqr; Fri, 9 Jun 2023 07:21:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5402DnfTDpDGRn/fXFyS2Toltpw8kDbCszh9+dYzfm67nymnAa9NU5+K1DicyArPEe+7PU X-Received: by 2002:a17:902:db0f:b0:1b0:4bc7:31ee with SMTP id m15-20020a170902db0f00b001b04bc731eemr1531453plx.32.1686320467193; Fri, 09 Jun 2023 07:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686320467; cv=none; d=google.com; s=arc-20160816; b=npvatb6IycvZ9xRNDHBDIalYOpE11NgZCSSFo63OAxs14+7NMGiWibWQARTeM0CNbH bFgC8xh+0C5HuJJ/ltGEmcuB0i2ju8F+0jAzP+Rju0WTZqG2J5E1LE6Kw6Z0Uo1fh+S8 8yh2amWALATr3Uyeqq1N+4VYx9VC8a1h3mFYk7H6oD7ZK5YnMDCP7hSLdtku+EW6VsBk oAYjh9Oat1hrVdHFnWZthTxcl2RhDJljICIWneIkhJShBlQGFZL8pumy/CTs45qaGMvU PlMVzZNd/Fa54X1bq4l6XP12qPoZtQygek7Lwu+qKPg8g6eyufTRdv7aFE4f6hnVYYth dyiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=h7/Xf5Toe34wsk9morWfdaW8uhzw5Xjamq9aeozLMqY=; b=SBbeSVX6OrdpVzttQovlaEjbg5HDYHh2EMUbY0821V6lKDN47VjI8DGAe3noii3DlH 3B58asgDl2Z9SPeUHxlR5JNvQQhSs9ocroq1uhQlc6DbHwDm+hKvzLDqHNwUqXzFkMZQ BdnJs3+XsUZvoYTgZWkuGht/Ohd39+IrD6jGGpOnDZB7bOnGRbpAayHvnJfzb8hvzFve LhfKiqKSGKXcG2fu5ih0Q250kE48uqOscv85Ur7KNS9WuNi1e0T60QXwBT7Acx+Bk2Hl L8yBjr2FzDEYEMNN6vb1BJad8WeSbz4dvkYpqVlPDP9xF8CUDIvV7SgLsYeaPlVz/N/h sYPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DScfDBQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c18-20020a170903235200b001adc5bc4d8asi2917789plh.572.2023.06.09.07.20.52; Fri, 09 Jun 2023 07:21:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DScfDBQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbjFIOAt (ORCPT + 99 others); Fri, 9 Jun 2023 10:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbjFIOAq (ORCPT ); Fri, 9 Jun 2023 10:00:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF5CB3588 for ; Fri, 9 Jun 2023 07:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686319201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h7/Xf5Toe34wsk9morWfdaW8uhzw5Xjamq9aeozLMqY=; b=DScfDBQlv2AyfMMoH2wi+Z5F1nH16ClB8pLAUtEBs3bBvO65k579nW+2PN0ojX/vzUFJbR Y230qN0CNmfHTq8ngyjEmJobuNtMUGovoz9wKdDJ3FS1kj8gbvWBwoBoqWjVvjB6d42gmu lKxtzfNTbZnZrxM5tr8gqSI3C3P+4ms= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-okLFairfP_SVYewF52FZlg-1; Fri, 09 Jun 2023 09:59:56 -0400 X-MC-Unique: okLFairfP_SVYewF52FZlg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22488800962; Fri, 9 Jun 2023 13:59:56 +0000 (UTC) Received: from RHTPC1VM0NT.lan (unknown [10.22.17.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 962D010724; Fri, 9 Jun 2023 13:59:55 +0000 (UTC) From: Aaron Conole To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, dev@openvswitch.org, Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Eelco Chaudron , Dumitru Ceara , Ilya Maximets Subject: [PATCH net-next] net: openvswitch: add support for l4 symmetric hashing Date: Fri, 9 Jun 2023 09:59:55 -0400 Message-Id: <20230609135955.3024931-1-aconole@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768235170167002902?= X-GMAIL-MSGID: =?utf-8?q?1768235170167002902?= Since its introduction, the ovs module execute_hash action allowed hash algorithms other than the skb->l4_hash to be used. However, additional hash algorithms were not implemented. This means flows requiring different hash distributions weren't able to use the kernel datapath. Now, introduce support for symmetric hashing algorithm as an alternative hash supported by the ovs module using the flow dissector. Output of flow using l4_sym hash: recirc_id(0),in_port(3),eth(),eth_type(0x0800), ipv4(dst=64.0.0.0/192.0.0.0,proto=6,frag=no), packets:30473425, bytes:45902883702, used:0.000s, flags:SP., actions:hash(sym_l4(0)),recirc(0xd) Some performance testing with no GRO/GSO, two veths, single flow: hash(l4(0)): 4.35 GBits/s hash(l4_sym(0)): 4.24 GBits/s Signed-off-by: Aaron Conole --- include/uapi/linux/openvswitch.h | 1 + net/openvswitch/actions.c | 12 ++++++++++-- net/openvswitch/flow_netlink.c | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index c5d62ee825673..e94870e77ee96 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h @@ -765,6 +765,7 @@ struct ovs_action_push_vlan { */ enum ovs_hash_alg { OVS_HASH_ALG_L4, + OVS_HASH_ALG_SYM_L4, }; /* diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index a8cf9a88758ef..35b20d03c14a6 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -1072,8 +1072,16 @@ static void execute_hash(struct sk_buff *skb, struct sw_flow_key *key, struct ovs_action_hash *hash_act = nla_data(attr); u32 hash = 0; - /* OVS_HASH_ALG_L4 is the only possible hash algorithm. */ - hash = skb_get_hash(skb); + if (hash_act->hash_alg == OVS_HASH_ALG_L4) { + /* OVS_HASH_ALG_L4 hasing type. */ + hash = skb_get_hash(skb); + } else if (hash_act->hash_alg == OVS_HASH_ALG_SYM_L4) { + /* OVS_HASH_ALG_SYM_L4 hashing type. NOTE: this doesn't + * extend past an encapsulated header. + */ + hash = __skb_get_hash_symmetric(skb); + } + hash = jhash_1word(hash, hash_act->hash_basis); if (!hash) hash = 0x1; diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index ead5418c126e3..41116361433da 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -3221,6 +3221,8 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr, switch (act_hash->hash_alg) { case OVS_HASH_ALG_L4: + fallthrough; + case OVS_HASH_ALG_SYM_L4: break; default: return -EINVAL;