google / gvisor

Application Kernel for Containers

Home Page:https://gvisor.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Listen leaves port bound if registration with demuxer fails.

hbhasker opened this issue · comments

Description

endpoint.listen does not free the bound port if RegisterTransportEndpoint fails. It also leaves the endpoint in StateBound (which is not really a TCP state anyway).

Linux OTOH moves the socket to a CLOSED state and also never registers a port this is because in linux there are not two entities port manager/demuxer like we do in Netstack. Ideally demuxer should not exist at all and all port registration should be the purview of the Port manager.
See: https://github.com/torvalds/linux/blob/559089e0a93d44280ec3ab478830af319c56dbe3/net/ipv4/inet_connection_sock.c#L1065

We should at the least confirm with linux and free up any bound ports and move the socket to a CLOSED state.

Steps to reproduce

No response

runsc version

No response

docker version (if using docker)

No response

uname

No response

kubectl (if using Kubernetes)

No response

repo state (if built from source)

No response

runsc debug logs (if available)

No response