Skip to content

Commit cbe35ad

Browse files
author
Alexei Starovoitov
committed
Merge branch 'selftests-bpf-retire-bpf_tcp_helpers-h'
Martin KaFai Lau says: ==================== selftests/bpf: Retire bpf_tcp_helpers.h From: Martin KaFai Lau <martin.lau@kernel.org> The earlier commit 8e6d9ae ("selftests/bpf: Use bpf_tracing.h instead of bpf_tcp_helpers.h") removed the bpf_tcp_helpers.h usages from the non networking tests. This patch set is a continuation of this effort to retire the bpf_tcp_helpers.h from the networking tests (mostly tcp-cc related). The main usage of the bpf_tcp_helpers.h is the partial kernel socket definitions (e.g. sock, tcp_sock). New fields are kept adding back to those partial socket definitions while everything is available in the vmlinux.h. The recent bpf_cc_cubic.c test tried to extend bpf_tcp_helpers.c but eventually used the vmlinux.h instead. To avoid this unnecessary detour for new tests and have one consistent way of using the kernel sockets, this patch set retires the bpf_tcp_helpers.h usages and consolidates the tests to use vmlinux.h instead. ==================== Link: https://lore.kernel.org/r/20240509175026.3423614-1-martin.lau@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents 0093670 + 6a65081 commit cbe35ad

20 files changed

Lines changed: 191 additions & 426 deletions

tools/testing/selftests/bpf/bpf_tcp_helpers.h

Lines changed: 0 additions & 241 deletions
This file was deleted.

tools/testing/selftests/bpf/progs/bpf_cc_cubic.c

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
* kernel functions.
1414
*/
1515

16-
#include "vmlinux.h"
17-
16+
#include "bpf_tracing_net.h"
1817
#include <bpf/bpf_helpers.h>
1918
#include <bpf/bpf_tracing.h>
20-
#include "bpf_tracing_net.h"
21-
22-
#define BPF_STRUCT_OPS(name, args...) \
23-
SEC("struct_ops/"#name) \
24-
BPF_PROG(name, args)
2519

2620
#define USEC_PER_SEC 1000000UL
2721
#define TCP_PACING_SS_RATIO (200)
@@ -40,16 +34,6 @@ extern __u32 tcp_reno_undo_cwnd(struct sock *sk) __ksym;
4034
extern void cubictcp_acked(struct sock *sk, const struct ack_sample *sample) __ksym;
4135
extern void cubictcp_cong_avoid(struct sock *sk, __u32 ack, __u32 acked) __ksym;
4236

43-
static struct inet_connection_sock *inet_csk(const struct sock *sk)
44-
{
45-
return (struct inet_connection_sock *)sk;
46-
}
47-
48-
static struct tcp_sock *tcp_sk(const struct sock *sk)
49-
{
50-
return (struct tcp_sock *)sk;
51-
}
52-
5337
static bool before(__u32 seq1, __u32 seq2)
5438
{
5539
return (__s32)(seq1-seq2) < 0;
@@ -126,18 +110,21 @@ static bool tcp_may_raise_cwnd(const struct sock *sk, const int flag)
126110
return flag & FLAG_DATA_ACKED;
127111
}
128112

129-
void BPF_STRUCT_OPS(bpf_cubic_init, struct sock *sk)
113+
SEC("struct_ops")
114+
void BPF_PROG(bpf_cubic_init, struct sock *sk)
130115
{
131116
cubictcp_init(sk);
132117
}
133118

134-
void BPF_STRUCT_OPS(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event event)
119+
SEC("struct_ops")
120+
void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event event)
135121
{
136122
cubictcp_cwnd_event(sk, event);
137123
}
138124

139-
void BPF_STRUCT_OPS(bpf_cubic_cong_control, struct sock *sk, __u32 ack, int flag,
140-
const struct rate_sample *rs)
125+
SEC("struct_ops")
126+
void BPF_PROG(bpf_cubic_cong_control, struct sock *sk, __u32 ack, int flag,
127+
const struct rate_sample *rs)
141128
{
142129
struct tcp_sock *tp = tcp_sk(sk);
143130

@@ -163,23 +150,26 @@ void BPF_STRUCT_OPS(bpf_cubic_cong_control, struct sock *sk, __u32 ack, int flag
163150
tcp_update_pacing_rate(sk);
164151
}
165152

166-
__u32 BPF_STRUCT_OPS(bpf_cubic_recalc_ssthresh, struct sock *sk)
153+
SEC("struct_ops")
154+
__u32 BPF_PROG(bpf_cubic_recalc_ssthresh, struct sock *sk)
167155
{
168156
return cubictcp_recalc_ssthresh(sk);
169157
}
170158

171-
void BPF_STRUCT_OPS(bpf_cubic_state, struct sock *sk, __u8 new_state)
159+
SEC("struct_ops")
160+
void BPF_PROG(bpf_cubic_state, struct sock *sk, __u8 new_state)
172161
{
173162
cubictcp_state(sk, new_state);
174163
}
175164

176-
void BPF_STRUCT_OPS(bpf_cubic_acked, struct sock *sk,
177-
const struct ack_sample *sample)
165+
SEC("struct_ops")
166+
void BPF_PROG(bpf_cubic_acked, struct sock *sk, const struct ack_sample *sample)
178167
{
179168
cubictcp_acked(sk, sample);
180169
}
181170

182-
__u32 BPF_STRUCT_OPS(bpf_cubic_undo_cwnd, struct sock *sk)
171+
SEC("struct_ops")
172+
__u32 BPF_PROG(bpf_cubic_undo_cwnd, struct sock *sk)
183173
{
184174
return tcp_reno_undo_cwnd(sk);
185175
}

0 commit comments

Comments
 (0)