镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

test: check net.ipv4.ip_unprivileged_port_start in parallel/test-cluster-bind-privileged-port #45838

Description

@bnoordhuis

test/parallel/test-cluster-bind-privileged-port.js expects binding to port 42 to fail but that's not an always-correct assumption.

Check the output of sysctl net.ipv4.ip_unprivileged_port_start because it's possible (albeit unlikely) for that port to be unprivileged.

Example output:

$ sysctl net.ipv4.ip_unprivileged_port_start
net.ipv4.ip_unprivileged_port_start = 1

Activity

  1. added
    testIssues and PRs related to Node.js core tests and test infrastructure.
    good first issueIssues that are suitable for first-time contributors.
    linuxIssues and PRs related to the Linux platform.
    on Dec 13, 2022
  2. 7suyash7 commented on Dec 15, 2022

    @7suyash7
    Contributor
    $ sysctl net.ipv4.ip_unprivileged_port_start
    net.ipv4.ip_unprivileged_port_start = 1024
    

    Here's the output for me on Ubuntu 22.04.1

  3. bnoordhuis commented on Dec 16, 2022

    @bnoordhuis
    MemberAuthor

    Yes, that's the default (and traditional UNIX behavior.) The test starts failing when it's <= 42.

  4. 7suyash7 commented on Dec 16, 2022

    @7suyash7
    Contributor

    So, you're saying the test should be modified to check the range of reserved ports on the current system, rather than assuming that it will always be 42?

  5. bnoordhuis commented on Dec 16, 2022

    @bnoordhuis
    MemberAuthor

    The test should bail out with common.skip('...') if port 42 is unprivileged, yes.

  6. 7suyash7 commented on Dec 16, 2022

    @7suyash7
    Contributor

    Can I take a try at this? I would write a function to find the first unprivileged port and then try to attach a process to the port just before the first unprivileged port. Then basically the same checks as before (making sure the exit code is 0, etc) Is this implementation fine?
    @bnoordhuis

  7. bnoordhuis commented on Dec 16, 2022

    @bnoordhuis
    MemberAuthor

    Go for it but I'd rather it just exits if port 42 is unprivileged. Principle of least surprise and all that.

  8. 7suyash7 commented on Dec 16, 2022

    @7suyash7
    Contributor

    That makes sense, I'll send in a PR in some time!

  9. 7suyash7 commented on Dec 16, 2022

    @7suyash7
    Contributor
  10. 7suyash7 commented on Dec 16, 2022

    @7suyash7
    Contributor

    Please ignore the second PR, I think it got added due to me changing branches locally and pushing.

  11. bnoordhuis commented on Dec 18, 2022

    @bnoordhuis
    MemberAuthor

    Can you link me to your PR? I can't find it for some reason.

  12. 7suyash7 commented on Dec 18, 2022

    @7suyash7
    Contributor

    @bnoordhuis I messed up my Git locally and had to create a new PR. I hope you can see it now?

  13. KrayzeeKev commented on Feb 7, 2023

    @KrayzeeKev
    Contributor

    This "fix" has meant that the test suite can not run on Linux kernels < 4.1 because that sysctl feature does not exist.
    I'm building for CentOS 7 which is kernel 3.10 - And the reason I'm building is that the official build moved to RHEL 8. NodeJS itself does not need this kernel feature, only the guard case in the test.
    I'm going to work on a fix for this that assumed that the priv port limit is 1024 if that sysctl fails (which seems like a reasonable presumption)

  14. KrayzeeKev commented on Feb 7, 2023

    @KrayzeeKev
    Contributor

    I've put in the above PR #46536 - to fix v18 as well, do I just do another branch with a -t upstream/v18.x ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.linuxIssues and PRs related to the Linux platform.testIssues and PRs related to Node.js core tests and test infrastructure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions