Daniel Borkmann 566fc3f5d1 bpf, testing: Add get{peer, sock}name selftests to test_progs
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
2020-05-19 11:32:04 -07:00
..
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-05-15 12:57:50 -07:00
2020-05-07 15:22:08 -07:00
2020-04-04 10:08:18 -07:00
2020-04-09 11:01:42 -07:00
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-04-03 13:12:26 -07:00
2020-04-01 16:09:12 -07:00
2020-04-04 10:08:18 -07:00