summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/socket/netstack/netstack.go15
-rw-r--r--pkg/sentry/socket/unix/transport/transport_state_autogen.go3
-rw-r--r--pkg/sentry/socket/unix/transport/unix.go11
-rw-r--r--pkg/sentry/socket/unix/unix.go3
-rw-r--r--pkg/sentry/socket/unix/unix_state_autogen.go3
-rw-r--r--pkg/tcpip/socketops.go45
-rw-r--r--pkg/tcpip/tcpip.go11
-rw-r--r--pkg/tcpip/tcpip_state_autogen.go24
-rw-r--r--pkg/tcpip/transport/icmp/endpoint.go7
-rw-r--r--pkg/tcpip/transport/icmp/icmp_state_autogen.go3
-rw-r--r--pkg/tcpip/transport/packet/endpoint.go7
-rw-r--r--pkg/tcpip/transport/packet/packet_state_autogen.go3
-rw-r--r--pkg/tcpip/transport/raw/endpoint.go7
-rw-r--r--pkg/tcpip/transport/raw/raw_state_autogen.go3
-rw-r--r--pkg/tcpip/transport/tcp/endpoint.go20
-rw-r--r--pkg/tcpip/transport/tcp/tcp_state_autogen.go194
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go22
-rw-r--r--pkg/tcpip/transport/udp/udp_state_autogen.go58
18 files changed, 271 insertions, 168 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 86c634715..7d0ae15ca 100644
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -262,6 +262,9 @@ type commonEndpoint interface {
// LastError implements tcpip.Endpoint.LastError.
LastError() *tcpip.Error
+
+ // SocketOptions implements tcpip.Endpoint.SocketOptions.
+ SocketOptions() *tcpip.SocketOptions
}
// LINT.IfChange
@@ -1163,13 +1166,8 @@ func getSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, fam
return nil, syserr.ErrInvalidArgument
}
- v, err := ep.GetSockOptBool(tcpip.BroadcastOption)
- if err != nil {
- return nil, syserr.TranslateNetstackError(err)
- }
-
- vP := primitive.Int32(boolToInt32(v))
- return &vP, nil
+ v := primitive.Int32(boolToInt32(ep.SocketOptions().GetBroadcast()))
+ return &v, nil
case linux.SO_KEEPALIVE:
if outLen < sizeOfInt32 {
@@ -1916,7 +1914,8 @@ func setSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, nam
}
v := usermem.ByteOrder.Uint32(optVal)
- return syserr.TranslateNetstackError(ep.SetSockOptBool(tcpip.BroadcastOption, v != 0))
+ ep.SocketOptions().SetBroadcast(v != 0)
+ return nil
case linux.SO_PASSCRED:
if len(optVal) < sizeOfInt32 {
diff --git a/pkg/sentry/socket/unix/transport/transport_state_autogen.go b/pkg/sentry/socket/unix/transport/transport_state_autogen.go
index 4ec849a7f..e20168bb3 100644
--- a/pkg/sentry/socket/unix/transport/transport_state_autogen.go
+++ b/pkg/sentry/socket/unix/transport/transport_state_autogen.go
@@ -334,6 +334,7 @@ func (e *baseEndpoint) StateFields() []string {
"connected",
"path",
"linger",
+ "ops",
}
}
@@ -347,6 +348,7 @@ func (e *baseEndpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(3, &e.connected)
stateSinkObject.Save(4, &e.path)
stateSinkObject.Save(5, &e.linger)
+ stateSinkObject.Save(6, &e.ops)
}
func (e *baseEndpoint) afterLoad() {}
@@ -358,6 +360,7 @@ func (e *baseEndpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(3, &e.connected)
stateSourceObject.Load(4, &e.path)
stateSourceObject.Load(5, &e.linger)
+ stateSourceObject.Load(6, &e.ops)
}
func init() {
diff --git a/pkg/sentry/socket/unix/transport/unix.go b/pkg/sentry/socket/unix/transport/unix.go
index b648273a4..18a50e9f8 100644
--- a/pkg/sentry/socket/unix/transport/unix.go
+++ b/pkg/sentry/socket/unix/transport/unix.go
@@ -205,6 +205,9 @@ type Endpoint interface {
// LastError implements tcpip.Endpoint.LastError.
LastError() *tcpip.Error
+
+ // SocketOptions implements tcpip.Endpoint.SocketOptions.
+ SocketOptions() *tcpip.SocketOptions
}
// A Credentialer is a socket or endpoint that supports the SO_PASSCRED socket
@@ -757,6 +760,8 @@ type baseEndpoint struct {
// linger is used for SO_LINGER socket option.
linger tcpip.LingerOption
+
+ ops tcpip.SocketOptions
}
// EventRegister implements waiter.Waitable.EventRegister.
@@ -865,7 +870,6 @@ func (e *baseEndpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
func (e *baseEndpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error {
switch opt {
- case tcpip.BroadcastOption:
case tcpip.PasscredOption:
e.setPasscred(v)
case tcpip.ReuseAddressOption:
@@ -980,6 +984,11 @@ func (*baseEndpoint) LastError() *tcpip.Error {
return nil
}
+// SocketOptions implements Endpoint.SocketOptions.
+func (e *baseEndpoint) SocketOptions() *tcpip.SocketOptions {
+ return &e.ops
+}
+
// Shutdown closes the read and/or write end of the endpoint connection to its
// peer.
func (e *baseEndpoint) Shutdown(flags tcpip.ShutdownFlags) *syserr.Error {
diff --git a/pkg/sentry/socket/unix/unix.go b/pkg/sentry/socket/unix/unix.go
index b32bb7ba8..3e520d2ee 100644
--- a/pkg/sentry/socket/unix/unix.go
+++ b/pkg/sentry/socket/unix/unix.go
@@ -115,6 +115,9 @@ type socketOpsCommon struct {
// bound, they cannot be modified.
abstractName string
abstractNamespace *kernel.AbstractSocketNamespace
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
func (s *socketOpsCommon) isPacket() bool {
diff --git a/pkg/sentry/socket/unix/unix_state_autogen.go b/pkg/sentry/socket/unix/unix_state_autogen.go
index fba990d9a..9e9055b79 100644
--- a/pkg/sentry/socket/unix/unix_state_autogen.go
+++ b/pkg/sentry/socket/unix/unix_state_autogen.go
@@ -87,6 +87,7 @@ func (s *socketOpsCommon) StateFields() []string {
"stype",
"abstractName",
"abstractNamespace",
+ "ops",
}
}
@@ -99,6 +100,7 @@ func (s *socketOpsCommon) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(2, &s.stype)
stateSinkObject.Save(3, &s.abstractName)
stateSinkObject.Save(4, &s.abstractNamespace)
+ stateSinkObject.Save(5, &s.ops)
}
func (s *socketOpsCommon) afterLoad() {}
@@ -109,6 +111,7 @@ func (s *socketOpsCommon) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(2, &s.stype)
stateSourceObject.Load(3, &s.abstractName)
stateSourceObject.Load(4, &s.abstractNamespace)
+ stateSourceObject.Load(5, &s.ops)
}
func (s *SocketVFS2) StateTypeName() string {
diff --git a/pkg/tcpip/socketops.go b/pkg/tcpip/socketops.go
new file mode 100644
index 000000000..2a6c7c7c0
--- /dev/null
+++ b/pkg/tcpip/socketops.go
@@ -0,0 +1,45 @@
+// Copyright 2020 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.
+
+package tcpip
+
+import (
+ "gvisor.dev/gvisor/pkg/sync"
+)
+
+// SocketOptions contains all the variables which store values for socket
+// level options.
+//
+// +stateify savable
+type SocketOptions struct {
+ // mu protects fields below.
+ mu sync.Mutex `state:"nosave"`
+ broadcastEnabled bool
+}
+
+// GetBroadcast gets value for SO_BROADCAST option.
+func (so *SocketOptions) GetBroadcast() bool {
+ so.mu.Lock()
+ defer so.mu.Unlock()
+
+ return so.broadcastEnabled
+}
+
+// SetBroadcast sets value for SO_BROADCAST option.
+func (so *SocketOptions) SetBroadcast(v bool) {
+ so.mu.Lock()
+ defer so.mu.Unlock()
+
+ so.broadcastEnabled = v
+}
diff --git a/pkg/tcpip/tcpip.go b/pkg/tcpip/tcpip.go
index 9a0c63ae4..f9e83dd1c 100644
--- a/pkg/tcpip/tcpip.go
+++ b/pkg/tcpip/tcpip.go
@@ -634,6 +634,10 @@ type Endpoint interface {
// LastError clears and returns the last error reported by the endpoint.
LastError() *Error
+
+ // SocketOptions returns the structure which contains all the socket
+ // level options.
+ SocketOptions() *SocketOptions
}
// LinkPacketInfo holds Link layer information for a received packet.
@@ -694,15 +698,10 @@ type WriteOptions struct {
type SockOptBool int
const (
- // BroadcastOption is used by SetSockOptBool/GetSockOptBool to specify
- // whether datagram sockets are allowed to send packets to a broadcast
- // address.
- BroadcastOption SockOptBool = iota
-
// CorkOption is used by SetSockOptBool/GetSockOptBool to specify if
// data should be held until segments are full by the TCP transport
// protocol.
- CorkOption
+ CorkOption SockOptBool = iota
// DelayOption is used by SetSockOptBool/GetSockOptBool to specify if
// data should be sent out immediately by the transport protocol. For
diff --git a/pkg/tcpip/tcpip_state_autogen.go b/pkg/tcpip/tcpip_state_autogen.go
index 638637135..09aeb0f74 100644
--- a/pkg/tcpip/tcpip_state_autogen.go
+++ b/pkg/tcpip/tcpip_state_autogen.go
@@ -6,6 +6,29 @@ import (
"gvisor.dev/gvisor/pkg/state"
)
+func (so *SocketOptions) StateTypeName() string {
+ return "pkg/tcpip.SocketOptions"
+}
+
+func (so *SocketOptions) StateFields() []string {
+ return []string{
+ "broadcastEnabled",
+ }
+}
+
+func (so *SocketOptions) beforeSave() {}
+
+func (so *SocketOptions) StateSave(stateSinkObject state.Sink) {
+ so.beforeSave()
+ stateSinkObject.Save(0, &so.broadcastEnabled)
+}
+
+func (so *SocketOptions) afterLoad() {}
+
+func (so *SocketOptions) StateLoad(stateSourceObject state.Source) {
+ stateSourceObject.Load(0, &so.broadcastEnabled)
+}
+
func (f *FullAddress) StateTypeName() string {
return "pkg/tcpip.FullAddress"
}
@@ -167,6 +190,7 @@ func (i *IPPacketInfo) StateLoad(stateSourceObject state.Source) {
}
func init() {
+ state.Register((*SocketOptions)(nil))
state.Register((*FullAddress)(nil))
state.Register((*ControlMessages)(nil))
state.Register((*LinkPacketInfo)(nil))
diff --git a/pkg/tcpip/transport/icmp/endpoint.go b/pkg/tcpip/transport/icmp/endpoint.go
index 763cd8f84..440cb0352 100644
--- a/pkg/tcpip/transport/icmp/endpoint.go
+++ b/pkg/tcpip/transport/icmp/endpoint.go
@@ -79,6 +79,9 @@ type endpoint struct {
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
func newEndpoint(s *stack.Stack, netProto tcpip.NetworkProtocolNumber, transProto tcpip.TransportProtocolNumber, waiterQueue *waiter.Queue) (tcpip.Endpoint, *tcpip.Error) {
@@ -853,3 +856,7 @@ func (*endpoint) Wait() {}
func (*endpoint) LastError() *tcpip.Error {
return nil
}
+
+func (e *endpoint) SocketOptions() *tcpip.SocketOptions {
+ return &e.ops
+}
diff --git a/pkg/tcpip/transport/icmp/icmp_state_autogen.go b/pkg/tcpip/transport/icmp/icmp_state_autogen.go
index 2acf00a72..81d864da0 100644
--- a/pkg/tcpip/transport/icmp/icmp_state_autogen.go
+++ b/pkg/tcpip/transport/icmp/icmp_state_autogen.go
@@ -60,6 +60,7 @@ func (e *endpoint) StateFields() []string {
"ttl",
"linger",
"owner",
+ "ops",
}
}
@@ -80,6 +81,7 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(11, &e.ttl)
stateSinkObject.Save(12, &e.linger)
stateSinkObject.Save(13, &e.owner)
+ stateSinkObject.Save(14, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -96,6 +98,7 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(11, &e.ttl)
stateSourceObject.Load(12, &e.linger)
stateSourceObject.Load(13, &e.owner)
+ stateSourceObject.Load(14, &e.ops)
stateSourceObject.LoadValue(5, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.AfterLoad(e.afterLoad)
}
diff --git a/pkg/tcpip/transport/packet/endpoint.go b/pkg/tcpip/transport/packet/endpoint.go
index 31831a6d8..3bff3755a 100644
--- a/pkg/tcpip/transport/packet/endpoint.go
+++ b/pkg/tcpip/transport/packet/endpoint.go
@@ -89,6 +89,9 @@ type endpoint struct {
// lastErrorMu protects lastError.
lastErrorMu sync.Mutex `state:"nosave"`
lastError *tcpip.Error `state:".(string)"`
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
// NewEndpoint returns a new packet endpoint.
@@ -549,3 +552,7 @@ func (ep *endpoint) Stats() tcpip.EndpointStats {
}
func (ep *endpoint) SetOwner(owner tcpip.PacketOwner) {}
+
+func (ep *endpoint) SocketOptions() *tcpip.SocketOptions {
+ return &ep.ops
+}
diff --git a/pkg/tcpip/transport/packet/packet_state_autogen.go b/pkg/tcpip/transport/packet/packet_state_autogen.go
index 66b6a4cc2..2ce71eb84 100644
--- a/pkg/tcpip/transport/packet/packet_state_autogen.go
+++ b/pkg/tcpip/transport/packet/packet_state_autogen.go
@@ -64,6 +64,7 @@ func (ep *endpoint) StateFields() []string {
"boundNIC",
"linger",
"lastError",
+ "ops",
}
}
@@ -86,6 +87,7 @@ func (ep *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(11, &ep.bound)
stateSinkObject.Save(12, &ep.boundNIC)
stateSinkObject.Save(13, &ep.linger)
+ stateSinkObject.Save(15, &ep.ops)
}
func (ep *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -102,6 +104,7 @@ func (ep *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(11, &ep.bound)
stateSourceObject.Load(12, &ep.boundNIC)
stateSourceObject.Load(13, &ep.linger)
+ stateSourceObject.Load(15, &ep.ops)
stateSourceObject.LoadValue(5, new(int), func(y interface{}) { ep.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.LoadValue(14, new(string), func(y interface{}) { ep.loadLastError(y.(string)) })
stateSourceObject.AfterLoad(ep.afterLoad)
diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go
index 7b6a87ba9..4ae1f92ab 100644
--- a/pkg/tcpip/transport/raw/endpoint.go
+++ b/pkg/tcpip/transport/raw/endpoint.go
@@ -89,6 +89,9 @@ type endpoint struct {
// owner is used to get uid and gid of the packet.
owner tcpip.PacketOwner
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
// NewEndpoint returns a raw endpoint for the given protocols.
@@ -756,3 +759,7 @@ func (*endpoint) Wait() {}
func (*endpoint) LastError() *tcpip.Error {
return nil
}
+
+func (e *endpoint) SocketOptions() *tcpip.SocketOptions {
+ return &e.ops
+}
diff --git a/pkg/tcpip/transport/raw/raw_state_autogen.go b/pkg/tcpip/transport/raw/raw_state_autogen.go
index 7a5831bf3..26fc86a27 100644
--- a/pkg/tcpip/transport/raw/raw_state_autogen.go
+++ b/pkg/tcpip/transport/raw/raw_state_autogen.go
@@ -61,6 +61,7 @@ func (e *endpoint) StateFields() []string {
"bound",
"linger",
"owner",
+ "ops",
}
}
@@ -82,6 +83,7 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(12, &e.bound)
stateSinkObject.Save(13, &e.linger)
stateSinkObject.Save(14, &e.owner)
+ stateSinkObject.Save(15, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -99,6 +101,7 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(12, &e.bound)
stateSourceObject.Load(13, &e.linger)
stateSourceObject.Load(14, &e.owner)
+ stateSourceObject.Load(15, &e.ops)
stateSourceObject.LoadValue(6, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
stateSourceObject.AfterLoad(e.afterLoad)
}
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go
index 23b9de8c5..194d3a8a4 100644
--- a/pkg/tcpip/transport/tcp/endpoint.go
+++ b/pkg/tcpip/transport/tcp/endpoint.go
@@ -440,9 +440,6 @@ type endpoint struct {
ttl uint8
v6only bool
isConnectNotified bool
- // TCP should never broadcast but Linux nevertheless supports enabling/
- // disabling SO_BROADCAST, albeit as a NOOP.
- broadcast bool
// portFlags stores the current values of port related flags.
portFlags ports.Flags
@@ -685,6 +682,9 @@ type endpoint struct {
// linger is used for SO_LINGER socket option.
linger tcpip.LingerOption
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
// UniqueID implements stack.TransportEndpoint.UniqueID.
@@ -1599,11 +1599,6 @@ func (e *endpoint) windowCrossedACKThresholdLocked(deltaBefore int) (crossed boo
func (e *endpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error {
switch opt {
- case tcpip.BroadcastOption:
- e.LockUser()
- e.broadcast = v
- e.UnlockUser()
-
case tcpip.CorkOption:
e.LockUser()
if !v {
@@ -1950,11 +1945,6 @@ func (e *endpoint) readyReceiveSize() (int, *tcpip.Error) {
// GetSockOptBool implements tcpip.Endpoint.GetSockOptBool.
func (e *endpoint) GetSockOptBool(opt tcpip.SockOptBool) (bool, *tcpip.Error) {
switch opt {
- case tcpip.BroadcastOption:
- e.LockUser()
- v := e.broadcast
- e.UnlockUser()
- return v, nil
case tcpip.CorkOption:
return atomic.LoadUint32(&e.cork) != 0, nil
@@ -3130,3 +3120,7 @@ func (e *endpoint) Wait() {
<-notifyCh
}
}
+
+func (e *endpoint) SocketOptions() *tcpip.SocketOptions {
+ return &e.ops
+}
diff --git a/pkg/tcpip/transport/tcp/tcp_state_autogen.go b/pkg/tcpip/transport/tcp/tcp_state_autogen.go
index 8782316f2..2a2960d80 100644
--- a/pkg/tcpip/transport/tcp/tcp_state_autogen.go
+++ b/pkg/tcpip/transport/tcp/tcp_state_autogen.go
@@ -176,7 +176,6 @@ func (e *endpoint) StateFields() []string {
"ttl",
"v6only",
"isConnectNotified",
- "broadcast",
"portFlags",
"boundBindToDevice",
"boundPortFlags",
@@ -224,6 +223,7 @@ func (e *endpoint) StateFields() []string {
"txHash",
"owner",
"linger",
+ "ops",
}
}
@@ -234,9 +234,9 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
var stateValue EndpointState = e.saveState()
stateSinkObject.SaveValue(11, stateValue)
var recentTSTimeValue unixTime = e.saveRecentTSTime()
- stateSinkObject.SaveValue(26, recentTSTimeValue)
+ stateSinkObject.SaveValue(25, recentTSTimeValue)
var acceptedChanValue []*endpoint = e.saveAcceptedChan()
- stateSinkObject.SaveValue(52, acceptedChanValue)
+ stateSinkObject.SaveValue(51, acceptedChanValue)
stateSinkObject.Save(0, &e.EndpointInfo)
stateSinkObject.Save(1, &e.waiterQueue)
stateSinkObject.Save(2, &e.uniqueID)
@@ -251,52 +251,52 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(13, &e.ttl)
stateSinkObject.Save(14, &e.v6only)
stateSinkObject.Save(15, &e.isConnectNotified)
- stateSinkObject.Save(16, &e.broadcast)
- stateSinkObject.Save(17, &e.portFlags)
- stateSinkObject.Save(18, &e.boundBindToDevice)
- stateSinkObject.Save(19, &e.boundPortFlags)
- stateSinkObject.Save(20, &e.boundDest)
- stateSinkObject.Save(21, &e.effectiveNetProtos)
- stateSinkObject.Save(22, &e.workerRunning)
- stateSinkObject.Save(23, &e.workerCleanup)
- stateSinkObject.Save(24, &e.sendTSOk)
- stateSinkObject.Save(25, &e.recentTS)
- stateSinkObject.Save(27, &e.tsOffset)
- stateSinkObject.Save(28, &e.shutdownFlags)
- stateSinkObject.Save(29, &e.sackPermitted)
- stateSinkObject.Save(30, &e.sack)
- stateSinkObject.Save(31, &e.bindToDevice)
- stateSinkObject.Save(32, &e.delay)
- stateSinkObject.Save(33, &e.cork)
- stateSinkObject.Save(34, &e.scoreboard)
- stateSinkObject.Save(35, &e.slowAck)
- stateSinkObject.Save(36, &e.segmentQueue)
- stateSinkObject.Save(37, &e.synRcvdCount)
- stateSinkObject.Save(38, &e.userMSS)
- stateSinkObject.Save(39, &e.maxSynRetries)
- stateSinkObject.Save(40, &e.windowClamp)
- stateSinkObject.Save(41, &e.sndBufSize)
- stateSinkObject.Save(42, &e.sndBufUsed)
- stateSinkObject.Save(43, &e.sndClosed)
- stateSinkObject.Save(44, &e.sndBufInQueue)
- stateSinkObject.Save(45, &e.sndQueue)
- stateSinkObject.Save(46, &e.cc)
- stateSinkObject.Save(47, &e.packetTooBigCount)
- stateSinkObject.Save(48, &e.sndMTU)
- stateSinkObject.Save(49, &e.keepalive)
- stateSinkObject.Save(50, &e.userTimeout)
- stateSinkObject.Save(51, &e.deferAccept)
- stateSinkObject.Save(53, &e.rcv)
- stateSinkObject.Save(54, &e.snd)
- stateSinkObject.Save(55, &e.connectingAddress)
- stateSinkObject.Save(56, &e.amss)
- stateSinkObject.Save(57, &e.sendTOS)
- stateSinkObject.Save(58, &e.gso)
- stateSinkObject.Save(59, &e.tcpLingerTimeout)
- stateSinkObject.Save(60, &e.closed)
- stateSinkObject.Save(61, &e.txHash)
- stateSinkObject.Save(62, &e.owner)
- stateSinkObject.Save(63, &e.linger)
+ stateSinkObject.Save(16, &e.portFlags)
+ stateSinkObject.Save(17, &e.boundBindToDevice)
+ stateSinkObject.Save(18, &e.boundPortFlags)
+ stateSinkObject.Save(19, &e.boundDest)
+ stateSinkObject.Save(20, &e.effectiveNetProtos)
+ stateSinkObject.Save(21, &e.workerRunning)
+ stateSinkObject.Save(22, &e.workerCleanup)
+ stateSinkObject.Save(23, &e.sendTSOk)
+ stateSinkObject.Save(24, &e.recentTS)
+ stateSinkObject.Save(26, &e.tsOffset)
+ stateSinkObject.Save(27, &e.shutdownFlags)
+ stateSinkObject.Save(28, &e.sackPermitted)
+ stateSinkObject.Save(29, &e.sack)
+ stateSinkObject.Save(30, &e.bindToDevice)
+ stateSinkObject.Save(31, &e.delay)
+ stateSinkObject.Save(32, &e.cork)
+ stateSinkObject.Save(33, &e.scoreboard)
+ stateSinkObject.Save(34, &e.slowAck)
+ stateSinkObject.Save(35, &e.segmentQueue)
+ stateSinkObject.Save(36, &e.synRcvdCount)
+ stateSinkObject.Save(37, &e.userMSS)
+ stateSinkObject.Save(38, &e.maxSynRetries)
+ stateSinkObject.Save(39, &e.windowClamp)
+ stateSinkObject.Save(40, &e.sndBufSize)
+ stateSinkObject.Save(41, &e.sndBufUsed)
+ stateSinkObject.Save(42, &e.sndClosed)
+ stateSinkObject.Save(43, &e.sndBufInQueue)
+ stateSinkObject.Save(44, &e.sndQueue)
+ stateSinkObject.Save(45, &e.cc)
+ stateSinkObject.Save(46, &e.packetTooBigCount)
+ stateSinkObject.Save(47, &e.sndMTU)
+ stateSinkObject.Save(48, &e.keepalive)
+ stateSinkObject.Save(49, &e.userTimeout)
+ stateSinkObject.Save(50, &e.deferAccept)
+ stateSinkObject.Save(52, &e.rcv)
+ stateSinkObject.Save(53, &e.snd)
+ stateSinkObject.Save(54, &e.connectingAddress)
+ stateSinkObject.Save(55, &e.amss)
+ stateSinkObject.Save(56, &e.sendTOS)
+ stateSinkObject.Save(57, &e.gso)
+ stateSinkObject.Save(58, &e.tcpLingerTimeout)
+ stateSinkObject.Save(59, &e.closed)
+ stateSinkObject.Save(60, &e.txHash)
+ stateSinkObject.Save(61, &e.owner)
+ stateSinkObject.Save(62, &e.linger)
+ stateSinkObject.Save(63, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -314,56 +314,56 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(13, &e.ttl)
stateSourceObject.Load(14, &e.v6only)
stateSourceObject.Load(15, &e.isConnectNotified)
- stateSourceObject.Load(16, &e.broadcast)
- stateSourceObject.Load(17, &e.portFlags)
- stateSourceObject.Load(18, &e.boundBindToDevice)
- stateSourceObject.Load(19, &e.boundPortFlags)
- stateSourceObject.Load(20, &e.boundDest)
- stateSourceObject.Load(21, &e.effectiveNetProtos)
- stateSourceObject.Load(22, &e.workerRunning)
- stateSourceObject.Load(23, &e.workerCleanup)
- stateSourceObject.Load(24, &e.sendTSOk)
- stateSourceObject.Load(25, &e.recentTS)
- stateSourceObject.Load(27, &e.tsOffset)
- stateSourceObject.Load(28, &e.shutdownFlags)
- stateSourceObject.Load(29, &e.sackPermitted)
- stateSourceObject.Load(30, &e.sack)
- stateSourceObject.Load(31, &e.bindToDevice)
- stateSourceObject.Load(32, &e.delay)
- stateSourceObject.Load(33, &e.cork)
- stateSourceObject.Load(34, &e.scoreboard)
- stateSourceObject.Load(35, &e.slowAck)
- stateSourceObject.LoadWait(36, &e.segmentQueue)
- stateSourceObject.Load(37, &e.synRcvdCount)
- stateSourceObject.Load(38, &e.userMSS)
- stateSourceObject.Load(39, &e.maxSynRetries)
- stateSourceObject.Load(40, &e.windowClamp)
- stateSourceObject.Load(41, &e.sndBufSize)
- stateSourceObject.Load(42, &e.sndBufUsed)
- stateSourceObject.Load(43, &e.sndClosed)
- stateSourceObject.Load(44, &e.sndBufInQueue)
- stateSourceObject.LoadWait(45, &e.sndQueue)
- stateSourceObject.Load(46, &e.cc)
- stateSourceObject.Load(47, &e.packetTooBigCount)
- stateSourceObject.Load(48, &e.sndMTU)
- stateSourceObject.Load(49, &e.keepalive)
- stateSourceObject.Load(50, &e.userTimeout)
- stateSourceObject.Load(51, &e.deferAccept)
- stateSourceObject.LoadWait(53, &e.rcv)
- stateSourceObject.LoadWait(54, &e.snd)
- stateSourceObject.Load(55, &e.connectingAddress)
- stateSourceObject.Load(56, &e.amss)
- stateSourceObject.Load(57, &e.sendTOS)
- stateSourceObject.Load(58, &e.gso)
- stateSourceObject.Load(59, &e.tcpLingerTimeout)
- stateSourceObject.Load(60, &e.closed)
- stateSourceObject.Load(61, &e.txHash)
- stateSourceObject.Load(62, &e.owner)
- stateSourceObject.Load(63, &e.linger)
+ stateSourceObject.Load(16, &e.portFlags)
+ stateSourceObject.Load(17, &e.boundBindToDevice)
+ stateSourceObject.Load(18, &e.boundPortFlags)
+ stateSourceObject.Load(19, &e.boundDest)
+ stateSourceObject.Load(20, &e.effectiveNetProtos)
+ stateSourceObject.Load(21, &e.workerRunning)
+ stateSourceObject.Load(22, &e.workerCleanup)
+ stateSourceObject.Load(23, &e.sendTSOk)
+ stateSourceObject.Load(24, &e.recentTS)
+ stateSourceObject.Load(26, &e.tsOffset)
+ stateSourceObject.Load(27, &e.shutdownFlags)
+ stateSourceObject.Load(28, &e.sackPermitted)
+ stateSourceObject.Load(29, &e.sack)
+ stateSourceObject.Load(30, &e.bindToDevice)
+ stateSourceObject.Load(31, &e.delay)
+ stateSourceObject.Load(32, &e.cork)
+ stateSourceObject.Load(33, &e.scoreboard)
+ stateSourceObject.Load(34, &e.slowAck)
+ stateSourceObject.LoadWait(35, &e.segmentQueue)
+ stateSourceObject.Load(36, &e.synRcvdCount)
+ stateSourceObject.Load(37, &e.userMSS)
+ stateSourceObject.Load(38, &e.maxSynRetries)
+ stateSourceObject.Load(39, &e.windowClamp)
+ stateSourceObject.Load(40, &e.sndBufSize)
+ stateSourceObject.Load(41, &e.sndBufUsed)
+ stateSourceObject.Load(42, &e.sndClosed)
+ stateSourceObject.Load(43, &e.sndBufInQueue)
+ stateSourceObject.LoadWait(44, &e.sndQueue)
+ stateSourceObject.Load(45, &e.cc)
+ stateSourceObject.Load(46, &e.packetTooBigCount)
+ stateSourceObject.Load(47, &e.sndMTU)
+ stateSourceObject.Load(48, &e.keepalive)
+ stateSourceObject.Load(49, &e.userTimeout)
+ stateSourceObject.Load(50, &e.deferAccept)
+ stateSourceObject.LoadWait(52, &e.rcv)
+ stateSourceObject.LoadWait(53, &e.snd)
+ stateSourceObject.Load(54, &e.connectingAddress)
+ stateSourceObject.Load(55, &e.amss)
+ stateSourceObject.Load(56, &e.sendTOS)
+ stateSourceObject.Load(57, &e.gso)
+ stateSourceObject.Load(58, &e.tcpLingerTimeout)
+ stateSourceObject.Load(59, &e.closed)
+ stateSourceObject.Load(60, &e.txHash)
+ stateSourceObject.Load(61, &e.owner)
+ stateSourceObject.Load(62, &e.linger)
+ stateSourceObject.Load(63, &e.ops)
stateSourceObject.LoadValue(3, new(string), func(y interface{}) { e.loadLastError(y.(string)) })
stateSourceObject.LoadValue(11, new(EndpointState), func(y interface{}) { e.loadState(y.(EndpointState)) })
- stateSourceObject.LoadValue(26, new(unixTime), func(y interface{}) { e.loadRecentTSTime(y.(unixTime)) })
- stateSourceObject.LoadValue(52, new([]*endpoint), func(y interface{}) { e.loadAcceptedChan(y.([]*endpoint)) })
+ stateSourceObject.LoadValue(25, new(unixTime), func(y interface{}) { e.loadRecentTSTime(y.(unixTime)) })
+ stateSourceObject.LoadValue(51, new([]*endpoint), func(y interface{}) { e.loadAcceptedChan(y.([]*endpoint)) })
stateSourceObject.AfterLoad(e.afterLoad)
}
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index 9bcb918bb..57976d4e3 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -108,7 +108,6 @@ type endpoint struct {
multicastLoop bool
portFlags ports.Flags
bindToDevice tcpip.NICID
- broadcast bool
noChecksum bool
lastErrorMu sync.Mutex `state:"nosave"`
@@ -157,6 +156,9 @@ type endpoint struct {
// linger is used for SO_LINGER socket option.
linger tcpip.LingerOption
+
+ // ops is used to get socket level options.
+ ops tcpip.SocketOptions
}
// +stateify savable
@@ -508,7 +510,7 @@ func (e *endpoint) write(p tcpip.Payloader, opts tcpip.WriteOptions) (int64, <-c
resolve = route.Resolve
}
- if !e.broadcast && route.IsOutboundBroadcast() {
+ if !e.ops.GetBroadcast() && route.IsOutboundBroadcast() {
return 0, nil, tcpip.ErrBroadcastDisabled
}
@@ -553,11 +555,6 @@ func (e *endpoint) Peek([][]byte) (int64, tcpip.ControlMessages, *tcpip.Error) {
// SetSockOptBool implements tcpip.Endpoint.SetSockOptBool.
func (e *endpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error {
switch opt {
- case tcpip.BroadcastOption:
- e.mu.Lock()
- e.broadcast = v
- e.mu.Unlock()
-
case tcpip.MulticastLoopOption:
e.mu.Lock()
e.multicastLoop = v
@@ -614,7 +611,6 @@ func (e *endpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error {
e.v6only = v
}
-
return nil
}
@@ -830,12 +826,6 @@ func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
// GetSockOptBool implements tcpip.Endpoint.GetSockOptBool.
func (e *endpoint) GetSockOptBool(opt tcpip.SockOptBool) (bool, *tcpip.Error) {
switch opt {
- case tcpip.BroadcastOption:
- e.mu.RLock()
- v := e.broadcast
- e.mu.RUnlock()
- return v, nil
-
case tcpip.KeepaliveEnabledOption:
return false, nil
@@ -1525,3 +1515,7 @@ func isBroadcastOrMulticast(a tcpip.Address) bool {
func (e *endpoint) SetOwner(owner tcpip.PacketOwner) {
e.owner = owner
}
+
+func (e *endpoint) SocketOptions() *tcpip.SocketOptions {
+ return &e.ops
+}
diff --git a/pkg/tcpip/transport/udp/udp_state_autogen.go b/pkg/tcpip/transport/udp/udp_state_autogen.go
index 06d025590..6a715cc10 100644
--- a/pkg/tcpip/transport/udp/udp_state_autogen.go
+++ b/pkg/tcpip/transport/udp/udp_state_autogen.go
@@ -72,7 +72,6 @@ func (e *endpoint) StateFields() []string {
"multicastLoop",
"portFlags",
"bindToDevice",
- "broadcast",
"noChecksum",
"lastError",
"boundBindToDevice",
@@ -86,6 +85,7 @@ func (e *endpoint) StateFields() []string {
"effectiveNetProtos",
"owner",
"linger",
+ "ops",
}
}
@@ -94,7 +94,7 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
var rcvBufSizeMaxValue int = e.saveRcvBufSizeMax()
stateSinkObject.SaveValue(5, rcvBufSizeMaxValue)
var lastErrorValue string = e.saveLastError()
- stateSinkObject.SaveValue(22, lastErrorValue)
+ stateSinkObject.SaveValue(21, lastErrorValue)
stateSinkObject.Save(0, &e.TransportEndpointInfo)
stateSinkObject.Save(1, &e.waiterQueue)
stateSinkObject.Save(2, &e.uniqueID)
@@ -114,19 +114,19 @@ func (e *endpoint) StateSave(stateSinkObject state.Sink) {
stateSinkObject.Save(17, &e.multicastLoop)
stateSinkObject.Save(18, &e.portFlags)
stateSinkObject.Save(19, &e.bindToDevice)
- stateSinkObject.Save(20, &e.broadcast)
- stateSinkObject.Save(21, &e.noChecksum)
- stateSinkObject.Save(23, &e.boundBindToDevice)
- stateSinkObject.Save(24, &e.boundPortFlags)
- stateSinkObject.Save(25, &e.sendTOS)
- stateSinkObject.Save(26, &e.receiveTOS)
- stateSinkObject.Save(27, &e.receiveTClass)
- stateSinkObject.Save(28, &e.receiveIPPacketInfo)
- stateSinkObject.Save(29, &e.shutdownFlags)
- stateSinkObject.Save(30, &e.multicastMemberships)
- stateSinkObject.Save(31, &e.effectiveNetProtos)
- stateSinkObject.Save(32, &e.owner)
- stateSinkObject.Save(33, &e.linger)
+ stateSinkObject.Save(20, &e.noChecksum)
+ stateSinkObject.Save(22, &e.boundBindToDevice)
+ stateSinkObject.Save(23, &e.boundPortFlags)
+ stateSinkObject.Save(24, &e.sendTOS)
+ stateSinkObject.Save(25, &e.receiveTOS)
+ stateSinkObject.Save(26, &e.receiveTClass)
+ stateSinkObject.Save(27, &e.receiveIPPacketInfo)
+ stateSinkObject.Save(28, &e.shutdownFlags)
+ stateSinkObject.Save(29, &e.multicastMemberships)
+ stateSinkObject.Save(30, &e.effectiveNetProtos)
+ stateSinkObject.Save(31, &e.owner)
+ stateSinkObject.Save(32, &e.linger)
+ stateSinkObject.Save(33, &e.ops)
}
func (e *endpoint) StateLoad(stateSourceObject state.Source) {
@@ -149,21 +149,21 @@ func (e *endpoint) StateLoad(stateSourceObject state.Source) {
stateSourceObject.Load(17, &e.multicastLoop)
stateSourceObject.Load(18, &e.portFlags)
stateSourceObject.Load(19, &e.bindToDevice)
- stateSourceObject.Load(20, &e.broadcast)
- stateSourceObject.Load(21, &e.noChecksum)
- stateSourceObject.Load(23, &e.boundBindToDevice)
- stateSourceObject.Load(24, &e.boundPortFlags)
- stateSourceObject.Load(25, &e.sendTOS)
- stateSourceObject.Load(26, &e.receiveTOS)
- stateSourceObject.Load(27, &e.receiveTClass)
- stateSourceObject.Load(28, &e.receiveIPPacketInfo)
- stateSourceObject.Load(29, &e.shutdownFlags)
- stateSourceObject.Load(30, &e.multicastMemberships)
- stateSourceObject.Load(31, &e.effectiveNetProtos)
- stateSourceObject.Load(32, &e.owner)
- stateSourceObject.Load(33, &e.linger)
+ stateSourceObject.Load(20, &e.noChecksum)
+ stateSourceObject.Load(22, &e.boundBindToDevice)
+ stateSourceObject.Load(23, &e.boundPortFlags)
+ stateSourceObject.Load(24, &e.sendTOS)
+ stateSourceObject.Load(25, &e.receiveTOS)
+ stateSourceObject.Load(26, &e.receiveTClass)
+ stateSourceObject.Load(27, &e.receiveIPPacketInfo)
+ stateSourceObject.Load(28, &e.shutdownFlags)
+ stateSourceObject.Load(29, &e.multicastMemberships)
+ stateSourceObject.Load(30, &e.effectiveNetProtos)
+ stateSourceObject.Load(31, &e.owner)
+ stateSourceObject.Load(32, &e.linger)
+ stateSourceObject.Load(33, &e.ops)
stateSourceObject.LoadValue(5, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) })
- stateSourceObject.LoadValue(22, new(string), func(y interface{}) { e.loadLastError(y.(string)) })
+ stateSourceObject.LoadValue(21, new(string), func(y interface{}) { e.loadLastError(y.(string)) })
stateSourceObject.AfterLoad(e.afterLoad)
}