-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix(plugins.snmp): Update gosnmp to prevent panic in snmp agents #17367
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stepga Thanks for reporting this and putting up the PR!
You're right about the version bump: gosnmp v1.41.0 → v1.42.1
, this is needed and correctly addresses the panic.
However, the line change from ¶ms
to params
seems unrelated and potentially incorrect: It’s not tied to the EOF panic, that issue is entirely within gosnmp
see issue #521, PR #522
It could break behavior by changing how the trap listener receives parameters
Suggestion:
Keep the version bump
Drop the ¶ms → params
change, it’s unnecessary for fixing the issue and could introduce side effects.
The dependency update alone resolves the panic.
Hey @skartikey, thanks for reviewing the PR!
You are right: the code change in Of course, my first PR draft modified only $ make check go vet $(go list ./... | grep -v ./plugins/parsers/influx) # github.com/influxdata/telegraf/plugins/inputs/snmp_trap # [github.com/influxdata/telegraf/plugins/inputs/snmp_trap] plugins/inputs/snmp_trap/snmp_trap.go:92:12: assignment copies lock value to params: github.com/gosnmp/gosnmp.GoSNMP contains sync.Mutex go vet has found suspicious constructs. Please remediate any reported errors to fix them before submitting code for review. make: *** [Makefile:173: vet] Error 1 This As IMO the safe fix here would be to explicitly create a new local struct with the global |
As described in the respective gosnmp issue [1], gosnmp improperly handled an EOF/closed connection during a SNMP over TCP session. This led to huge telegraf logs full of stack traces. The issue has been fixed gosnmp v1.42.1 [2]. Also, adapt to the new `gosnmp` version, and make `make check` pass (see plugins/inputs/snmp_trap/snmp_trap.go). [1] gosnmp/gosnmp#521 [2] https://github.com/gosnmp/gosnmp/releases/tag/v1.42.1 resolves influxdata#17366 Signed-off-by: Stephan Gabert <stepga@nirgendwo.eu>
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
@stepga Got the full picture now, great catch on both issues! 1)The Your explicit struct initialization is cleaner, avoids hidden bugs, and improves maintainability. Nicely done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stepga Thanks for the contribution!
) Signed-off-by: Stephan Gabert <stepga@nirgendwo.eu> Co-authored-by: Stephan Gabert <stepga@nirgendwo.eu> (cherry picked from commit 8fd174c)
As described in the respective gosnmp issue [1], gosnmp improperly handled an EOF/closed connection during a SNMP over TCP session.
This led to huge telegraf logs full of stack traces.
The issue has been fixed gosnmp v1.42.1 [2].
[1] gosnmp/gosnmp#521
[2] https://github.com/gosnmp/gosnmp/releases/tag/v1.42.1
Summary
Checklist
Related issues
resolves #17366