Commit ca5cd355 authored by John Fastabend's avatar John Fastabend Committed by Daniel Borkmann

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: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/159594714197.21431.10113693935099326445.stgit@john-Precision-5820-Tower
parent 3c4f850e
...@@ -34,7 +34,7 @@ serverPort = int(sys.argv[1]) ...@@ -34,7 +34,7 @@ serverPort = int(sys.argv[1])
# create active socket # create active socket
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
try: try:
sock.connect(('localhost', serverPort)) sock.connect(('::1', serverPort))
except socket.error as e: except socket.error as e:
sys.exit(1) sys.exit(1)
......
...@@ -38,7 +38,7 @@ serverSocket = None ...@@ -38,7 +38,7 @@ serverSocket = None
# create passive socket # create passive socket
serverSocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) serverSocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
try: serverSocket.bind(('localhost', 0)) try: serverSocket.bind(('::1', 0))
except socket.error as msg: except socket.error as msg:
print('bind fails: ' + str(msg)) print('bind fails: ' + str(msg))
......
...@@ -82,9 +82,9 @@ int main(int argc, char **argv) ...@@ -82,9 +82,9 @@ int main(int argc, char **argv)
} }
if (system("which ping6 &>/dev/null") == 0) if (system("which ping6 &>/dev/null") == 0)
assert(!system("ping6 localhost -c 10000 -f -q > /dev/null")); assert(!system("ping6 ::1 -c 10000 -f -q > /dev/null"));
else else
assert(!system("ping -6 localhost -c 10000 -f -q > /dev/null")); assert(!system("ping -6 ::1 -c 10000 -f -q > /dev/null"));
if (bpf_prog_query(cgroup_fd, BPF_CGROUP_INET_EGRESS, 0, NULL, NULL, if (bpf_prog_query(cgroup_fd, BPF_CGROUP_INET_EGRESS, 0, NULL, NULL,
&prog_cnt)) { &prog_cnt)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment