Don't use SOL_UDP when creating sockets

SOL_UDP is used when get/set-ing socket options to specify the socket
level. When creating normal UDP sockets, the protocol need not be
specified. When creating RAW IP sockets for UDP, use IPPROTO_UDP.

PiperOrigin-RevId: 396675986
This commit is contained in:
Ghanan Gowripalan
2021-09-14 14:03:53 -07:00
committed by gVisor bot
parent 2b46e2d19e
commit 5593b8a7e6
+2 -2
View File
@@ -950,7 +950,7 @@ void TestRawSocketMaybeBindReceive(bool do_bind) {
};
FileDescriptor udp_sock =
ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_INET, SOCK_DGRAM, SOL_UDP));
ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_INET, SOCK_DGRAM, 0));
sockaddr_in udp_sock_bind_addr = addr;
socklen_t udp_sock_bind_addr_len = sizeof(udp_sock_bind_addr);
ASSERT_THAT(bind(udp_sock.get(),
@@ -964,7 +964,7 @@ void TestRawSocketMaybeBindReceive(bool do_bind) {
ASSERT_EQ(udp_sock_bind_addr_len, sizeof(udp_sock_bind_addr));
FileDescriptor raw_sock =
ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_INET, SOCK_RAW, SOL_UDP));
ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_INET, SOCK_RAW, IPPROTO_UDP));
auto test_recv = [&](const char* scope, uint32_t expected_destination) {
SCOPED_TRACE(scope);