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