MCPcopy
hub / github.com/google/seesaw / expandFWMServices

Method expandFWMServices

engine/vserver.go:340–384  ·  view source on GitHub ↗

expandFWMServices returns a list of services that have been expanded from the vserver configuration for a firewall mark based vserver.

()

Source from the content-addressed store, hash-verified

338// expandFWMServices returns a list of services that have been expanded from the
339// vserver configuration for a firewall mark based vserver.
340func (v *vserver) expandFWMServices() map[serviceKey]*service {
341 svcs := make(map[serviceKey]*service)
342 for _, af := range seesaw.AFs() {
343 var ip net.IP
344 switch af {
345 case seesaw.IPv4:
346 ip = v.config.Host.IPv4Addr
347 case seesaw.IPv6:
348 ip = v.config.Host.IPv6Addr
349 }
350 if ip == nil {
351 continue
352 }
353
354 // Persistence, etc., is stored in the VserverEntry. For FWM services, these
355 // values must be the same for all VserverEntries, so just use the first
356 // one.
357 var ventry *config.VserverEntry
358 for _, entry := range v.config.Entries {
359 ventry = entry
360 break
361 }
362
363 if v.fwm[af] == 0 {
364 mark, err := v.engine.fwmAlloc.get()
365 if err != nil {
366 log.Fatalf("%v: failed to get mark: %v", v, err)
367 }
368 v.fwm[af] = mark
369 }
370 svc := &service{
371 serviceKey: serviceKey{
372 af: af,
373 fwm: v.fwm[af],
374 },
375 ip: seesaw.NewIP(ip),
376 ventry: ventry,
377 vserver: v,
378 stats: &seesaw.ServiceStats{},
379 }
380 svc.ipvsSvc = svc.ipvsService()
381 svcs[svc.serviceKey] = svc
382 }
383 return svcs
384}
385
386// expandDests returns a list of destinations that have been expanded from the
387// vserver configuration and a given service.

Callers 1

expandServicesMethod · 0.95

Calls 4

ipvsServiceMethod · 0.95
AFsFunction · 0.92
NewIPFunction · 0.92
getMethod · 0.80

Tested by

no test coverage detected