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

close all maps when agent is terminating (#196)


Signed-off-by: default avatarmsherif1234 <mmahmoud@redhat.com>
parent 6feace71
No related branches found
No related tags found
No related merge requests found
...@@ -288,19 +288,23 @@ func (m *FlowFetcher) registerIngress(iface ifaces.Interface, ipvlan netlink.Lin ...@@ -288,19 +288,23 @@ func (m *FlowFetcher) registerIngress(iface ifaces.Interface, ipvlan netlink.Lin
} }
// Close the eBPF fetcher from the system. // Close the eBPF fetcher from the system.
// We don't need an "Close(iface)" method because the filters and qdiscs // We don't need a "Close(iface)" method because the filters and qdiscs
// are automatically removed when the interface is down // are automatically removed when the interface is down
// nolint:cyclop
func (m *FlowFetcher) Close() error { func (m *FlowFetcher) Close() error {
log.Debug("unregistering eBPF objects") log.Debug("unregistering eBPF objects")
var errs []error var errs []error
if m.pktDropsTracePoint != nil { if m.pktDropsTracePoint != nil {
m.pktDropsTracePoint.Close() if err := m.pktDropsTracePoint.Close(); err != nil {
errs = append(errs, err)
}
} }
if m.dnsTrackerTracePoint != nil { if m.dnsTrackerTracePoint != nil {
m.dnsTrackerTracePoint.Close() if err := m.dnsTrackerTracePoint.Close(); err != nil {
errs = append(errs, err)
}
} }
// m.ringbufReader.Read is a blocking operation, so we need to close the ring buffer // m.ringbufReader.Read is a blocking operation, so we need to close the ring buffer
// from another goroutine to avoid the system not being able to exit if there // from another goroutine to avoid the system not being able to exit if there
...@@ -323,7 +327,15 @@ func (m *FlowFetcher) Close() error { ...@@ -323,7 +327,15 @@ func (m *FlowFetcher) Close() error {
if err := m.objects.DirectFlows.Close(); err != nil { if err := m.objects.DirectFlows.Close(); err != nil {
errs = append(errs, err) errs = append(errs, err)
} }
m.objects = nil if err := m.objects.DnsFlows.Close(); err != nil {
errs = append(errs, err)
}
if err := m.objects.FlowSequences.Close(); err != nil {
errs = append(errs, err)
}
if len(errs) == 0 {
m.objects = nil
}
} }
for iface, ef := range m.egressFilters { for iface, ef := range m.egressFilters {
log := log.WithField("interface", iface) log := log.WithField("interface", iface)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment