xref: /linux/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c (revision 5a8cd539ac19f7a68e68e1d25ef9ca2ff55b8500)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 
4 #include <linux/err.h>
5 #include <netinet/tcp.h>
6 #include <test_progs.h>
7 #include "network_helpers.h"
8 #include "bpf_dctcp.skel.h"
9 #include "bpf_cubic.skel.h"
10 #include "bpf_tcp_nogpl.skel.h"
11 #include "tcp_ca_update.skel.h"
12 #include "bpf_dctcp_release.skel.h"
13 #include "tcp_ca_write_sk_pacing.skel.h"
14 #include "tcp_ca_incompl_cong_ops.skel.h"
15 #include "tcp_ca_unsupp_cong_op.skel.h"
16 #include "tcp_ca_kfunc.skel.h"
17 #include "tcp_ca_untrusted_btf_write.skel.h"
18 #include "bpf_cc_cubic.skel.h"
19 
20 static const unsigned int total_bytes = 10 * 1024 * 1024;
21 static int expected_stg = 0xeB9F;
22 
23 struct cb_opts {
24 	const char *cc;
25 	int map_fd;
26 };
27 
settcpca(int fd,const char * tcp_ca)28 static int settcpca(int fd, const char *tcp_ca)
29 {
30 	int err;
31 
32 	err = setsockopt(fd, IPPROTO_TCP, TCP_CONGESTION, tcp_ca, strlen(tcp_ca));
33 	if (!ASSERT_NEQ(err, -1, "setsockopt"))
34 		return -1;
35 
36 	return 0;
37 }
38 
start_test(char * addr_str,const struct network_helper_opts * srv_opts,const struct network_helper_opts * cli_opts,int * srv_fd,int * cli_fd)39 static bool start_test(char *addr_str,
40 		       const struct network_helper_opts *srv_opts,
41 		       const struct network_helper_opts *cli_opts,
42 		       int *srv_fd, int *cli_fd)
43 {
44 	*srv_fd = start_server_str(AF_INET6, SOCK_STREAM, addr_str, 0, srv_opts);
45 	if (!ASSERT_NEQ(*srv_fd, -1, "start_server_str"))
46 		goto err;
47 
48 	/* connect to server */
49 	*cli_fd = connect_to_fd_opts(*srv_fd, cli_opts);
50 	if (!ASSERT_NEQ(*cli_fd, -1, "connect_to_fd_opts"))
51 		goto err;
52 
53 	return true;
54 
55 err:
56 	if (*srv_fd != -1) {
57 		close(*srv_fd);
58 		*srv_fd = -1;
59 	}
60 	if (*cli_fd != -1) {
61 		close(*cli_fd);
62 		*cli_fd = -1;
63 	}
64 	return false;
65 }
66 
do_test(const struct network_helper_opts * opts)67 static void do_test(const struct network_helper_opts *opts)
68 {
69 	int lfd = -1, fd = -1;
70 
71 	if (!start_test(NULL, opts, opts, &lfd, &fd))
72 		goto done;
73 
74 	ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data");
75 
76 done:
77 	if (lfd != -1)
78 		close(lfd);
79 	if (fd != -1)
80 		close(fd);
81 }
82 
cc_cb(int fd,void * opts)83 static int cc_cb(int fd, void *opts)
84 {
85 	struct cb_opts *cb_opts = (struct cb_opts *)opts;
86 
87 	return settcpca(fd, cb_opts->cc);
88 }
89 
test_cubic(void)90 static void test_cubic(void)
91 {
92 	struct cb_opts cb_opts = {
93 		.cc = "bpf_cubic",
94 	};
95 	struct network_helper_opts opts = {
96 		.post_socket_cb	= cc_cb,
97 		.cb_opts	= &cb_opts,
98 	};
99 	struct bpf_cubic *cubic_skel;
100 	struct bpf_link *link;
101 
102 	cubic_skel = bpf_cubic__open_and_load();
103 	if (!ASSERT_OK_PTR(cubic_skel, "bpf_cubic__open_and_load"))
104 		return;
105 
106 	link = bpf_map__attach_struct_ops(cubic_skel->maps.cubic);
107 	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
108 		bpf_cubic__destroy(cubic_skel);
109 		return;
110 	}
111 
112 	do_test(&opts);
113 
114 	ASSERT_EQ(cubic_skel->bss->bpf_cubic_acked_called, 1, "pkts_acked called");
115 
116 	ASSERT_TRUE(cubic_skel->bss->nodelay_init_reject, "init reject nodelay option");
117 	ASSERT_TRUE(cubic_skel->bss->nodelay_cwnd_event_tx_start_reject,
118 		    "cwnd_event_tx_start reject nodelay option");
119 
120 	bpf_link__destroy(link);
121 	bpf_cubic__destroy(cubic_skel);
122 }
123 
stg_post_socket_cb(int fd,void * opts)124 static int stg_post_socket_cb(int fd, void *opts)
125 {
126 	struct cb_opts *cb_opts = (struct cb_opts *)opts;
127 	int err;
128 
129 	err = settcpca(fd, cb_opts->cc);
130 	if (err)
131 		return err;
132 
133 	err = bpf_map_update_elem(cb_opts->map_fd, &fd,
134 				  &expected_stg, BPF_NOEXIST);
135 	if (!ASSERT_OK(err, "bpf_map_update_elem(sk_stg_map)"))
136 		return err;
137 
138 	return 0;
139 }
140 
test_dctcp(void)141 static void test_dctcp(void)
142 {
143 	struct cb_opts cb_opts = {
144 		.cc = "bpf_dctcp",
145 	};
146 	struct network_helper_opts opts = {
147 		.post_socket_cb	= cc_cb,
148 		.cb_opts	= &cb_opts,
149 	};
150 	struct network_helper_opts cli_opts = {
151 		.post_socket_cb	= stg_post_socket_cb,
152 		.cb_opts	= &cb_opts,
153 	};
154 	int lfd = -1, fd = -1, tmp_stg, err;
155 	struct bpf_dctcp *dctcp_skel;
156 	struct bpf_link *link;
157 
158 	dctcp_skel = bpf_dctcp__open_and_load();
159 	if (!ASSERT_OK_PTR(dctcp_skel, "bpf_dctcp__open_and_load"))
160 		return;
161 
162 	link = bpf_map__attach_struct_ops(dctcp_skel->maps.dctcp);
163 	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
164 		bpf_dctcp__destroy(dctcp_skel);
165 		return;
166 	}
167 
168 	cb_opts.map_fd = bpf_map__fd(dctcp_skel->maps.sk_stg_map);
169 	if (!start_test(NULL, &opts, &cli_opts, &lfd, &fd))
170 		goto done;
171 
172 	err = bpf_map_lookup_elem(cb_opts.map_fd, &fd, &tmp_stg);
173 	if (!ASSERT_ERR(err, "bpf_map_lookup_elem(sk_stg_map)") ||
174 			!ASSERT_EQ(errno, ENOENT, "bpf_map_lookup_elem(sk_stg_map)"))
175 		goto done;
176 
177 	ASSERT_OK(send_recv_data(lfd, fd, total_bytes), "send_recv_data");
178 	ASSERT_EQ(dctcp_skel->bss->stg_result, expected_stg, "stg_result");
179 
180 done:
181 	bpf_link__destroy(link);
182 	bpf_dctcp__destroy(dctcp_skel);
183 	if (lfd != -1)
184 		close(lfd);
185 	if (fd != -1)
186 		close(fd);
187 }
188 
test_dctcp_autoattach_map(void)189 static void test_dctcp_autoattach_map(void)
190 {
191 	struct cb_opts cb_opts = {
192 		.cc = "bpf_dctcp",
193 	};
194 	struct network_helper_opts opts = {
195 		.post_socket_cb	= cc_cb,
196 		.cb_opts	= &cb_opts,
197 	};
198 	struct bpf_dctcp *dctcp_skel;
199 	struct bpf_link *link;
200 
201 	dctcp_skel = bpf_dctcp__open_and_load();
202 	if (!ASSERT_OK_PTR(dctcp_skel, "bpf_dctcp__open_and_load"))
203 		return;
204 
205 	bpf_map__set_autoattach(dctcp_skel->maps.dctcp, true);
206 	bpf_map__set_autoattach(dctcp_skel->maps.dctcp_nouse, false);
207 
208 	if (!ASSERT_OK(bpf_dctcp__attach(dctcp_skel), "bpf_dctcp__attach"))
209 		goto destroy;
210 
211 	/* struct_ops is auto-attached  */
212 	link = dctcp_skel->links.dctcp;
213 	if (!ASSERT_OK_PTR(link, "link"))
214 		goto destroy;
215 
216 	do_test(&opts);
217 
218 destroy:
219 	bpf_dctcp__destroy(dctcp_skel);
220 }
221 
222 static char *err_str;
223 static bool found;
224 
libbpf_debug_print(enum libbpf_print_level level,const char * format,va_list args)225 static int libbpf_debug_print(enum libbpf_print_level level,
226 			      const char *format, va_list args)
227 {
228 	const char *prog_name, *log_buf;
229 
230 	if (level != LIBBPF_WARN ||
231 	    !strstr(format, "-- BEGIN PROG LOAD LOG --")) {
232 		vprintf(format, args);
233 		return 0;
234 	}
235 
236 	prog_name = va_arg(args, char *);
237 	log_buf = va_arg(args, char *);
238 	if (!log_buf)
239 		goto out;
240 	if (err_str && strstr(log_buf, err_str) != NULL)
241 		found = true;
242 out:
243 	printf(format, prog_name, log_buf);
244 	return 0;
245 }
246 
test_invalid_license(void)247 static void test_invalid_license(void)
248 {
249 	libbpf_print_fn_t old_print_fn;
250 	struct bpf_tcp_nogpl *skel;
251 
252 	err_str = "struct ops programs must have a GPL compatible license";
253 	found = false;
254 	old_print_fn = libbpf_set_print(libbpf_debug_print);
255 
256 	skel = bpf_tcp_nogpl__open_and_load();
257 	ASSERT_NULL(skel, "bpf_tcp_nogpl");
258 	ASSERT_EQ(found, true, "expected_err_msg");
259 
260 	bpf_tcp_nogpl__destroy(skel);
261 	libbpf_set_print(old_print_fn);
262 }
263 
test_dctcp_fallback(void)264 static void test_dctcp_fallback(void)
265 {
266 	int err, lfd = -1, cli_fd = -1, srv_fd = -1;
267 	struct bpf_dctcp *dctcp_skel;
268 	struct bpf_link *link = NULL;
269 	struct cb_opts dctcp = {
270 		.cc = "bpf_dctcp",
271 	};
272 	struct network_helper_opts srv_opts = {
273 		.post_socket_cb = cc_cb,
274 		.cb_opts = &dctcp,
275 	};
276 	struct cb_opts cubic = {
277 		.cc = "cubic",
278 	};
279 	struct network_helper_opts cli_opts = {
280 		.post_socket_cb = cc_cb,
281 		.cb_opts = &cubic,
282 	};
283 	char srv_cc[16];
284 	socklen_t cc_len = sizeof(srv_cc);
285 
286 	dctcp_skel = bpf_dctcp__open();
287 	if (!ASSERT_OK_PTR(dctcp_skel, "dctcp_skel"))
288 		return;
289 	strscpy(dctcp_skel->rodata->fallback_cc, "cubic");
290 	if (!ASSERT_OK(bpf_dctcp__load(dctcp_skel), "bpf_dctcp__load"))
291 		goto done;
292 
293 	link = bpf_map__attach_struct_ops(dctcp_skel->maps.dctcp);
294 	if (!ASSERT_OK_PTR(link, "dctcp link"))
295 		goto done;
296 
297 	if (!start_test("::1", &srv_opts, &cli_opts, &lfd, &cli_fd))
298 		goto done;
299 
300 	srv_fd = accept(lfd, NULL, 0);
301 	if (!ASSERT_GE(srv_fd, 0, "srv_fd"))
302 		goto done;
303 	ASSERT_STREQ(dctcp_skel->bss->cc_res, "cubic", "cc_res");
304 	ASSERT_EQ(dctcp_skel->bss->tcp_cdg_res, -ENOTSUPP, "tcp_cdg_res");
305 	/* All setsockopt(TCP_CONGESTION) in the recurred
306 	 * bpf_dctcp->init() should fail with -EBUSY.
307 	 */
308 	ASSERT_EQ(dctcp_skel->bss->ebusy_cnt, 3, "ebusy_cnt");
309 
310 	err = getsockopt(srv_fd, SOL_TCP, TCP_CONGESTION, srv_cc, &cc_len);
311 	if (!ASSERT_OK(err, "getsockopt(srv_fd, TCP_CONGESTION)"))
312 		goto done;
313 	ASSERT_STREQ(srv_cc, "cubic", "srv_fd cc");
314 
315 done:
316 	bpf_link__destroy(link);
317 	bpf_dctcp__destroy(dctcp_skel);
318 	if (lfd != -1)
319 		close(lfd);
320 	if (srv_fd != -1)
321 		close(srv_fd);
322 	if (cli_fd != -1)
323 		close(cli_fd);
324 }
325 
test_rel_setsockopt(void)326 static void test_rel_setsockopt(void)
327 {
328 	struct bpf_dctcp_release *rel_skel;
329 	libbpf_print_fn_t old_print_fn;
330 
331 	err_str = "program of this type cannot use helper bpf_setsockopt";
332 	found = false;
333 
334 	old_print_fn = libbpf_set_print(libbpf_debug_print);
335 	rel_skel = bpf_dctcp_release__open_and_load();
336 	libbpf_set_print(old_print_fn);
337 
338 	ASSERT_ERR_PTR(rel_skel, "rel_skel");
339 	ASSERT_TRUE(found, "expected_err_msg");
340 
341 	bpf_dctcp_release__destroy(rel_skel);
342 }
343 
test_write_sk_pacing(void)344 static void test_write_sk_pacing(void)
345 {
346 	struct tcp_ca_write_sk_pacing *skel;
347 	struct bpf_link *link;
348 
349 	skel = tcp_ca_write_sk_pacing__open_and_load();
350 	if (!ASSERT_OK_PTR(skel, "open_and_load"))
351 		return;
352 
353 	link = bpf_map__attach_struct_ops(skel->maps.write_sk_pacing);
354 	ASSERT_OK_PTR(link, "attach_struct_ops");
355 
356 	bpf_link__destroy(link);
357 	tcp_ca_write_sk_pacing__destroy(skel);
358 }
359 
test_incompl_cong_ops(void)360 static void test_incompl_cong_ops(void)
361 {
362 	struct tcp_ca_incompl_cong_ops *skel;
363 	struct bpf_link *link;
364 
365 	skel = tcp_ca_incompl_cong_ops__open_and_load();
366 	if (!ASSERT_OK_PTR(skel, "open_and_load"))
367 		return;
368 
369 	/* That cong_avoid() and cong_control() are missing is only reported at
370 	 * this point:
371 	 */
372 	link = bpf_map__attach_struct_ops(skel->maps.incompl_cong_ops);
373 	ASSERT_ERR_PTR(link, "attach_struct_ops");
374 
375 	bpf_link__destroy(link);
376 	tcp_ca_incompl_cong_ops__destroy(skel);
377 }
378 
test_unsupp_cong_op(void)379 static void test_unsupp_cong_op(void)
380 {
381 	libbpf_print_fn_t old_print_fn;
382 	struct tcp_ca_unsupp_cong_op *skel;
383 
384 	err_str = "attach to unsupported member get_info";
385 	found = false;
386 	old_print_fn = libbpf_set_print(libbpf_debug_print);
387 
388 	skel = tcp_ca_unsupp_cong_op__open_and_load();
389 	ASSERT_NULL(skel, "open_and_load");
390 	ASSERT_EQ(found, true, "expected_err_msg");
391 
392 	tcp_ca_unsupp_cong_op__destroy(skel);
393 	libbpf_set_print(old_print_fn);
394 }
395 
test_update_ca(void)396 static void test_update_ca(void)
397 {
398 	struct cb_opts cb_opts = {
399 		.cc = "tcp_ca_update",
400 	};
401 	struct network_helper_opts opts = {
402 		.post_socket_cb	= cc_cb,
403 		.cb_opts	= &cb_opts,
404 	};
405 	struct tcp_ca_update *skel;
406 	struct bpf_link *link;
407 	int saved_ca1_cnt;
408 	int err;
409 
410 	skel = tcp_ca_update__open_and_load();
411 	if (!ASSERT_OK_PTR(skel, "open"))
412 		return;
413 
414 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
415 	if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
416 		goto out;
417 
418 	do_test(&opts);
419 	saved_ca1_cnt = skel->bss->ca1_cnt;
420 	ASSERT_GT(saved_ca1_cnt, 0, "ca1_ca1_cnt");
421 
422 	err = bpf_link__update_map(link, skel->maps.ca_update_2);
423 	ASSERT_OK(err, "update_map");
424 
425 	do_test(&opts);
426 	ASSERT_EQ(skel->bss->ca1_cnt, saved_ca1_cnt, "ca2_ca1_cnt");
427 	ASSERT_GT(skel->bss->ca2_cnt, 0, "ca2_ca2_cnt");
428 
429 	bpf_link__destroy(link);
430 out:
431 	tcp_ca_update__destroy(skel);
432 }
433 
test_update_wrong(void)434 static void test_update_wrong(void)
435 {
436 	struct cb_opts cb_opts = {
437 		.cc = "tcp_ca_update",
438 	};
439 	struct network_helper_opts opts = {
440 		.post_socket_cb	= cc_cb,
441 		.cb_opts	= &cb_opts,
442 	};
443 	struct tcp_ca_update *skel;
444 	struct bpf_link *link;
445 	int saved_ca1_cnt;
446 	int err;
447 
448 	skel = tcp_ca_update__open_and_load();
449 	if (!ASSERT_OK_PTR(skel, "open"))
450 		return;
451 
452 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
453 	if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
454 		goto out;
455 
456 	do_test(&opts);
457 	saved_ca1_cnt = skel->bss->ca1_cnt;
458 	ASSERT_GT(saved_ca1_cnt, 0, "ca1_ca1_cnt");
459 
460 	err = bpf_link__update_map(link, skel->maps.ca_wrong);
461 	ASSERT_ERR(err, "update_map");
462 
463 	do_test(&opts);
464 	ASSERT_GT(skel->bss->ca1_cnt, saved_ca1_cnt, "ca2_ca1_cnt");
465 
466 	bpf_link__destroy(link);
467 out:
468 	tcp_ca_update__destroy(skel);
469 }
470 
test_mixed_links(void)471 static void test_mixed_links(void)
472 {
473 	struct cb_opts cb_opts = {
474 		.cc = "tcp_ca_update",
475 	};
476 	struct network_helper_opts opts = {
477 		.post_socket_cb	= cc_cb,
478 		.cb_opts	= &cb_opts,
479 	};
480 	struct tcp_ca_update *skel;
481 	struct bpf_link *link, *link_nl;
482 	int err;
483 
484 	skel = tcp_ca_update__open_and_load();
485 	if (!ASSERT_OK_PTR(skel, "open"))
486 		return;
487 
488 	link_nl = bpf_map__attach_struct_ops(skel->maps.ca_no_link);
489 	if (!ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl"))
490 		goto out;
491 
492 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
493 	ASSERT_OK_PTR(link, "attach_struct_ops");
494 
495 	do_test(&opts);
496 	ASSERT_GT(skel->bss->ca1_cnt, 0, "ca1_ca1_cnt");
497 
498 	err = bpf_link__update_map(link, skel->maps.ca_no_link);
499 	ASSERT_ERR(err, "update_map");
500 
501 	bpf_link__destroy(link);
502 	bpf_link__destroy(link_nl);
503 out:
504 	tcp_ca_update__destroy(skel);
505 }
506 
test_multi_links(void)507 static void test_multi_links(void)
508 {
509 	struct tcp_ca_update *skel;
510 	struct bpf_link *link;
511 
512 	skel = tcp_ca_update__open_and_load();
513 	if (!ASSERT_OK_PTR(skel, "open"))
514 		return;
515 
516 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
517 	ASSERT_OK_PTR(link, "attach_struct_ops_1st");
518 	bpf_link__destroy(link);
519 
520 	/* A map should be able to be used to create links multiple
521 	 * times.
522 	 */
523 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
524 	ASSERT_OK_PTR(link, "attach_struct_ops_2nd");
525 	bpf_link__destroy(link);
526 
527 	tcp_ca_update__destroy(skel);
528 }
529 
test_link_replace(void)530 static void test_link_replace(void)
531 {
532 	DECLARE_LIBBPF_OPTS(bpf_link_update_opts, opts);
533 	struct tcp_ca_update *skel;
534 	struct bpf_link *link;
535 	int err;
536 
537 	skel = tcp_ca_update__open_and_load();
538 	if (!ASSERT_OK_PTR(skel, "open"))
539 		return;
540 
541 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
542 	ASSERT_OK_PTR(link, "attach_struct_ops_1st");
543 	bpf_link__destroy(link);
544 
545 	link = bpf_map__attach_struct_ops(skel->maps.ca_update_2);
546 	if (!ASSERT_OK_PTR(link, "attach_struct_ops_2nd"))
547 		goto out;
548 
549 	/* BPF_F_REPLACE with a wrong old map Fd. It should fail!
550 	 *
551 	 * With BPF_F_REPLACE, the link should be updated only if the
552 	 * old map fd given here matches the map backing the link.
553 	 */
554 	opts.old_map_fd = bpf_map__fd(skel->maps.ca_update_1);
555 	opts.flags = BPF_F_REPLACE;
556 	err = bpf_link_update(bpf_link__fd(link),
557 			      bpf_map__fd(skel->maps.ca_update_1),
558 			      &opts);
559 	ASSERT_ERR(err, "bpf_link_update_fail");
560 
561 	/* BPF_F_REPLACE with a correct old map Fd. It should success! */
562 	opts.old_map_fd = bpf_map__fd(skel->maps.ca_update_2);
563 	err = bpf_link_update(bpf_link__fd(link),
564 			      bpf_map__fd(skel->maps.ca_update_1),
565 			      &opts);
566 	ASSERT_OK(err, "bpf_link_update_success");
567 
568 	bpf_link__destroy(link);
569 
570 out:
571 	tcp_ca_update__destroy(skel);
572 }
573 
test_tcp_ca_kfunc(void)574 static void test_tcp_ca_kfunc(void)
575 {
576 	struct tcp_ca_kfunc *skel;
577 
578 	skel = tcp_ca_kfunc__open_and_load();
579 	ASSERT_OK_PTR(skel, "tcp_ca_kfunc__open_and_load");
580 	tcp_ca_kfunc__destroy(skel);
581 }
582 
test_untrusted_btf_write(void)583 static void test_untrusted_btf_write(void)
584 {
585 	struct tcp_ca_untrusted_btf_write *skel;
586 
587 	skel = tcp_ca_untrusted_btf_write__open_and_load();
588 	ASSERT_ERR_PTR(skel, "tcp_ca_untrusted_btf_write__open_and_load");
589 	tcp_ca_untrusted_btf_write__destroy(skel);
590 }
591 
test_cc_cubic(void)592 static void test_cc_cubic(void)
593 {
594 	struct cb_opts cb_opts = {
595 		.cc = "bpf_cc_cubic",
596 	};
597 	struct network_helper_opts opts = {
598 		.post_socket_cb	= cc_cb,
599 		.cb_opts	= &cb_opts,
600 	};
601 	struct bpf_cc_cubic *cc_cubic_skel;
602 	struct bpf_link *link;
603 
604 	cc_cubic_skel = bpf_cc_cubic__open_and_load();
605 	if (!ASSERT_OK_PTR(cc_cubic_skel, "bpf_cc_cubic__open_and_load"))
606 		return;
607 
608 	link = bpf_map__attach_struct_ops(cc_cubic_skel->maps.cc_cubic);
609 	if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
610 		bpf_cc_cubic__destroy(cc_cubic_skel);
611 		return;
612 	}
613 
614 	do_test(&opts);
615 
616 	bpf_link__destroy(link);
617 	bpf_cc_cubic__destroy(cc_cubic_skel);
618 }
619 
test_bpf_tcp_ca(void)620 void test_bpf_tcp_ca(void)
621 {
622 	if (test__start_subtest("dctcp"))
623 		test_dctcp();
624 	if (test__start_subtest("cubic"))
625 		test_cubic();
626 	if (test__start_subtest("invalid_license"))
627 		test_invalid_license();
628 	if (test__start_subtest("dctcp_fallback"))
629 		test_dctcp_fallback();
630 	if (test__start_subtest("rel_setsockopt"))
631 		test_rel_setsockopt();
632 	if (test__start_subtest("write_sk_pacing"))
633 		test_write_sk_pacing();
634 	if (test__start_subtest("incompl_cong_ops"))
635 		test_incompl_cong_ops();
636 	if (test__start_subtest("unsupp_cong_op"))
637 		test_unsupp_cong_op();
638 	if (test__start_subtest("update_ca"))
639 		test_update_ca();
640 	if (test__start_subtest("update_wrong"))
641 		test_update_wrong();
642 	if (test__start_subtest("mixed_links"))
643 		test_mixed_links();
644 	if (test__start_subtest("multi_links"))
645 		test_multi_links();
646 	if (test__start_subtest("link_replace"))
647 		test_link_replace();
648 	if (test__start_subtest("tcp_ca_kfunc"))
649 		test_tcp_ca_kfunc();
650 	if (test__start_subtest("untrusted_btf_write"))
651 		test_untrusted_btf_write();
652 	if (test__start_subtest("cc_cubic"))
653 		test_cc_cubic();
654 	if (test__start_subtest("dctcp_autoattach_map"))
655 		test_dctcp_autoattach_map();
656 }
657