From patchwork Mon Oct 14 12:09:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1996869 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=aLIyY+Rx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4XRwz94PWZz1xvK for ; Mon, 14 Oct 2024 23:10:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1BB6C40949; Mon, 14 Oct 2024 12:10:07 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id EqmVtU0S3SkR; Mon, 14 Oct 2024 12:10:04 +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 smtp2.osuosl.org 6CFF0405D8 Authentication-Results: smtp2.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=aLIyY+Rx Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6CFF0405D8; Mon, 14 Oct 2024 12:10:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 511F3C08A3; Mon, 14 Oct 2024 12:10:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 92F7FC08A3 for ; Mon, 14 Oct 2024 12:10:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 814A4405B3 for ; Mon, 14 Oct 2024 12:10:01 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 93rla5bsaB-W for ; Mon, 14 Oct 2024 12:10:00 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=echaudro@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 1AFB2405CC Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1AFB2405CC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1AFB2405CC for ; Mon, 14 Oct 2024 12:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728907798; 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=AnAy9Tv3SSxcOQBIsxuMRwtW71UokH+qGoTPXVegwZ4=; b=aLIyY+RxaK1Pgt1phRTc4deyL9ln265NZExDuLxbJO92ja7eUBBuljqQY77x5gAfz5+rsN 7VqYiQOOqmEuKR7+gwNTxpVsmDqheTIHKKu4stqHhpEEkqtm4QAzAlB6sxpMUPNuy5BYH+ HHohZV+eoA1mmXapmPmk+kV0t74tKok= Received: from mx-prod-mc-03.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-70-0UxneBLGPIWTcxskVaz3gQ-1; Mon, 14 Oct 2024 08:09:57 -0400 X-MC-Unique: 0UxneBLGPIWTcxskVaz3gQ-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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 948FF19560B4; Mon, 14 Oct 2024 12:09:56 +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 ADED519560AE; Mon, 14 Oct 2024 12:09:55 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 14 Oct 2024 14:09:02 +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 1/4] netdev-offload-tc: Check if TCA_FLOWER_KEY_ENC_FLAGS is 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 checks to see if the TCA_FLOWER_KEY_ENC_FLAGS key is supported. Signed-off-by: Eelco Chaudron Acked-by: Roi Dayan --- acinclude.m4 | 6 +++--- include/linux/pkt_cls.h | 28 +++++++++++++++++++++++- lib/netdev-offload-tc.c | 47 ++++++++++++++++++++++++++++++++++++++++- lib/tc.c | 29 ++++++++++++++++++++++--- lib/tc.h | 15 ++++++++++--- 5 files changed, 114 insertions(+), 11 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 1ace70c92..f4cb4a146 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -163,10 +163,10 @@ dnl Configure Linux tc compat. AC_DEFUN([OVS_CHECK_LINUX_TC], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([#include ], [ - int x = TCA_ACT_FLAGS_SKIP_HW; + int x = TCA_FLOWER_KEY_ENC_FLAGS_MASK; ])], - [AC_DEFINE([HAVE_TCA_ACT_FLAGS_SKIP_HW], [1], - [Define to 1 if TCA_ACT_FLAGS_SKIP_HW is available.])]) + [AC_DEFINE([HAVE_TCA_FLOWER_KEY_ENC_FLAGS_MASK], [1], + [Define to 1 if TCA_FLOWER_KEY_ENC_FLAGS_MASK is available.])]) AC_CHECK_MEMBERS([struct tcf_t.firstuse], [], [], [#include ]) diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h index fb4a7ecea..5890dc157 100644 --- a/include/linux/pkt_cls.h +++ b/include/linux/pkt_cls.h @@ -1,7 +1,7 @@ #ifndef __LINUX_PKT_CLS_WRAPPER_H #define __LINUX_PKT_CLS_WRAPPER_H 1 -#if defined(__KERNEL__) || defined(HAVE_TCA_ACT_FLAGS_SKIP_HW) +#if defined(__KERNEL__) || defined(HAVE_TCA_FLOWER_KEY_ENC_FLAGS_MASK) #include_next #else @@ -252,6 +252,28 @@ enum { TCA_FLOWER_KEY_CT_LABELS, /* u128 */ TCA_FLOWER_KEY_CT_LABELS_MASK, /* u128 */ + TCA_FLOWER_KEY_MPLS_OPTS, + + TCA_FLOWER_KEY_HASH, /* u32 */ + TCA_FLOWER_KEY_HASH_MASK, /* u32 */ + + TCA_FLOWER_KEY_NUM_OF_VLANS, /* u8 */ + + TCA_FLOWER_KEY_PPPOE_SID, /* be16 */ + TCA_FLOWER_KEY_PPP_PROTO, /* be16 */ + + TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */ + + TCA_FLOWER_L2_MISS, /* u8 */ + + TCA_FLOWER_KEY_CFM, /* nested */ + + TCA_FLOWER_KEY_SPI, /* be32 */ + TCA_FLOWER_KEY_SPI_MASK, /* be32 */ + + TCA_FLOWER_KEY_ENC_FLAGS, /* be32 */ + TCA_FLOWER_KEY_ENC_FLAGS_MASK, /* be32 */ + __TCA_FLOWER_MAX, }; @@ -306,6 +328,10 @@ enum { enum { TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0), TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1), + TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM = (1 << 2), + TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT = (1 << 3), + TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM = (1 << 4), + TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT = (1 << 5), }; /* Match-all classifier */ diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 3be1c08d2..a2aa4062a 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -53,6 +53,7 @@ static bool multi_mask_per_prio = false; static bool block_support = false; static uint16_t ct_state_support; static bool vxlan_gbp_support = false; +static bool enc_flags_support = false; struct netlink_field { int offset; @@ -407,7 +408,7 @@ get_next_available_prio(ovs_be16 protocol) /* last_prio can overflow if there will be many different kinds of * flows which shouldn't happen organically. */ - if (last_prio == UINT16_MAX) { + if (last_prio == TC_MAX_PRIORITY) { return TC_RESERVED_PRIORITY_NONE; } @@ -2863,6 +2864,49 @@ out: tc_add_del_qdisc(ifindex, false, block_id, TC_INGRESS); } +static void +probe_enc_flags_support(int ifindex) +{ + struct tc_flower flower; + struct tcf_id id; + int block_id = 0; + int prio = TC_RESERVED_PRIORITY_FEATURE_PROBE; + int error; + + error = tc_add_del_qdisc(ifindex, true, block_id, TC_INGRESS); + if (error) { + return; + } + + memset(&flower, 0, sizeof flower); + flower.tc_policy = TC_POLICY_SKIP_HW; + flower.key.eth_type = htons(ETH_P_IP); + flower.mask.eth_type = OVS_BE16_MAX; + flower.tunnel = true; + flower.mask.tunnel.id = OVS_BE64_MAX; + flower.mask.tunnel.ipv4.ipv4_src = OVS_BE32_MAX; + flower.mask.tunnel.ipv4.ipv4_dst = OVS_BE32_MAX; + flower.mask.tunnel.tp_dst = OVS_BE16_MAX; + flower.mask.tunnel.tc_enc_flags = TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT; + flower.key.tunnel.ipv4.ipv4_src = htonl(0x01010101); + flower.key.tunnel.ipv4.ipv4_dst = htonl(0x01010102); + flower.key.tunnel.tp_dst = htons(46354); + flower.key.tunnel.tc_enc_flags = TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT; + + id = tc_make_tcf_id(ifindex, block_id, prio, TC_INGRESS); + error = tc_replace_flower(&id, &flower); + if (error) { + goto out; + } + + tc_del_flower_filter(&id); + + enc_flags_support = true; + VLOG_INFO("probe tc: enc flags are supported."); +out: + tc_add_del_qdisc(ifindex, false, block_id, TC_INGRESS); +} + static int tc_get_policer_action_ids(struct hmap *map) { @@ -2991,6 +3035,7 @@ netdev_tc_init_flow_api(struct netdev *netdev) probe_multi_mask_per_prio(ifindex); probe_ct_state_support(ifindex); probe_vxlan_gbp_support(ifindex); + probe_enc_flags_support(ifindex); ovs_mutex_lock(&meter_police_ids_mutex); meter_police_ids = id_pool_create(METER_POLICE_IDS_BASE, diff --git a/lib/tc.c b/lib/tc.c index e55ba3b1b..6c853b8e6 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -454,6 +454,9 @@ static const struct nl_policy tca_flower_policy[] = { [TCA_FLOWER_KEY_ENC_OPTS] = { .type = NL_A_NESTED, .optional = true, }, [TCA_FLOWER_KEY_ENC_OPTS_MASK] = { .type = NL_A_NESTED, .optional = true, }, + [TCA_FLOWER_KEY_ENC_FLAGS] = { .type = NL_A_BE32, .optional = true, }, + [TCA_FLOWER_KEY_ENC_FLAGS_MASK] = { .type = NL_A_BE32, + .optional = true, }, [TCA_FLOWER_KEY_CT_STATE] = { .type = NL_A_U16, .optional = true, }, [TCA_FLOWER_KEY_CT_STATE_MASK] = { .type = NL_A_U16, .optional = true, }, [TCA_FLOWER_KEY_CT_ZONE] = { .type = NL_A_U16, .optional = true, }, @@ -865,6 +868,13 @@ nl_parse_flower_tunnel(struct nlattr **attrs, struct tc_flower *flower) flower->tunnel = true; } + if (attrs[TCA_FLOWER_KEY_ENC_FLAGS_MASK]) { + flower->key.tunnel.tc_enc_flags = ntohl( + nl_attr_get_be32(attrs[TCA_FLOWER_KEY_ENC_FLAGS])); + flower->mask.tunnel.tc_enc_flags = ntohl( + nl_attr_get_be32(attrs[TCA_FLOWER_KEY_ENC_FLAGS_MASK])); + } + if (attrs[TCA_FLOWER_KEY_ENC_OPTS] && attrs[TCA_FLOWER_KEY_ENC_OPTS_MASK]) { err = nl_parse_flower_tunnel_opts(attrs[TCA_FLOWER_KEY_ENC_OPTS], @@ -3611,6 +3621,7 @@ nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower) struct in6_addr *ipv6_src = &flower->key.tunnel.ipv6.ipv6_src; struct in6_addr *ipv6_dst = &flower->key.tunnel.ipv6.ipv6_dst; ovs_be32 id = be64_to_be32(flower->key.tunnel.id); + ovs_be32 enc_flags = htonl(flower->key.tunnel.tc_enc_flags); ovs_be16 tp_src = flower->key.tunnel.tp_src; ovs_be16 tp_dst = flower->key.tunnel.tp_dst; uint8_t tos = flower->key.tunnel.tos; @@ -3618,6 +3629,7 @@ nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower) uint8_t tos_mask = flower->mask.tunnel.tos; uint8_t ttl_mask = flower->mask.tunnel.ttl; ovs_be64 id_mask = flower->mask.tunnel.id; + ovs_be32 enc_flags_mask = htonl(flower->mask.tunnel.tc_enc_flags); ovs_be16 tp_src_mask = flower->mask.tunnel.tp_src; ovs_be16 tp_dst_mask = flower->mask.tunnel.tp_dst; @@ -3655,6 +3667,11 @@ nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower) nl_msg_put_be16(request, TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, tp_dst_mask); } + if (enc_flags_mask) { + nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_FLAGS, enc_flags); + nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_FLAGS_MASK, + enc_flags_mask); + } if (id_mask) { nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_KEY_ID, id); } @@ -3961,6 +3978,7 @@ tc_replace_flower(struct tcf_id *id, struct tc_flower *flower) struct ofpbuf b = ofpbuf_const_initializer(reply->data, reply->size); struct nlmsghdr *nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg); struct tcmsg *tc = ofpbuf_try_pull(&b, sizeof *tc); + bool is_probe = id->prio == TC_RESERVED_PRIORITY_FEATURE_PROBE; if (!nlmsg || !tc) { COVERAGE_INC(tc_netlink_malformed_reply); @@ -3980,9 +3998,14 @@ tc_replace_flower(struct tcf_id *id, struct tc_flower *flower) false); if (ret || !cmp_tc_flower_match_action(flower, &flower_out)) { - VLOG_WARN_RL(&error_rl, "Kernel flower acknowledgment does " - "not match request! Set dpif_netlink to dbg to " - "see which rule caused this error."); + if (is_probe) { + error = EINVAL; + } else { + VLOG_WARN_RL(&error_rl, "Kernel flower acknowledgment " + "does not match request! Set " + "dpif_netlink to dbg to see " + "which rule caused this error."); + } } } ofpbuf_delete(reply); diff --git a/lib/tc.h b/lib/tc.h index 8442c8d8b..c0a1d5d0e 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -46,15 +46,23 @@ #define TC_POLICY_DEFAULT "none" -enum tc_flower_reserved_prio { +enum tc_flower_reserved_prio +{ TC_RESERVED_PRIORITY_NONE, TC_RESERVED_PRIORITY_POLICE, TC_RESERVED_PRIORITY_IPV4, TC_RESERVED_PRIORITY_IPV6, TC_RESERVED_PRIORITY_VLAN, - __TC_RESERVED_PRIORITY_MAX + __TC_RESERVED_PRIORITY_MAX, + + TC_MAX_PRIORITY = UINT16_MAX - 1, + /* This priority is reserved solely for probing purposes. + * Since it's not used in actual traffic flows, we assign it a high value + * to avoid impacting vendor specific hardware offload implementations. */ + TC_RESERVED_PRIORITY_FEATURE_PROBE }; -#define TC_RESERVED_PRIORITY_MAX (__TC_RESERVED_PRIORITY_MAX -1) +#define TC_RESERVED_PRIORITY_MAX (__TC_RESERVED_PRIORITY_MAX - 1) + enum tc_qdisc_hook { TC_INGRESS, @@ -125,6 +133,7 @@ struct tc_flower_tunnel { uint8_t ttl; ovs_be16 tp_src; ovs_be16 tp_dst; + uint32_t tc_enc_flags; struct tc_tunnel_gbp gbp; ovs_be64 id; struct tun_metadata metadata; 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); From patchwork Mon Oct 14 12:09:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1996870 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=B2H/ymyR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4XRwz96Q2xz1xvx for ; Mon, 14 Oct 2024 23:10:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 214B580F87; Mon, 14 Oct 2024 12:10:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Ka8SlZFiASCg; Mon, 14 Oct 2024 12:10:11 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EB82381026 Authentication-Results: smtp1.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=B2H/ymyR Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id EB82381026; Mon, 14 Oct 2024 12:10:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BE299C08A6; Mon, 14 Oct 2024 12:10:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CFEFAC08A3 for ; Mon, 14 Oct 2024 12:10:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7F10540967 for ; Mon, 14 Oct 2024 12:10:09 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2mS-O_RMvpCS for ; Mon, 14 Oct 2024 12:10:07 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=echaudro@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 4FDA8405BF Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4FDA8405BF Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B2H/ymyR Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4FDA8405BF for ; Mon, 14 Oct 2024 12:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728907803; 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=ghgMeZhKJtVx1UcFi84lOtvzUv7Q006wtTWCo84WAYc=; b=B2H/ymyRPezdJq1P5MFWSn8VAL1zS6iWI5w+eFT4N/z1PCv0tefptgGM/Qfl2xVVIqXzOl vXOphvFZRk3UoqDFzEh60BBMA/PGj/7T+jPsnbW0L3wd3Zq7jZSZYBmfgzOX1iQk5ErVwJ NbH+pa7CzuES/lBQrK7qxsZ82/ykWmA= Received: from mx-prod-mc-02.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-132-9TE5AYwZP-2L-O3v7tkHJA-1; Mon, 14 Oct 2024 08:10:00 -0400 X-MC-Unique: 9TE5AYwZP-2L-O3v7tkHJA-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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 393D11955EE9; Mon, 14 Oct 2024 12:09:59 +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 5593819560AE; Mon, 14 Oct 2024 12:09:58 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 14 Oct 2024 14:09:04 +0200 Message-ID: <7b6d177d692fd08b64a5b15828238ec1dd6440f2.1728907640.git.echaudro@redhat.com> 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 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. Acked-by: Roi Dayan Signed-off-by: Eelco Chaudron --- acinclude.m4 | 6 +++--- include/linux/tc_act/tc_tunnel_key.h | 3 ++- lib/netdev-offload-tc.c | 16 +++++++++++----- lib/tc.c | 6 ++++++ lib/tc.h | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index f4cb4a146..8658bcfcb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -193,10 +193,10 @@ AC_DEFUN([OVS_CHECK_LINUX_TC], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([#include ], [ - int x = TCA_TUNNEL_KEY_ENC_OPTS_VXLAN; + int x = TCA_TUNNEL_KEY_NO_FRAG; ])], - [AC_DEFINE([HAVE_TCA_TUNNEL_KEY_ENC_OPTS_VXLAN], [1], - [Define to 1 if TCA_TUNNEL_KEY_ENC_OPTS_VXLAN is available.])]) + [AC_DEFINE([HAVE_TCA_TUNNEL_KEY_NO_FRAG], [1], + [Define to 1 if TCA_TUNNEL_KEY_NO_FRAG is available.])]) AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([#include ], [ diff --git a/include/linux/tc_act/tc_tunnel_key.h b/include/linux/tc_act/tc_tunnel_key.h index 17291b90b..edb64262e 100644 --- a/include/linux/tc_act/tc_tunnel_key.h +++ b/include/linux/tc_act/tc_tunnel_key.h @@ -1,7 +1,7 @@ #ifndef __LINUX_TC_ACT_TC_TUNNEL_KEY_WRAPPER_H #define __LINUX_TC_ACT_TC_TUNNEL_KEY_WRAPPER_H 1 -#if defined(__KERNEL__) || defined(HAVE_TCA_TUNNEL_KEY_ENC_OPTS_VXLAN) +#if defined(__KERNEL__) || defined(HAVE_TCA_TUNNEL_KEY_NO_FRAG) #include_next #else @@ -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 c6aa51c68..dd2afc64f 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 c0a1d5d0e..8b9a1655a 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -229,6 +229,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; From patchwork Mon Oct 14 12:09:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1996868 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=UgI1zO5U; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::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 4XRwz94YfYz1xvt for ; Mon, 14 Oct 2024 23:10:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D644060816; Mon, 14 Oct 2024 12:10:10 +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 M96Igs-enSwh; Mon, 14 Oct 2024 12:10:08 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 62AB4607FC 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=UgI1zO5U Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 62AB4607FC; Mon, 14 Oct 2024 12:10:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 94E10C08A6; Mon, 14 Oct 2024 12:10:07 +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 3FDE9C08BA for ; Mon, 14 Oct 2024 12:10:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2B604404DB for ; Mon, 14 Oct 2024 12:10:06 +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 BWQr_rluxU21 for ; Mon, 14 Oct 2024 12:10:05 +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 6735440493 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 6735440493 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=UgI1zO5U 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 6735440493 for ; Mon, 14 Oct 2024 12:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728907804; 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=MTsCTFtWcg7dQq9IYQ3B8nhKzKfpkMGadML5sPBfybw=; b=UgI1zO5U0eWmE1hyUMWJxCiFlzWSjzRZY9VsUnOvFt362ynDjtkJzmTnfyZY/I0/aTfpP4 92LCX/XJZ0W5M4X9djSx3SSRBnGt3xNsbC9ioPn9H2w12R+moMRxenexqfi2xbZXmpMQfl fX/Yti53cCoGTC9WTH6u0kAuF6GuLBU= 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-359-3MiqzdZrNPWKZDPpEEI2DA-1; Mon, 14 Oct 2024 08:10:01 -0400 X-MC-Unique: 3MiqzdZrNPWKZDPpEEI2DA-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 8139E19560A3; Mon, 14 Oct 2024 12:10:00 +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 9E2D919560AE; Mon, 14 Oct 2024 12:09:59 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 14 Oct 2024 14:09:05 +0200 Message-ID: <0135a1f6db2ad5345d8c32edbd1b3fd26af6942a.1728907640.git.echaudro@redhat.com> 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 4/4] system-offload: Add TC tunnel flags test case. 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" Add a TC specific test case to test the tunnel match and action flags. Acked-by: Roi Dayan Signed-off-by: Eelco Chaudron --- tests/system-offloads-traffic.at | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index d1da33d96..6e3b063ee 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -933,3 +933,62 @@ OVS_WAIT_UNTIL([grep -q "Datapath does not support explicit drop action" ovs-vsw OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([offload - Tunnel offloading with flags]) +AT_SKIP_IF([test $HAVE_NC = no]) +OVS_CHECK_VXLAN() + +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . \ + other_config:hw-offload=true]) +AT_SKIP_IF([! grep -q "probe tc: enc flags are supported." ovs-vswitchd.log]) + +ADD_BR([br-underlay]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) + +ADD_NAMESPACES(at_ns0) + +dnl Set up underlay link from host into the namespace using veth pair. +ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") +AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) +AT_CHECK([ip link set dev br-underlay up]) + +dnl Set up tunnel endpoints on OVS outside the namespace and with a native +dnl Linux device inside the namespace. +ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) +ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], + [10.1.1.1/24], [id 0 dstport 4789]) + +dnl First, check the underlay. +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -W 2 172.31.1.100 | FORMAT_PING], + [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +dnl Check the overlay, with some icmp traffic. +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -W 2 10.1.1.100 | FORMAT_PING], + [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +# Check for a set tunnel action with df flag set. +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded], [], [stdout]) +AT_CHECK( + [grep -q -F "set(tunnel(dst=172.31.1.1,ttl=64,tp_dst=4789,flags(df)))" \ + stdout]) +AT_CHECK( + [grep -q -F "tunnel(tun_id=0x0,src=172.31.1.1,dst=172.31.1.100,tp_dst=4789,flags(-df+csum+key))" \ + stdout]) + +# Now verify the none df, and forced csum case. +AT_CHECK([ovs-vsctl set int at_vxlan0 options:df_default=false \ + options:csum=true]) +AT_CHECK([ovs-appctl revalidator/wait]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded ], [], [stdout]) +AT_CHECK( + [grep -q -F "set(tunnel(dst=172.31.1.1,ttl=64,tp_dst=4789,flags(csum)))" \ + stdout]) + +OVS_TRAFFIC_VSWITCHD_STOP +AT_CLEANUP \ No newline at end of file