From patchwork Tue Oct 8 13:52:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1994276 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=Vaz93YIg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4XNHYP45wtz1xvN for ; Wed, 9 Oct 2024 00:53:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BB4944057B; Tue, 8 Oct 2024 13:53:42 +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 GLIU4-NNwe76; Tue, 8 Oct 2024 13:53:40 +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 smtp4.osuosl.org E1E6840539 Authentication-Results: smtp4.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=Vaz93YIg Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id E1E6840539; Tue, 8 Oct 2024 13:53:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BE14FC08A6; Tue, 8 Oct 2024 13:53:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E99CC08A3 for ; Tue, 8 Oct 2024 13:53:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F15076087E for ; Tue, 8 Oct 2024 13:53:38 +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 dZzpFsJmbr_C for ; Tue, 8 Oct 2024 13:53:37 +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 smtp3.osuosl.org 6FF576087A Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6FF576087A Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vaz93YIg Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6FF576087A for ; Tue, 8 Oct 2024 13:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728395616; 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=Qni+YwyXPKYiUelQMTdT5jhz3GVMemSt+ZtRlc4I9Sw=; b=Vaz93YIgvgrmTO4dKJ4OGFDYpH3+K36pbERrvPhQ8tcRBRjFw/S6JJEGcldoAoBMQ13uxt TqYUbx/3xLcCcJMXIi1z2H5irJGnyI2K95rOHr8mfyvpijdG/geYeUoDLD4zpH4kiHLSVC AetK8BnSBEovNB3h4qeJ7r673QWE3tE= Received: from mx-prod-mc-01.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-173-ouQCTCqlN_6hKrGn8V_PbA-1; Tue, 08 Oct 2024 09:53:34 -0400 X-MC-Unique: ouQCTCqlN_6hKrGn8V_PbA-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0AAC31956077 for ; Tue, 8 Oct 2024 13:53:34 +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 52F361956088 for ; Tue, 8 Oct 2024 13:53:33 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Tue, 8 Oct 2024 15:52:44 +0200 Message-ID: <33e81a4162a1349a50d029cdc74833da5b93c258.1728395410.git.echaudro@redhat.com> 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 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 --- acinclude.m4 | 6 +++--- include/linux/pkt_cls.h | 28 ++++++++++++++++++++++++- lib/netdev-offload-tc.c | 45 +++++++++++++++++++++++++++++++++++++++++ lib/tc.c | 29 +++++++++++++++++++++++--- lib/tc.h | 2 ++ 5 files changed, 103 insertions(+), 7 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..fcd206f2c 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; @@ -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..8ec4857b7 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -52,6 +52,7 @@ enum tc_flower_reserved_prio { TC_RESERVED_PRIORITY_IPV4, TC_RESERVED_PRIORITY_IPV6, TC_RESERVED_PRIORITY_VLAN, + TC_RESERVED_PRIORITY_FEATURE_PROBE, __TC_RESERVED_PRIORITY_MAX }; #define TC_RESERVED_PRIORITY_MAX (__TC_RESERVED_PRIORITY_MAX -1) @@ -125,6 +126,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;