Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Martin KaFai Lau and committed by
Alexei Starovoitov
b1d87ae9 7d3851a3

+18 -18
+10 -10
tools/testing/selftests/bpf/progs/bpf_cubic.c
··· 70 70 / (bic_scale * 10); 71 71 72 72 /* BIC TCP Parameters */ 73 - struct bictcp { 73 + struct bpf_bictcp { 74 74 __u32 cnt; /* increase cwnd by 1 after ACKs */ 75 75 __u32 last_max_cwnd; /* last maximum snd_cwnd */ 76 76 __u32 last_cwnd; /* the last snd_cwnd */ ··· 91 91 __u32 curr_rtt; /* the minimum rtt of current round */ 92 92 }; 93 93 94 - static void bictcp_reset(struct bictcp *ca) 94 + static void bictcp_reset(struct bpf_bictcp *ca) 95 95 { 96 96 ca->cnt = 0; 97 97 ca->last_max_cwnd = 0; ··· 161 161 static void bictcp_hystart_reset(struct sock *sk) 162 162 { 163 163 struct tcp_sock *tp = tcp_sk(sk); 164 - struct bictcp *ca = inet_csk_ca(sk); 164 + struct bpf_bictcp *ca = inet_csk_ca(sk); 165 165 166 166 ca->round_start = ca->last_ack = bictcp_clock_us(sk); 167 167 ca->end_seq = tp->snd_nxt; ··· 172 172 SEC("struct_ops") 173 173 void BPF_PROG(bpf_cubic_init, struct sock *sk) 174 174 { 175 - struct bictcp *ca = inet_csk_ca(sk); 175 + struct bpf_bictcp *ca = inet_csk_ca(sk); 176 176 177 177 bictcp_reset(ca); 178 178 ··· 187 187 void BPF_PROG(bpf_cubic_cwnd_event, struct sock *sk, enum tcp_ca_event event) 188 188 { 189 189 if (event == CA_EVENT_TX_START) { 190 - struct bictcp *ca = inet_csk_ca(sk); 190 + struct bpf_bictcp *ca = inet_csk_ca(sk); 191 191 __u32 now = tcp_jiffies32; 192 192 __s32 delta; 193 193 ··· 261 261 /* 262 262 * Compute congestion window to use. 263 263 */ 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) 265 265 { 266 266 __u32 delta, bic_target, max_cnt; 267 267 __u64 offs, t; ··· 378 378 void BPF_PROG(bpf_cubic_cong_avoid, struct sock *sk, __u32 ack, __u32 acked) 379 379 { 380 380 struct tcp_sock *tp = tcp_sk(sk); 381 - struct bictcp *ca = inet_csk_ca(sk); 381 + struct bpf_bictcp *ca = inet_csk_ca(sk); 382 382 383 383 if (!tcp_is_cwnd_limited(sk)) 384 384 return; ··· 398 398 __u32 BPF_PROG(bpf_cubic_recalc_ssthresh, struct sock *sk) 399 399 { 400 400 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); 402 402 403 403 ca->epoch_start = 0; /* end of epoch */ 404 404 ··· 446 446 static void hystart_update(struct sock *sk, __u32 delay) 447 447 { 448 448 struct tcp_sock *tp = tcp_sk(sk); 449 - struct bictcp *ca = inet_csk_ca(sk); 449 + struct bpf_bictcp *ca = inet_csk_ca(sk); 450 450 __u32 threshold; 451 451 452 452 if (hystart_detect & HYSTART_ACK_TRAIN) { ··· 495 495 void BPF_PROG(bpf_cubic_acked, struct sock *sk, const struct ack_sample *sample) 496 496 { 497 497 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); 499 499 __u32 delay; 500 500 501 501 bpf_cubic_acked_called = 1;
+8 -8
tools/testing/selftests/bpf/progs/bpf_dctcp.c
··· 35 35 36 36 #define DCTCP_MAX_ALPHA 1024U 37 37 38 - struct dctcp { 38 + struct bpf_dctcp { 39 39 __u32 old_delivered; 40 40 __u32 old_delivered_ce; 41 41 __u32 prior_rcv_nxt; ··· 48 48 static unsigned int dctcp_shift_g = 4; /* g = 1/2^4 */ 49 49 static unsigned int dctcp_alpha_on_init = DCTCP_MAX_ALPHA; 50 50 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) 52 52 { 53 53 ca->next_seq = tp->snd_nxt; 54 54 ··· 60 60 void BPF_PROG(dctcp_init, struct sock *sk) 61 61 { 62 62 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); 64 64 int *stg; 65 65 66 66 if (!(tp->ecn_flags & TCP_ECN_OK) && fallback[0]) { ··· 106 106 SEC("struct_ops") 107 107 __u32 BPF_PROG(dctcp_ssthresh, struct sock *sk) 108 108 { 109 - struct dctcp *ca = inet_csk_ca(sk); 109 + struct bpf_dctcp *ca = inet_csk_ca(sk); 110 110 struct tcp_sock *tp = tcp_sk(sk); 111 111 112 112 ca->loss_cwnd = tp->snd_cwnd; ··· 117 117 void BPF_PROG(dctcp_update_alpha, struct sock *sk, __u32 flags) 118 118 { 119 119 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); 121 121 122 122 /* Expired RTT */ 123 123 if (!before(tp->snd_una, ca->next_seq)) { ··· 145 145 146 146 static void dctcp_react_to_loss(struct sock *sk) 147 147 { 148 - struct dctcp *ca = inet_csk_ca(sk); 148 + struct bpf_dctcp *ca = inet_csk_ca(sk); 149 149 struct tcp_sock *tp = tcp_sk(sk); 150 150 151 151 ca->loss_cwnd = tp->snd_cwnd; ··· 202 202 SEC("struct_ops") 203 203 void BPF_PROG(dctcp_cwnd_event, struct sock *sk, enum tcp_ca_event ev) 204 204 { 205 - struct dctcp *ca = inet_csk_ca(sk); 205 + struct bpf_dctcp *ca = inet_csk_ca(sk); 206 206 207 207 switch (ev) { 208 208 case CA_EVENT_ECN_IS_CE: ··· 221 221 SEC("struct_ops") 222 222 __u32 BPF_PROG(dctcp_cwnd_undo, struct sock *sk) 223 223 { 224 - const struct dctcp *ca = inet_csk_ca(sk); 224 + const struct bpf_dctcp *ca = inet_csk_ca(sk); 225 225 226 226 return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd); 227 227 }