outlet/flow: make the condition to use sampled header easier to read
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled

This commit is contained in:
Vincent Bernat
2025-12-09 09:01:34 +01:00
parent 4d254fdb58
commit 2783bdea19

View File

@@ -95,10 +95,13 @@ func (nd *Decoder) decode(packet sflow.Packet, bf *schema.FlowMessage, finalize
switch recordData := record.Data.(type) { switch recordData := record.Data.(type) {
case sflow.SampledHeader: case sflow.SampledHeader:
// Only process this header if: // Only process this header if:
// - we don't have a sampled IPv4 header nor a sampled IPv4 header, or // - we're missing both sampled IPv4 and IPv6 headers, or
// - we need L2 data and we don't have sampled ethernet header or we don't have extended switch record // - we need L2 data and are missing either sampled ethernet or extended switch, or
// - we need L3/L4 data // - we need L3/L4 data
if !hasSampledIPv4 && !hasSampledIPv6 || !nd.d.Schema.IsDisabled(schema.ColumnGroupL2) && (!hasSampledEthernet || !hasExtendedSwitch) || !nd.d.Schema.IsDisabled(schema.ColumnGroupL3L4) { needsIPData := !(hasSampledIPv4 || hasSampledIPv6)
needsL2Data := !(nd.d.Schema.IsDisabled(schema.ColumnGroupL2) || (hasSampledEthernet && hasExtendedSwitch))
needsL3L4Data := !nd.d.Schema.IsDisabled(schema.ColumnGroupL3L4)
if needsIPData || needsL2Data || needsL3L4Data {
if l := nd.parseSampledHeader(bf, &recordData); l > 0 { if l := nd.parseSampledHeader(bf, &recordData); l > 0 {
l3length = l l3length = l
} }