Skip to content
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

Do not conflate AddressInUse and AddrNotAvailable errors #1246

Closed
fujiapple852 opened this issue Jul 27, 2024 · 0 comments · Fixed by #1245
Closed

Do not conflate AddressInUse and AddrNotAvailable errors #1246

fujiapple852 opened this issue Jul 27, 2024 · 0 comments · Fixed by #1245
Labels
bug Something isn't working
Milestone

Comments

@fujiapple852
Copy link
Owner

fujiapple852 commented Jul 27, 2024

The tracer has the ability to "skip" probes which fail with either AddressInUse or AddrNotAvailable errors.

This was added for TCP, where the the network layer performs a socket connect() after binding to the local socket address for each probe. By default for TCP tracing, the src port is set to be the sequence number and so if any of the src ports are in use (i.e. TIME_WAIT status) then the connect() operation will fail. The tracer can detect this situation and "skip" probes which cannot be bound.

Currently the tracer will do this if for both AddressInUse or AddrNotAvailable errors, however this is incorrect, it should only do this for the AddressInUse error.

macOS defines these errors as:

[EADDRINUSE]       The address is already in use.

[EADDRNOTAVAIL]    The specified address is not available on this machine.

Linux defines these errors as:

EADDRINUSE
      Local address is already in use.

EADDRNOTAVAIL
      (Internet  domain  sockets) The socket referred to by sockfd had not previously been bound 
to an address and, upon attempting to bind it to an ephemeral port, it was determined that all 
port numbers in the ephemeral port range are currently in use.

Testing on macOS confirms that only EADDRINUSE occurs in this scenario. Note that the stream socket sets SO_REUSEPORT which, on Linux, prevents this error from occurring. It does not appear to have any effect on macOS, the man page for setsockopt(2) says it should, but for UDP only:

SO_REUSEPORT allows completely duplicate bindings by multiple processes if they all set SO_REUSEPORT before binding the port. This option permits multiple instances of a program to each receive UDP/IP multicast or broadcast datagrams destined for the bound port.

@fujiapple852 fujiapple852 added the bug Something isn't working label Jul 27, 2024
@fujiapple852 fujiapple852 added this to the 0.11.0 milestone Jul 27, 2024
@fujiapple852 fujiapple852 self-assigned this Jul 27, 2024
@fujiapple852 fujiapple852 changed the title do not conflate AddressInUse and AddrNotAvailable errors Do not conflate AddressInUse and AddrNotAvailable errors Jul 27, 2024
@fujiapple852 fujiapple852 removed their assignment Aug 9, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 12, 2024
[0.11.0] - 2024-08-11

Added

- Added NAT detection for `IPv4/udp/dublin` ([#1104](fujiapple852/trippy#1104))
- Added public API ([#1192](fujiapple852/trippy#1192))
- Added support for NAT detection (`N`) column ([#1219](fujiapple852/trippy#1219))
- Added support for last icmp packet type (`T`) column ([#1105](fujiapple852/trippy#1105))
- Added support for last icmp packet code (`C`) column ([#1109](fujiapple852/trippy#1109))
- Added support for the probe failure count (`f`) column ([#1258](fujiapple852/trippy#1258))
- Added settings dialog tab hotkeys ([#1217](fujiapple852/trippy#1217))
- Added `--dns-ttl` flag to allow refreshing the reverse DNS
  results ([#1233](fujiapple852/trippy#1233))
- Added `--generate-man` flag for generating [ROFF](https://en.wikipedia.org/wiki/Roff_(software)) man
  page ([#85](fujiapple852/trippy#85))
- Added Ubuntu PPA package ([#859](fujiapple852/trippy#859))
- Added Chocolatey package ([#572](fujiapple852/trippy#572))

Changed

- [BREAKING CHANGE] Changed initial sequence to be `33434` ([#1203](fujiapple852/trippy#1203))
- [BREAKING CHANGE] Renamed `tui-max-[samples|flows]`
  as `max-[samples|flows]` ([#1187](fujiapple852/trippy#1187))
- Separated library and binary crates ([#1141](fujiapple852/trippy#1141))
- Record `icmp` packet code ([#734](fujiapple852/trippy#734))
- Transient error handling for `IPv4` on macOS, Linux &
  Windows ([#1255](fujiapple852/trippy#1255))
- Improved error messages ([#1150](fujiapple852/trippy#1150))
- Revamp the help dialog ([#1260](fujiapple852/trippy#1260))

Fixed

- Fixed `DestinationUnreachable` incorrectly assumed to come from target
  host ([#1225](fujiapple852/trippy#1225))
- Fixed incorrect target hop calculation ([#1226](fujiapple852/trippy#1226))
- Do not conflate `AddressInUse` and `AddrNotAvailable`
  errors ([#1246](fujiapple852/trippy#1246))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant