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

Crash on accessing missing index in proto.IsIPv4 #251

Closed
simPod opened this issue Dec 6, 2023 · 2 comments · Fixed by #252
Closed

Crash on accessing missing index in proto.IsIPv4 #251

simPod opened this issue Dec 6, 2023 · 2 comments · Fixed by #252
Labels
bug Something isn't working

Comments

@simPod
Copy link
Contributor

simPod commented Dec 6, 2023

Describe the bug

Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: panic: runtime error: index out of range [0] with length 0
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: goroutine 152 [running]:
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.IsIPv4(...)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:211
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.ParseEthernetHeader(0xc0071a6d20, {0xc006d184b0, 0x40, 0x1e78}, 0x0)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:265 +0x1dbc
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.ParseSampledHeaderConfig(0x4?, 0x6?, 0x6?)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:384 +0x2d
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.SearchSFlowSampleConfig(0xc0071a6d20, {0xace180?, 0xc0032242d0?}, 0xc00511f908?)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:414 +0x75c
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.SearchSFlowSamplesConfig({0xc00304e280?, 0x6, 0xc00511f950?}, 0x4524e9?)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:473 +0xf4
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.ProcessMessageSFlowConfig(0x9f7360?, 0xc00511f860?)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/producer_sf.go:492 +0x273
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/producer/proto.(*ProtoProducer).Produce(0xc0001dc820, {0xa4f2e0?, 0xc002b77f40?}, 0xc00854f730)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/producer/proto/proto.go:73 +0x14e
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/metrics.(*PromProducerWrapper).Produce(0xa4f360?, {0xa4f2e0?, 0xc002b77f40?}, 0xc00854f730)
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/metrics/producer.go:20 +0x52
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/utils.(*SFlowPipe).DecodeFlow(0xc000296cc0, {0x9f6160?, 0xc00854f6c0})
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/utils/pipe.go:127 +0x306
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: main.main.PromDecoderWrapper.func5({0x9f6160?, 0xc00854f6c0?})
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/metrics/decoder.go:53 +0x63c
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: github.com/netsampler/goflow2/v2/utils.(*UDPReceiver).decoders.func1()
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/utils/udp.go:215 +0x249
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]: created by github.com/netsampler/goflow2/v2/utils.(*UDPReceiver).decoders in goroutine 1
Dec 06 12:30:42 flop-goflow-1 goflow2[2464383]:         /buildir/utils/udp.go:200 +0x32
Dec 06 12:30:42 flop-goflow-1 systemd[1]: goflow2.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

To Reproduce
Steps to reproduce the behavior:

  1. Unfortunately I don't have the problematic packet captured yet.

Expected behavior
No crash

Captures
If applicable, add output (JSON, protobuf), packet captures and device configuration.

Sampler device:

N/A for now

  • Brand: [e.g. Cisco, Juniper, Arista, Mikrotik]
  • Model: [e.g. MX, QFX]
  • Version: [e.g. 22]
  • Estimated flow traffic: 32K

GoFlow2:

  • Version: v2
@simPod simPod added the bug Something isn't working label Dec 6, 2023
@simPod
Copy link
Contributor Author

simPod commented Dec 6, 2023

I had no such issue with previous goflow where this works https://github.com/simPod/goflow/blob/23c8e95f8ba7ceadb535a3d1260a6b968140f0ac/producer/producer_sf.go#L83

@lspgn
Copy link
Member

lspgn commented Dec 6, 2023

Thank you for reporting, could you check if #252 works for you?

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.

2 participants