diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-11-18 22:39:51 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-18 22:39:51 +0000 |
commit | 0e43c0c8fb48ec92a81599b016d35a28e9e0f168 (patch) | |
tree | f150ad2d41e4eb59e4cead6f51bfd6327243a5c6 /pkg/tcpip/transport/udp | |
parent | 3cae5fbf49773ca2ec7b2ea5163899a3965ff504 (diff) | |
parent | df37babd576ba4607e2fe69eb2c669aa2954b9cb (diff) |
Merge release-20201109.0-79-gdf37babd5 (automated)
Diffstat (limited to 'pkg/tcpip/transport/udp')
-rw-r--r-- | pkg/tcpip/transport/udp/endpoint.go | 40 | ||||
-rw-r--r-- | pkg/tcpip/transport/udp/udp_state_autogen.go | 131 |
2 files changed, 83 insertions, 88 deletions
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go index 5aa16bf35..e57833644 100644 --- a/pkg/tcpip/transport/udp/endpoint.go +++ b/pkg/tcpip/transport/udp/endpoint.go @@ -77,6 +77,7 @@ func (s EndpointState) String() string { // +stateify savable type endpoint struct { stack.TransportEndpointInfo + tcpip.DefaultSocketOptionsHandler // The following fields are initialized at creation time and do not // change throughout the lifetime of the endpoint. @@ -194,6 +195,7 @@ func newEndpoint(s *stack.Stack, netProto tcpip.NetworkProtocolNumber, waiterQue state: StateInitial, uniqueID: s.UniqueID(), } + e.ops.InitHandler(e) // Override with stack defaults. var ss stack.SendBufferSizeOption @@ -574,6 +576,20 @@ func (e *endpoint) Peek([][]byte) (int64, tcpip.ControlMessages, *tcpip.Error) { return 0, tcpip.ControlMessages{}, nil } +// OnReuseAddressSet implements tcpip.SocketOptionsHandler.OnReuseAddressSet. +func (e *endpoint) OnReuseAddressSet(v bool) { + e.mu.Lock() + e.portFlags.MostRecent = v + e.mu.Unlock() +} + +// OnReusePortSet implements tcpip.SocketOptionsHandler.OnReusePortSet. +func (e *endpoint) OnReusePortSet(v bool) { + e.mu.Lock() + e.portFlags.LoadBalanced = v + e.mu.Unlock() +} + // SetSockOptBool implements tcpip.Endpoint.SetSockOptBool. func (e *endpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error { switch opt { @@ -602,16 +618,6 @@ func (e *endpoint) SetSockOptBool(opt tcpip.SockOptBool, v bool) *tcpip.Error { e.receiveIPPacketInfo = v e.mu.Unlock() - case tcpip.ReuseAddressOption: - e.mu.Lock() - e.portFlags.MostRecent = v - e.mu.Unlock() - - case tcpip.ReusePortOption: - e.mu.Lock() - e.portFlags.LoadBalanced = v - e.mu.Unlock() - case tcpip.V6OnlyOption: // We only recognize this option on v6 endpoints. if e.NetProto != header.IPv6ProtocolNumber { @@ -875,20 +881,6 @@ func (e *endpoint) GetSockOptBool(opt tcpip.SockOptBool) (bool, *tcpip.Error) { e.mu.RUnlock() return v, nil - case tcpip.ReuseAddressOption: - e.mu.RLock() - v := e.portFlags.MostRecent - e.mu.RUnlock() - - return v, nil - - case tcpip.ReusePortOption: - e.mu.RLock() - v := e.portFlags.LoadBalanced - e.mu.RUnlock() - - return v, nil - case tcpip.V6OnlyOption: // We only recognize this option on v6 endpoints. if e.NetProto != header.IPv6ProtocolNumber { diff --git a/pkg/tcpip/transport/udp/udp_state_autogen.go b/pkg/tcpip/transport/udp/udp_state_autogen.go index 9350a4809..cb05b5cd8 100644 --- a/pkg/tcpip/transport/udp/udp_state_autogen.go +++ b/pkg/tcpip/transport/udp/udp_state_autogen.go @@ -53,6 +53,7 @@ func (e *endpoint) StateTypeName() string { func (e *endpoint) StateFields() []string { return []string{ "TransportEndpointInfo", + "DefaultSocketOptionsHandler", "waiterQueue", "uniqueID", "rcvReady", @@ -91,76 +92,78 @@ func (e *endpoint) StateFields() []string { func (e *endpoint) StateSave(stateSinkObject state.Sink) { e.beforeSave() var rcvBufSizeMaxValue int = e.saveRcvBufSizeMax() - stateSinkObject.SaveValue(5, rcvBufSizeMaxValue) + stateSinkObject.SaveValue(6, rcvBufSizeMaxValue) var lastErrorValue string = e.saveLastError() - stateSinkObject.SaveValue(20, lastErrorValue) + stateSinkObject.SaveValue(21, lastErrorValue) stateSinkObject.Save(0, &e.TransportEndpointInfo) - stateSinkObject.Save(1, &e.waiterQueue) - stateSinkObject.Save(2, &e.uniqueID) - stateSinkObject.Save(3, &e.rcvReady) - stateSinkObject.Save(4, &e.rcvList) - stateSinkObject.Save(6, &e.rcvBufSize) - stateSinkObject.Save(7, &e.rcvClosed) - stateSinkObject.Save(8, &e.sndBufSize) - stateSinkObject.Save(9, &e.sndBufSizeMax) - stateSinkObject.Save(10, &e.state) - stateSinkObject.Save(11, &e.dstPort) - stateSinkObject.Save(12, &e.v6only) - stateSinkObject.Save(13, &e.ttl) - stateSinkObject.Save(14, &e.multicastTTL) - stateSinkObject.Save(15, &e.multicastAddr) - stateSinkObject.Save(16, &e.multicastNICID) - stateSinkObject.Save(17, &e.multicastLoop) - stateSinkObject.Save(18, &e.portFlags) - stateSinkObject.Save(19, &e.bindToDevice) - stateSinkObject.Save(21, &e.boundBindToDevice) - stateSinkObject.Save(22, &e.boundPortFlags) - stateSinkObject.Save(23, &e.sendTOS) - stateSinkObject.Save(24, &e.receiveTOS) - stateSinkObject.Save(25, &e.receiveTClass) - stateSinkObject.Save(26, &e.receiveIPPacketInfo) - stateSinkObject.Save(27, &e.shutdownFlags) - stateSinkObject.Save(28, &e.multicastMemberships) - stateSinkObject.Save(29, &e.effectiveNetProtos) - stateSinkObject.Save(30, &e.owner) - stateSinkObject.Save(31, &e.linger) - stateSinkObject.Save(32, &e.ops) + stateSinkObject.Save(1, &e.DefaultSocketOptionsHandler) + stateSinkObject.Save(2, &e.waiterQueue) + stateSinkObject.Save(3, &e.uniqueID) + stateSinkObject.Save(4, &e.rcvReady) + stateSinkObject.Save(5, &e.rcvList) + stateSinkObject.Save(7, &e.rcvBufSize) + stateSinkObject.Save(8, &e.rcvClosed) + stateSinkObject.Save(9, &e.sndBufSize) + stateSinkObject.Save(10, &e.sndBufSizeMax) + stateSinkObject.Save(11, &e.state) + stateSinkObject.Save(12, &e.dstPort) + stateSinkObject.Save(13, &e.v6only) + stateSinkObject.Save(14, &e.ttl) + stateSinkObject.Save(15, &e.multicastTTL) + stateSinkObject.Save(16, &e.multicastAddr) + stateSinkObject.Save(17, &e.multicastNICID) + stateSinkObject.Save(18, &e.multicastLoop) + stateSinkObject.Save(19, &e.portFlags) + stateSinkObject.Save(20, &e.bindToDevice) + 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) { stateSourceObject.Load(0, &e.TransportEndpointInfo) - stateSourceObject.Load(1, &e.waiterQueue) - stateSourceObject.Load(2, &e.uniqueID) - stateSourceObject.Load(3, &e.rcvReady) - stateSourceObject.Load(4, &e.rcvList) - stateSourceObject.Load(6, &e.rcvBufSize) - stateSourceObject.Load(7, &e.rcvClosed) - stateSourceObject.Load(8, &e.sndBufSize) - stateSourceObject.Load(9, &e.sndBufSizeMax) - stateSourceObject.Load(10, &e.state) - stateSourceObject.Load(11, &e.dstPort) - stateSourceObject.Load(12, &e.v6only) - stateSourceObject.Load(13, &e.ttl) - stateSourceObject.Load(14, &e.multicastTTL) - stateSourceObject.Load(15, &e.multicastAddr) - stateSourceObject.Load(16, &e.multicastNICID) - stateSourceObject.Load(17, &e.multicastLoop) - stateSourceObject.Load(18, &e.portFlags) - stateSourceObject.Load(19, &e.bindToDevice) - stateSourceObject.Load(21, &e.boundBindToDevice) - stateSourceObject.Load(22, &e.boundPortFlags) - stateSourceObject.Load(23, &e.sendTOS) - stateSourceObject.Load(24, &e.receiveTOS) - stateSourceObject.Load(25, &e.receiveTClass) - stateSourceObject.Load(26, &e.receiveIPPacketInfo) - stateSourceObject.Load(27, &e.shutdownFlags) - stateSourceObject.Load(28, &e.multicastMemberships) - stateSourceObject.Load(29, &e.effectiveNetProtos) - stateSourceObject.Load(30, &e.owner) - stateSourceObject.Load(31, &e.linger) - stateSourceObject.Load(32, &e.ops) - stateSourceObject.LoadValue(5, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) }) - stateSourceObject.LoadValue(20, new(string), func(y interface{}) { e.loadLastError(y.(string)) }) + stateSourceObject.Load(1, &e.DefaultSocketOptionsHandler) + stateSourceObject.Load(2, &e.waiterQueue) + stateSourceObject.Load(3, &e.uniqueID) + stateSourceObject.Load(4, &e.rcvReady) + stateSourceObject.Load(5, &e.rcvList) + stateSourceObject.Load(7, &e.rcvBufSize) + stateSourceObject.Load(8, &e.rcvClosed) + stateSourceObject.Load(9, &e.sndBufSize) + stateSourceObject.Load(10, &e.sndBufSizeMax) + stateSourceObject.Load(11, &e.state) + stateSourceObject.Load(12, &e.dstPort) + stateSourceObject.Load(13, &e.v6only) + stateSourceObject.Load(14, &e.ttl) + stateSourceObject.Load(15, &e.multicastTTL) + stateSourceObject.Load(16, &e.multicastAddr) + stateSourceObject.Load(17, &e.multicastNICID) + stateSourceObject.Load(18, &e.multicastLoop) + stateSourceObject.Load(19, &e.portFlags) + stateSourceObject.Load(20, &e.bindToDevice) + 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(6, new(int), func(y interface{}) { e.loadRcvBufSizeMax(y.(int)) }) + stateSourceObject.LoadValue(21, new(string), func(y interface{}) { e.loadLastError(y.(string)) }) stateSourceObject.AfterLoad(e.afterLoad) } |