-
Notifications
You must be signed in to change notification settings - Fork 706
pkg/portfwd: Remove SO_REUSEPORT
#4160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/portfwd: Remove SO_REUSEPORT
#4160
Conversation
Since we’re using a single accepting go routine on the port forwarder’s listener, `SO_REUSEPORT` is unnecessary. Applying this change prevents the port forwarder from binding if the listening port is already listened by another process with `SO_REUSEPORT`, resulting in a "bind: address already in use" error. Previously, if the listening port was listened by another process with `SO_REUSEPORT`, the port forwarder succeeded in binding, but the client’s connection could be handled by another process, leading to port forwarding issues without errors. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
This also may happen in guest OS on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com> hack/test-port-forwarding.pl: Add a connection timeout option and relax it from 1 second to 2 seconds. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com> hack/test-port-forwarding.pl: Add a connection timeout option and relax it from 1 second to 2 seconds. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com> hack/test-port-forwarding.pl: Add a connection timeout option and relax it from 1 second to 3 seconds. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
support `socat` as a listener and writer. ```console $ ./hack/test-port-forwarding.pl default [nc|socat] [nc|socat] ``` The `nc` command always sets `SO_REUSEPORT` on the listening TCP port. The `socat` command provides a `reuseport` option that enables `SO_REUSEPORT` on the listening TCP port. Ref: lima-vm#4160 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com> hack/test-port-forwarding.pl: Add a connection timeout option and relax it from 1 second to 3 seconds. Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Thanks! 🙏🏻 |
Since we’re using a single accepting go routine on the port forwarder’s listener,
SO_REUSEPORT
is unnecessary.Applying this change prevents the port forwarder from binding if the listening port is already listened by another process with
SO_REUSEPORT
, resulting in a "bind: address already in use" error.Previously, if the listening port was listened by another process with
SO_REUSEPORT
, the port forwarder succeeded in binding, but the client’s connection could be handled by another process, leading to port forwarding issues without errors.