diff --git a/go.mod b/go.mod index 7d8fd3e95..2072b6c0f 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/netobserv/gopipes v0.3.0 github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500 - github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20241213165959-7e7f8c42a3f6 + github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250115132126-73256abeed31 github.com/netsampler/goflow2 v1.3.7 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.5 diff --git a/go.sum b/go.sum index c0c7b627a..9ca53eaf7 100644 --- a/go.sum +++ b/go.sum @@ -693,8 +693,8 @@ github.com/netobserv/gopipes v0.3.0 h1:IYmPnnAVCdSK7VmHmpFhrVBOEm45qpgbZmJz1sSW+ github.com/netobserv/gopipes v0.3.0/go.mod h1:N7/Gz05EOF0CQQSKWsv3eof22Cj2PB08Pbttw98YFYU= github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500 h1:RmnoJe/ci5q+QdM7upFdxiU+D8F3L3qTd5wXCwwHefw= github.com/netobserv/loki-client-go v0.0.0-20220927092034-f37122a54500/go.mod h1:LHXpc5tjKvsfZn0pwLKrvlgEhZcCaw3Di9mUEZGAI4E= -github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20241213165959-7e7f8c42a3f6 h1:ZuEAJ7Ui0fsMX8tGSz70cXDjlzRnviHjzqlJfWJh9VY= -github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20241213165959-7e7f8c42a3f6/go.mod h1:20e1OPAs7h3k9PvNZWS9D6BnXEtkTk2LlfzD66uhvxY= +github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250115132126-73256abeed31 h1:fQB0tCcX0Fkk+I2lvzzVj2cQpeAYlh8UFmL45s3Nh5w= +github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250115132126-73256abeed31/go.mod h1:2UT/wN+zmU+pCajg0crx8+0KOmzS8pBNql5VqXAGY5I= github.com/netsampler/goflow2 v1.3.7 h1:XZaTy8kkMnGXpJ9hS3KbO1McyrFTpVNhVFEx9rNhMmc= github.com/netsampler/goflow2 v1.3.7/go.mod h1:4UZsVGVAs//iMCptUHn3WNScztJeUhZH7kDW2+/vDdQ= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= diff --git a/pkg/pipeline/pipeline_test.go b/pkg/pipeline/pipeline_test.go index be68af181..c998fa706 100644 --- a/pkg/pipeline/pipeline_test.go +++ b/pkg/pipeline/pipeline_test.go @@ -177,7 +177,13 @@ parameters: someDuration := endTime.Sub(startTime) _, err = flowSender.Client().Send(context.Background(), &pbflow.Records{ Entries: []*pbflow.Record{{ - Interface: "eth0", + Interface: "eth0", + DupList: []*pbflow.DupMapEntry{ + { + Interface: "eth0", + Direction: pbflow.Direction_EGRESS, + }, + }, EthProtocol: 2048, Bytes: 456, Packets: 123, @@ -213,7 +219,7 @@ parameters: DnsLatency: durationpb.New(someDuration), DnsId: 1, DnsFlags: 0x80, - DnsErrno: 1, + DnsErrno: 22, TimeFlowRtt: durationpb.New(someDuration), }}, }) @@ -252,7 +258,7 @@ parameters: "DnsLatencyMs": float64(someDuration.Milliseconds()), "DnsId": float64(1), "DnsFlags": float64(0x80), - "DnsErrno": float64(1), + "DnsErrno": float64(22), "DnsFlagsResponseCode": "NoError", "TimeFlowRttNs": float64(someDuration.Nanoseconds()), }, capturedRecord) 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 f98e6b340..9bdd7d14e 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 @@ -67,9 +67,14 @@ func RecordToMap(fr *model.Record) config.GenericMap { "AgentIP": fr.AgentIP.String(), } - if fr.Duplicate { - out["Duplicate"] = true + var directions []int + var interfaces []string + for _, intf := range fr.Interfaces { + directions = append(directions, intf.Direction) + interfaces = append(interfaces, intf.Interface) } + out["IfDirections"] = directions + out["Interfaces"] = interfaces if fr.Metrics.Bytes != 0 { out["Bytes"] = fr.Metrics.Bytes @@ -82,22 +87,6 @@ func RecordToMap(fr *model.Record) config.GenericMap { if fr.Metrics.Sampling != 0 { out["Sampling"] = fr.Metrics.Sampling } - var interfaces []string - var directions []int - if len(fr.DupList) != 0 { - for _, m := range fr.DupList { - for key, value := range m { - interfaces = append(interfaces, key) - directions = append(directions, int(model.Direction(value))) - } - } - } else { - interfaces = append(interfaces, fr.Interface) - directions = append(directions, int(fr.ID.Direction)) - } - out["Interfaces"] = interfaces - out["IfDirections"] = directions - if fr.Metrics.EthProtocol == uint16(ethernet.EtherTypeIPv4) || fr.Metrics.EthProtocol == uint16(ethernet.EtherTypeIPv6) { out["SrcAddr"] = model.IP(fr.ID.SrcIp).String() out["DstAddr"] = model.IP(fr.ID.DstIp).String() diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.go index f12dda23f..968a8e117 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.go @@ -13,14 +13,18 @@ import ( ) type BpfAdditionalMetrics struct { + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 DnsRecord BpfDnsRecordT PktDrops BpfPktDropsT FlowRtt uint64 - NetworkEventsIdx uint8 NetworkEvents [4][8]uint8 - _ [1]byte TranslatedFlow BpfTranslatedFlowT - _ [6]byte + ObservedIntf [4]BpfObservedIntfT + EthProtocol uint16 + NetworkEventsIdx uint8 + NbObservedIntf uint8 + _ [4]byte } type BpfDirectionT uint32 @@ -42,12 +46,11 @@ type BpfDnsFlowId struct { } type BpfDnsRecordT struct { + Latency uint64 Id uint16 Flags uint16 - _ [4]byte - Latency uint64 Errno uint8 - _ [7]byte + _ [3]byte } type BpfFilterActionT uint32 @@ -90,35 +93,34 @@ type BpfFilterValueT struct { type BpfFlowId BpfFlowIdT type BpfFlowIdT struct { - Direction uint8 SrcIp [16]uint8 DstIp [16]uint8 - _ [1]byte SrcPort uint16 DstPort uint16 TransportProtocol uint8 IcmpType uint8 IcmpCode uint8 - _ [3]byte - IfIndex uint32 + _ [1]byte } type BpfFlowMetrics BpfFlowMetricsT type BpfFlowMetricsT struct { - Lock struct{ Val uint32 } - EthProtocol uint16 - SrcMac [6]uint8 - DstMac [6]uint8 - _ [2]byte - Packets uint32 - Bytes uint64 - StartMonoTimeTs uint64 - EndMonoTimeTs uint64 - Flags uint16 - Errno uint8 - Dscp uint8 - Sampling uint32 + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 + Bytes uint64 + Packets uint32 + EthProtocol uint16 + Flags uint16 + SrcMac [6]uint8 + DstMac [6]uint8 + IfIndexFirstSeen uint32 + Lock struct{ Val uint32 } + Sampling uint32 + DirectionFirstSeen uint8 + Errno uint8 + Dscp uint8 + _ [5]byte } type BpfFlowRecordT struct { @@ -138,17 +140,23 @@ const ( BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_GROUPID_MISMATCH BpfGlobalCountersKeyT = 6 BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS BpfGlobalCountersKeyT = 7 BpfGlobalCountersKeyTNETWORK_EVENTS_GOOD BpfGlobalCountersKeyT = 8 - BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTOBSERVED_INTF_MISSED BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 10 ) +type BpfObservedIntfT struct { + Direction uint8 + _ [3]byte + IfIndex uint32 +} + type BpfPktDropsT struct { - Packets uint32 - _ [4]byte Bytes uint64 + Packets uint32 + LatestDropCause uint32 LatestFlags uint16 LatestState uint8 - _ [1]byte - LatestDropCause uint32 + _ [5]byte } type BpfTcpFlagsT uint32 diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.o b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.o index 240486c52..ec4cc8cf2 100644 Binary files a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.o and b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_arm64_bpfel.o differ diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.go index a8b825750..99bad4e85 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.go @@ -13,14 +13,18 @@ import ( ) type BpfAdditionalMetrics struct { + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 DnsRecord BpfDnsRecordT PktDrops BpfPktDropsT FlowRtt uint64 - NetworkEventsIdx uint8 NetworkEvents [4][8]uint8 - _ [1]byte TranslatedFlow BpfTranslatedFlowT - _ [6]byte + ObservedIntf [4]BpfObservedIntfT + EthProtocol uint16 + NetworkEventsIdx uint8 + NbObservedIntf uint8 + _ [4]byte } type BpfDirectionT uint32 @@ -42,12 +46,11 @@ type BpfDnsFlowId struct { } type BpfDnsRecordT struct { + Latency uint64 Id uint16 Flags uint16 - _ [4]byte - Latency uint64 Errno uint8 - _ [7]byte + _ [3]byte } type BpfFilterActionT uint32 @@ -90,35 +93,34 @@ type BpfFilterValueT struct { type BpfFlowId BpfFlowIdT type BpfFlowIdT struct { - Direction uint8 SrcIp [16]uint8 DstIp [16]uint8 - _ [1]byte SrcPort uint16 DstPort uint16 TransportProtocol uint8 IcmpType uint8 IcmpCode uint8 - _ [3]byte - IfIndex uint32 + _ [1]byte } type BpfFlowMetrics BpfFlowMetricsT type BpfFlowMetricsT struct { - Lock struct{ Val uint32 } - EthProtocol uint16 - SrcMac [6]uint8 - DstMac [6]uint8 - _ [2]byte - Packets uint32 - Bytes uint64 - StartMonoTimeTs uint64 - EndMonoTimeTs uint64 - Flags uint16 - Errno uint8 - Dscp uint8 - Sampling uint32 + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 + Bytes uint64 + Packets uint32 + EthProtocol uint16 + Flags uint16 + SrcMac [6]uint8 + DstMac [6]uint8 + IfIndexFirstSeen uint32 + Lock struct{ Val uint32 } + Sampling uint32 + DirectionFirstSeen uint8 + Errno uint8 + Dscp uint8 + _ [5]byte } type BpfFlowRecordT struct { @@ -138,17 +140,23 @@ const ( BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_GROUPID_MISMATCH BpfGlobalCountersKeyT = 6 BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS BpfGlobalCountersKeyT = 7 BpfGlobalCountersKeyTNETWORK_EVENTS_GOOD BpfGlobalCountersKeyT = 8 - BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTOBSERVED_INTF_MISSED BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 10 ) +type BpfObservedIntfT struct { + Direction uint8 + _ [3]byte + IfIndex uint32 +} + type BpfPktDropsT struct { - Packets uint32 - _ [4]byte Bytes uint64 + Packets uint32 + LatestDropCause uint32 LatestFlags uint16 LatestState uint8 - _ [1]byte - LatestDropCause uint32 + _ [5]byte } type BpfTcpFlagsT uint32 diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.o b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.o index fae0677f0..d3253a5ec 100644 Binary files a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.o and b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_powerpc_bpfel.o differ diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.go index 3372ed20b..08e9d2e22 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.go @@ -13,14 +13,18 @@ import ( ) type BpfAdditionalMetrics struct { + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 DnsRecord BpfDnsRecordT PktDrops BpfPktDropsT FlowRtt uint64 - NetworkEventsIdx uint8 NetworkEvents [4][8]uint8 - _ [1]byte TranslatedFlow BpfTranslatedFlowT - _ [6]byte + ObservedIntf [4]BpfObservedIntfT + EthProtocol uint16 + NetworkEventsIdx uint8 + NbObservedIntf uint8 + _ [4]byte } type BpfDirectionT uint32 @@ -42,12 +46,11 @@ type BpfDnsFlowId struct { } type BpfDnsRecordT struct { + Latency uint64 Id uint16 Flags uint16 - _ [4]byte - Latency uint64 Errno uint8 - _ [7]byte + _ [3]byte } type BpfFilterActionT uint32 @@ -90,35 +93,34 @@ type BpfFilterValueT struct { type BpfFlowId BpfFlowIdT type BpfFlowIdT struct { - Direction uint8 SrcIp [16]uint8 DstIp [16]uint8 - _ [1]byte SrcPort uint16 DstPort uint16 TransportProtocol uint8 IcmpType uint8 IcmpCode uint8 - _ [3]byte - IfIndex uint32 + _ [1]byte } type BpfFlowMetrics BpfFlowMetricsT type BpfFlowMetricsT struct { - Lock struct{ Val uint32 } - EthProtocol uint16 - SrcMac [6]uint8 - DstMac [6]uint8 - _ [2]byte - Packets uint32 - Bytes uint64 - StartMonoTimeTs uint64 - EndMonoTimeTs uint64 - Flags uint16 - Errno uint8 - Dscp uint8 - Sampling uint32 + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 + Bytes uint64 + Packets uint32 + EthProtocol uint16 + Flags uint16 + SrcMac [6]uint8 + DstMac [6]uint8 + IfIndexFirstSeen uint32 + Lock struct{ Val uint32 } + Sampling uint32 + DirectionFirstSeen uint8 + Errno uint8 + Dscp uint8 + _ [5]byte } type BpfFlowRecordT struct { @@ -138,17 +140,23 @@ const ( BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_GROUPID_MISMATCH BpfGlobalCountersKeyT = 6 BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS BpfGlobalCountersKeyT = 7 BpfGlobalCountersKeyTNETWORK_EVENTS_GOOD BpfGlobalCountersKeyT = 8 - BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTOBSERVED_INTF_MISSED BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 10 ) +type BpfObservedIntfT struct { + Direction uint8 + _ [3]byte + IfIndex uint32 +} + type BpfPktDropsT struct { - Packets uint32 - _ [4]byte Bytes uint64 + Packets uint32 + LatestDropCause uint32 LatestFlags uint16 LatestState uint8 - _ [1]byte - LatestDropCause uint32 + _ [5]byte } type BpfTcpFlagsT uint32 diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.o b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.o index aae1b0003..3f8e693eb 100644 Binary files a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.o and b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_s390_bpfeb.o differ diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.go index a5839acdd..b8f401958 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.go @@ -13,14 +13,18 @@ import ( ) type BpfAdditionalMetrics struct { + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 DnsRecord BpfDnsRecordT PktDrops BpfPktDropsT FlowRtt uint64 - NetworkEventsIdx uint8 NetworkEvents [4][8]uint8 - _ [1]byte TranslatedFlow BpfTranslatedFlowT - _ [6]byte + ObservedIntf [4]BpfObservedIntfT + EthProtocol uint16 + NetworkEventsIdx uint8 + NbObservedIntf uint8 + _ [4]byte } type BpfDirectionT uint32 @@ -42,12 +46,11 @@ type BpfDnsFlowId struct { } type BpfDnsRecordT struct { + Latency uint64 Id uint16 Flags uint16 - _ [4]byte - Latency uint64 Errno uint8 - _ [7]byte + _ [3]byte } type BpfFilterActionT uint32 @@ -90,35 +93,34 @@ type BpfFilterValueT struct { type BpfFlowId BpfFlowIdT type BpfFlowIdT struct { - Direction uint8 SrcIp [16]uint8 DstIp [16]uint8 - _ [1]byte SrcPort uint16 DstPort uint16 TransportProtocol uint8 IcmpType uint8 IcmpCode uint8 - _ [3]byte - IfIndex uint32 + _ [1]byte } type BpfFlowMetrics BpfFlowMetricsT type BpfFlowMetricsT struct { - Lock struct{ Val uint32 } - EthProtocol uint16 - SrcMac [6]uint8 - DstMac [6]uint8 - _ [2]byte - Packets uint32 - Bytes uint64 - StartMonoTimeTs uint64 - EndMonoTimeTs uint64 - Flags uint16 - Errno uint8 - Dscp uint8 - Sampling uint32 + StartMonoTimeTs uint64 + EndMonoTimeTs uint64 + Bytes uint64 + Packets uint32 + EthProtocol uint16 + Flags uint16 + SrcMac [6]uint8 + DstMac [6]uint8 + IfIndexFirstSeen uint32 + Lock struct{ Val uint32 } + Sampling uint32 + DirectionFirstSeen uint8 + Errno uint8 + Dscp uint8 + _ [5]byte } type BpfFlowRecordT struct { @@ -138,17 +140,23 @@ const ( BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_GROUPID_MISMATCH BpfGlobalCountersKeyT = 6 BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS BpfGlobalCountersKeyT = 7 BpfGlobalCountersKeyTNETWORK_EVENTS_GOOD BpfGlobalCountersKeyT = 8 - BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTOBSERVED_INTF_MISSED BpfGlobalCountersKeyT = 9 + BpfGlobalCountersKeyTMAX_COUNTERS BpfGlobalCountersKeyT = 10 ) +type BpfObservedIntfT struct { + Direction uint8 + _ [3]byte + IfIndex uint32 +} + type BpfPktDropsT struct { - Packets uint32 - _ [4]byte Bytes uint64 + Packets uint32 + LatestDropCause uint32 LatestFlags uint16 LatestState uint8 - _ [1]byte - LatestDropCause uint32 + _ [5]byte } type BpfTcpFlagsT uint32 diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.o b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.o index 9399eaff3..894a97a78 100644 Binary files a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.o and b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/bpf_x86_bpfel.o differ diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/gen.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/gen.go index 3ec45b49c..a95d9ba48 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/gen.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf/gen.go @@ -1,4 +1,4 @@ package ebpf // $BPF_CLANG and $BPF_CFLAGS are set by the Makefile. -//go:generate bpf2go -cc $BPF_CLANG -cflags $BPF_CFLAGS -target amd64,arm64,ppc64le,s390x -type flow_metrics_t -type flow_id_t -type flow_record_t -type pkt_drops_t -type dns_record_t -type global_counters_key_t -type direction_t -type filter_action_t -type tcp_flags_t -type translated_flow_t Bpf ../../bpf/flows.c -- -I../../bpf/headers +//go:generate bpf2go -cc $BPF_CLANG -cflags $BPF_CFLAGS -target amd64,arm64,ppc64le,s390x -type flow_metrics_t -type flow_id_t -type flow_record_t -type pkt_drops_t -type dns_record_t -type global_counters_key_t -type direction_t -type filter_action_t -type tcp_flags_t -type translated_flow_t -type observed_intf_t Bpf ../../bpf/flows.c -- -I../../bpf/headers diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/flow_content.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/flow_content.go index 111303565..155926f37 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/flow_content.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/flow_content.go @@ -1,21 +1,16 @@ package model -import "github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf" +import ( + "github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf" +) type BpfFlowContent struct { *ebpf.BpfFlowMetrics AdditionalMetrics *ebpf.BpfAdditionalMetrics } -type BpfFlowContents []BpfFlowContent - -func (a *BpfFlowContents) Accumulate() BpfFlowContent { - res := BpfFlowContent{} - for _, p := range *a { - res.AccumulateBase(p.BpfFlowMetrics) - res.AccumulateAdditional(p.AdditionalMetrics) - } - return res +func NewBpfFlowContent(metrics ebpf.BpfFlowMetrics) BpfFlowContent { + return BpfFlowContent{BpfFlowMetrics: &metrics} } func (p *BpfFlowContent) AccumulateBase(other *ebpf.BpfFlowMetrics) { @@ -57,10 +52,30 @@ func AccumulateBase(p *ebpf.BpfFlowMetrics, other *ebpf.BpfFlowMetrics) *ebpf.Bp return p } +func (p *BpfFlowContent) buildBaseFromAdditional(add *ebpf.BpfAdditionalMetrics) { + if add == nil { + return + } + // Accumulate time into base metrics if unset + if p.BpfFlowMetrics.StartMonoTimeTs == 0 || (p.BpfFlowMetrics.StartMonoTimeTs > add.StartMonoTimeTs && add.StartMonoTimeTs != 0) { + p.BpfFlowMetrics.StartMonoTimeTs = add.StartMonoTimeTs + } + if p.BpfFlowMetrics.EndMonoTimeTs == 0 || p.BpfFlowMetrics.EndMonoTimeTs < add.EndMonoTimeTs { + p.BpfFlowMetrics.EndMonoTimeTs = add.EndMonoTimeTs + } + if p.BpfFlowMetrics.EthProtocol == 0 { + p.BpfFlowMetrics.EthProtocol = add.EthProtocol + } + if p.BpfFlowMetrics.Flags == 0 && add.PktDrops.LatestFlags != 0 { + p.BpfFlowMetrics.Flags = add.PktDrops.LatestFlags + } +} + func (p *BpfFlowContent) AccumulateAdditional(other *ebpf.BpfAdditionalMetrics) { if other == nil { return } + p.buildBaseFromAdditional(other) if p.AdditionalMetrics == nil { p.AdditionalMetrics = other return @@ -83,6 +98,9 @@ func (p *BpfFlowContent) AccumulateAdditional(other *ebpf.BpfAdditionalMetrics) if other.PktDrops.LatestDropCause != 0 { p.AdditionalMetrics.PktDrops.LatestDropCause = other.PktDrops.LatestDropCause } + if other.PktDrops.LatestState != 0 { + p.AdditionalMetrics.PktDrops.LatestState = other.PktDrops.LatestState + } // RTT if p.AdditionalMetrics.FlowRtt < other.FlowRtt { p.AdditionalMetrics.FlowRtt = other.FlowRtt @@ -98,6 +116,26 @@ func (p *BpfFlowContent) AccumulateAdditional(other *ebpf.BpfAdditionalMetrics) if !AllZeroIP(IP(other.TranslatedFlow.Saddr)) && !AllZeroIP(IP(other.TranslatedFlow.Daddr)) { p.AdditionalMetrics.TranslatedFlow = other.TranslatedFlow } + // Accumulate interfaces + directions + accumulateInterfaces(&p.AdditionalMetrics.NbObservedIntf, &p.AdditionalMetrics.ObservedIntf, other.NbObservedIntf, other.ObservedIntf) +} + +func accumulateInterfaces(dstSize *uint8, dstIntf *[MaxObservedInterfaces]ebpf.BpfObservedIntfT, srcSize uint8, srcIntf [MaxObservedInterfaces]ebpf.BpfObservedIntfT) { + iObs := uint8(0) +outer: + for *dstSize < uint8(len(dstIntf)) && iObs < srcSize { + for u := uint8(0); u < *dstSize; u++ { + if dstIntf[u].Direction == srcIntf[iObs].Direction && + dstIntf[u].IfIndex == srcIntf[iObs].IfIndex { + // Ignore if already exists + iObs++ + continue outer + } + } + dstIntf[*dstSize] = srcIntf[iObs] + *dstSize++ + iObs++ + } } func allZerosMac(s [6]uint8) bool { diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/record.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/record.go index 8f6b83230..0698e771d 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/record.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/model/record.go @@ -14,16 +14,14 @@ import ( // Values according to field 61 in https://www.iana.org/assignments/ipfix/ipfix.xhtml const ( - DirectionIngress = uint8(0) - DirectionEgress = uint8(1) -) -const MacLen = 6 - -// IPv4Type / IPv6Type value as defined in IEEE 802: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml -const ( + DirectionIngress = 0 + DirectionEgress = 1 + MacLen = 6 + // IPv4Type / IPv6Type value as defined in IEEE 802: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml IPv6Type = 0x86DD NetworkEventsMaxEventsMD = 8 MaxNetworkEvents = 4 + MaxObservedInterfaces = 4 ) type HumanBytes uint64 @@ -36,6 +34,18 @@ type Direction uint8 // (same behavior as Go's net.IP type) type IPAddr [net.IPv6len]uint8 +type InterfaceNamer func(ifIndex int) string + +var ( + agentIP net.IP + interfaceNamer InterfaceNamer = func(ifIndex int) string { return fmt.Sprintf("[namer unset] %d", ifIndex) } +) + +func SetGlobals(ip net.IP, ifaceNamer InterfaceNamer) { + agentIP = ip + interfaceNamer = ifaceNamer +} + // record structure as parsed from eBPF type RawRecord ebpf.BpfFlowRecordT @@ -48,20 +58,11 @@ type Record struct { TimeFlowStart time.Time TimeFlowEnd time.Time DNSLatency time.Duration - Interface string - // Duplicate tells whether this flow has another duplicate so it has to be excluded from - // any metrics' aggregation (e.g. bytes/second rates between two pods). - // The reason for this field is that the same flow can be observed from multiple interfaces, - // so the agent needs to choose only a view of the same flow and mark the others as - // "exclude from aggregation". Otherwise rates, sums, etc... values would be multiplied by the - // number of interfaces this flow is observed from. - Duplicate bool - + Interfaces []IntfDir // AgentIP provides information about the source of the flow (the Agent that traced it) AgentIP net.IP // Calculated RTT which is set when record is created by calling NewRecord TimeFlowRtt time.Duration - DupList []map[string]uint8 NetworkMonitorEventsMD []config.GenericMap } @@ -79,8 +80,16 @@ func NewRecord( Metrics: *metrics, TimeFlowStart: currentTime.Add(-startDelta), TimeFlowEnd: currentTime.Add(-endDelta), + AgentIP: agentIP, + Interfaces: []IntfDir{NewIntfDir(interfaceNamer(int(metrics.IfIndexFirstSeen)), int(metrics.DirectionFirstSeen))}, } if metrics.AdditionalMetrics != nil { + for i := uint8(0); i < record.Metrics.AdditionalMetrics.NbObservedIntf; i++ { + record.Interfaces = append(record.Interfaces, NewIntfDir( + interfaceNamer(int(metrics.AdditionalMetrics.ObservedIntf[i].IfIndex)), + int(metrics.AdditionalMetrics.ObservedIntf[i].Direction), + )) + } if metrics.AdditionalMetrics.FlowRtt != 0 { record.TimeFlowRtt = time.Duration(metrics.AdditionalMetrics.FlowRtt) } @@ -88,11 +97,17 @@ func NewRecord( record.DNSLatency = time.Duration(metrics.AdditionalMetrics.DnsRecord.Latency) } } - record.DupList = make([]map[string]uint8, 0) record.NetworkMonitorEventsMD = make([]config.GenericMap, 0) return &record } +type IntfDir struct { + Interface string + Direction int +} + +func NewIntfDir(intf string, dir int) IntfDir { return IntfDir{Interface: intf, Direction: dir} } + func networkEventsMDExist(events [MaxNetworkEvents][NetworkEventsMaxEventsMD]uint8, md [NetworkEventsMaxEventsMD]uint8) bool { for _, e := range events { if reflect.DeepEqual(e, md) { diff --git a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow/proto.go b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow/proto.go index 27b7e57c0..ccbc8c6ab 100644 --- a/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow/proto.go +++ b/vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow/proto.go @@ -40,7 +40,7 @@ func FlowsToPB(inputRecords []*model.Record, maxLen int, s *ovnobserv.SampleDeco func FlowToPB(fr *model.Record, s *ovnobserv.SampleDecoder) *Record { var pbflowRecord = Record{ EthProtocol: uint32(fr.Metrics.EthProtocol), - Direction: Direction(fr.ID.Direction), + Direction: Direction(fr.Metrics.DirectionFirstSeen), DataLink: &DataLink{ SrcMac: macToUint64(&fr.Metrics.SrcMac), DstMac: macToUint64(&fr.Metrics.DstMac), @@ -65,10 +65,8 @@ func FlowToPB(fr *model.Record, s *ovnobserv.SampleDecoder) *Record { Nanos: int32(fr.TimeFlowEnd.Nanosecond()), }, Packets: uint64(fr.Metrics.Packets), - Duplicate: fr.Duplicate, AgentIp: agentIP(fr.AgentIP), Flags: uint32(fr.Metrics.Flags), - Interface: fr.Interface, TimeFlowRtt: durationpb.New(fr.TimeFlowRtt), Sampling: fr.Metrics.Sampling, } @@ -91,16 +89,12 @@ func FlowToPB(fr *model.Record, s *ovnobserv.SampleDecoder) *Record { IcmpId: uint32(fr.Metrics.AdditionalMetrics.TranslatedFlow.IcmpId), } } - if len(fr.DupList) != 0 { - pbflowRecord.DupList = make([]*DupMapEntry, 0) - for _, m := range fr.DupList { - for key, value := range m { - pbflowRecord.DupList = append(pbflowRecord.DupList, &DupMapEntry{ - Interface: key, - Direction: Direction(value), - }) - } - } + pbflowRecord.DupList = make([]*DupMapEntry, 0) + for _, intf := range fr.Interfaces { + pbflowRecord.DupList = append(pbflowRecord.DupList, &DupMapEntry{ + Interface: intf.Interface, + Direction: Direction(intf.Direction), + }) } if fr.Metrics.EthProtocol == model.IPv6Type { pbflowRecord.Network.SrcAddr = &IP{IpFamily: &IP_Ipv6{Ipv6: fr.ID.SrcIp[:]}} @@ -164,7 +158,6 @@ func PBToFlow(pb *Record) *model.Record { } out := model.Record{ ID: ebpf.BpfFlowId{ - Direction: uint8(pb.Direction), TransportProtocol: uint8(pb.Transport.Protocol), SrcIp: ipToIPAddr(pb.Network.GetSrcAddr()), DstIp: ipToIPAddr(pb.Network.GetDstAddr()), @@ -211,19 +204,16 @@ func PBToFlow(pb *Record) *model.Record { TimeFlowStart: pb.TimeFlowStart.AsTime(), TimeFlowEnd: pb.TimeFlowEnd.AsTime(), AgentIP: pbIPToNetIP(pb.AgentIp), - Duplicate: pb.Duplicate, - Interface: pb.Interface, TimeFlowRtt: pb.TimeFlowRtt.AsDuration(), DNSLatency: pb.DnsLatency.AsDuration(), } if len(pb.GetDupList()) != 0 { for _, entry := range pb.GetDupList() { - intf := entry.Interface - dir := uint8(entry.Direction) - out.DupList = append(out.DupList, map[string]uint8{intf: dir}) + out.Interfaces = append(out.Interfaces, model.NewIntfDir(entry.Interface, int(entry.Direction))) } } + if len(pb.GetNetworkEventsMetadata()) != 0 { for _, e := range pb.GetNetworkEventsMetadata() { m := config.GenericMap{} @@ -232,7 +222,7 @@ func PBToFlow(pb *Record) *model.Record { } out.NetworkMonitorEventsMD = append(out.NetworkMonitorEventsMD, m) } - protoLog.Debugf("decoded Network events monitor metadata: %v", out.NetworkMonitorEventsMD) + protoLog.Tracef("decoded Network events monitor metadata: %v", out.NetworkMonitorEventsMD) } return &out diff --git a/vendor/modules.txt b/vendor/modules.txt index 447c809ec..b5513dc2c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -310,7 +310,7 @@ github.com/netobserv/loki-client-go/pkg/labelutil github.com/netobserv/loki-client-go/pkg/logproto github.com/netobserv/loki-client-go/pkg/metric github.com/netobserv/loki-client-go/pkg/urlutil -# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20241213165959-7e7f8c42a3f6 +# github.com/netobserv/netobserv-ebpf-agent v1.7.0-community.0.20250115132126-73256abeed31 ## explicit; go 1.22.3 github.com/netobserv/netobserv-ebpf-agent/pkg/decode github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf