From 2b531e139c5ae6be6703a18bc2cb1d7527df027f Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Fri, 3 Mar 2023 15:52:34 -0800 Subject: [PATCH] Enable more tests on raw sockets. ICMP (aka ping) sockets are not supported on Linux by default, so those remain disabled for hostinet and linux. PiperOrigin-RevId: 513942981 --- .../linux/socket_ipv4_datagram_based_socket_unbound.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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())); } }