Skip to content

Commit

Permalink
kill established connections only on fw/monitor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed May 19, 2024
1 parent 8c25c3f commit 661e3da
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions daemon/ui/config_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ func (c *Client) reloadConfiguration(reload bool, newConfig config.Config) *moni
log.Debug("[config] config.rules.path not changed")
}

reloadFw := false
if c.GetFirewallType() != newConfig.Firewall ||
newConfig.FwOptions.ConfigPath != c.config.FwOptions.ConfigPath ||
newConfig.FwOptions.QueueNum != c.config.FwOptions.QueueNum ||
newConfig.FwOptions.MonitorInterval != c.config.FwOptions.MonitorInterval {
log.Debug("[config] reloading config.firewall")
reloadFw = true

firewall.Reload(
newConfig.Firewall,
Expand All @@ -181,13 +183,6 @@ func (c *Client) reloadConfiguration(reload bool, newConfig config.Config) *moni
log.Debug("[config] config.firewall not changed")
}

if newConfig.Internal.FlushConnsOnStart {
log.Debug("[config] flushing established connections")
netlink.FlushConnections()
} else {
log.Debug("[config] not flushing established connections")
}

reloadProc := false
if c.config.ProcMonitorMethod == "" ||
newConfig.ProcMonitorMethod != c.config.ProcMonitorMethod {
Expand All @@ -213,5 +208,12 @@ func (c *Client) reloadConfiguration(reload bool, newConfig config.Config) *moni
log.Debug("[config] config.procmon not changed")
}

if (reloadProc || reloadFw) && newConfig.Internal.FlushConnsOnStart {
log.Debug("[config] flushing established connections")
netlink.FlushConnections()
} else {
log.Debug("[config] not flushing established connections")
}

return nil
}

0 comments on commit 661e3da

Please sign in to comment.