Skip to content

fix: ping over the address family -4 or -6 asks for - #159

Merged
maddie merged 1 commit into
librespeed:masterfrom
BKPepe:fix/icmp-address-family
Nov 23, 2026
Merged

maddie merged 1 commit into
librespeed:masterfrom
BKPepe:fix/icmp-address-family

Conversation

@BKPepe

@BKPepe BKPepe commented Nov 22, 2026

Copy link
Copy Markdown
Member

The ICMP pinger resolved its target before the address family was set, so -4 and -6 did not apply to the ICMP ping. With -6, a dual-stack server was pinged over IPv4 while the HTTP requests went over IPv6.

Local server on 127.0.0.1 and ::1, a localhost server URL, -6 --debug:

before: Pinging 127.0.0.1 over ICMP (IPv4)
after:  Pinging ::1 over ICMP (IPv6)

The ICMP pinger resolved its target before the family was set, so with
--ipv6 a dual-stack server was pinged over IPv4 while the transfers ran
over IPv6.
@BKPepe
BKPepe force-pushed the fix/icmp-address-family branch from eb922dc to cf2bdc1 Compare November 22, 2026 14:34

@maddie maddie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at cf2bdc1. The fix is correct: probing.NewPinger resolves during construction with the default "ip" network, so setting the network afterwards could never change the family of the resolved address. newPinger sets it before Resolve(), and pro-bing v0.9.1 honours p.network there (ping.go:418, mapped at ping.go:459-467). I reproduced the old and the new behaviour: ::1 with ip4 and 127.0.0.1 with ip6 returned the wrong-family literal before and now return no suitable address found; a dual-stack name such as dns.google with ip6 resolves to an IPv6 address now and to IPv4 before. The empty network still behaves exactly as before, and defs/server.go:163-168 falls back to TCP when the pinger cannot be created, so no caller regresses.

Build, vet, the full test suite and -race pass. The new test fails on master with the old helper, so it does guard the fix.

Two optional nits, neither blocking:

  • 💡 defs/pinger_test.go:50-51 — on a host without an AAAA record for localhost the ip6 subtest skips, so the dual-stack case that actually triggered the report is not asserted in CI. Since the old code returned 127.0.0.1 with a nil error for this input, the skip branch could assert newPinger("localhost", "ip6") returns an error instead.
  • 💡 defs/server.go:230-239 — the doc comment promises ip/ip4/ip6, but SetNetwork silently maps anything else, including "", to ip. All current callers are correct, so this is only a note that the helper cannot flag a bad network string.

Approved – ready for merge.

@maddie
maddie merged commit 63ec1a4 into librespeed:master Nov 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants