diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-11-13 07:00:09 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-13 07:00:09 +0000 |
commit | f560fd07ef27eef3027f03e93e2c958375d60dd7 (patch) | |
tree | 38c9c19a5948edaa06ab43454fb38a96d9f9531d /pkg/tcpip/transport/udp | |
parent | f942d232b2c93d40a7af7007a8490c51d663e7f5 (diff) | |
parent | 5bb64ce1b8c42fcd96e44a5be05e17f34a83f840 (diff) |
Merge release-20201030.0-83-g5bb64ce1b (automated)
Diffstat (limited to 'pkg/tcpip/transport/udp')
-rw-r--r-- | pkg/tcpip/transport/udp/endpoint.go | 22 | ||||
-rw-r--r-- | pkg/tcpip/transport/udp/udp_state_autogen.go | 58 |
2 files changed, 37 insertions, 43 deletions
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) } |