TencentOS-kernel/tools/testing/selftests/bpf/prog_tests
Daniel Borkmann f2bcf1b93d bpf, testing: Add get{peer, sock}name selftests to test_progs
[upstream commit 566fc3f5d1c641b510ec487cf274a047f8a1e849]

Extend the existing connect_force_port test to assert get{peer,sock}name programs
as well. The workflow for e.g. IPv4 is as follows: i) server binds to concrete
port, ii) client calls getsockname() on server fd which exposes 1.2.3.4:60000 to
client, iii) client connects to service address 1.2.3.4:60000 binds to concrete
local address (127.0.0.1:22222) and remaps service address to a concrete backend
address (127.0.0.1:60123), iv) client then calls getsockname() on its own fd to
verify local address (127.0.0.1:22222) and getpeername() on its own fd which then
publishes service address (1.2.3.4:60000) instead of actual backend. Same workflow
is done for IPv6 just with different address/port tuples.

  # ./test_progs -t connect_force_port
  #14 connect_force_port:OK
  Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Andrey Ignatov <rdna@fb.com>
Link: https://lore.kernel.org/bpf/3343da6ad08df81af715a95d61a84fb4a960f2bf.1589841594.git.daniel@iogearbox.net
2022-07-18 19:48:53 +08:00
..
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
attach_probe.c selftests/bpf: use hrtimer_nanosleep() for attach_probe test 2022-06-21 14:20:01 +08:00
bpf_iter.c selftests/bpf: fix compile error for bpf_iter 2022-06-21 10:27:20 +08:00
bpf_obj_id.c selftests/bpf: Test bpf_link's get_next_id, get_fd_by_id, and get_obj_info 2022-06-21 10:27:18 +08:00
bpf_tcp_ca.c bpf: Add bpf_dctcp example 2022-06-21 10:27:18 +08:00
bpf_verif_scale.c selftests/bpf: Integrate verbose verifier log into test_progs 2022-06-21 10:27:19 +08:00
cgroup_attach_autodetach.c selftests/bpf: fix compile errors 2022-06-21 10:27:18 +08:00
cgroup_attach_multi.c selftests/bpf: Test BPF_F_REPLACE in cgroup_attach_multi 2022-06-21 10:27:18 +08:00
cgroup_attach_override.c selftests/bpf: fix compile errors 2022-06-21 10:27:18 +08:00
cgroup_link.c selftests/bpf: Test FD-based cgroup attachment 2022-06-21 10:27:18 +08:00
connect_force_port.c bpf, testing: Add get{peer, sock}name selftests to test_progs 2022-07-18 19:48:53 +08:00
core_reloc.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
fentry_fexit.c selftests/bpf: sync fentry/fexit test from upstream 2022-06-21 10:27:18 +08:00
fentry_test.c selftests/bpf: sync fentry/fexit test from upstream 2022-06-21 10:27:18 +08:00
fexit_bpf2bpf.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
fexit_stress.c selftests/bpf: Add stress test for maximum number of progs 2022-06-21 10:27:18 +08:00
fexit_test.c selftests/bpf: sync fentry/fexit test from upstream 2022-06-21 10:27:18 +08:00
flow_dissector.c selftests/bpf: Extend test_flow_dissector to cover link creation 2022-06-21 10:27:19 +08:00
flow_dissector_load_bytes.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
flow_dissector_reattach.c selftests/bpf: Add tests for attaching bpf_link to netns 2022-06-21 10:27:19 +08:00
get_stack_raw_tp.c bpf: Test_progs, add test to catch retval refine error handling 2021-03-16 16:26:42 +08:00
global_data.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
l4lb_all.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
link_pinning.c selftests/bpf: Add link pinning selftests 2022-06-21 10:27:18 +08:00
map_lock.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
map_ptr.c selftests/bpf: Pass page size from userspace in map_ptr 2022-06-21 10:27:21 +08:00
modify_return.c bpf: Add test ops for BPF_PROG_TYPE_TRACING 2022-06-21 10:27:18 +08:00
obj_name.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
perf_buffer.c selftests/bpf: Switch perf_buffer test to tracepoint and skeleton 2022-06-21 10:27:21 +08:00
pkt_access.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
pkt_md_access.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
prog_run_xattr.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
queue_stack_map.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
raw_tp_writable_reject_nbd_invalid.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
raw_tp_writable_test_run.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
reference_tracking.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ringbuf.c libbpf: Fix ring_buffer__poll() to return number of consumed samples 2022-06-21 10:27:20 +08:00
ringbuf_multi.c libbpf: Fix ring_buffer__poll() to return number of consumed samples 2022-06-21 10:27:20 +08:00
send_signal.c selftests/bpf: remove or fix some tests 2022-06-21 14:19:11 +08:00
signal_pending.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
sk_assign.c selftests: bpf: Extend sk_assign tests for UDP 2022-06-21 10:27:19 +08:00
sk_lookup.c selftests/bpf: Tests for BPF_SK_LOOKUP attach point 2022-06-21 10:27:19 +08:00
skb_ctx.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
sockmap_basic.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sockopt.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sockopt_inherit.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sockopt_multi.c selftests/bpf: Fix error return code in run_getsockopt_test() 2021-03-16 16:41:20 +08:00
sockopt_sk.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
spinlock.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
stacktrace_build_id.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
stacktrace_build_id_nmi.c selftests/bpf: fix goto cleanup label not defined 2021-03-16 16:27:46 +08:00
stacktrace_map.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
stacktrace_map_raw_tp.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tailcalls.c bpf, testing: Add various tail call test cases 2022-06-21 10:27:18 +08:00
task_fd_query_rawtp.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
task_fd_query_tp.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tcp_estats.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
tcp_rtt.c bpf: selftests: A few improvements to network_helpers.c 2022-06-21 10:27:19 +08:00
test_local_storage.c bpf: Add selftests for local_storage 2022-06-21 10:27:20 +08:00
test_lsm.c bpf, lsm: Fix the file_mprotect LSM test. 2022-06-21 10:27:18 +08:00
tp_attach_query.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
xdp.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
xdp_adjust_tail.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
xdp_noinline.c selftests/bpf: Move existing common networking parts into network_helpers 2022-06-21 10:27:19 +08:00
xdp_perf.c selftests: bpf: Add xdp_perf test 2022-06-21 10:27:06 +08:00