patch 'kni: use dedicated function to set MAC address' has been queued to stable release 19.11.13

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Thu Jul 7 09:54:47 CEST 2022


Hi,

FYI, your patch has been queued to stable release 19.11.13

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

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

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 1093a40bd849732e0bb5dba21cb10b8e13fae444 Mon Sep 17 00:00:00 2001
From: Ke Zhang <ke1x.zhang at intel.com>
Date: Wed, 8 Jun 2022 15:11:17 +0300
Subject: [PATCH] kni: use dedicated function to set MAC address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit b99bd4a0aacab47165d045a6aeee88ee74744600 ]

The warning info:
warning: passing argument 1 of ‘memcpy’ discards ‘const’
qualifier from pointer target type

Variable dev_addr is done const intentionally in v5.17 to prevent using
it directly.  See the following Linux kernel changeset for details:

commit adeef3e32146 ("net: constify netdev->dev_addr")

Used helper function was introduced earlier in v5.15.

Fixes: ea6b39b5b847 ("kni: remove ethtool support")

Signed-off-by: Ke Zhang <ke1x.zhang at intel.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
Acked-by: Ferruh Yigit <ferruh.yigit at xilinx.com>
---
 kernel/linux/kni/compat.h   | 4 ++++
 kernel/linux/kni/kni_misc.c | 9 +++++++--
 kernel/linux/kni/kni_net.c  | 4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h
index 0db29a4a6f..3a86d12bbc 100644
--- a/kernel/linux/kni/compat.h
+++ b/kernel/linux/kni/compat.h
@@ -142,6 +142,10 @@
 #define HAVE_TSK_IN_GUP
 #endif
 
+#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE
+#define HAVE_ETH_HW_ADDR_SET
+#endif
+
 #if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
 #define HAVE_NETIF_RX_NI
 #endif
diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index f908ebcd82..12ece28a84 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -400,11 +400,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
 	pr_debug("mbuf_size:    %u\n", kni->mbuf_size);
 
 	/* if user has provided a valid mac address */
-	if (is_valid_ether_addr(dev_info.mac_addr))
+	if (is_valid_ether_addr(dev_info.mac_addr)) {
+#ifdef HAVE_ETH_HW_ADDR_SET
+		eth_hw_addr_set(net_dev, dev_info.mac_addr);
+#else
 		memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN);
-	else
+#endif
+	} else {
 		/* Assign random MAC address. */
 		eth_hw_addr_random(net_dev);
+	}
 
 	if (dev_info.mtu)
 		net_dev->mtu = dev_info.mtu;
diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index e54864c977..1270c367d8 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -756,7 +756,11 @@ kni_net_set_mac(struct net_device *netdev, void *p)
 		return -EADDRNOTAVAIL;
 
 	memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
+#ifdef HAVE_ETH_HW_ADDR_SET
+	eth_hw_addr_set(netdev, addr->sa_data);
+#else
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+#endif
 
 	kni = netdev_priv(netdev);
 	ret = kni_net_process_request(kni, &req);
-- 
2.37.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-07-07 09:54:13.371636562 +0200
+++ 0052-kni-use-dedicated-function-to-set-MAC-address.patch	2022-07-07 09:54:10.941824469 +0200
@@ -1 +1 @@
-From b99bd4a0aacab47165d045a6aeee88ee74744600 Mon Sep 17 00:00:00 2001
+From 1093a40bd849732e0bb5dba21cb10b8e13fae444 Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit b99bd4a0aacab47165d045a6aeee88ee74744600 ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -48 +49 @@
-index 4f6dd373a3..0c3a86ee35 100644
+index f908ebcd82..12ece28a84 100644
@@ -51 +52 @@
-@@ -402,11 +402,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
+@@ -400,11 +400,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
@@ -71 +72 @@
-index 41805fcabf..779ee3451a 100644
+index e54864c977..1270c367d8 100644
@@ -74 +75 @@
-@@ -783,7 +783,11 @@ kni_net_set_mac(struct net_device *netdev, void *p)
+@@ -756,7 +756,11 @@ kni_net_set_mac(struct net_device *netdev, void *p)
@@ -84,2 +85,2 @@
- 	ret = kni_net_process_request(netdev, &req);
- 
+ 	kni = netdev_priv(netdev);
+ 	ret = kni_net_process_request(kni, &req);


More information about the stable mailing list