summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport
diff options
context:
space:
mode:
authorGhanan Gowripalan <ghanan@google.com>2021-09-20 19:35:51 -0700
committergVisor bot <gvisor-bot@google.com>2021-09-20 19:37:57 -0700
commit3fe8d7ecf193b4efd099ceabe2d39a119ffe4fbc (patch)
tree67261d505ae4bf516d234eaad14fdf88480e3d39 /pkg/tcpip/transport
parent206d7bb90cfbd017fbb26db805aa2fcf6cdffa4f (diff)
Support getsockname for packet sockets
Updates #6621 PiperOrigin-RevId: 397898852
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r--pkg/tcpip/transport/packet/endpoint.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/tcpip/transport/packet/endpoint.go b/pkg/tcpip/transport/packet/endpoint.go
index d669fe55e..e4a64e191 100644
--- a/pkg/tcpip/transport/packet/endpoint.go
+++ b/pkg/tcpip/transport/packet/endpoint.go
@@ -318,8 +318,14 @@ func (ep *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 (ep *endpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error) {
+ ep.mu.RLock()
+ defer ep.mu.RUnlock()
+
+ return tcpip.FullAddress{
+ NIC: ep.boundNIC,
+ Port: uint16(ep.boundNetProto),
+ }, nil
}
// GetRemoteAddress implements tcpip.Endpoint.GetRemoteAddress.