Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

John Fastabend and committed by
Daniel Borkmann
ca5cd355 3c4f850e

+4 -4
+1 -1
tools/testing/selftests/bpf/tcp_client.py
··· 34 34 # create active socket 35 35 sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) 36 36 try: 37 - sock.connect(('localhost', serverPort)) 37 + sock.connect(('::1', serverPort)) 38 38 except socket.error as e: 39 39 sys.exit(1) 40 40
+1 -1
tools/testing/selftests/bpf/tcp_server.py
··· 38 38 # create passive socket 39 39 serverSocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) 40 40 41 - try: serverSocket.bind(('localhost', 0)) 41 + try: serverSocket.bind(('::1', 0)) 42 42 except socket.error as msg: 43 43 print('bind fails: ' + str(msg)) 44 44
+2 -2
tools/testing/selftests/bpf/test_netcnt.c
··· 82 82 } 83 83 84 84 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")); 86 86 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")); 88 88 89 89 if (bpf_prog_query(cgroup_fd, BPF_CGROUP_INET_EGRESS, 0, NULL, NULL, 90 90 &prog_cnt)) {