代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/dpdk 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 4cfe56040171e791b021d5490f8fd58c55b088fb Mon Sep 17 00:00:00 2001
From: Ke Zhang <ke1x.zhang@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@intel.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Ferruh Yigit <ferruh.yigit@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 38fcd7f4f2..feed12b568 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -404,11 +404,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 41805fcabf..779ee3451a 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -783,7 +783,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
ret = kni_net_process_request(netdev, &req);
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。