Skip to contentSkip to conversation

selftests/bpf: use localhost in tcp_{server,client}.py

PATCH Applied Stanislav Fomichev 2 participants 2 messages Feb 4, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: use localhost in tcp_{server,client}.py

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.

---
 tools/testing/selftests/bpf/tcp_client.py | 3 +--
 tools/testing/selftests/bpf/tcp_server.py | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/tcp_client.py +1 -2
index 7f8200a8702b..a53ed58528d6 100755
@@ -30,12 +30,11 @@ import select
 
 
 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)
 
tools/testing/selftests/bpf/tcp_server.py +1 -4
index b39903fca4c8..0ca60d193bed 100755
@@ -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))
 
Signature · 1 line
2.20.1.611.gfbb209baf1-goog
maintainer Applied
#1 lore raw
Quoted 5 lines · Stanislav Fomichev

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.

Applied, thanks!