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 378C7A0542; Mon, 6 Jun 2022 09:29:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1C5640A7F; Mon, 6 Jun 2022 09:29:36 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 44E7440150; Mon, 6 Jun 2022 09:29:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654500575; x=1686036575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qn5jN4f0NgOBZffwMd/l2tRi1uwI+jve+sPN6guI7OE=; b=hag7aUecx0Kk1xKtZslM3xu9KxK4rU/m54cXWEwfAch+X8ktviHENGk9 /57gqQ0YetecY4SjP9CH8xsegBbKeymJsZT9ouc0RNh12M7uxVgqHc+A4 KJPAitftZ+i1f57jAE7pZLG7O5OisqEWmCXqDurmST8PTW9BOghPHJBMa CWTqiLr6FMIaBWfQxC2j20pQEO5Pwi/yVnG2pNizZrTRMF6ZOkQ3gv0xA sUomoKfcsXSopkKiocAlhJQ7ADG2SgdUeJ5VrXcF7jXQRfS01lpNtzu7v TTq0UOEeBA6M3ZGuOriyRj+gtFVgsx77pd7FV0zOxp/tsL5KZfwCfTdPk w==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="362975672" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="362975672" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 00:29:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="635463286" Received: from unknown (HELO localhost.localdomain) ([10.239.251.104]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 00:29:32 -0700 From: Ke Zhang To: ferruh.yigit@intel.com, dev@dpdk.org Cc: Ke Zhang , stable@dpdk.org, Andrew Rybchenko Subject: [PATCH v3] kni: fix warning about discarding const qualifier Date: Mon, 6 Jun 2022 07:22:45 +0000 Message-Id: <20220606072246.88311-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531081304.229902-1-ke1x.zhang@intel.com> References: <20220531081304.229902-1-ke1x.zhang@intel.com> 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 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 | 6 +++++- kernel/linux/kni/kni_net.c | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h index 664785674f..ef1526ef85 100644 --- a/kernel/linux/kni/compat.h +++ b/kernel/linux/kni/compat.h @@ -141,3 +141,7 @@ #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE #define HAVE_TSK_IN_GUP #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 780187d8bf..11fea961b3 100644 --- a/kernel/linux/kni/kni_misc.c +++ b/kernel/linux/kni/kni_misc.c @@ -403,10 +403,14 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num, /* if user has provided a valid mac address */ 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); +#endif else /* Generate random MAC address. */ - eth_random_addr(net_dev->dev_addr); + 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 29e5b9e21f..496ce7e4ae 100644 --- a/kernel/linux/kni/kni_net.c +++ b/kernel/linux/kni/kni_net.c @@ -779,8 +779,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); return (ret == 0 ? req.result : ret); -- 2.25.1