From a7f3f6af89bdafcb61f9b54bd84afcc710f59c8a Mon Sep 17 00:00:00 2001 From: Julien Pinsonneau Date: Wed, 21 Feb 2024 12:56:22 +0100 Subject: [PATCH] always send plural --- .../pkg/decode/decode_protobuf.go | 16 ++++++++-------- .../netobserv-ebpf-agent/pkg/utils/utils.go | 8 -------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/decode/decode_protobuf.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/decode/decode_protobuf.go index a3d73d858..306ddc18f 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/decode/decode_protobuf.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/decode/decode_protobuf.go @@ -49,6 +49,7 @@ func PBFlowToMap(flow *pbflow.Record) config.GenericMap { "SrcMac": macToStr(flow.DataLink.GetSrcMac()), "DstMac": macToStr(flow.DataLink.GetDstMac()), "Etype": flow.EthProtocol, + "Duplicate": flow.Duplicate, // TODO: remove duplicate field as soon as metrics doesn't rely on it anymore "TimeFlowStartMs": flow.TimeFlowStart.AsTime().UnixMilli(), "TimeFlowEndMs": flow.TimeFlowEnd.AsTime().UnixMilli(), "TimeReceived": time.Now().Unix(), @@ -63,20 +64,19 @@ func PBFlowToMap(flow *pbflow.Record) config.GenericMap { out["Packets"] = flow.Packets } + var interfaces []string + var directions []int if len(flow.GetDupList()) != 0 { - var interfaces []interface{} - var directions []interface{} for _, entry := range flow.GetDupList() { interfaces = append(interfaces, entry.Interface) - directions = append(directions, entry.Direction) + directions = append(directions, int(entry.Direction)) } - out["Interfaces"] = interfaces - out["FlowDirections"] = directions } else { - out["Interface"] = flow.Interface - out["FlowDirection"] = int(flow.Direction.Number()) - out["Duplicate"] = flow.Duplicate + interfaces = append(interfaces, flow.Interface) + directions = append(directions, int(flow.Direction)) } + out["Interfaces"] = interfaces + out["IfDirections"] = directions ethType := ethernet.EtherType(flow.EthProtocol) if ethType == ethernet.EtherTypeIPv4 || ethType == ethernet.EtherTypeIPv6 { diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go index c2a4c80ea..f813fd9ca 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go @@ -91,11 +91,3 @@ func utsnameStr[T int8 | uint8](in []T) string { } return string(out) } - -func GetInterfaceName(ifIndex uint32) string { - iface, err := net.InterfaceByIndex(int(ifIndex)) - if err != nil { - return "" - } - return iface.Name -}