diff --git a/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc b/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc index a61d509a1..71c4c50ea 100644 --- a/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc +++ b/test/syscalls/linux/socket_ipv4_datagram_based_socket_unbound.cc @@ -24,9 +24,15 @@ namespace testing { void IPv4DatagramBasedUnboundSocketTest::SetUp() { if (GetParam().type & SOCK_RAW) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveRawIPSocketCapability())); + } - // TODO(b/267210840): Support raw sockets on hostinet. - SKIP_IF(IsRunningWithHostinet()); + if (GetParam().protocol & IPPROTO_ICMP) { + // By default, ICMP sockets cannot be created on Linux, even with root + // privs. So we only run the test with gVisor and not hostinet, and even + // then require CAP_NET_RAW. + // See https://lwn.net/Articles/443051/ + SKIP_IF(!IsRunningOnGvisor() || IsRunningWithHostinet() || + ASSERT_NO_ERRNO_AND_VALUE(HaveRawIPSocketCapability())); } }