Skip to content

Ping class ignoring timeout on Linux #34855

Closed

Description

@sakno

Ping class ignoring timeout on Linux when running from regular user, not from the root. I guess that the reason is in SendPingCore method which uses ping utility if raw socket cannot be created (due to non-root user). As a result, timeout used only for process exit only.

To fix this issue, ConstructCommandLine method inside of UnixCommandLinePing class should accept timeout and pass it as -W flag to the tool according with this man page.

Version information:

  • ,NET Core 3.1.201
  • Ubuntu Linux 18.04.4 LTS x64 (kernel 4.15.0)

Activity

  1. added
    untriaged
    on Apr 11, 2020
  2. sakno commented on Apr 11, 2020

    @sakno
    ContributorAuthor

    My original use case is to use Ping class for path MTU discovery. The very simple code for this is here. I was surprised that on Linux I got IPStatus.TimedOut result. On Windows, I have IPStatus.PacketTooBig as expected. Just pass large value to timeout parameter and you will see that freeze on Send method is no longer than 1 second.

    I'm ready to fix that and create pull request if you will mark this issue with up-for-grabs label.

  3. davidsh commented on Apr 11, 2020

    @davidsh
    Contributor
  4. wfurt commented on Apr 11, 2020

    @wfurt
    Member

    That sounds reasonable. It seems like that should work with busybox as well as OSX & FreeBSD.

  5. added
    help wanted
    on Apr 11, 2020
  6. sakno commented on Apr 12, 2020

    @sakno
    ContributorAuthor

    Results of my investigation:

    • BusyBox supports necessary flag but precision is seconds instead of millis. Example: ping -W 2 -c 1 1.1.1.1
    • Linux is the same
    • FreeBSD supports the same flag but precision is milliseconds.
    • MacOS X, I guess the same as FreeBSD

    @wfurt , BusyBox and Linux doesn't support timeout in milliseconds. However, it's possible to round it. What is the best option: floor or ceiling?

  7. wfurt commented on Apr 13, 2020

    @wfurt
    Member

    I would personally use ceiling. Since Unix is not generally real-time OS, timeout(x) usually means atLeast(x). It seems like in most cases waiting little bit longer and getting positive answer would be more appreciated than failing - as long as there is some cap to avoid super long delays.

  8. added
    enhancement
    and removed
    untriaged
    on Apr 13, 2020
  9. added this to the Future milestone on Apr 13, 2020
  10. sakno commented on May 26, 2020

    @sakno
    ContributorAuthor

    @wfurt , @karelz can I close this issue? PR was merged.

  11. wfurt commented on May 26, 2020

    @wfurt
    Member

    it would normally be closed automatically.

  12. modified the milestones: Future, 5.0.0 on Aug 18, 2020
  13. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
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

    area-System.Netenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions