patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Bing Zhao <bingz@nvidia.com>
Cc: Matan Azrad <matan@nvidia.com>, dpdk stable <stable@dpdk.org>
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	[thread overview]
Message-ID: <20230330083600.473876-4-ktraynor@redhat.com> (raw)
In-Reply-To: <20230330083600.473876-1-ktraynor@redhat.com>

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 <bingz@nvidia.com>
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 <bingz@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 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)


  parent reply	other threads:[~2023-03-30  8:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  8:35 patch 'examples/qos_sched: fix config entries in wrong sections' " Kevin Traynor
2023-03-30  8:35 ` patch 'net/mlx5: fix build with GCC 12 and ASan' " Kevin Traynor
2023-03-30  8:35 ` patch 'net/mlx5: fix CQE dump for Tx' " Kevin Traynor
2023-03-30  8:35 ` Kevin Traynor [this message]
2023-03-30  8:35 ` patch 'test/crypto: fix statistics error messages' " Kevin Traynor
2023-03-30  8:35 ` patch 'pdump: fix build with GCC 12' " Kevin Traynor
2023-03-30  8:35 ` patch 'acl: fix crash on PPC64 with GCC 11' " Kevin Traynor
2023-03-30  8:36 ` patch 'doc: fix pipeline example path in user guide' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230330083600.473876-4-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=bingz@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).