tools/testing/selftests/bpf/prog_tests/empty_skb.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/empty_skb.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/empty_skb.c
Extension
.c
Size
4827 bytes
Lines
186
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

bpf_object__for_each_program(prog, bpf_obj->obj) {
			bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
			bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
			bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room");
			int expected_ret;
			char buf[128];

			if (tests[i].adjust_room != is_adjust_room)
				continue;

			expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;

			tattr.data_in = tests[i].data_in;
			tattr.data_size_in = tests[i].data_size_in;

			tattr.data_size_out = 0;
			bpf_obj->bss->ifindex = *tests[i].ifindex;
			bpf_obj->bss->ret = 0;
			err = bpf_prog_test_run_opts(bpf_program__fd(prog), &tattr);
			sprintf(buf, "err: %s [%s]", tests[i].msg, bpf_program__name(prog));

			if (at_tc && tests[i].success_on_tc)
				ASSERT_GE(err, 0, buf);
			else
				ASSERT_EQ(err, tests[i].err, buf);
			sprintf(buf, "ret: %s [%s]", tests[i].msg, bpf_program__name(prog));
			if (at_tc && tests[i].success_on_tc)
				ASSERT_GE(bpf_obj->bss->ret, 0, buf);
			else
				ASSERT_EQ(bpf_obj->bss->ret, expected_ret, buf);
		}
	}

out:
	if (bpf_obj)
		empty_skb__destroy(bpf_obj);
	if (tok)
		close_netns(tok);
	SYS_NOFAIL("ip netns del empty_skb");
}

Annotation

Implementation Notes