mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Skip listening TCP ports when trying to bind a free port.
PiperOrigin-RevId: 327686558
This commit is contained in:
committed by
gVisor bot
parent
7ca62b9daa
commit
f12b545d8f
@@ -803,7 +803,20 @@ func (s *socketOpsCommon) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error {
|
||||
}
|
||||
|
||||
// Issue the bind request to the endpoint.
|
||||
return syserr.TranslateNetstackError(s.Endpoint.Bind(addr))
|
||||
err := s.Endpoint.Bind(addr)
|
||||
if err == tcpip.ErrNoPortAvailable {
|
||||
// Bind always returns EADDRINUSE irrespective of if the specified port was
|
||||
// already bound or if an ephemeral port was requested but none were
|
||||
// available.
|
||||
//
|
||||
// tcpip.ErrNoPortAvailable is mapped to EAGAIN in syserr package because
|
||||
// UDP connect returns EAGAIN on ephemeral port exhaustion.
|
||||
//
|
||||
// TCP connect returns EADDRNOTAVAIL on ephemeral port exhaustion.
|
||||
err = tcpip.ErrPortInUse
|
||||
}
|
||||
|
||||
return syserr.TranslateNetstackError(err)
|
||||
}
|
||||
|
||||
// Listen implements the linux syscall listen(2) for sockets backed by
|
||||
|
||||
Reference in New Issue
Block a user