2023-10-13 00:40:52

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the bpf-next tree

Hi all,

After merging the bpf-next tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:

net/ipv4/af_inet.c: In function 'inet_getname':
net/ipv4/af_inet.c:791:13: warning: unused variable 'sin_addr_len' [-Wunused-variable]
791 | int sin_addr_len = sizeof(*sin);
| ^~~~~~~~~~~~

Introduced by commit

fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2023-10-13 05:31:02

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the bpf-next tree

Hi all,

On Fri, 13 Oct 2023 11:40:07 +1100 Stephen Rothwell <[email protected]> wrote:
>
> After merging the bpf-next tree, today's linux-next build (arm
> multi_v7_defconfig) produced this warning:
>
> net/ipv4/af_inet.c: In function 'inet_getname':
> net/ipv4/af_inet.c:791:13: warning: unused variable 'sin_addr_len' [-Wunused-variable]
> 791 | int sin_addr_len = sizeof(*sin);
> | ^~~~~~~~~~~~
>
> Introduced by commit
>
> fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")

This became a build failure for the i386 defconfig build, so I applied
the following patch:

From: Stephen Rothwell <[email protected]>
Date: Fri, 13 Oct 2023 16:25:08 +1100
Subject: [PATCH] fix up for "bpf: Propagate modified uaddrlen from cgroup sockaddr programs"

Signed-off-by: Stephen Rothwell <[email protected]>
---
net/ipv4/af_inet.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 7e27ad37b939..0fcab6b6cb04 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -788,7 +788,9 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
struct sock *sk = sock->sk;
struct inet_sock *inet = inet_sk(sk);
DECLARE_SOCKADDR(struct sockaddr_in *, sin, uaddr);
+#ifdef CONFIG_CGROUP_BPF
int sin_addr_len = sizeof(*sin);
+#endif

sin->sin_family = AF_INET;
lock_sock(sk);
--
2.40.1

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2023-10-13 16:55:03

by Martin KaFai Lau

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the bpf-next tree

On 10/12/23 10:30 PM, Stephen Rothwell wrote:
> Hi all,
>
> On Fri, 13 Oct 2023 11:40:07 +1100 Stephen Rothwell <[email protected]> wrote:
>>
>> After merging the bpf-next tree, today's linux-next build (arm
>> multi_v7_defconfig) produced this warning:
>>
>> net/ipv4/af_inet.c: In function 'inet_getname':
>> net/ipv4/af_inet.c:791:13: warning: unused variable 'sin_addr_len' [-Wunused-variable]
>> 791 | int sin_addr_len = sizeof(*sin);
>> | ^~~~~~~~~~~~
>>
>> Introduced by commit
>>
>> fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")
>
> This became a build failure for the i386 defconfig build, so I applied
> the following patch:
>
> From: Stephen Rothwell <[email protected]>
> Date: Fri, 13 Oct 2023 16:25:08 +1100
> Subject: [PATCH] fix up for "bpf: Propagate modified uaddrlen from cgroup sockaddr programs"
>
> Signed-off-by: Stephen Rothwell <[email protected]>
> ---
> net/ipv4/af_inet.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 7e27ad37b939..0fcab6b6cb04 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -788,7 +788,9 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
> struct sock *sk = sock->sk;
> struct inet_sock *inet = inet_sk(sk);
> DECLARE_SOCKADDR(struct sockaddr_in *, sin, uaddr);
> +#ifdef CONFIG_CGROUP_BPF
> int sin_addr_len = sizeof(*sin);
> +#endif

Thanks for the report and taking care of it.

Daan, something that was missed in ipv4 getname. It should be done similar to
inet6_getname() in af_inet6.c such that it "return sin_addr_len;" in this
function to avoid the compiler warning here in ipv4.