From 04c85433066f17ebd2edbf8deb85036cd5c82de8 Mon Sep 17 00:00:00 2001 From: lspgn Date: Wed, 9 Jun 2021 18:08:55 -0700 Subject: [PATCH] Bugfix NetFlow/IPFIX producer * Source and destination mac addresses are fed from `NFV9_FIELD_xx_yyy_MAC` Fixes a bug where the samples were missing either source or destination Mac. This is supposed to be linked to the sampling direction. --- producer/producer_nf.go | 4 ++++ utils/sflow_test.go | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/producer/producer_nf.go b/producer/producer_nf.go index 2332784..f895616 100644 --- a/producer/producer_nf.go +++ b/producer/producer_nf.go @@ -254,6 +254,10 @@ func ConvertNetFlowDataSet(version uint16, baseTime uint32, uptime uint32, recor // Mac case netflow.NFV9_FIELD_IN_SRC_MAC: DecodeUNumber(v, &(flowMessage.SrcMac)) + case netflow.NFV9_FIELD_IN_DST_MAC: + DecodeUNumber(v, &(flowMessage.DstMac)) + case netflow.NFV9_FIELD_OUT_SRC_MAC: + DecodeUNumber(v, &(flowMessage.SrcMac)) case netflow.NFV9_FIELD_OUT_DST_MAC: DecodeUNumber(v, &(flowMessage.DstMac)) diff --git a/utils/sflow_test.go b/utils/sflow_test.go index e4a5f75..76f3316 100644 --- a/utils/sflow_test.go +++ b/utils/sflow_test.go @@ -12,8 +12,7 @@ func TestDecodeFlowExpandedSFlow(t *testing.T) { Payload: getExpandedSFlowDecode(), } - s := &StateSFlow{ - } + s := &StateSFlow{} assert.Nil(t, s.DecodeFlow(msg)) }