[stable-22.11] kni: fix build with Linux 6.8

Message ID 20240312084914.92056-1-jslaby@suse.cz (mailing list archive)
State Not Applicable, archived
Delegated to: Thomas Monjalon
Headers
Series [stable-22.11] kni: fix build with Linux 6.8 |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation warning apply patch failure
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Jiri Slaby March 12, 2024, 8:49 a.m. UTC
  strlcpy() was removed in commit d26270061ae6 (string: Remove strlcpy()), use
strscpy() instead.

The patches fixes this:
kernel/linux/kni/kni_net.c: In function ‘kni_get_drvinfo’:
kernel/linux/kni/kni_net.c:835:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’?

Intended esp. for stable/22.11. It should go wherever kni is still in
the tree.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/linux/kni/kni_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

David Marchand March 12, 2024, 8:59 a.m. UTC | #1
Hello Jiri,

On Tue, Mar 12, 2024 at 9:57 AM Jiri Slaby <jslaby@suse.cz> wrote:
>
> strlcpy() was removed in commit d26270061ae6 (string: Remove strlcpy()), use
> strscpy() instead.
>
> The patches fixes this:
> kernel/linux/kni/kni_net.c: In function ‘kni_get_drvinfo’:
> kernel/linux/kni/kni_net.c:835:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’?
>
> Intended esp. for stable/22.11. It should go wherever kni is still in
> the tree.

Thanks for the patch.

Cc: stable and LTS maintainers.

>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  
Kevin Traynor March 12, 2024, 10:26 a.m. UTC | #2
On 12/03/2024 08:59, David Marchand wrote:
> Hello Jiri,
> 
> On Tue, Mar 12, 2024 at 9:57 AM Jiri Slaby <jslaby@suse.cz> wrote:
>>
>> strlcpy() was removed in commit d26270061ae6 (string: Remove strlcpy()), use
>> strscpy() instead.
>>
>> The patches fixes this:
>> kernel/linux/kni/kni_net.c: In function ‘kni_get_drvinfo’:
>> kernel/linux/kni/kni_net.c:835:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’?
>>
>> Intended esp. for stable/22.11. It should go wherever kni is still in
>> the tree.
> 
> Thanks for the patch.
> 
> Cc: stable and LTS maintainers.
> 
>>
>> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> 
> 

Thanks Jiri and David. I will take this for 21.11 LTS also.
  
Jiri Slaby March 12, 2024, 10:40 a.m. UTC | #3
On 12. 03. 24, 11:26, Kevin Traynor wrote:
> On 12/03/2024 08:59, David Marchand wrote:
>> Hello Jiri,
>>
>> On Tue, Mar 12, 2024 at 9:57 AM Jiri Slaby <jslaby@suse.cz> wrote:
>>>
>>> strlcpy() was removed in commit d26270061ae6 (string: Remove strlcpy()), use
>>> strscpy() instead.
>>>
>>> The patches fixes this:
>>> kernel/linux/kni/kni_net.c: In function ‘kni_get_drvinfo’:
>>> kernel/linux/kni/kni_net.c:835:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’?
>>>
>>> Intended esp. for stable/22.11. It should go wherever kni is still in
>>> the tree.
>>
>> Thanks for the patch.
>>
>> Cc: stable and LTS maintainers.
>>
>>>
>>> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
>>
>>
> 
> Thanks Jiri and David. I will take this for 21.11 LTS also.

Just heads up: I've just realized, that strscpy() was introduces only in

commit 30035e45753b708e7d47a98398500ca005e02b86
Author: Chris Metcalf <cmetcalf@ezchip.com>
Date:   Wed Apr 29 12:52:04 2015 -0400

     string: provide strscpy()

in v4.3. If you support older kernels, the patch needs modifications. 
Like some #if's depending on the kernel version or some HAVE_STRSCPY 
defines.

thanks,
  
Kevin Traynor March 12, 2024, 11:20 a.m. UTC | #4
On 12/03/2024 10:40, Jiri Slaby wrote:
> On 12. 03. 24, 11:26, Kevin Traynor wrote:
>> On 12/03/2024 08:59, David Marchand wrote:
>>> Hello Jiri,
>>>
>>> On Tue, Mar 12, 2024 at 9:57 AM Jiri Slaby <jslaby@suse.cz> wrote:
>>>>
>>>> strlcpy() was removed in commit d26270061ae6 (string: Remove strlcpy()), use
>>>> strscpy() instead.
>>>>
>>>> The patches fixes this:
>>>> kernel/linux/kni/kni_net.c: In function ‘kni_get_drvinfo’:
>>>> kernel/linux/kni/kni_net.c:835:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strscpy’?
>>>>
>>>> Intended esp. for stable/22.11. It should go wherever kni is still in
>>>> the tree.
>>>
>>> Thanks for the patch.
>>>
>>> Cc: stable and LTS maintainers.
>>>
>>>>
>>>> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
>>>
>>>
>>
>> Thanks Jiri and David. I will take this for 21.11 LTS also.
> 
> Just heads up: I've just realized, that strscpy() was introduces only in
> 
> commit 30035e45753b708e7d47a98398500ca005e02b86
> Author: Chris Metcalf <cmetcalf@ezchip.com>
> Date:   Wed Apr 29 12:52:04 2015 -0400
> 
>      string: provide strscpy()
> 
> in v4.3. If you support older kernels, the patch needs modifications. 
> Like some #if's depending on the kernel version or some HAVE_STRSCPY 
> defines.
> 
> thanks,

ok, thanks for letting us know. We should be fine for supported kernels
from kernel.org but it will probably an issue for Centos7 with older
DPDK LTS, though it is EoL very shortly.
  

Patch

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 779ee345..c115a728 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -832,8 +832,8 @@  static const struct net_device_ops kni_net_netdev_ops = {
 static void kni_get_drvinfo(struct net_device *dev,
 			    struct ethtool_drvinfo *info)
 {
-	strlcpy(info->version, KNI_VERSION, sizeof(info->version));
-	strlcpy(info->driver, "kni", sizeof(info->driver));
+	strscpy(info->version, KNI_VERSION, sizeof(info->version));
+	strscpy(info->driver, "kni", sizeof(info->driver));
 }
 
 static const struct ethtool_ops kni_net_ethtool_ops = {