Skip to contentSkip to conversation

bpf: Define struct bpf_tcp_req_attrs when CONFIG_SYN_COOKIES=n.

PATCH Applied Kuniyuki Iwashima 2 participants 2 messages Jan 18, 2024 – Jan 23, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Define struct bpf_tcp_req_attrs when CONFIG_SYN_COOKIES=n.

kernel test robot reported the warning below:

Quoted 1 line
Quoted 1 line

net/core/filter.c:11842:13: warning: declaration of 'struct bpf_tcp_req_attrs' will not be visible outside of this function [-Wvisibility]

11842 | struct bpf_tcp_req_attrs *attrs, int attrs__sz)
| ^
1 warning generated.

struct bpf_tcp_req_attrs is defined under CONFIG_SYN_COOKIES but used in kfunc without the config.

Let's move struct bpf_tcp_req_attrs definition outside of CONFIG_SYN_COOKIES guard.

Fixes b9c3eca5c086 ("bpf: tcp: Support arbitrary SYN Cookie.")
---
 include/net/tcp.h | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)
include/net/tcp.h +16 -14
index 451dc1373970..58e65af74ad1 100644
@@ -498,6 +498,22 @@ struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
 					    struct tcp_options_received *tcp_opt,
 					    int mss, u32 tsoff);
 
+#if IS_ENABLED(CONFIG_BPF)
+struct bpf_tcp_req_attrs {
+	u32 rcv_tsval;
+	u32 rcv_tsecr;
+	u16 mss;
+	u8 rcv_wscale;
+	u8 snd_wscale;
+	u8 ecn_ok;
+	u8 wscale_ok;
+	u8 sack_ok;
+	u8 tstamp_ok;
+	u8 usec_ts_ok;
+	u8 reserved[3];
+};
+#endif
+
 #ifdef CONFIG_SYN_COOKIES
 
 /* Syncookies use a monotonic timer which increments every 60 seconds.
@@ -600,20 +616,6 @@ static inline bool cookie_ecn_ok(const struct net *net, const struct dst_entry *
 }
 
 #if IS_ENABLED(CONFIG_BPF)
-struct bpf_tcp_req_attrs {
-	u32 rcv_tsval;
-	u32 rcv_tsecr;
-	u16 mss;
-	u8 rcv_wscale;
-	u8 snd_wscale;
-	u8 ecn_ok;
-	u8 wscale_ok;
-	u8 sack_ok;
-	u8 tstamp_ok;
-	u8 usec_ts_ok;
-	u8 reserved[3];
-};
-
 static inline bool cookie_bpf_ok(struct sk_buff *skb)
 {
 	return skb->sk;
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

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

Quoted 8 lines · On Thu, 18 Jan 2024 13:17:51 -0800 you wrote:

kernel test robot reported the warning below:

Quoted 1 line
Quoted 1 line

net/core/filter.c:11842:13: warning: declaration of 'struct bpf_tcp_req_attrs' will not be visible outside of this function [-Wvisibility]

11842 | struct bpf_tcp_req_attrs *attrs, int attrs__sz)
| ^
1 warning generated.

[...]

Here is the summary with links:
- [v1,bpf-next] bpf: Define struct bpf_tcp_req_attrs when CONFIG_SYN_COOKIES=n.

    https://git.kernel.org/bpf/bpf-next/c/b3f086a7a136

You are awesome, thank you!

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