Skip to content

fix(inputs.ping): Use deterministic packet IDs to prevent collisions#18870

Merged
skartikey merged 6 commits into
influxdata:masterfrom
srebhan:ping_issue_8980
May 22, 2026
Merged

fix(inputs.ping): Use deterministic packet IDs to prevent collisions#18870
skartikey merged 6 commits into
influxdata:masterfrom
srebhan:ping_issue_8980

Conversation

@srebhan

@srebhan srebhan commented May 8, 2026

Copy link
Copy Markdown
Member

Summary

This PR prevents collisions for native pining when interpreting received packet and doing false assignments to the corresponding sent packet. This false assignment produces wrong timings, mangles statistics and produces wrong results (see #8980 for details).

This PR introduces a deterministic packet-ID assignment to Pingers accross all plugin instances to allow the underlying library to correctly assign a received packet to its correct sent-packet origin.

Checklist

Related issues

resolves #8980

@telegraf-tiger telegraf-tiger Bot added area/ping fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels May 8, 2026
Comment thread plugins/inputs/ping/ping.go Outdated
Comment thread plugins/inputs/ping/ping.go Outdated
@srebhan srebhan self-assigned this May 8, 2026
@srebhan srebhan marked this pull request as draft May 8, 2026 15:44
@srebhan srebhan marked this pull request as draft May 8, 2026 15:44
@srebhan srebhan force-pushed the ping_issue_8980 branch from 1953dc7 to f8ae40c Compare May 8, 2026 19:03
@srebhan srebhan marked this pull request as ready for review May 8, 2026 19:03
@srebhan

srebhan commented May 8, 2026

Copy link
Copy Markdown
Member Author

Thanks for making me think @Hipska! IMO the current implementation is much better as it

  1. uses less memory
  2. is fast on normal use-cases, i.e. if you ping less than 65535 with one Telegraf process
  3. has no limitation about the number of endpoints to ping other than performance
  4. looks much cleaner

Please take a look!

@Hipska Hipska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great new approach! I do have some questions.

Comment thread plugins/inputs/ping/ping.go Outdated
Comment thread plugins/inputs/ping/ping.go Outdated
Comment thread plugins/inputs/ping/ping.go Outdated
@srebhan

srebhan commented May 11, 2026

Copy link
Copy Markdown
Member Author

Addressed your comments @Hipska, please take another look!

@Hipska Hipska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great implementation! Just a minor comment remark.

Comment thread plugins/inputs/ping/ping.go
@srebhan srebhan assigned skartikey and unassigned srebhan May 20, 2026
@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label May 20, 2026

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@srebhan Thanks! Please take a look at the comments.

Comment thread plugins/inputs/ping/ping.go Outdated
Comment thread plugins/inputs/ping/ping.go Outdated
Comment thread plugins/inputs/ping/ping_test.go Outdated
Comment thread plugins/inputs/ping/ping_test.go
Comment thread plugins/inputs/ping/ping.go Outdated
@srebhan srebhan force-pushed the ping_issue_8980 branch from e2cefc9 to 535df93 Compare May 22, 2026 12:56
@srebhan srebhan requested a review from skartikey May 22, 2026 12:57

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@srebhan Thanks!

@telegraf-tiger

Copy link
Copy Markdown
Contributor

@skartikey skartikey merged commit 81d4259 into influxdata:master May 22, 2026
26 of 27 checks passed
@github-actions github-actions Bot added this to the v1.38.5 milestone May 22, 2026

@Hipska Hipska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only a few comment typo's

usedIDsCond.L.Lock()
defer usedIDsCond.L.Unlock()

// Wait for an ID to become avaulable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Wait for an ID to become avaulable
// Wait for an ID to become available

}
usedIDsCond.L.Unlock()

// Signal all waiting pingers to check for the free ID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Signal all waiting pingers to check for the free ID
// Signal one waiting pinger to check for the free ID

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

Labels

area/ping fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ping input providing false/unreliable statistics with multiple url's

3 participants