diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-09-20 19:35:51 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-20 19:37:57 -0700 |
commit | 3fe8d7ecf193b4efd099ceabe2d39a119ffe4fbc (patch) | |
tree | 67261d505ae4bf516d234eaad14fdf88480e3d39 /pkg/tcpip/transport | |
parent | 206d7bb90cfbd017fbb26db805aa2fcf6cdffa4f (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.go | 10 |
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. |