From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 952E242850 for ; Thu, 30 Mar 2023 10:36:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FBA240E25; Thu, 30 Mar 2023 10:36:15 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id E3A9640685 for ; Thu, 30 Mar 2023 10:36:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680165372; 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=izOYkkfcV+/Rcr/8AAanhHzZ/7JKaso6ZCyDxqZl5rs=; b=NAC3asrC3xSh0sYjS8ekkJigkEIzvqzOnHFIqm39/9wy4JCMEjSWarLFSMNoUVDlib/piS M54/NDu7fo7SGJW7uOepDC2d9KYUakxitTP2iJYx4AQX64U7LxS5Bfpvmvuzn87KuWwVoV mcPWAtd2vW068mNkqWoVPgZhF4uERjU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-138-uPf4QLtoPyqTXsIlrf831A-1; Thu, 30 Mar 2023 04:36:08 -0400 X-MC-Unique: uPf4QLtoPyqTXsIlrf831A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE481101A552; Thu, 30 Mar 2023 08:36:07 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A0C40521FD; Thu, 30 Mar 2023 08:36:07 +0000 (UTC) From: Kevin Traynor To: Bing Zhao Cc: Matan Azrad , dpdk stable Subject: patch 'net/mlx5: fix sysfs port name translation' has been queued to stable release 21.11.4 Date: Thu, 30 Mar 2023 09:35:56 +0100 Message-Id: <20230330083600.473876-4-ktraynor@redhat.com> In-Reply-To: <20230330083600.473876-1-ktraynor@redhat.com> References: <20230330083600.473876-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/02/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/80a576917cceba0b3eeeae7ad08d93162f1c877e Thanks. Kevin --- >From 80a576917cceba0b3eeeae7ad08d93162f1c877e Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Thu, 23 Mar 2023 12:54:14 +0200 Subject: [PATCH] net/mlx5: fix sysfs port name translation [ upstream commit f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec ] With some OFED or upstream kernel of mlx5, the port name fetched from "/sys/class/net/[DEV]/phys_port_name" may have a tailing "\n" as the EOL. The sscanf() will return the scanned items number with this EOL. In such case, the "equal to" condition is considered as false and the function mlx5_translate_port_name() will recognize the port type wrongly with UNKNOWN result. The tailing carriage return character should be removed before calling the mlx5_translate_port_name(), this was already done in the NL message handling. In the meanwhile, the possible incorrect line feed character is also taken into consideration. Fixes: 654810b56828 ("common/mlx5: share Netlink commands") Fixes: 420bbdae89f2 ("net/mlx5: fix host physical function representor naming") Signed-off-by: Bing Zhao Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 368d22de89..89095e856f 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1106,5 +1106,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) { char ifname[IF_NAMESIZE]; - char port_name[IF_NAMESIZE]; + char *port_name = NULL; + size_t port_name_size = 0; FILE *file; struct mlx5_switch_info data = { @@ -1119,4 +1120,5 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) bool device_dir = false; char c; + ssize_t line_size; if (!if_indextoname(ifindex, ifname)) { @@ -1134,6 +1136,19 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) file = fopen(phys_port_name, "rb"); if (file != NULL) { - if (fgets(port_name, IF_NAMESIZE, file) != NULL) + char *tail_nl; + + line_size = getline(&port_name, &port_name_size, file); + if (line_size < 0) { + fclose(file); + rte_errno = errno; + return -rte_errno; + } else if (line_size > 0) { + /* Remove tailing newline character. */ + tail_nl = strchr(port_name, '\n'); + if (tail_nl) + *tail_nl = '\0'; mlx5_translate_port_name(port_name, &data); + } + free(port_name); fclose(file); } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-03-30 09:30:45.388825455 +0100 +++ 0005-net-mlx5-fix-sysfs-port-name-translation.patch 2023-03-30 09:30:45.251229249 +0100 @@ -1 +1 @@ -From f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec Mon Sep 17 00:00:00 2001 +From 80a576917cceba0b3eeeae7ad08d93162f1c877e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f8a226ed65fa1c6e085fb0d5a91bab7fb5034aec ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index f1ff6f49f9..55801534d1 100644 +index 368d22de89..89095e856f 100644 @@ -33 +34 @@ -@@ -1036,5 +1036,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1106,5 +1106,6 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) @@ -41 +42 @@ -@@ -1049,4 +1050,5 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1119,4 +1120,5 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) @@ -47 +48 @@ -@@ -1064,6 +1066,19 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) +@@ -1134,6 +1136,19 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info)