Skip to content
Snippets Groups Projects
Unverified Commit af7d59da authored by Mohamed S. Mahmoud's avatar Mohamed S. Mahmoud Committed by GitHub
Browse files

NETOBSERV-1223: check Maps to make sure not nil b4 iterating (#167)


Signed-off-by: default avatarmsherif1234 <mmahmoud@redhat.com>
parent 8150ccc2
Branches
Tags
No related merge requests found
...@@ -406,12 +406,14 @@ func (m *FlowFetcher) lookupAndDeleteDNSMap(timeOut time.Duration) { ...@@ -406,12 +406,14 @@ func (m *FlowFetcher) lookupAndDeleteDNSMap(timeOut time.Duration) {
var dnsKey BpfDnsFlowId var dnsKey BpfDnsFlowId
var dnsVal uint64 var dnsVal uint64
iterator := dnsMap.Iterate() if dnsMap != nil {
for iterator.Next(&dnsKey, &dnsVal) { iterator := dnsMap.Iterate()
if time.Duration(uint64(monotonicTimeNow)-dnsVal) >= timeOut { for iterator.Next(&dnsKey, &dnsVal) {
if err := dnsMap.Delete(dnsKey); err != nil { if time.Duration(uint64(monotonicTimeNow)-dnsVal) >= timeOut {
log.WithError(err).WithField("dnsKey", dnsKey). if err := dnsMap.Delete(dnsKey); err != nil {
Warnf("couldn't delete DNS record entry") log.WithError(err).WithField("dnsKey", dnsKey).
Warnf("couldn't delete DNS record entry")
}
} }
} }
} }
...@@ -425,12 +427,14 @@ func (m *FlowFetcher) lookupAndDeleteRTTMap(timeOut time.Duration) { ...@@ -425,12 +427,14 @@ func (m *FlowFetcher) lookupAndDeleteRTTMap(timeOut time.Duration) {
var rttKey BpfFlowSeqId var rttKey BpfFlowSeqId
var rttVal uint64 var rttVal uint64
iterator := rttMap.Iterate() if rttMap != nil {
for iterator.Next(&rttKey, &rttVal) { iterator := rttMap.Iterate()
if time.Duration(uint64(monotonicTimeNow)-rttVal) >= timeOut { for iterator.Next(&rttKey, &rttVal) {
if err := rttMap.Delete(rttKey); err != nil { if time.Duration(uint64(monotonicTimeNow)-rttVal) >= timeOut {
log.WithError(err).WithField("rttKey", rttKey). if err := rttMap.Delete(rttKey); err != nil {
Warnf("couldn't delete RTT record entry") log.WithError(err).WithField("rttKey", rttKey).
Warnf("couldn't delete RTT record entry")
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment