[dpdk-stable] patch 'common/mlx5: fix Netlink port name padding in probing' has been queued to stable release 19.11.10

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Tue Aug 10 17:39:00 CEST 2021


Hi,

FYI, your patch has been queued to stable release 19.11.10

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/12/21. 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/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/479de253642b9ffc6592cf71efb7bb835a1c646c

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 479de253642b9ffc6592cf71efb7bb835a1c646c Mon Sep 17 00:00:00 2001
From: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
Date: Sat, 19 Jun 2021 16:56:28 +0300
Subject: [PATCH] common/mlx5: fix Netlink port name padding in probing

[ upstream commit 568d97c09ca00e52fd7805ef0cab522250dac18b ]

On some kernels the string attributes within Netlink
reply messages might be not padded with zeroes (in cases
when string length is aligned with 4-byte boundary).
While device probing, the physical port name was wrongly recognized,
causing a probing failure.

Fixes: 30a86157f6d5 ("net/mlx5: support PF representor")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
---
 drivers/net/mlx5/mlx5_nl.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
index 64580b9e6a..668affb0b1 100644
--- a/drivers/net/mlx5/mlx5_nl.c
+++ b/drivers/net/mlx5/mlx5_nl.c
@@ -30,6 +30,8 @@
 #define MLX5_SEND_BUF_SIZE 32768
 /* Receive buffer size for the Netlink socket */
 #define MLX5_RECV_BUF_SIZE 32768
+/* Maximal physical port name length. */
+#define MLX5_PHYS_PORT_NAME_MAX 128
 
 /** Parameters of VLAN devices created by driver. */
 #define MLX5_VMWA_VLAN_DEVICE_PFX "evmlx"
@@ -1029,6 +1031,7 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)
 	size_t off = NLMSG_LENGTH(sizeof(struct ifinfomsg));
 	bool switch_id_set = false;
 	bool num_vf_set = false;
+	int len;
 
 	if (nh->nlmsg_type != RTM_NEWLINK)
 		goto error;
@@ -1044,7 +1047,24 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)
 			num_vf_set = true;
 			break;
 		case IFLA_PHYS_PORT_NAME:
-			mlx5_translate_port_name((char *)payload, &info);
+			len = RTA_PAYLOAD(ra);
+			/* Some kernels do not pad attributes with zero. */
+			if (len > 0 && len < MLX5_PHYS_PORT_NAME_MAX) {
+				char name[MLX5_PHYS_PORT_NAME_MAX];
+
+				/*
+				 * We can't just patch the message with padding
+				 * zero - it might corrupt the following items
+				 * in the message, we have to copy the string
+				 * by attribute length and pad the copied one.
+				 */
+				memcpy(name, payload, len);
+				name[len] = 0;
+				mlx5_translate_port_name(name, &info);
+			} else {
+				info.name_type =
+					MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;
+			}
 			break;
 		case IFLA_PHYS_SWITCH_ID:
 			info.switch_id = 0;
-- 
2.32.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-08-10 15:11:13.853478648 +0200
+++ 0020-common-mlx5-fix-Netlink-port-name-padding-in-probing.patch	2021-08-10 15:11:12.922637408 +0200
@@ -1 +1 @@
-From 568d97c09ca00e52fd7805ef0cab522250dac18b Mon Sep 17 00:00:00 2001
+From 479de253642b9ffc6592cf71efb7bb835a1c646c Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 568d97c09ca00e52fd7805ef0cab522250dac18b ]
+
@@ -13 +14,0 @@
-Cc: stable at dpdk.org
@@ -18 +19 @@
- drivers/common/mlx5/linux/mlx5_nl.c | 22 +++++++++++++++++++++-
+ drivers/net/mlx5/mlx5_nl.c | 22 +++++++++++++++++++++-
@@ -21,5 +22,5 @@
-diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c
-index f0d04f9473..3f1912d078 100644
---- a/drivers/common/mlx5/linux/mlx5_nl.c
-+++ b/drivers/common/mlx5/linux/mlx5_nl.c
-@@ -33,6 +33,8 @@
+diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c
+index 64580b9e6a..668affb0b1 100644
+--- a/drivers/net/mlx5/mlx5_nl.c
++++ b/drivers/net/mlx5/mlx5_nl.c
+@@ -30,6 +30,8 @@
@@ -34 +35 @@
-@@ -1191,6 +1193,7 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)
+@@ -1029,6 +1031,7 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)
@@ -42 +43 @@
-@@ -1206,7 +1209,24 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)
+@@ -1044,7 +1047,24 @@ mlx5_nl_switch_info_cb(struct nlmsghdr *nh, void *arg)


More information about the stable mailing list