Enable more hostinet socket tests.

Fixes:
* Support for SO_MULTICAST_IF socket option.
* Support IPPROTO_ICMP protocol.

The tests that require raw sockets are disabled on hostinet, since those are
not yet supported.

PiperOrigin-RevId: 509563771
This commit is contained in:
Nicolas Lacasse
2023-02-14 10:07:54 -08:00
committed by gVisor bot
parent f3185ca575
commit 5c30349f08
5 changed files with 11 additions and 0 deletions
+3
View File
@@ -239,6 +239,9 @@ const SockAddrMax = 128
// +marshal
type InetAddr [4]byte
// SizeOfInetAddr is the size of InetAddr.
var SizeOfInetAddr = uint32((*InetAddr)(nil).SizeBytes())
// SockAddrInet is struct sockaddr_in, from uapi/linux/in.h.
//
// +marshal
+2
View File
@@ -193,6 +193,8 @@ func (p *socketProvider) Socket(t *kernel.Task, stypeflags linux.SockType, proto
// IPPROTO_IP with SOCK_DGRAM causes proto to actually
// be IPPROTO_UDP.
protocol = unix.IPPROTO_UDP
case unix.IPPROTO_ICMP:
// ok
case unix.IPPROTO_UDP:
// ok
default:
+1
View File
@@ -59,6 +59,7 @@ type SockOpt struct {
var SockOpts = []SockOpt{
{linux.SOL_IP, linux.IP_ADD_MEMBERSHIP, 0, false, true},
{linux.SOL_IP, linux.IP_DROP_MEMBERSHIP, 0, false, true},
{linux.SOL_IP, linux.IP_MULTICAST_IF, uint64(linux.SizeOfInetAddr), true, true},
{linux.SOL_IP, linux.IP_MULTICAST_LOOP, 0 /* can be 32-bit int or 8-bit uint */, true, true},
{linux.SOL_IP, linux.IP_MULTICAST_TTL, 0 /* can be 32-bit int or 8-bit uint */, true, true},
{linux.SOL_IP, linux.IP_PKTINFO, sizeofInt32, true, true},
+2
View File
@@ -730,6 +730,7 @@ syscall_test(
)
syscall_test(
add_hostinet = True,
test = "//test/syscalls/linux:socket_ipv4_udp_unbound_external_networking_test",
)
@@ -775,6 +776,7 @@ syscall_test(
syscall_test(
size = "medium",
add_hostinet = True,
test = "//test/syscalls/linux:socket_ipv4_datagram_based_socket_unbound_loopback_test",
)
@@ -24,6 +24,9 @@ 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());
}
}