From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BC00A00C3; Wed, 8 Jun 2022 13:14:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAC9D4282D; Wed, 8 Jun 2022 13:14:10 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 39EE3415D7; Wed, 8 Jun 2022 13:14:08 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 115) id E430E311; Wed, 8 Jun 2022 14:14:07 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail1.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD autolearn=no autolearn_force=no version=3.4.6 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 7BEB5309; Wed, 8 Jun 2022 14:14:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 7BEB5309 Authentication-Results: shelob.oktetlabs.ru/7BEB5309; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ferruh Yigit , Stephen Hemminger Cc: dev@dpdk.org, Min Hu , Ke Zhang , stable@dpdk.org Subject: [PATCH v4 2/2] kni: fix warning about discarding const qualifier Date: Wed, 8 Jun 2022 14:13:59 +0300 Message-Id: <20220608111359.1234110-3-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220608111359.1234110-1-andrew.rybchenko@oktetlabs.ru> References: <20220531091330.230715-1-ke1x.zhang@intel.com> <20220608111359.1234110-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ke Zhang 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 kernel series [1] for more information. [1] https://lore.kernel.org/netdev/YZYAb4X%2FVQFy0iks@shredder/T/ Fixes: ea6b39b5b847 ("kni: remove ethtool support") Cc: stable@dpdk.org Signed-off-by: Ke Zhang Signed-off-by: Andrew Rybchenko --- 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..2c8f346ddf 100644 --- a/kernel/linux/kni/compat.h +++ b/kernel/linux/kni/compat.h @@ -145,3 +145,7 @@ #if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE #define HAVE_NETIF_RX_NI #endif + +#if KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE +#define HAVE_ETH_HW_ADDR_SET +#endif diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c index 4f6dd373a3..0c3a86ee35 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -402,11 +402,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..6257dcb1a8 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(net_dev, addr->sa_data); +#else memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); +#endif ret = kni_net_process_request(netdev, &req); -- 2.30.2