Skip to contentSkip to conversation

net/bpf: Avoid unused "sin_addr_len" warning when CONFIG_CGROUP_BPF is not set

PATCH Applied Martin KaFai Lau 3 participants 3 messages Oct 13, 2023

Subsystems (3)
lore
Share & tools
lore

Martin KaFai Lau

author reviewer
#0 lore raw

PATCH 1/1 net/bpf: Avoid unused "sin_addr_len" warning when CONFIG_CGROUP_BPF is not set

From: Martin KaFai Lau <[email protected]>

It was reported that there is a compiler warning on the unused variable "sin_addr_len" in af_inet.c when CONFIG_CGROUP_BPF is not set. This patch is to address it similar to the ipv6 counterpart in inet6_getname(). It is to "return sin_addr_len;"
instead of "return sizeof(*sin);".

Cc Daan De Meyer <[email protected]>
Fixes fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")
---
 net/ipv4/af_inet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/af_inet.c +1 -1
index 7e27ad37b939..5ce275b2d7ef 100644
@@ -814,7 +814,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
 	}
 	release_sock(sk);
 	memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
-	return sizeof(*sin);
+	return sin_addr_len;
 }
 EXPORT_SYMBOL(inet_getname);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

From: Martin KaFai Lau <[email protected]>
Date: Fri, 13 Oct 2023 11:57:02 -0700

Quoted 8 lines

From: Martin KaFai Lau <[email protected]>

It was reported that there is a compiler warning on the unused variable "sin_addr_len" in af_inet.c when CONFIG_CGROUP_BPF is not set. This patch is to address it similar to the ipv6 counterpart in inet6_getname(). It is to "return sin_addr_len;"
instead of "return sizeof(*sin);".

Quoted 5 lines
Cc Daan De Meyer <[email protected]>
Fixes fefba7d1ae19 ("bpf: Propagate modified uaddrlen from cgroup sockaddr programs")

Thanks!

Quoted 19 lines
---
 net/ipv4/af_inet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/af_inet.c +1 -1
index 7e27ad37b939..5ce275b2d7ef 100644
@@ -814,7 +814,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
 	}
 	release_sock(sk);
 	memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
-	return sizeof(*sin);
+	return sin_addr_len;
 }
 EXPORT_SYMBOL(inet_getname);
 
Signature · 1 line
2.34.1
#2 lore raw
In reply to Martin KaFai Lau
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 9 lines · On Fri, 13 Oct 2023 11:57:02 -0700 you wrote:

From: Martin KaFai Lau <[email protected]>

It was reported that there is a compiler warning on the unused variable "sin_addr_len" in af_inet.c when CONFIG_CGROUP_BPF is not set. This patch is to address it similar to the ipv6 counterpart in inet6_getname(). It is to "return sin_addr_len;"
instead of "return sizeof(*sin);".

[...]

Here is the summary with links:
- [bpf-next] net/bpf: Avoid unused "sin_addr_len" warning when CONFIG_CGROUP_BPF is not set

    https://git.kernel.org/bpf/bpf-next/c/9c1292eca243

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html