patch 'net/mlx5: fix build with recent compilers' has been queued to stable release 21.11.3

Kevin Traynor ktraynor at redhat.com
Fri Nov 11 11:33:37 CET 2022


Hi,

FYI, your patch has been queued to stable release 21.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/14/22. 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/81aba30795dfef41ab7d782ecdf3fa4cb3752a96

Thanks.

Kevin

---
>From 81aba30795dfef41ab7d782ecdf3fa4cb3752a96 Mon Sep 17 00:00:00 2001
From: Bing Zhao <bingz at nvidia.com>
Date: Mon, 31 Oct 2022 20:24:56 +0200
Subject: [PATCH] net/mlx5: fix build with recent compilers

[ upstream commit ccc6ea5d9c90650e3a8e29ab45e18b9fffd3d061 ]

With some higher GCC/CLANG version, it is not recommended to use a
structure with a tailing flexible array inside another structure.
Accessing this array may be considered as a risk to corrupt the
following field even if it is by intention.

The error below was observed:

  drivers/net/mlx5/linux/mlx5_ethdev_os.c: In function 'mlx5_get_flag_dropless_rq':
  drivers/net/mlx5/linux/mlx5_ethdev_os.c:1679:42: error:
  invalid use of structure with flexible array member [-Werror=pedantic]
  1679 | struct ethtool_sset_info hdr;
       | ^~~

Changing it to memory dynamic allocation method will help to get
rid of this complain.

Fixes: e848218741ea ("net/mlx5: check delay drop settings in kernel driver")

Signed-off-by: Bing Zhao <bingz at nvidia.com>
Acked-by: Thomas Monjalon <thomas at monjalon.net>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index fadcbd7ef7..368d22de89 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -1683,8 +1683,5 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
 int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
 {
-	struct {
-		struct ethtool_sset_info hdr;
-		uint32_t buf[1];
-	} sset_info;
+	struct ethtool_sset_info *sset_info = NULL;
 	struct ethtool_drvinfo drvinfo;
 	struct ifreq ifr;
@@ -1697,13 +1694,19 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
 	int ret;
 
-	sset_info.hdr.cmd = ETHTOOL_GSSET_INFO;
-	sset_info.hdr.reserved = 0;
-	sset_info.hdr.sset_mask = 1ULL << ETH_SS_PRIV_FLAGS;
+	sset_info = mlx5_malloc(0, sizeof(struct ethtool_sset_info) +
+			sizeof(uint32_t), 0, SOCKET_ID_ANY);
+	if (sset_info == NULL) {
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	sset_info->cmd = ETHTOOL_GSSET_INFO;
+	sset_info->reserved = 0;
+	sset_info->sset_mask = 1ULL << ETH_SS_PRIV_FLAGS;
 	ifr.ifr_data = (caddr_t)&sset_info;
 	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
 	if (!ret) {
-		const uint32_t *sset_lengths = sset_info.hdr.data;
+		const uint32_t *sset_lengths = sset_info->data;
 
-		len = sset_info.hdr.sset_mask ? sset_lengths[0] : 0;
+		len = sset_info->sset_mask ? sset_lengths[0] : 0;
 	} else if (ret == -EOPNOTSUPP) {
 		drvinfo.cmd = ETHTOOL_GDRVINFO;
@@ -1778,4 +1781,5 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
 exit:
 	mlx5_free(strings);
+	mlx5_free(sset_info);
 	return ret;
 }
-- 
2.38.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-11-11 10:32:18.170746756 +0000
+++ 0047-net-mlx5-fix-build-with-recent-compilers.patch	2022-11-11 10:32:17.132301002 +0000
@@ -1 +1 @@
-From ccc6ea5d9c90650e3a8e29ab45e18b9fffd3d061 Mon Sep 17 00:00:00 2001
+From 81aba30795dfef41ab7d782ecdf3fa4cb3752a96 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit ccc6ea5d9c90650e3a8e29ab45e18b9fffd3d061 ]
+
@@ -23 +24,0 @@
-Cc: stable at dpdk.org
@@ -32 +33 @@
-index 661d362dc0..72268c0c8a 100644
+index fadcbd7ef7..368d22de89 100644
@@ -35 +36 @@
-@@ -1676,8 +1676,5 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
+@@ -1683,8 +1683,5 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
@@ -45 +46 @@
-@@ -1690,13 +1687,19 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
+@@ -1697,13 +1694,19 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
@@ -70 +71 @@
-@@ -1771,4 +1774,5 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)
+@@ -1778,4 +1781,5 @@ int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev)



More information about the stable mailing list