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
No related branches found
No related tags found
No related merge requests found
......@@ -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")
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment