kni: use dedicated function to set MAC address
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: ea6b39b5b8
("kni: remove ethtool support")
Cc: stable@dpdk.org
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>
This commit is contained in:
parent
2ee8c67ef9
commit
b99bd4a0aa
@ -142,6 +142,10 @@
|
|||||||
#define HAVE_TSK_IN_GUP
|
#define HAVE_TSK_IN_GUP
|
||||||
#endif
|
#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
|
#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
|
||||||
#define HAVE_NETIF_RX_NI
|
#define HAVE_NETIF_RX_NI
|
||||||
#endif
|
#endif
|
||||||
|
@ -402,11 +402,16 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,
|
|||||||
pr_debug("mbuf_size: %u\n", kni->mbuf_size);
|
pr_debug("mbuf_size: %u\n", kni->mbuf_size);
|
||||||
|
|
||||||
/* if user has provided a valid mac address */
|
/* 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);
|
memcpy(net_dev->dev_addr, dev_info.mac_addr, ETH_ALEN);
|
||||||
else
|
#endif
|
||||||
|
} else {
|
||||||
/* Assign random MAC address. */
|
/* Assign random MAC address. */
|
||||||
eth_hw_addr_random(net_dev);
|
eth_hw_addr_random(net_dev);
|
||||||
|
}
|
||||||
|
|
||||||
if (dev_info.mtu)
|
if (dev_info.mtu)
|
||||||
net_dev->mtu = dev_info.mtu;
|
net_dev->mtu = dev_info.mtu;
|
||||||
|
@ -783,7 +783,11 @@ kni_net_set_mac(struct net_device *netdev, void *p)
|
|||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
|
|
||||||
memcpy(req.mac_addr, addr->sa_data, netdev->addr_len);
|
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);
|
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = kni_net_process_request(netdev, &req);
|
ret = kni_net_process_request(netdev, &req);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user