From: Gabe Black Date: Sat, 28 Oct 2017 07:36:13 +0000 (-0700) Subject: base: Fix forcing loopback only binding for listeners. X-Git-Tag: v19.0.0.0~2591 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44896ba35b0874b9925ebd7927e196d0eb639b5e;p=gem5.git base: Fix forcing loopback only binding for listeners. Despite online documentation, the type used for sin_addr.s_addr is not actually an unsigned long, it is an in_addr_t. When an unsigned long is a 64 bit value, the endian conversion moves the relevant bits of the 32 bit in_addr_t to positions which are truncated away. This forces the value to 0 which means to bind to any interface, the opposite of the intended effect. Change-Id: I53c63dea6bd88144dfef1a9a49b478fab30a8ba2 Reviewed-on: https://gem5-review.googlesource.com/5301 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- diff --git a/src/base/socket.cc b/src/base/socket.cc index 5ef0f4b9e..a09b51fb2 100644 --- a/src/base/socket.cc +++ b/src/base/socket.cc @@ -106,7 +106,7 @@ ListenSocket::listen(int port, bool reuse) struct sockaddr_in sockaddr; sockaddr.sin_family = PF_INET; sockaddr.sin_addr.s_addr = - htobe(bindToLoopback ? INADDR_LOOPBACK : INADDR_ANY); + htobe(bindToLoopback ? INADDR_LOOPBACK : INADDR_ANY); sockaddr.sin_port = htons(port); // finally clear sin_zero memset(&sockaddr.sin_zero, 0, sizeof(sockaddr.sin_zero));