diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-11-19 15:08:47 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-19 15:11:17 -0800 |
commit | 209a95a35a2e4d38998962f6a351766e816805d8 (patch) | |
tree | f8e3e1a88c0cea879e6e32cf63687bc3465fde4f /test/syscalls | |
parent | 3454d572199679d6abc66c0c29539829dd9baf51 (diff) |
Propagate IP address prefix from host to netstack
Closes #4022
PiperOrigin-RevId: 343378647
Diffstat (limited to 'test/syscalls')
-rw-r--r-- | test/syscalls/linux/socket_inet_loopback.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_inet_loopback.cc b/test/syscalls/linux/socket_inet_loopback.cc index 27e9816eb..51b77ad85 100644 --- a/test/syscalls/linux/socket_inet_loopback.cc +++ b/test/syscalls/linux/socket_inet_loopback.cc @@ -2830,5 +2830,28 @@ INSTANTIATE_TEST_SUITE_P( } // namespace +// Check that loopback receives connections from any address in the range: +// 127.0.0.1 to 127.254.255.255. This behavior is exclusive to IPv4. +TEST_F(SocketInetLoopbackTest, LoopbackAddressRangeConnect) { + TestAddress const& listener = V4Any(); + + in_addr_t addresses[] = { + INADDR_LOOPBACK, + INADDR_LOOPBACK + 1, // 127.0.0.2 + (in_addr_t)0x7f000101, // 127.0.1.1 + (in_addr_t)0x7f010101, // 127.1.1.1 + (in_addr_t)0x7ffeffff, // 127.254.255.255 + }; + for (const auto& address : addresses) { + TestAddress connector("V4Loopback"); + connector.addr.ss_family = AF_INET; + connector.addr_len = sizeof(sockaddr_in); + reinterpret_cast<sockaddr_in*>(&connector.addr)->sin_addr.s_addr = + htonl(address); + + tcpSimpleConnectTest(listener, connector, true); + } +} + } // namespace testing } // namespace gvisor |