Skip to content

Commit b1d87ae

Browse files
Martin KaFai LauAlexei Starovoitov
authored andcommitted
selftests/bpf: Rename tcp-cc private struct in bpf_cubic and bpf_dctcp
The "struct bictcp" and "struct dctcp" are private to the bpf prog and they are stored in the private buffer in inet_csk(sk)->icsk_ca_priv. Hence, there is no bpf CO-RE required. The same struct name exists in the vmlinux.h. To reuse vmlinux.h, they need to be renamed such that the bpf prog logic will be immuned from the kernel tcp-cc changes. This patch adds a "bpf_" prefix to them. Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20240509175026.3423614-6-martin.lau@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 7d3851a commit b1d87ae

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static const __u64 cube_factor = (__u64)(1ull << (10+3*BICTCP_HZ))
7070
/ (bic_scale * 10);
7171

7272
/* BIC TCP Parameters */
73-
struct bictcp {
73+
struct bpf_bictcp {
7474
__u32 cnt; /* increase cwnd by 1 after ACKs */
7575
__u32 last_max_cwnd; /* last maximum snd_cwnd */
7676
__u32 last_cwnd; /* the last snd_cwnd */
@@ -91,7 +91,7 @@ struct bictcp {
9191
__u32 curr_rtt; /* the minimum rtt of current round */
9292
};
9393

94-
static void bictcp_reset(struct bictcp *ca)
94+
static void bictcp_reset(struct bpf_bictcp *ca)
9595
{
9696
ca->cnt = 0;
9797
ca->last_max_cwnd = 0;
@@ -161,7 +161,7 @@ static __u32 bictcp_clock_us(const struct sock *sk)
161161
static void bictcp_hystart_reset(struct sock *sk)
162162
{
163163
struct tcp_sock *tp = tcp_sk(sk);
164-
struct bictcp *ca = inet_csk_ca(sk);
164+
struct bpf_bictcp *ca = inet_csk_ca(sk);
165165

166166
ca->round_start = ca->last_ack = bictcp_clock_us(sk);
167167
ca->end_seq = tp->snd_nxt;
@@ -172,7 +172,7 @@ static void bictcp_hystart_reset(struct sock *sk)
172172
SEC("struct_ops")
173173
void BPF_PROG(bpf_cubic_init, struct sock *sk)
174174
{
175-
struct bictcp *ca = inet_csk_ca(sk);
175+
struct bpf_bictcp *ca = inet_csk_ca(sk);
176176

177177
bictcp_reset(ca);
178178

@@ -187,7 +187,7 @@ SEC("struct_ops")
187187
void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event event)
188188
{
189189
if (event == CA_EVENT_TX_START) {
190-
struct bictcp *ca = inet_csk_ca(sk);
190+
struct bpf_bictcp *ca = inet_csk_ca(sk);
191191
__u32 now = tcp_jiffies32;
192192
__s32 delta;
193193

@@ -261,7 +261,7 @@ static __u32 cubic_root(__u64 a)
261261
/*
262262
* Compute congestion window to use.
263263
*/
264-
static void bictcp_update(struct bictcp *ca, __u32 cwnd, __u32 acked)
264+
static void bictcp_update(struct bpf_bictcp *ca, __u32 cwnd, __u32 acked)
265265
{
266266
__u32 delta, bic_target, max_cnt;
267267
__u64 offs, t;
@@ -378,7 +378,7 @@ SEC("struct_ops")
378378
void BPF_PROG(bpf_cubic_cong_avoid, struct sock *sk, __u32 ack, __u32 acked)
379379
{
380380
struct tcp_sock *tp = tcp_sk(sk);
381-
struct bictcp *ca = inet_csk_ca(sk);
381+
struct bpf_bictcp *ca = inet_csk_ca(sk);
382382

383383
if (!tcp_is_cwnd_limited(sk))
384384
return;
@@ -398,7 +398,7 @@ SEC("struct_ops")
398398
__u32 BPF_PROG(bpf_cubic_recalc_ssthresh, struct sock *sk)
399399
{
400400
const struct tcp_sock *tp = tcp_sk(sk);
401-
struct bictcp *ca = inet_csk_ca(sk);
401+
struct bpf_bictcp *ca = inet_csk_ca(sk);
402402

403403
ca->epoch_start = 0; /* end of epoch */
404404

@@ -446,7 +446,7 @@ static __u32 hystart_ack_delay(struct sock *sk)
446446
static void hystart_update(struct sock *sk, __u32 delay)
447447
{
448448
struct tcp_sock *tp = tcp_sk(sk);
449-
struct bictcp *ca = inet_csk_ca(sk);
449+
struct bpf_bictcp *ca = inet_csk_ca(sk);
450450
__u32 threshold;
451451

452452
if (hystart_detect & HYSTART_ACK_TRAIN) {
@@ -495,7 +495,7 @@ SEC("struct_ops")
495495
void BPF_PROG(bpf_cubic_acked, struct sock *sk, const struct ack_sample *sample)
496496
{
497497
const struct tcp_sock *tp = tcp_sk(sk);
498-
struct bictcp *ca = inet_csk_ca(sk);
498+
struct bpf_bictcp *ca = inet_csk_ca(sk);
499499
__u32 delay;
500500

501501
bpf_cubic_acked_called = 1;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct {
3535

3636
#define DCTCP_MAX_ALPHA 1024U
3737

38-
struct dctcp {
38+
struct bpf_dctcp {
3939
__u32 old_delivered;
4040
__u32 old_delivered_ce;
4141
__u32 prior_rcv_nxt;
@@ -48,7 +48,7 @@ struct dctcp {
4848
static unsigned int dctcp_shift_g = 4; /* g = 1/2^4 */
4949
static unsigned int dctcp_alpha_on_init = DCTCP_MAX_ALPHA;
5050

51-
static void dctcp_reset(const struct tcp_sock *tp, struct dctcp *ca)
51+
static void dctcp_reset(const struct tcp_sock *tp, struct bpf_dctcp *ca)
5252
{
5353
ca->next_seq = tp->snd_nxt;
5454

@@ -60,7 +60,7 @@ SEC("struct_ops")
6060
void BPF_PROG(dctcp_init, struct sock *sk)
6161
{
6262
const struct tcp_sock *tp = tcp_sk(sk);
63-
struct dctcp *ca = inet_csk_ca(sk);
63+
struct bpf_dctcp *ca = inet_csk_ca(sk);
6464
int *stg;
6565

6666
if (!(tp->ecn_flags & TCP_ECN_OK) && fallback[0]) {
@@ -106,7 +106,7 @@ void BPF_PROG(dctcp_init, struct sock *sk)
106106
SEC("struct_ops")
107107
__u32 BPF_PROG(dctcp_ssthresh, struct sock *sk)
108108
{
109-
struct dctcp *ca = inet_csk_ca(sk);
109+
struct bpf_dctcp *ca = inet_csk_ca(sk);
110110
struct tcp_sock *tp = tcp_sk(sk);
111111

112112
ca->loss_cwnd = tp->snd_cwnd;
@@ -117,7 +117,7 @@ SEC("struct_ops")
117117
void BPF_PROG(dctcp_update_alpha, struct sock *sk, __u32 flags)
118118
{
119119
const struct tcp_sock *tp = tcp_sk(sk);
120-
struct dctcp *ca = inet_csk_ca(sk);
120+
struct bpf_dctcp *ca = inet_csk_ca(sk);
121121

122122
/* Expired RTT */
123123
if (!before(tp->snd_una, ca->next_seq)) {
@@ -145,7 +145,7 @@ void BPF_PROG(dctcp_update_alpha, struct sock *sk, __u32 flags)
145145

146146
static void dctcp_react_to_loss(struct sock *sk)
147147
{
148-
struct dctcp *ca = inet_csk_ca(sk);
148+
struct bpf_dctcp *ca = inet_csk_ca(sk);
149149
struct tcp_sock *tp = tcp_sk(sk);
150150

151151
ca->loss_cwnd = tp->snd_cwnd;
@@ -202,7 +202,7 @@ static void dctcp_ece_ack_update(struct sock *sk, enum tcp_ca_event evt,
202202
SEC("struct_ops")
203203
void BPF_PROG(dctcp_cwnd_event, struct sock *sk, enum tcp_ca_event ev)
204204
{
205-
struct dctcp *ca = inet_csk_ca(sk);
205+
struct bpf_dctcp *ca = inet_csk_ca(sk);
206206

207207
switch (ev) {
208208
case CA_EVENT_ECN_IS_CE:
@@ -221,7 +221,7 @@ void BPF_PROG(dctcp_cwnd_event, struct sock *sk, enum tcp_ca_event ev)
221221
SEC("struct_ops")
222222
__u32 BPF_PROG(dctcp_cwnd_undo, struct sock *sk)
223223
{
224-
const struct dctcp *ca = inet_csk_ca(sk);
224+
const struct bpf_dctcp *ca = inet_csk_ca(sk);
225225

226226
return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
227227
}

0 commit comments

Comments
 (0)