initNetwork initialises the network configuration for load balancing.
()
| 275 | |
| 276 | // initNetwork initialises the network configuration for load balancing. |
| 277 | func (e *Engine) initNetwork() { |
| 278 | if e.config.AnycastEnabled { |
| 279 | if err := e.ncc.BGPWithdrawAll(); err != nil { |
| 280 | log.Fatalf("Failed to withdraw all BGP advertisements: %v", err) |
| 281 | } |
| 282 | } |
| 283 | if err := e.ncc.IPVSFlush(); err != nil { |
| 284 | log.Fatalf("Failed to flush IPVS table: %v", err) |
| 285 | } |
| 286 | |
| 287 | lbCfg := &ncctypes.LBConfig{ |
| 288 | ClusterVIP: e.config.ClusterVIP, |
| 289 | DummyInterface: e.config.DummyInterface, |
| 290 | NodeInterface: e.config.NodeInterface, |
| 291 | Node: e.config.Node, |
| 292 | RoutingTableID: e.config.RoutingTableID, |
| 293 | VRID: e.config.VRID, |
| 294 | UseVMAC: e.config.UseVMAC, |
| 295 | } |
| 296 | e.lbInterface = e.ncc.NewLBInterface(e.config.LBInterface, lbCfg) |
| 297 | |
| 298 | if err := e.lbInterface.Init(); err != nil { |
| 299 | log.Fatalf("Failed to initialise LB interface: %v", err) |
| 300 | } |
| 301 | |
| 302 | if e.config.AnycastEnabled { |
| 303 | e.initAnycast() |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // initAnycast initialises the anycast configuration. |
| 308 | func (e *Engine) initAnycast() { |
no test coverage detected