diff --git a/pkg/ebpf/tracer.go b/pkg/ebpf/tracer.go index 4aa7b2dea6cab18220439b3a6e517f53f7e7a753..0db9308c276f1e0b350a384177247d017851b230 100644 --- a/pkg/ebpf/tracer.go +++ b/pkg/ebpf/tracer.go @@ -406,12 +406,14 @@ func (m *FlowFetcher) lookupAndDeleteDNSMap(timeOut time.Duration) { var dnsKey BpfDnsFlowId var dnsVal uint64 - iterator := dnsMap.Iterate() - for iterator.Next(&dnsKey, &dnsVal) { - if time.Duration(uint64(monotonicTimeNow)-dnsVal) >= timeOut { - if err := dnsMap.Delete(dnsKey); err != nil { - log.WithError(err).WithField("dnsKey", dnsKey). - Warnf("couldn't delete DNS record entry") + if dnsMap != nil { + iterator := dnsMap.Iterate() + for iterator.Next(&dnsKey, &dnsVal) { + if time.Duration(uint64(monotonicTimeNow)-dnsVal) >= timeOut { + if err := dnsMap.Delete(dnsKey); err != nil { + log.WithError(err).WithField("dnsKey", dnsKey). + Warnf("couldn't delete DNS record entry") + } } } } @@ -425,12 +427,14 @@ func (m *FlowFetcher) lookupAndDeleteRTTMap(timeOut time.Duration) { var rttKey BpfFlowSeqId var rttVal uint64 - iterator := rttMap.Iterate() - for iterator.Next(&rttKey, &rttVal) { - if time.Duration(uint64(monotonicTimeNow)-rttVal) >= timeOut { - if err := rttMap.Delete(rttKey); err != nil { - log.WithError(err).WithField("rttKey", rttKey). - Warnf("couldn't delete RTT record entry") + if rttMap != nil { + iterator := rttMap.Iterate() + for iterator.Next(&rttKey, &rttVal) { + if time.Duration(uint64(monotonicTimeNow)-rttVal) >= timeOut { + if err := rttMap.Delete(rttKey); err != nil { + log.WithError(err).WithField("rttKey", rttKey). + Warnf("couldn't delete RTT record entry") + } } } }