Skip to content

Commit

Permalink
Improve connector iptables maintainence
Browse files Browse the repository at this point in the history
Signed-off-by: yanjianbo <[email protected]>
  • Loading branch information
yanjianbo1983 committed Oct 30, 2023
1 parent 270740d commit 8db6329
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/connector/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (c Config) Manager() (*Manager, error) {
tm, err := strongswan.New(
strongswan.SocketFile(c.ViciSocket),
strongswan.StartAction("none"),
strongswan.InitTimeout(10),
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -180,8 +181,6 @@ func (m *Manager) notify() {
func (m *Manager) Start() {
about.DisplayVersion()

m.removeAllChains()

go m.runLeaderElection()
go m.runHTTPServer()
go m.workLoop()
Expand Down Expand Up @@ -327,12 +326,15 @@ func (m *Manager) workLoop() {
continue
}

m.maintainTunnels()
m.maintainRoutes()

m.iptHandler.maintainIPTables()
m.ipt6Handler.maintainIPTables()
m.broadcastConnectorPrefixes()

// maintainTunnels may last for minutes, so put it at the end, otherwise it may cause error, such as wrong iptables
// rules and wrong routes are generated after isLeader is set to false
m.maintainTunnels()
}
}

Expand Down

0 comments on commit 8db6329

Please sign in to comment.