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
This commit is contained in:
Nicolas Lacasse
2023-03-04 00:51:08 -08:00
committed by gVisor bot
parent e4ece21634
commit 2b531e139c
@@ -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()));
}
}