2016-04-13 20:53:41 -04:00
|
|
|
package libnetwork
|
|
|
|
|
2016-05-25 01:46:18 -04:00
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// A global monotonic counter to assign firewall marks to
|
|
|
|
// services.
|
|
|
|
fwMarkCtr uint32 = 256
|
|
|
|
fwMarkCtrMu sync.Mutex
|
|
|
|
)
|
2016-05-08 03:48:04 -04:00
|
|
|
|
2016-04-13 20:53:41 -04:00
|
|
|
type service struct {
|
2016-05-25 01:46:18 -04:00
|
|
|
name string // Service Name
|
|
|
|
id string // Service ID
|
2016-04-13 20:53:41 -04:00
|
|
|
|
2016-05-25 01:46:18 -04:00
|
|
|
// Map of loadbalancers for the service one-per attached
|
|
|
|
// network. It is keyed with network ID.
|
|
|
|
loadBalancers map[string]*loadBalancer
|
2016-05-31 02:55:51 -04:00
|
|
|
|
|
|
|
// List of ingress ports exposed by the service
|
|
|
|
ingressPorts []*PortConfig
|
|
|
|
|
2016-05-25 01:46:18 -04:00
|
|
|
sync.Mutex
|
2016-04-13 20:53:41 -04:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:46:18 -04:00
|
|
|
type loadBalancer struct {
|
|
|
|
vip net.IP
|
|
|
|
fwMark uint32
|
2016-04-13 20:53:41 -04:00
|
|
|
|
2016-05-25 01:46:18 -04:00
|
|
|
// Map of backend IPs backing this loadbalancer on this
|
|
|
|
// network. It is keyed with endpoint ID.
|
|
|
|
backEnds map[string]net.IP
|
2016-05-31 02:55:51 -04:00
|
|
|
|
|
|
|
// Back pointer to service to which the loadbalancer belongs.
|
|
|
|
service *service
|
2016-04-13 20:53:41 -04:00
|
|
|
}
|