mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add support for custom socket options and setting the experiment IP option.
PiperOrigin-RevId: 700011458
This commit is contained in:
committed by
gVisor bot
parent
e816d99736
commit
2267c24a41
@@ -12,6 +12,7 @@ go_library(
|
||||
"netstack_state.go",
|
||||
"provider.go",
|
||||
"save_restore.go",
|
||||
"socketopt_custom.go",
|
||||
"stack.go",
|
||||
"tun.go",
|
||||
],
|
||||
|
||||
@@ -1107,6 +1107,10 @@ func getSockOptSocket(t *kernel.Task, s socket.Socket, ep commonEndpoint, family
|
||||
|
||||
v := primitive.Int32(ep.SocketOptions().GetRcvlowat())
|
||||
return &v, nil
|
||||
default:
|
||||
if v, err, handled := getSockOptSocketCustom(t, s, ep, name, outLen); handled {
|
||||
return v, err
|
||||
}
|
||||
}
|
||||
return nil, syserr.ErrProtocolNotAvailable
|
||||
}
|
||||
@@ -2028,6 +2032,10 @@ func setSockOptSocket(t *kernel.Task, s socket.Socket, ep commonEndpoint, name i
|
||||
v := hostarch.ByteOrder.Uint32(optVal)
|
||||
ep.SocketOptions().SetRcvlowat(int32(v))
|
||||
return nil
|
||||
default:
|
||||
if err, handled := setSockOptSocketCustom(t, s, ep, name, optVal); handled {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2024 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !false
|
||||
// +build !false
|
||||
|
||||
package netstack
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel"
|
||||
"gvisor.dev/gvisor/pkg/sentry/socket"
|
||||
"gvisor.dev/gvisor/pkg/syserr"
|
||||
)
|
||||
|
||||
// setSockOptSocketCustom handles SetSockOpt options not handled by setSockOptSocket.
|
||||
// It returns a bool indicating whether the option was handled in addition to
|
||||
// return values from setSockOptSocket.
|
||||
func setSockOptSocketCustom(t *kernel.Task, s socket.Socket, ep commonEndpoint, name int, optVal []byte) (*syserr.Error, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// getSockOptSocketCustom handles GetSockOpt options not handled by getSockOptSocket.
|
||||
// It returns a bool indicating whether the option was handled in addition to
|
||||
// return values from getSockOptSocket.
|
||||
func getSockOptSocketCustom(t *kernel.Task, s socket.Socket, ep commonEndpoint, name int, outLen int) (marshal.Marshallable, *syserr.Error, bool) {
|
||||
return nil, nil, false
|
||||
}
|
||||
Reference in New Issue
Block a user