mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Support IP_TOS and IPV6_TCLASS socket options for hostinet sockets.
There are two potential ways of sending a TOS byte with outgoing packets: including a control message in sendmsg, or setting the IP_TOS/IPV6_TCLASS socket options (for IPV4 and IPV6 respectively). This change lets hostinet support the latter. Fixes #1188 PiperOrigin-RevId: 283550925
This commit is contained in:
@@ -289,12 +289,12 @@ func (s *socketOperations) GetSockOpt(t *kernel.Task, level int, name int, outPt
|
||||
switch level {
|
||||
case linux.SOL_IP:
|
||||
switch name {
|
||||
case linux.IP_RECVTOS:
|
||||
case linux.IP_TOS, linux.IP_RECVTOS:
|
||||
optlen = sizeofInt32
|
||||
}
|
||||
case linux.SOL_IPV6:
|
||||
switch name {
|
||||
case linux.IPV6_RECVTCLASS, linux.IPV6_V6ONLY:
|
||||
case linux.IPV6_TCLASS, linux.IPV6_RECVTCLASS, linux.IPV6_V6ONLY:
|
||||
optlen = sizeofInt32
|
||||
}
|
||||
case linux.SOL_SOCKET:
|
||||
@@ -334,12 +334,12 @@ func (s *socketOperations) SetSockOpt(t *kernel.Task, level int, name int, opt [
|
||||
switch level {
|
||||
case linux.SOL_IP:
|
||||
switch name {
|
||||
case linux.IP_RECVTOS:
|
||||
case linux.IP_TOS, linux.IP_RECVTOS:
|
||||
optlen = sizeofInt32
|
||||
}
|
||||
case linux.SOL_IPV6:
|
||||
switch name {
|
||||
case linux.IPV6_RECVTCLASS, linux.IPV6_V6ONLY:
|
||||
case linux.IPV6_TCLASS, linux.IPV6_RECVTCLASS, linux.IPV6_V6ONLY:
|
||||
optlen = sizeofInt32
|
||||
}
|
||||
case linux.SOL_SOCKET:
|
||||
|
||||
@@ -310,11 +310,21 @@ func hostInetFilters() seccomp.SyscallRules {
|
||||
syscall.SYS_GETPEERNAME: {},
|
||||
syscall.SYS_GETSOCKNAME: {},
|
||||
syscall.SYS_GETSOCKOPT: []seccomp.Rule{
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IP),
|
||||
seccomp.AllowValue(syscall.IP_TOS),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IP),
|
||||
seccomp.AllowValue(syscall.IP_RECVTOS),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IPV6),
|
||||
seccomp.AllowValue(syscall.IPV6_TCLASS),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IPV6),
|
||||
@@ -423,6 +433,13 @@ func hostInetFilters() seccomp.SyscallRules {
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(4),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IP),
|
||||
seccomp.AllowValue(syscall.IP_TOS),
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(4),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IP),
|
||||
@@ -430,6 +447,13 @@ func hostInetFilters() seccomp.SyscallRules {
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(4),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IPV6),
|
||||
seccomp.AllowValue(syscall.IPV6_TCLASS),
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(4),
|
||||
},
|
||||
{
|
||||
seccomp.AllowAny{},
|
||||
seccomp.AllowValue(syscall.SOL_IPV6),
|
||||
|
||||
Reference in New Issue
Block a user