Skip to content

Commit

Permalink
selftests/bpf: use localhost in tcp_{server,client}.py
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stanislav Fomichev authored and Daniel Borkmann committed Feb 4, 2019
1 parent ecc15f1 commit 7e8a590
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 1 addition & 2 deletions tools/testing/selftests/bpf/tcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions tools/testing/selftests/bpf/tcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ def send(sock, s):
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))

Expand Down

0 comments on commit 7e8a590

Please sign in to comment.