summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-07-21 05:54:22 +0000
committergVisor bot <gvisor-bot@google.com>2021-07-21 05:54:22 +0000
commit01e6d5f5906f7004619267e133dbabb2852e54f5 (patch)
treeb897e21e50b2ce0252d9ee3a07bc1305b2895dd2 /pkg
parent8a46e1d02adb39c257578fc616340fa6ad33b705 (diff)
parent9e805ce937ef2f2934e72f873ea4ae8451801c82 (diff)
Merge release-20210712.0-34-g9e805ce93 (automated)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tcpip/transport/raw/endpoint.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/pkg/tcpip/transport/raw/endpoint.go b/pkg/tcpip/transport/raw/endpoint.go
index ab5da987a..b3d8951ff 100644
--- a/pkg/tcpip/transport/raw/endpoint.go
+++ b/pkg/tcpip/transport/raw/endpoint.go
@@ -455,8 +455,21 @@ func (e *endpoint) Bind(addr tcpip.FullAddress) tcpip.Error {
}
// GetLocalAddress implements tcpip.Endpoint.GetLocalAddress.
-func (*endpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error) {
- return tcpip.FullAddress{}, &tcpip.ErrNotSupported{}
+func (e *endpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error) {
+ e.mu.RLock()
+ defer e.mu.RUnlock()
+
+ addr := e.BindAddr
+ if e.connected {
+ addr = e.route.LocalAddress()
+ }
+
+ return tcpip.FullAddress{
+ NIC: e.RegisterNICID,
+ Addr: addr,
+ // Linux returns the protocol in the port field.
+ Port: uint16(e.TransProto),
+ }, nil
}
// GetRemoteAddress implements tcpip.Endpoint.GetRemoteAddress.