1 Star 0 Fork 75

sky/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0217-kni-use-dedicated-function-to-set-MAC-address.patch 2.74 KB
一键复制 编辑 原始数据 按行查看 历史
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nlgwcy/dpdk.git
git@gitee.com:nlgwcy/dpdk.git
nlgwcy
dpdk
dpdk
master

搜索帮助