From patchwork Tue Oct 8 13:52:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1994278 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=EgEmjXqV; 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 4XNHYY2Jnvz1xtV for ; Wed, 9 Oct 2024 00:53:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E295260883; Tue, 8 Oct 2024 13:53:50 +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 sE5dgZc6LWQ9; Tue, 8 Oct 2024 13:53:49 +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 7023C60893 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=EgEmjXqV Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7023C60893; Tue, 8 Oct 2024 13:53:49 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 52269C08A6; Tue, 8 Oct 2024 13:53:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 15247C08A8 for ; Tue, 8 Oct 2024 13:53:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C24794053D for ; Tue, 8 Oct 2024 13:53:43 +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 XAEd-kEEIIq6 for ; Tue, 8 Oct 2024 13:53:42 +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 13FF040563 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 13FF040563 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=EgEmjXqV 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 13FF040563 for ; Tue, 8 Oct 2024 13:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728395619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GuRDI4w3kMGjKim8FPi8v/OCaBNpkRX7KS0ZJmsit5o=; b=EgEmjXqVEAkCwH3YqZKSt38CENNa4vG5pyjydJgd2HPlEhhLe10AcOIlHDVp5ieLXRK+S7 CwqgugV2LlqOL6Lx+FQZ1qxIDbiwEQHkD8/9zzyr4bV8KBJ0T+/AgS3dlp7rm8NA34zfNq E4lZLwjtm8OgqfoVG53dGS0aSqWCVVo= 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-255-tzYv4LaJMoal6fx-eEkr8w-1; Tue, 08 Oct 2024 09:53:38 -0400 X-MC-Unique: tzYv4LaJMoal6fx-eEkr8w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 C45B51955F29 for ; Tue, 8 Oct 2024 13:53:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.95]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1AE761956088 for ; Tue, 8 Oct 2024 13:53:36 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Tue, 8 Oct 2024 15:52:46 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 3/4] netdev-offload-tc: Add don't fragment support to encap action. 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 "Don't Fragment" (DF) flag support to the encap action, if supported by the kernel. If the kernel does not support this, it falls back to the previous behavior of ignoring the DF request. Signed-off-by: Eelco Chaudron Acked-by: Roi Dayan --- include/linux/tc_act/tc_tunnel_key.h | 1 + lib/netdev-offload-tc.c | 16 +++++++++++----- lib/tc.c | 6 ++++++ lib/tc.h | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/linux/tc_act/tc_tunnel_key.h b/include/linux/tc_act/tc_tunnel_key.h index 17291b90b..a6b8bd59d 100644 --- a/include/linux/tc_act/tc_tunnel_key.h +++ b/include/linux/tc_act/tc_tunnel_key.h @@ -42,6 +42,7 @@ enum { */ TCA_TUNNEL_KEY_ENC_TOS, /* u8 */ TCA_TUNNEL_KEY_ENC_TTL, /* u8 */ + TCA_TUNNEL_KEY_NO_FRAG, /* flag */ __TCA_TUNNEL_KEY_MAX, }; diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 53c4245b9..8ff662ccd 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -919,6 +919,9 @@ parse_tc_flower_to_actions__(struct tc_flower *flower, struct ofpbuf *buf, if (!action->encap.no_csum) { nl_msg_put_flag(buf, OVS_TUNNEL_KEY_ATTR_CSUM); } + if (action->encap.dont_fragment) { + nl_msg_put_flag(buf, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT); + } ret = parse_tc_flower_vxlan_tun_opts(action, buf); if (ret) { return ret; @@ -1641,11 +1644,14 @@ parse_put_flow_set_action(struct tc_flower *flower, struct tc_action *action, } break; case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT: { - /* XXX: This is wrong! We're ignoring the DF flag configuration - * requested by the user. However, TC for now has no way to pass - * that flag and it is set by default, meaning tunnel offloading - * will not work if 'options:df_default=false' is not set. - * Keeping incorrect behavior for now. */ + if (enc_flags_support) { + action->encap.dont_fragment = true; + } else { + /* For kernels not supporting the DF flag, we ignoring the + * configuration requested by the user. This to keep the old, + * incorrect behaviour, and allow tunnels to be offloaded by + * TC with these kernels. */ + } } break; case OVS_TUNNEL_KEY_ATTR_CSUM: { diff --git a/lib/tc.c b/lib/tc.c index 6c853b8e6..175e770d4 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -1229,6 +1229,7 @@ static const struct nl_policy tunnel_key_policy[] = { [TCA_TUNNEL_KEY_ENC_TTL] = { .type = NL_A_U8, .optional = true, }, [TCA_TUNNEL_KEY_ENC_OPTS] = { .type = NL_A_NESTED, .optional = true, }, [TCA_TUNNEL_KEY_NO_CSUM] = { .type = NL_A_U8, .optional = true, }, + [TCA_TUNNEL_KEY_NO_FRAG] = { .type = NL_A_FLAG, .optional = true, }, }; static int @@ -1394,6 +1395,7 @@ nl_parse_act_tunnel_key(struct nlattr *options, struct tc_flower *flower) struct nlattr *ttl = tun_attrs[TCA_TUNNEL_KEY_ENC_TTL]; struct nlattr *tun_opt = tun_attrs[TCA_TUNNEL_KEY_ENC_OPTS]; struct nlattr *no_csum = tun_attrs[TCA_TUNNEL_KEY_NO_CSUM]; + struct nlattr *no_frag = tun_attrs[TCA_TUNNEL_KEY_NO_FRAG]; action = &flower->actions[flower->action_count++]; action->type = TC_ACT_ENCAP; @@ -1411,6 +1413,7 @@ nl_parse_act_tunnel_key(struct nlattr *options, struct tc_flower *flower) action->encap.tos = tos ? nl_attr_get_u8(tos) : 0; action->encap.ttl = ttl ? nl_attr_get_u8(ttl) : 0; action->encap.no_csum = no_csum ? nl_attr_get_u8(no_csum) : 0; + action->encap.dont_fragment = no_frag ? true : false; err = nl_parse_act_tunnel_opts(tun_opt, action); if (err) { @@ -2747,6 +2750,9 @@ nl_msg_put_act_tunnel_key_set(struct ofpbuf *request, nl_msg_put_be16(request, TCA_TUNNEL_KEY_ENC_DST_PORT, encap->tp_dst); } + if (encap->dont_fragment) { + nl_msg_put_flag(request, TCA_TUNNEL_KEY_NO_FRAG); + } nl_msg_put_act_tunnel_vxlan_opts(request, encap); nl_msg_put_act_tunnel_geneve_option(request, &encap->data); nl_msg_put_u8(request, TCA_TUNNEL_KEY_NO_CSUM, encap->no_csum); diff --git a/lib/tc.h b/lib/tc.h index 8ec4857b7..32a5cfaf9 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -222,6 +222,7 @@ struct tc_action_encap { uint8_t tos; uint8_t ttl; uint8_t no_csum; + bool dont_fragment; struct { ovs_be32 ipv4_src; ovs_be32 ipv4_dst;