ipvsService returns an IPVS Service for the given service.
()
| 109 | |
| 110 | // ipvsService returns an IPVS Service for the given service. |
| 111 | func (s *service) ipvsService() *ipvs.Service { |
| 112 | var flags ipvs.ServiceFlags |
| 113 | if s.ventry.Persistence > 0 { |
| 114 | flags |= ipvs.SFPersistent |
| 115 | } |
| 116 | if s.ventry.OnePacket { |
| 117 | flags |= ipvs.SFOnePacket |
| 118 | } |
| 119 | // Enables fallback and port for hashing schedulers. |
| 120 | // Maps to ipvs sh-fallback, sh-port, mh-fallback and mh-port. |
| 121 | switch s.ventry.Scheduler { |
| 122 | case seesaw.LBSchedulerSH: |
| 123 | flags |= ipvs.SFSchedSHFallback | ipvs.SFSchedSHPort |
| 124 | case seesaw.LBSchedulerMH: |
| 125 | flags |= ipvs.SFSchedMHFallback | ipvs.SFSchedMHPort |
| 126 | } |
| 127 | var ip net.IP |
| 128 | switch { |
| 129 | case s.fwm > 0 && s.af == seesaw.IPv4: |
| 130 | ip = net.IPv4zero |
| 131 | case s.fwm > 0 && s.af == seesaw.IPv6: |
| 132 | ip = net.IPv6zero |
| 133 | default: |
| 134 | ip = s.ip.IP() |
| 135 | } |
| 136 | return &ipvs.Service{ |
| 137 | Address: ip, |
| 138 | Protocol: ipvs.IPProto(s.proto), |
| 139 | Port: s.port, |
| 140 | Scheduler: s.ventry.Scheduler.String(), |
| 141 | FirewallMark: s.fwm, |
| 142 | Flags: flags, |
| 143 | Timeout: uint32(s.ventry.Persistence), |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // ipvsEqual returns true if two services have the same IPVS configuration. |
| 148 | // Transient state and the services' destinations are ignored. |
no test coverage detected