]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
selftests/bpf: use localhost in tcp_{server,client}.py
authorStanislav Fomichev <sdf@google.com>
Mon, 4 Feb 2019 18:43:19 +0000 (10:43 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 4 Feb 2019 20:29:27 +0000 (21:29 +0100)
Bind and connect to localhost. There is no reason for this test to
use non-localhost interface. This lets us run this test in a network
namespace.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/tcp_client.py
tools/testing/selftests/bpf/tcp_server.py

index 7f8200a8702b79905fd838b6608d85b03ed20310..a53ed58528d6166b55ae5160fae02ceac39ced9f 100755 (executable)
@@ -30,12 +30,11 @@ def send(sock, s):
 
 
 serverPort = int(sys.argv[1])
-HostName = socket.gethostname()
 
 # create active socket
 sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
 try:
-    sock.connect((HostName, serverPort))
+    sock.connect(('localhost', serverPort))
 except socket.error as e:
     sys.exit(1)
 
index b39903fca4c898c014811d5a302b7872aabb40fe..0ca60d193bed3bce196898c108030c48703910ad 100755 (executable)
@@ -35,13 +35,10 @@ MAX_PORTS = 2
 serverPort = SERVER_PORT
 serverSocket = None
 
-HostName = socket.gethostname()
-
 # create passive socket
 serverSocket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
-host = socket.gethostname()
 
-try: serverSocket.bind((host, 0))
+try: serverSocket.bind(('localhost', 0))
 except socket.error as msg:
     print('bind fails: ' + str(msg))