From patchwork Tue Jun 27 10:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 1800532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=I9AuqOBd; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qr1g93ZsVz242H for ; Tue, 27 Jun 2023 20:49:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 93E6241C36; Tue, 27 Jun 2023 10:49:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 93E6241C36 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=I9AuqOBd X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6fhRLHfTxUH3; Tue, 27 Jun 2023 10:49:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id F1BDB41DD8; Tue, 27 Jun 2023 10:49:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F1BDB41DD8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C79FCC0072; Tue, 27 Jun 2023 10:49:20 +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 07492C0037 for ; Tue, 27 Jun 2023 10:49:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BD8C2613B6 for ; Tue, 27 Jun 2023 10:49:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org BD8C2613B6 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=I9AuqOBd X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GxEd8TGtVlNV for ; Tue, 27 Jun 2023 10:48:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7A87B613C1 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::61b]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7A87B613C1 for ; Tue, 27 Jun 2023 10:48:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXtX2XadIYNHV3B5K9PdDphx9wY29gFrcw6CeT6B3q0aJkbZ5YwXQCsy8Jm1AOpOZxyYOdhzW4Kj8FCWkX6QCQVHh9TwZnSOmVQa5pg+L7kth5yUDwQI+KIxswSD4ZcIiUUrMRzOlGjNsHflWYUsSMkJckKiF+XQocGZBQ13MF27n3rhIV9j5yqYvFtvT04aKbGMZmpnqOrzWKZIAM1hlWDmAMQ2/pWjm6yiBnXAqs3veF8VwayAF9x91UJbOAf4HQCyDx2uh3L2L3En4zc3T9ovt/mOYJV0cyBe65NEJlOjknoulXo650kBT7dPrB7NR9B/qZwHRHe3HfiK5TiQpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ixy+1I9Q02PkuWiQGfhp61jiJRs2uQ3SZRGzhgfOrIE=; b=Ck7z71+TI4W2Wf7urRfX2KsoeyqSvoPPZPU9k0SNbDfXMZoDWx0cHl3YPNsaeLzl5eSqcLsgCel5pQYx1iBVcjroFmRMDgf+giGBPfF4odXfXFmKTjxTkQkJeJYYjcSH3cetkyh8Q7soaOjctWpjSJ391QWz0l9aRt8hAyvdijcUnAdJSTo27vz+Pbv0s/CLvrCWNHN1AtCQuwVI5OJRpvxrflOrW//Q9RJq0gIMkZ9Z5l+BaPFlLxoAgoR+KojeygCl0nwr0YJj34s0U893HgtdI3EMRdgqX6ymQ9FQkLkAb8vJqIB0M0g0yoGKlMPdZKnWF7S3dIXFzUTkmWGBkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ixy+1I9Q02PkuWiQGfhp61jiJRs2uQ3SZRGzhgfOrIE=; b=I9AuqOBdf2cUNIqGH9khvM6FOTjQXcjhZEQilyDvSI34a0OBK0jIj8PcwKfAw0HylVglJLH7rdQ5wwnEG/bhXCUtdx3KX3h1HKerxFJ9HZ3hIGIn4oTu86D/NksvIOnXc75hfCu8o6pI38jyRfkoBpwJmBTaMEV71SkvDI3LO5MfGyvXU8TWjl2875/XueYaWXgPQYe36WXVFeXXqVR+cdUdJwEJWnMrJSa9Y4q6Y/TggCIe9S0EJ1YnajauEez0Vi29CZNrwyV8EZ6ulsztxJk0V4+o8/WOWY/iNEB12Lz0uOyepS/Bmn7kbcFnFQMz5aa2XH9Pe+G/HzcvoX0c/w== Received: from BN9PR03CA0055.namprd03.prod.outlook.com (2603:10b6:408:fb::30) by DM4PR12MB6400.namprd12.prod.outlook.com (2603:10b6:8:b9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.45; Tue, 27 Jun 2023 10:48:52 +0000 Received: from BN8NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::92) by BN9PR03CA0055.outlook.office365.com (2603:10b6:408:fb::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.34 via Frontend Transport; Tue, 27 Jun 2023 10:48:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT055.mail.protection.outlook.com (10.13.177.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.47 via Frontend Transport; Tue, 27 Jun 2023 10:48:52 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 27 Jun 2023 03:48:42 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 27 Jun 2023 03:48:42 -0700 Received: from dev-r-vrt-138.mtr.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 27 Jun 2023 03:48:40 -0700 To: Date: Tue, 27 Jun 2023 13:48:13 +0300 Message-ID: <20230627104814.2028633-9-roid@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230627104814.2028633-1-roid@nvidia.com> References: <20230627104814.2028633-1-roid@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT055:EE_|DM4PR12MB6400:EE_ X-MS-Office365-Filtering-Correlation-Id: 77f26f36-5c91-49a7-c116-08db76fc18f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s+MCIbL4Em6UaHVxYDGrgz0rxs+pCL4XDqmP7I4OJS1piUlLYolr3u+iEd/43kebOdOVgFBEaxxpRkhP0wUEAdDZN2f3XS9bQ73JEOe9A1SNOlMgQb6dz3hryWzSzFSqNN14XbeRtpCRyMzMXgo8kZTBe04ER9I8VvLEolk5WqCtbE7Fp7OSbyk7WuXlp6rfr0/MNJNxo+zqouISPdI+miCpeQTqA8ovlNXgbs1XC0uzBTR5VSUcIGUS0ZruodZlX7e22yvKre/4FAIj39usSDmRXhqoVzE8ASjUNP0VRUoFZ2VEBXpunGLJ/C91iI89HrcIkJICIV3pY4Qcx7EBQcQL4TR5KvqyLLrN9I+fCk3bcnuhgvkY+12pz6ZDkEED8Yd7L96HkipSGIlAt+8NqCoQUJ2MQAKwe2XTVrB67IWHVKunSQYPcE/hyY46gwzOX67NmJ3vMHjXAsMRPkj2vvQGtrF5zGdkxTscVWMVpfwkD50PNRXK2+u49hY+Ml4YrKX5DDdjwG07AaSLo18tAA15HAA5qQ4+tM/lB0tMucu2UtPEkfJ9OK7eGcg0reGayUvCjdT2O0lk2B602EUd47AJblmPXmOHGi/w00sxBMyFCm5m98bFUVpsiuNr7fIShUrQzlsPGxa//YcSMdfIplnxMJtWguJafuf9vwSgJMHnIA68MPxQ3C1t8zldNtgG0Cl5RXqQphGPbWdnCKwb+YJe0uNWZlUI4b41KIqo8pc= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199021)(36840700001)(40470700004)(46966006)(70586007)(316002)(8936002)(4326008)(70206006)(6916009)(478600001)(8676002)(5660300002)(36756003)(2906002)(40460700003)(36860700001)(40480700001)(86362001)(54906003)(186003)(41300700001)(26005)(82310400005)(426003)(336012)(47076005)(82740400003)(1076003)(7636003)(356005)(2616005)(107886003)(83380400001)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 10:48:52.3777 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77f26f36-5c91-49a7-c116-08db76fc18f5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6400 Cc: Simon Horman , Gavi Teitz , Ilya Maximets , Gavin Li Subject: [ovs-dev] [PATCH v6 8/9] netdev-tc-offloads: Probe for allowing vxlan gbp support X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Roi Dayan via dev From: Roi Dayan Reply-To: Roi Dayan Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Gavin Li Kernels that do not support vxlan gbp would treat the rule that has vxlan gbp encap action or vxlan gbp id match differently, either reject it or just skip the action/match and continue processing the knowing ones. To solve the issue, probe and disallow inserting rules with vxlan gbp action/match if kernel does not support it. Signed-off-by: Gavin Li Reviewed-by: Roi Dayan Reviewed-by: Simon Horman Acked-by: Eelco Chaudron --- lib/netdev-offload-tc.c | 64 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index c43eacd4d94f..b846a63c222f 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -52,6 +52,7 @@ static struct hmap tc_to_ufid = HMAP_INITIALIZER(&tc_to_ufid); static bool multi_mask_per_prio = false; static bool block_support = false; static uint16_t ct_state_support; +static bool vxlan_gbp_support = false; struct netlink_field { int offset; @@ -668,14 +669,17 @@ static void parse_tc_flower_geneve_opts(struct tc_action *action, nl_msg_end_nested(buf, geneve_off); } -static void +static int parse_tc_flower_vxlan_tun_opts(struct tc_action *action, struct ofpbuf *buf) { size_t gbp_off; uint32_t gbp_raw; if (!action->encap.gbp.id_present) { - return; + return 0; + } + if (!vxlan_gbp_support) { + return -EOPNOTSUPP; } gbp_off = nl_msg_start_nested(buf, OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS); @@ -683,6 +687,7 @@ parse_tc_flower_vxlan_tun_opts(struct tc_action *action, struct ofpbuf *buf) action->encap.gbp.id); nl_msg_put_u32(buf, OVS_VXLAN_EXT_GBP, gbp_raw); nl_msg_end_nested(buf, gbp_off); + return 0; } static void @@ -845,6 +850,7 @@ parse_tc_flower_to_actions__(struct tc_flower *flower, struct ofpbuf *buf, size_t set_offset = nl_msg_start_nested(buf, OVS_ACTION_ATTR_SET); size_t tunnel_offset = nl_msg_start_nested(buf, OVS_KEY_ATTR_TUNNEL); + int ret; if (action->encap.id_present) { nl_msg_put_be64(buf, OVS_TUNNEL_KEY_ATTR_ID, action->encap.id); @@ -880,7 +886,10 @@ 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); } - parse_tc_flower_vxlan_tun_opts(action, buf); + ret = parse_tc_flower_vxlan_tun_opts(action, buf); + if (ret) { + return ret; + } parse_tc_flower_geneve_opts(action, buf); nl_msg_end_nested(buf, tunnel_offset); nl_msg_end_nested(buf, set_offset); @@ -1632,6 +1641,9 @@ parse_put_flow_set_action(struct tc_flower *flower, struct tc_action *action, } break; case OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS: { + if (!vxlan_gbp_support) { + return EOPNOTSUPP; + } if (odp_vxlan_tun_opts_from_attr(tun_attr, &action->encap.gbp.id, &action->encap.gbp.flags, @@ -2787,6 +2799,51 @@ probe_tc_block_support(int ifindex) } } +static void +probe_vxlan_gbp_support(int ifindex) +{ + struct tc_flower flower; + struct tcf_id id; + int block_id = 0; + int prio = 1; + 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.gbp.id = OVS_BE16_MAX; + 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.gbp.id = htons(512); + + 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); + + vxlan_gbp_support = true; + VLOG_INFO("probe tc: vxlan gbp is supported."); + +out: + tc_add_del_qdisc(ifindex, false, block_id, TC_INGRESS); +} + static int tc_get_policer_action_ids(struct hmap *map) { @@ -2914,6 +2971,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); ovs_mutex_lock(&meter_police_ids_mutex); meter_police_ids = id_pool_create(METER_POLICE_IDS_BASE,