diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2020-12-09 14:54:43 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2020-12-09 15:58:53 -0800 |
commit | 92ca72ecb73d91e9def31e7f9835adf7a50b3d65 (patch) | |
tree | 9884c48ff9039c0ff2ae249fedaa2633e9fa5032 /pkg/tcpip/socketops.go | |
parent | b4af9d4572707718514e66b7e537bc51216b60f6 (diff) |
Add support for IP_RECVORIGDSTADDR IP option.
Fixes #5004
PiperOrigin-RevId: 346643745
Diffstat (limited to 'pkg/tcpip/socketops.go')
-rw-r--r-- | pkg/tcpip/socketops.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/tcpip/socketops.go b/pkg/tcpip/socketops.go index c53698a6a..b14df9e09 100644 --- a/pkg/tcpip/socketops.go +++ b/pkg/tcpip/socketops.go @@ -130,6 +130,10 @@ type SocketOptions struct { // corkOptionEnabled is used to specify if data should be held until segments // are full by the TCP transport protocol. corkOptionEnabled uint32 + + // receiveOriginalDstAddress is used to specify if the original destination of + // the incoming packet should be returned as an ancillary message. + receiveOriginalDstAddress uint32 } // InitHandler initializes the handler. This must be called before using the @@ -302,3 +306,13 @@ func (so *SocketOptions) SetCorkOption(v bool) { storeAtomicBool(&so.corkOptionEnabled, v) so.handler.OnCorkOptionSet(v) } + +// GetReceiveOriginalDstAddress gets value for IP(V6)_RECVORIGDSTADDR option. +func (so *SocketOptions) GetReceiveOriginalDstAddress() bool { + return atomic.LoadUint32(&so.receiveOriginalDstAddress) != 0 +} + +// SetReceiveOriginalDstAddress sets value for IP(V6)_RECVORIGDSTADDR option. +func (so *SocketOptions) SetReceiveOriginalDstAddress(v bool) { + storeAtomicBool(&so.receiveOriginalDstAddress, v) +} |