ipvs

package
v0.0.0-...-1cdf2d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 86

Documentation

Overview

Package ipvs provides a Go interface to Linux IPVS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDestination

func AddDestination(svc Service, dst Destination) error

AddDestination adds the specified destination to the IPVS table.

func AddService

func AddService(svc Service) error

AddService adds the specified service to the IPVS table. Any destinations associated with the given service will also be added.

func DeleteDestination

func DeleteDestination(svc Service, dst Destination) error

DeleteDestination deletes the specified destination from the IPVS table.

func DeleteService

func DeleteService(svc Service) error

DeleteService deletes the specified service from the IPVS table.

func Flush

func Flush() error

Flush flushes all services and destinations from the IPVS table.

func Init

func Init() error

Init intialises IPVS.

func UpdateDestination

func UpdateDestination(svc Service, dst Destination) error

UpdateDestination updates the specified destination in the IPVS table.

func UpdateService

func UpdateService(svc Service) error

UpdateService updates the specified service in the IPVS table.

Types

type Destination

type Destination struct {
	Address        net.IP
	Port           uint16
	Weight         int32
	Flags          DestinationFlags
	LowerThreshold uint32
	UpperThreshold uint32
	Statistics     *DestinationStats
}

Destination represents an IPVS destination.

func (Destination) Equal

func (dest Destination) Equal(other Destination) bool

Equal returns true if two Destinations are the same.

func (Destination) String

func (dest Destination) String() string

String returns a string representation of a Destination.

type DestinationFlags

type DestinationFlags uint32

DestinationFlags specifies the flags for a connection to an IPVS destination.

const (
	DFForwardMask   DestinationFlags = ipvsDstFlagFwdMask
	DFForwardMasq   DestinationFlags = ipvsDstFlagFwdMasq
	DFForwardLocal  DestinationFlags = ipvsDstFlagFwdLocal
	DFForwardRoute  DestinationFlags = ipvsDstFlagFwdRoute
	DFForwardTunnel DestinationFlags = ipvsDstFlagFwdTunnel
	DFForwardBypass DestinationFlags = ipvsDstFlagFwdBypass
)

type DestinationStats

type DestinationStats struct {
	Stats
	ActiveConns   uint32
	InactiveConns uint32
	PersistConns  uint32
}

DestinationStats encapsulates statistics for an IPVS destination.

type IPProto

type IPProto uint16

IPProto specifies the protocol encapsulated within an IP datagram.

func (IPProto) String

func (proto IPProto) String() string

String returns the name for the given protocol value.

type IPVSVersion

type IPVSVersion struct {
	Major uint
	Minor uint
	Patch uint
}

IPVSVersion represents a IPVS version as major, minor and patch values.

func Version

func Version() IPVSVersion

Version returns the version number for IPVS.

func (IPVSVersion) String

func (v IPVSVersion) String() string

String returns a string representation of the IPVS version number.

type Service

type Service struct {
	Address           net.IP
	Protocol          IPProto
	Port              uint16
	FirewallMark      uint32
	Scheduler         string
	Flags             ServiceFlags
	Timeout           uint32
	PersistenceEngine string
	Statistics        *ServiceStats
	Destinations      []*Destination
}

Service represents an IPVS service.

func GetService

func GetService(svc *Service) (*Service, error)

GetService returns the service entry that is currently configured in the kernel IPVS table, which matches the specified service.

func GetServices

func GetServices() ([]*Service, error)

GetServices returns a list of service entries that are currently configured in the kernel IPVS table.

func (Service) Equal

func (svc Service) Equal(other Service) bool

Equal returns true if two Services are the same.

func (Service) String

func (svc Service) String() string

String returns a string representation of a Service.

type ServiceFlags

type ServiceFlags uint32

ServiceFlags specifies the flags for a IPVS service.

const (
	SFPersistent      ServiceFlags = ipvsSvcFlagPersist
	SFHashed          ServiceFlags = ipvsSvcFlagHashed
	SFOnePacket       ServiceFlags = ipvsSvcFlagOnePacket
	SFSchedSHFallback ServiceFlags = ipvsSvcFlagSchedSHFallback
	SFSchedSHPort     ServiceFlags = ipvsSvcFlagSchedSHPort
	SFSchedMHFallback ServiceFlags = ipvsSvcFlagSchedMHFallback
	SFSchedMHPort     ServiceFlags = ipvsSvcFlagSchedMHPort
)

func (ServiceFlags) Bytes

func (f ServiceFlags) Bytes() []byte

Bytes returns the netlink representation of the service flags.

func (*ServiceFlags) SetBytes

func (f *ServiceFlags) SetBytes(x []byte)

SetBytes sets the service flags from its netlink representation.

type ServiceStats

type ServiceStats struct {
	Stats
}

ServiceStats encapsulates statistics for an IPVS service.

type Stats

type Stats struct {
	Connections uint32 `netlink:"attr:1"`
	PacketsIn   uint32 `netlink:"attr:2"`
	PacketsOut  uint32 `netlink:"attr:3"`
	BytesIn     uint64 `netlink:"attr:4"`
	BytesOut    uint64 `netlink:"attr:5"`
	CPS         uint32 `netlink:"attr:6"`
	PPSIn       uint32 `netlink:"attr:7"`
	PPSOut      uint32 `netlink:"attr:8"`
	BPSIn       uint32 `netlink:"attr:9"`
	BPSOut      uint32 `netlink:"attr:10"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL