Skip to content

Commit ca5cd35

Browse files
jrfastabborkmann
authored andcommitted
bpf, selftests: use :: 1 for localhost in tcp_server.py
Using localhost requires the host to have a /etc/hosts file with that specific line in it. By default my dev box did not, they used ip6-localhost, so the test was failing. To fix remove the need for any /etc/hosts and use ::1. I could just add the line, but this seems easier. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Song Liu <songliubraving@fb.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/159594714197.21431.10113693935099326445.stgit@john-Precision-5820-Tower
1 parent 3c4f850 commit ca5cd35

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎tools/testing/selftests/bpf/tcp_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def send(sock, s):
3434
# create active socket
3535
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
3636
try:
37-
sock.connect(('localhost', serverPort))
37+
sock.connect(('::1', serverPort))
3838
except socket.error as e:
3939
sys.exit(1)
4040

‎tools/testing/selftests/bpf/tcp_server.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def send(sock, s):
3838
# create passive socket
3939
serverSocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
4040

41-
try: serverSocket.bind(('localhost', 0))
41+
try: serverSocket.bind(('::1', 0))
4242
except socket.error as msg:
4343
print('bind fails: ' + str(msg))
4444

‎tools/testing/selftests/bpf/test_netcnt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ int main(int argc, char **argv)
8282
}
8383

8484
if (system("which ping6 &>/dev/null") == 0)
85-
assert(!system("ping6 localhost -c 10000 -f -q > /dev/null"));
85+
assert(!system("ping6 ::1 -c 10000 -f -q > /dev/null"));
8686
else
87-
assert(!system("ping -6 localhost -c 10000 -f -q > /dev/null"));
87+
assert(!system("ping -6 ::1 -c 10000 -f -q > /dev/null"));
8888

8989
if (bpf_prog_query(cgroup_fd, BPF_CGROUP_INET_EGRESS, 0, NULL, NULL,
9090
&prog_cnt)) {

0 commit comments

Comments
 (0)