From patchwork Mon Oct 14 12:09:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1996867 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZALF5343; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XRwz41txlz1xvm for ; Mon, 14 Oct 2024 23:10:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 69585605D1; Mon, 14 Oct 2024 12:10:06 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id vZa12S7HgHls; Mon, 14 Oct 2024 12:10:05 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 174A0607C1 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZALF5343 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 174A0607C1; Mon, 14 Oct 2024 12:10:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E331EC08A6; Mon, 14 Oct 2024 12:10:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 471B0C08A6 for ; Mon, 14 Oct 2024 12:10:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EDE1C403D4 for ; Mon, 14 Oct 2024 12:10:01 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id FbQXvdXzJGUm for ; Mon, 14 Oct 2024 12:10:01 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=echaudro@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org D291D40316 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D291D40316 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZALF5343 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id D291D40316 for ; Mon, 14 Oct 2024 12:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728907799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mIuQGgwyUsjx4lkc8EGq02aahfJONxOrdWETrcgsOwY=; b=ZALF534377BC9132H28xqG9uPaaKEjHK03tm6o11wfEtHo4qWoYy/d5p+WgG5ak5zTu3SS 6JdUGgC5ulZY297Uo+sDIE9KO2I3MHVHQ6tcdbFCaFBPZ5/qSK8q87wlh7FCIt3Pwn2Ay5 EYNq49Q/iORU2cv0qIdIBjMBqU8agB0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-44DyXLlXMOuE2W3xyxTk2Q-1; Mon, 14 Oct 2024 08:09:58 -0400 X-MC-Unique: 44DyXLlXMOuE2W3xyxTk2Q-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DC33D195608D; Mon, 14 Oct 2024 12:09:57 +0000 (UTC) Received: from ebuild.redhat.com (unknown [10.39.194.17]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 042F119560AE; Mon, 14 Oct 2024 12:09:56 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 14 Oct 2024 14:09:03 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 2/4] netdev-offload-tc: Match against tunnel flags if supported. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch adds support for TC to match on tunnel flags, if supported by the kernel. If the kernel does not support this, it will fall back to the previous behavior, ignoring the DF and CSUM flags. Acked-by: Roi Dayan Signed-off-by: Eelco Chaudron --- lib/netdev-offload-tc.c | 74 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index a2aa4062a..c6aa51c68 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -737,6 +737,36 @@ flower_tun_opt_to_match(struct match *match, struct tc_flower *flower) } } +static void +flower_tun_enc_flags_to_match(struct match *match, struct tc_flower *flower) +{ + uint32_t tc_flags = flower->key.tunnel.tc_enc_flags; + uint32_t tc_mask = flower->mask.tunnel.tc_enc_flags; + uint16_t *m_flags = &match->flow.tunnel.flags; + uint16_t *m_mask = &match->wc.masks.tunnel.flags; + + if (tc_mask & TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM) { + if (tc_flags & TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM) { + *m_flags |= FLOW_TNL_F_OAM; + } + *m_mask |= FLOW_TNL_F_OAM; + } + + if (tc_mask & TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT) { + if (tc_flags & TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT) { + *m_flags |= FLOW_TNL_F_DONT_FRAGMENT; + } + *m_mask |= FLOW_TNL_F_DONT_FRAGMENT; + } + + if (tc_mask & TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM) { + if (tc_flags & TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM) { + *m_flags |= FLOW_TNL_F_CSUM; + } + *m_mask |= FLOW_TNL_F_CSUM; + } +} + static void parse_tc_flower_to_stats(struct tc_flower *flower, struct dpif_flow_stats *stats) @@ -1272,6 +1302,9 @@ parse_tc_flower_to_match(const struct netdev *netdev, flower->key.tunnel.gbp.flags, flower->mask.tunnel.gbp.flags); } + if (flower->mask.tunnel.tc_enc_flags) { + flower_tun_enc_flags_to_match(match, flower); + } if (!strcmp(netdev_get_type(netdev), "geneve")) { flower_tun_opt_to_match(match, flower); @@ -2293,12 +2326,41 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, memset(&tnl_mask->gbp_flags, 0, sizeof tnl_mask->gbp_flags); tnl_mask->flags &= ~FLOW_TNL_F_KEY; - /* XXX: This is wrong! We're ignoring DF and CSUM flags configuration - * requested by the user. However, TC for now has no way to pass - * these flags in a flower key and their masks are set by default, - * meaning tunnel offloading will not work at all if not cleared. - * Keeping incorrect behavior for now. */ - tnl_mask->flags &= ~(FLOW_TNL_F_DONT_FRAGMENT | FLOW_TNL_F_CSUM); + if (enc_flags_support) { + if (tnl_mask->flags & FLOW_TNL_F_OAM) { + if (tnl->flags & FLOW_TNL_F_OAM) { + flower.key.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM; + } + flower.mask.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM; + tnl_mask->flags &= ~FLOW_TNL_F_OAM; + } + if (tnl_mask->flags & FLOW_TNL_F_DONT_FRAGMENT) { + if (tnl->flags & FLOW_TNL_F_DONT_FRAGMENT) { + flower.key.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT; + } + flower.mask.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT; + tnl_mask->flags &= ~FLOW_TNL_F_DONT_FRAGMENT; + } + if (tnl_mask->flags & FLOW_TNL_F_CSUM) { + if (tnl->flags & FLOW_TNL_F_CSUM) { + flower.key.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM; + } + flower.mask.tunnel.tc_enc_flags |= + TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM; + tnl_mask->flags &= ~FLOW_TNL_F_CSUM; + } + } else { + /* For kernels not supporting the encapsulation flags we're + * ignoring DF and CSUM flags configuration requested by the user. + * This to keep the old, incorrect behaviour, and allow tunnels to + * be offloaded by TC with these kernels. */ + tnl_mask->flags &= ~(FLOW_TNL_F_DONT_FRAGMENT | FLOW_TNL_F_CSUM); + } if (!strcmp(netdev_get_type(netdev), "geneve")) { err = flower_match_to_tun_opt(&flower, tnl, tnl_mask);