sys/freebsd: improve udp tests

Add support for the UDP_ENCAP. Add required includes and
remove the Linux specific ones.
This commit is contained in:
Michael Tuexen 2018-12-04 13:56:01 +01:00 committed by Dmitry Vyukov
parent 6ad0ae6171
commit f162ad97ac
5 changed files with 48 additions and 7 deletions

View File

@ -20,7 +20,7 @@
#if GOARCH_amd64
#define GOARCH "amd64"
#define SYZ_REVISION "14c28af7b40c606be84ee475c6e8a7f63d052890"
#define SYZ_REVISION "8b3b74aded84239fffe46ae19976fae0cbcd9030"
#define SYZ_EXECUTOR_USES_FORK_SERVER 1
#define SYZ_EXECUTOR_USES_SHMEM 1
#define SYZ_PAGE_SIZE 4096

View File

@ -302,6 +302,7 @@ const call_t syscalls[] = {
{"getsockopt$inet6_int", 118},
{"getsockopt$inet6_tcp_buf", 118},
{"getsockopt$inet6_tcp_int", 118},
{"getsockopt$inet6_udp", 118},
{"getsockopt$inet6_udplite", 118},
{"getsockopt$inet_buf", 118},
{"getsockopt$inet_int", 118},
@ -311,6 +312,7 @@ const call_t syscalls[] = {
{"getsockopt$inet_opts", 118},
{"getsockopt$inet_tcp_buf", 118},
{"getsockopt$inet_tcp_int", 118},
{"getsockopt$inet_udp", 118},
{"getsockopt$inet_udplite", 118},
{"getsockopt$sock_cred", 118},
{"getsockopt$sock_int", 118},
@ -414,6 +416,7 @@ const call_t syscalls[] = {
{"setsockopt$inet6_tcp_TCP_CONGESTION", 105},
{"setsockopt$inet6_tcp_buf", 105},
{"setsockopt$inet6_tcp_int", 105},
{"setsockopt$inet6_udp", 105},
{"setsockopt$inet6_udplite", 105},
{"setsockopt$inet_MCAST_JOIN_GROUP", 105},
{"setsockopt$inet_MCAST_LEAVE_GROUP", 105},
@ -428,6 +431,7 @@ const call_t syscalls[] = {
{"setsockopt$inet_tcp_TCP_CONGESTION", 105},
{"setsockopt$inet_tcp_buf", 105},
{"setsockopt$inet_tcp_int", 105},
{"setsockopt$inet_udp", 105},
{"setsockopt$inet_udplite", 105},
{"setsockopt$sock_cred", 105},
{"setsockopt$sock_int", 105},

View File

@ -897,6 +897,13 @@ var syscalls_amd64 = []*Syscall{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4, ArgDir: 1}}}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optlen", TypeSize: 8}, Type: &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", TypeSize: 4, ArgDir: 2}}, Buf: "optval"}},
}},
{NR: 118, Name: "getsockopt$inet6_udp", CallName: "getsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udp6", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 17},
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "udp_option_types", FldName: "optname", TypeSize: 8}}, Vals: []uint64{1}, BitMask: true},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4, ArgDir: 1}}}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optlen", TypeSize: 8}, Type: &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", TypeSize: 4, ArgDir: 2}}, Buf: "optval"}},
}},
{NR: 118, Name: "getsockopt$inet6_udplite", CallName: "getsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udplite6", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 136},
@ -960,6 +967,13 @@ var syscalls_amd64 = []*Syscall{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4, ArgDir: 1}}}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optlen", TypeSize: 8}, Type: &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", TypeSize: 4, ArgDir: 2}}, Buf: "optval"}},
}},
{NR: 118, Name: "getsockopt$inet_udp", CallName: "getsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udp", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 17},
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "udp_option_types", FldName: "optname", TypeSize: 8}}, Vals: []uint64{1}, BitMask: true},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4, ArgDir: 1}}}},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optlen", TypeSize: 8}, Type: &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", TypeSize: 4, ArgDir: 2}}, Buf: "optval"}},
}},
{NR: 118, Name: "getsockopt$inet_udplite", CallName: "getsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udplite", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 136},
@ -1532,6 +1546,13 @@ var syscalls_amd64 = []*Syscall{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "optlen", TypeSize: 8}}, Buf: "optval"},
}},
{NR: 105, Name: "setsockopt$inet6_udp", CallName: "setsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udp6", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 17},
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "udp_option_types", FldName: "optname", TypeSize: 8}}, Vals: []uint64{1}, BitMask: true},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "optlen", TypeSize: 8}}, Buf: "optval"},
}},
{NR: 105, Name: "setsockopt$inet6_udplite", CallName: "setsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udplite6", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 136},
@ -1630,6 +1651,13 @@ var syscalls_amd64 = []*Syscall{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "optlen", TypeSize: 8}}, Buf: "optval"},
}},
{NR: 105, Name: "setsockopt$inet_udp", CallName: "setsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udp", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 17},
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "udp_option_types", FldName: "optname", TypeSize: 8}}, Vals: []uint64{1}, BitMask: true},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "optval", TypeSize: 8}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}},
&LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "optlen", TypeSize: 8}}, Buf: "optval"},
}},
{NR: 105, Name: "setsockopt$inet_udplite", CallName: "setsockopt", Args: []Type{
&ResourceType{TypeCommon: TypeCommon{TypeName: "sock_udplite", FldName: "fd", TypeSize: 4}},
&ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "level", TypeSize: 8}}, Val: 136},
@ -1936,6 +1964,7 @@ var consts_amd64 = []ConstValue{
{Name: "IPPROTO_IP"},
{Name: "IPPROTO_IPV6", Value: 41},
{Name: "IPPROTO_TCP", Value: 6},
{Name: "IPPROTO_UDP", Value: 17},
{Name: "IPPROTO_UDPLITE", Value: 136},
{Name: "IPV6_2292DSTOPTS", Value: 23},
{Name: "IPV6_2292HOPLIMIT", Value: 20},
@ -2376,6 +2405,7 @@ var consts_amd64 = []ConstValue{
{Name: "TIMER_ABSTIME", Value: 1},
{Name: "UDPLITE_RECV_CSCOV", Value: 4},
{Name: "UDPLITE_SEND_CSCOV", Value: 2},
{Name: "UDP_ENCAP", Value: 1},
{Name: "WCONTINUED", Value: 4},
{Name: "WEXITED", Value: 16},
{Name: "WNOHANG", Value: 1},
@ -2384,4 +2414,4 @@ var consts_amd64 = []ConstValue{
{Name: "WUNTRACED", Value: 2},
}
const revision_amd64 = "14c28af7b40c606be84ee475c6e8a7f63d052890"
const revision_amd64 = "8b3b74aded84239fffe46ae19976fae0cbcd9030"

View File

@ -6,8 +6,7 @@
include <sys/types.h>
include <sys/socket.h>
include <netinet/in.h>
include <linux/linux.h>
include <compat/linux/linux_socket.h>
include <netinet/udp.h>
resource sock_udp[sock_in]
@ -16,3 +15,10 @@ socket$inet_udp(domain const[AF_INET], type const[SOCK_DGRAM], proto const[0]) s
resource sock_udp6[sock_in6]
socket$inet6_udp(domain const[AF_INET6], type const[SOCK_DGRAM], proto const[0]) sock_udp6
udp_option_types = UDP_ENCAP
getsockopt$inet_udp(fd sock_udp, level const[IPPROTO_UDP], optname flags[udp_option_types], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
setsockopt$inet_udp(fd sock_udp, level const[IPPROTO_UDP], optname flags[udp_option_types], optval ptr[in, int32], optlen len[optval])
getsockopt$inet6_udp(fd sock_udp6, level const[IPPROTO_UDP], optname flags[udp_option_types], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
setsockopt$inet6_udp(fd sock_udp6, level const[IPPROTO_UDP], optname flags[udp_option_types], optval ptr[in, int32], optlen len[optval])

View File

@ -1,8 +1,9 @@
# AUTOGENERATED FILE
AF_INET = 2
AF_INET6 = 28
LINUX_AF_INET = 2
LINUX_AF_INET6 = 10
LINUX_SOCK_DGRAM = 2
IPPROTO_UDP = 17
SOCK_DGRAM = 2
SYS_getsockopt = 118
SYS_setsockopt = 105
SYS_socket = 97
UDP_ENCAP = 1