Skip to content

Fix v5 inByte/inPackets handling#155

Merged
synfinatic merged 1 commit into
synfinatic:mainfrom
TheSynus:main
Jun 19, 2026
Merged

Fix v5 inByte/inPackets handling#155
synfinatic merged 1 commit into
synfinatic:mainfrom
TheSynus:main

Conversation

@TheSynus

Copy link
Copy Markdown
Contributor

NetFlow v5 was already working since the goflow2 library does support it. Testing with v5 sources I noticed that no bandwidth information was populating in ntopng.
There was a error in Handling in the formatter, byte and packet counts were read from the custom ExtendedFlowMessage fields, which are only populated for v9/IPFIX via the mapping.yaml field remapping. I just added a check if the fields are 0, in which case FlowMessage.Bytes/FlowMessage.Packets is used instead.

I have only tested this with NetFlow v5 since I don't have devices with v9 support.

@synfinatic

Copy link
Copy Markdown
Owner

@TheSynus would be great if you could sign your commit please.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (28fee3f) to head (77eb9e0).

Files with missing lines Patch % Lines
formatter/ntopng_json.go 0.00% 10 Missing ⚠️
formatter/ntopng_tlv.go 0.00% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #155   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          7       7           
  Lines        656     668   +12     
=====================================
- Misses       656     668   +12     
Files with missing lines Coverage Δ
formatter/ntopng_json.go 0.00% <0.00%> (ø)
formatter/ntopng_tlv.go 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28fee3f...77eb9e0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes missing bandwidth/accounting data for NetFlow v5 exports by falling back to FlowMessage.Bytes / FlowMessage.Packets when the custom remapped ExtendedFlowMessage IN fields are zero (which occurs when the v9/IPFIX mapping.yaml remapping is not applied).

Changes:

  • Add fallback logic for in_bytes/in_packets to use baseFlow.Bytes/baseFlow.Packets when remapped fields are unpopulated.
  • Apply the same fix in both ntopng output formats (TLV and JSON), with clarifying inline comments.
  • Normalize OUT byte/packet values to uint64 in both formatters for consistent numeric handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
formatter/ntopng_tlv.go Adds v5-safe fallback for IN bytes/packets when remapped fields are zero.
formatter/ntopng_json.go Mirrors the same fallback logic for JSON output to keep behavior consistent across formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TheSynus

Copy link
Copy Markdown
Contributor Author

@synfinatic I amended the commit as requested

@synfinatic synfinatic merged commit 111d41d into synfinatic:main Jun 19, 2026
6 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.

3 participants