Documentation ¶
Index ¶
- Constants
- Variables
- func IPv4ToUint32(ipv4 string) (uint32, error)
- func IPv6AddrToString(ipv6addr IPv6Addr) string
- func LookupTypeOnStartup(alist []AttrListTuple, familyName string)
- func SerializeNLMsg(mt *MessageType, msg GNLMessage, portId, Seq uint32) ([]byte, error)
- func U32ToBinFlags(flags uint32) []byte
- func Uint32IPv4ToString(ipv4 uint32) string
- type AttrHdr
- type AttrListTuple
- type AttrListType
- type AttrTuple
- type BinaryType
- type Dest
- type GNLMessage
- type GNLMsgHdr
- type I32Type
- type IPv6Addr
- type IgnoreType
- type IpvsClient
- func (ipvs *IpvsClient) AddDest(vip string, port uint16, rip string, protocol uint16, weight int32) error
- func (ipvs *IpvsClient) AddDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16, ...) error
- func (ipvs *IpvsClient) AddFWMDest(fwmark uint32, rip string, vaf uint16, port uint16, weight int32) error
- func (ipvs *IpvsClient) AddFWMDestFWD(fwmark uint32, rip string, vaf uint16, port uint16, weight int32, fwd uint32) error
- func (ipvs *IpvsClient) AddFWMService(fwmark uint32, sched string, af uint16) error
- func (ipvs *IpvsClient) AddFWMServiceWithFlags(fwmark uint32, sched string, af uint16, flags []byte) error
- func (ipvs *IpvsClient) AddService(vip string, port uint16, protocol uint16, sched string) error
- func (ipvs *IpvsClient) AddServiceWithFlags(vip string, port uint16, protocol uint16, sched string, flags []byte) error
- func (ipvs *IpvsClient) DelDest(vip string, port uint16, rip string, protocol uint16) error
- func (ipvs *IpvsClient) DelDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16) error
- func (ipvs *IpvsClient) DelFWMDest(fwmark uint32, rip string, vaf uint16, port uint16) error
- func (ipvs *IpvsClient) DelFWMService(fwmark uint32, af uint16) error
- func (ipvs *IpvsClient) DelService(vip string, port uint16, protocol uint16) error
- func (ipvs *IpvsClient) Exit()
- func (ipvs *IpvsClient) Flush() error
- func (ipvs *IpvsClient) GetAllStatsBrief() (map[string]StatsIntf, error)
- func (ipvs *IpvsClient) GetPoolForService(svc Service) (Pool, error)
- func (ipvs *IpvsClient) GetPools() ([]Pool, error)
- func (ipvs *IpvsClient) Init() error
- func (ipvs *IpvsClient) UpdateDest(vip string, port uint16, rip string, protocol uint16, weight int32) error
- func (ipvs *IpvsClient) UpdateDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16, ...) error
- func (ipvs *IpvsClient) UpdateFWMDest(fwmark uint32, rip string, vaf uint16, port uint16, weight int32) error
- func (ipvs *IpvsClient) UpdateFWMDestFWD(fwmark uint32, rip string, vaf uint16, port uint16, weight int32, fwd uint32) error
- type MessageType
- func (mt *MessageType) DeserializeGNLMsg(sMsg []byte) (GNLMessage, error)
- func (mt *MessageType) InitGNLMessageStr(cmnd string, flags uint16) (GNLMessage, error)
- func (mt *MessageType) InitMessageType(alist []AttrListTuple, familyId uint16)
- func (mt *MessageType) SerializeGNLMsg(msg GNLMessage) ([]byte, error)
- type NLMsgHdr
- type NLSocket
- type Net16Type
- type Net32Type
- type NulStringType
- type Pool
- type SerDes
- type Service
- type Stats
- type Stats64
- type StatsIntf
- type U16Type
- type U32Type
- type U64Type
- type U8Type
Constants ¶
View Source
const ( REQUEST = 1 MULTI = 2 ACK = 4 ECHO = 8 DUMP_INTR = 16 ROOT = 0x100 MATCH = 0x200 ATOMIC = 0x400 DUMP = (ROOT | MATCH) REPLACE = 0x100 EXCL = 0x200 CREATE = 0x400 APPEND = 0x800 NETLINK_GENERIC = 16 ACK_REQUEST = (REQUEST | ACK) MATCH_ROOT_REQUEST = (MATCH | ROOT | REQUEST) )
View Source
const ( ControlMessageType = 16 ErrorMessageType = 2 DoneMessageType = 3 )
View Source
const ( IPVS_MASQUERADING = 0 IPVS_TUNNELING = 2 IPVS_DIRECTROUTE = 3 )
View Source
const ( NO_FLAGS = 0x0 /* no flags */ IP_VS_SVC_F_PERSISTENT = 0x0001 /* persistent port */ IP_VS_SVC_F_HASHED = 0x0002 /* hashed entry */ IP_VS_SVC_F_ONEPACKET = 0x0004 /* one-packet scheduling */ IP_VS_SVC_F_SCHED1 = 0x0008 /* scheduler flag 1 */ IP_VS_SVC_F_SCHED2 = 0x0010 /* scheduler flag 2 */ IP_VS_SVC_F_SCHED3 = 0x0020 /* scheduler flag 3 */ IP_VS_SVC_F_SCHED_SH_FALLBACK = IP_VS_SVC_F_SCHED1 IP_VS_SVC_F_SCHED_SH_PORT = IP_VS_SVC_F_SCHED2 )
Variables ¶
View Source
var ( CtrlOpsAttrList = CreateAttrListDefinition("CtrlOpsAttrList", []AttrTuple{ AttrTuple{Name: "ID", Type: "U32Type"}, AttrTuple{Name: "FLAGS", Type: "U32Type"}, }) CtrlMcastGroupAttrList = CreateAttrListDefinition("CtrlMcastGroupAttrList", []AttrTuple{ AttrTuple{Name: "NAME", Type: "NulStringType"}, AttrTuple{Name: "ID", Type: "U32Type"}, }) CtrlAttrList = CreateAttrListDefinition("CtrlAttrList", []AttrTuple{ AttrTuple{Name: "FAMILY_ID", Type: "U16Type"}, AttrTuple{Name: "FAMILY_NAME", Type: "NulStringType"}, AttrTuple{Name: "VERSION", Type: "U32Type"}, AttrTuple{Name: "HDRSIZE", Type: "U32Type"}, AttrTuple{Name: "MAXATTR", Type: "U32Type"}, AttrTuple{Name: "OPS", Type: "IgnoreType"}, AttrTuple{Name: "MCAST_GROUPS", Type: "CtrlMcastGroupAttrList"}, }) NoneAttrList = []AttrTuple{} CtrlMessageInitList = []AttrListTuple{ AttrListTuple{Name: "NEWFAMILY", AttrList: CreateAttrListType(CtrlAttrList)}, AttrListTuple{Name: "DELFAMILY", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "GETFAMILY", AttrList: CreateAttrListType(CtrlAttrList)}, AttrListTuple{Name: "NEWOPS", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "DELOPS", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "GETOPS", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "NEWMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "DELMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)}, AttrListTuple{Name: "GETMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)}, } ErrorMessageInitList = []AttrListTuple{} DoneMessageInitList = []AttrListTuple{} CtrlMessage = CreateMsgType(CtrlMessageInitList, 16) ErrorMessage = CreateMsgType(ErrorMessageInitList, 2) DoneMessage = CreateMsgType(DoneMessageInitList, 3) )
View Source
var ( Family2MT = make(map[uint16]*MessageType) LookupOnStartup = make(map[string][]AttrListTuple) MT2Family = make(map[string]uint16) ATLName2ATL = make(map[string][]AttrTuple) )
View Source
var ( BIN_NO_FLAGS = []byte{0, 0, 0, 0, 0, 0, 0, 0} /* no flags */ BIN_IP_VS_SVC_F_PERSISTENT = U32ToBinFlags(IP_VS_SVC_F_PERSISTENT) /* persistent port */ BIN_IP_VS_SVC_F_HASHED = U32ToBinFlags(IP_VS_SVC_F_HASHED) /* hashed entry */ BIN_IP_VS_SVC_F_ONEPACKET = U32ToBinFlags(IP_VS_SVC_F_ONEPACKET) /* one-packet scheduling */ BIN_IP_VS_SVC_F_SCHED1 = U32ToBinFlags(IP_VS_SVC_F_SCHED1) /* scheduler flag 1 */ BIN_IP_VS_SVC_F_SCHED2 = U32ToBinFlags(IP_VS_SVC_F_SCHED2) /* scheduler flag 2 */ BIN_IP_VS_SVC_F_SCHED3 = U32ToBinFlags(IP_VS_SVC_F_SCHED3) /* scheduler flag 3 */ BIN_IP_VS_SVC_F_SCHED_SH_FALLBACK = BIN_IP_VS_SVC_F_SCHED1 BIN_IP_VS_SVC_F_SCHED_SH_PORT = BIN_IP_VS_SVC_F_SCHED2 )
View Source
var ( IpvsStatsAttrList = CreateAttrListDefinition("IpvsStatsAttrList", []AttrTuple{ AttrTuple{Name: "CONNS", Type: "U32Type"}, AttrTuple{Name: "INPKTS", Type: "U32Type"}, AttrTuple{Name: "OUTPKTS", Type: "U32Type"}, AttrTuple{Name: "INBYTES", Type: "U64Type"}, AttrTuple{Name: "OUTBYTES", Type: "U64Type"}, AttrTuple{Name: "CPS", Type: "U32Type"}, AttrTuple{Name: "INPPS", Type: "U32Type"}, AttrTuple{Name: "OUTPPS", Type: "U32Type"}, AttrTuple{Name: "INBPS", Type: "U32Type"}, AttrTuple{Name: "OUTBPS", Type: "U32Type"}, }) IpvsStats64AttrList = CreateAttrListDefinition("IpvsStats64AttrList", []AttrTuple{ AttrTuple{Name: "CONNS", Type: "U64Type"}, AttrTuple{Name: "INPKTS", Type: "U64Type"}, AttrTuple{Name: "OUTPKTS", Type: "U64Type"}, AttrTuple{Name: "INBYTES", Type: "U64Type"}, AttrTuple{Name: "OUTBYTES", Type: "U64Type"}, AttrTuple{Name: "CPS", Type: "U64Type"}, AttrTuple{Name: "INPPS", Type: "U64Type"}, AttrTuple{Name: "OUTPPS", Type: "U64Type"}, AttrTuple{Name: "INBPS", Type: "U64Type"}, AttrTuple{Name: "OUTBPS", Type: "U64Type"}, }) IpvsServiceAttrList = CreateAttrListDefinition("IpvsServiceAttrList", []AttrTuple{ AttrTuple{Name: "AF", Type: "U16Type"}, AttrTuple{Name: "PROTOCOL", Type: "U16Type"}, AttrTuple{Name: "ADDR", Type: "BinaryType"}, AttrTuple{Name: "PORT", Type: "Net16Type"}, AttrTuple{Name: "FWMARK", Type: "U32Type"}, AttrTuple{Name: "SCHED_NAME", Type: "NulStringType"}, AttrTuple{Name: "FLAGS", Type: "BinaryType"}, AttrTuple{Name: "TIMEOUT", Type: "U32Type"}, AttrTuple{Name: "NETMASK", Type: "U32Type"}, AttrTuple{Name: "STATS", Type: "IpvsStatsAttrList"}, AttrTuple{Name: "PE_NAME", Type: "NulStringType"}, AttrTuple{Name: "STATS64", Type: "IpvsStats64AttrList"}, }) IpvsDestAttrList = CreateAttrListDefinition("IpvsDestAttrList", []AttrTuple{ AttrTuple{Name: "ADDR", Type: "BinaryType"}, AttrTuple{Name: "PORT", Type: "Net16Type"}, AttrTuple{Name: "FWD_METHOD", Type: "U32Type"}, AttrTuple{Name: "WEIGHT", Type: "I32Type"}, AttrTuple{Name: "U_THRESH", Type: "U32Type"}, AttrTuple{Name: "L_THRESH", Type: "U32Type"}, AttrTuple{Name: "ACTIVE_CONNS", Type: "U32Type"}, AttrTuple{Name: "INACT_CONNS", Type: "U32Type"}, AttrTuple{Name: "PERSIST_CONNS", Type: "U32Type"}, AttrTuple{Name: "STATS", Type: "IpvsStatsAttrList"}, AttrTuple{Name: "ADDR_FAMILY", Type: "U16Type"}, AttrTuple{Name: "STATS64", Type: "IpvsStats64AttrList"}, }) IpvsDaemonAttrList = CreateAttrListDefinition("IpvsDaemonAttrList", []AttrTuple{ AttrTuple{Name: "STATE", Type: "U32Type"}, AttrTuple{Name: "MCAST_IFN", Type: "NulStringType"}, AttrTuple{Name: "SYNC_ID", Type: "U32Type"}, }) IpvsInfoAttrList = CreateAttrListDefinition("IpvsInfoAttrList", []AttrTuple{ AttrTuple{Name: "VERSION", Type: "U32Type"}, AttrTuple{Name: "CONN_TAB_SIZE", Type: "U32Type"}, }) IpvsCmdAttrList = CreateAttrListDefinition("IpvsCmdAttrList", []AttrTuple{ AttrTuple{Name: "SERVICE", Type: "IpvsServiceAttrList"}, AttrTuple{Name: "DEST", Type: "IpvsDestAttrList"}, AttrTuple{Name: "DAEMON", Type: "IpvsDaemonAttrList"}, AttrTuple{Name: "TIMEOUT_TCP", Type: "U32Type"}, AttrTuple{Name: "TIMEOUT_TCP_FIN", Type: "U32Type"}, AttrTuple{Name: "TIMEOUT_UDP", Type: "U32Type"}, }) IpvsMessageInitList = []AttrListTuple{ AttrListTuple{Name: "NEW_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "SET_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "DEL_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "GET_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "NEW_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "SET_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "DEL_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "GET_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "NEW_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "DEL_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "GET_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "SET_CONFIG", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "GET_CONFIG", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "SET_INFO", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "GET_INFO", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "ZERO", AttrList: CreateAttrListType(IpvsCmdAttrList)}, AttrListTuple{Name: "FLUSH", AttrList: CreateAttrListType(IpvsCmdAttrList)}, } )
Functions ¶
func IPv4ToUint32 ¶
func IPv6AddrToString ¶
func LookupTypeOnStartup ¶
func LookupTypeOnStartup(alist []AttrListTuple, familyName string)
Routine, which helps us to resolve family's name to ID on startup
func SerializeNLMsg ¶
func SerializeNLMsg(mt *MessageType, msg GNLMessage, portId, Seq uint32) ([]byte, error)
func U32ToBinFlags ¶
func Uint32IPv4ToString ¶
Types ¶
type AttrListTuple ¶
type AttrListTuple struct { Name string AttrList AttrListType }
type AttrListType ¶
type AttrListType struct { Key2name map[int]string Name2key map[string]int Key2Type map[int]string Amap map[string]SerDes }
Struct describes how we encode (which netlink's msg type number coresponds to which type) Amap contains dict of SerDes types, which we can serialize or where we will deserialize incoming msg.
func CreateAttrListType ¶
func CreateAttrListType(attrListMap []AttrTuple) AttrListType
func (*AttrListType) Deserialize ¶
func (al *AttrListType) Deserialize(list []byte) error
func (*AttrListType) Serialize ¶
func (al *AttrListType) Serialize() ([]byte, error)
func (*AttrListType) Set ¶
func (al *AttrListType) Set(amap map[string]SerDes)
func (*AttrListType) Val ¶
func (al *AttrListType) Val()
type AttrTuple ¶
This struct has been used for describing and constructing netlink's attributes lists.
func CreateAttrListDefinition ¶
Routine which helps us to create global attributelists definition dict.
type BinaryType ¶
type BinaryType []byte
func (*BinaryType) Deserialize ¶
func (bt *BinaryType) Deserialize(buf []byte) error
func (*BinaryType) Serialize ¶
func (bt *BinaryType) Serialize() ([]byte, error)
func (*BinaryType) Val ¶
func (bt *BinaryType) Val()
type GNLMessage ¶
type GNLMessage struct { Hdr GNLMsgHdr AttrMap map[string]SerDes Family uint16 Flags uint16 MT *MessageType }
func DeserializeNLMsg ¶
func DeserializeNLMsg(sMsg []byte) (GNLMessage, []byte, error)
func (*GNLMessage) GetAttrList ¶
func (msg *GNLMessage) GetAttrList(name string) SerDes
func (*GNLMessage) Init ¶
func (msg *GNLMessage) Init(hdr GNLMsgHdr, amap map[string]SerDes, family, flags uint16)
func (*GNLMessage) SetAttrList ¶
func (msg *GNLMessage) SetAttrList(name string, val SerDes)
type IgnoreType ¶
type IgnoreType bool
func (*IgnoreType) Deserialize ¶
func (it *IgnoreType) Deserialize(buf []byte) error
func (*IgnoreType) Serialize ¶
func (it *IgnoreType) Serialize() ([]byte, error)
func (*IgnoreType) Val ¶
func (it *IgnoreType) Val()
type IpvsClient ¶
type IpvsClient struct { Sock NLSocket // contains filtered or unexported fields }
func (*IpvsClient) AddDestPort ¶
func (*IpvsClient) AddFWMDest ¶
func (*IpvsClient) AddFWMDestFWD ¶
func (*IpvsClient) AddFWMService ¶
func (ipvs *IpvsClient) AddFWMService(fwmark uint32, sched string, af uint16) error
func (*IpvsClient) AddFWMServiceWithFlags ¶
func (*IpvsClient) AddService ¶
func (*IpvsClient) AddServiceWithFlags ¶
func (*IpvsClient) DelDestPort ¶
func (*IpvsClient) DelFWMDest ¶
func (*IpvsClient) DelFWMService ¶
func (ipvs *IpvsClient) DelFWMService(fwmark uint32, af uint16) error
func (*IpvsClient) DelService ¶
func (ipvs *IpvsClient) DelService(vip string, port uint16, protocol uint16) error
func (*IpvsClient) Exit ¶
func (ipvs *IpvsClient) Exit()
func (*IpvsClient) Flush ¶
func (ipvs *IpvsClient) Flush() error
func (*IpvsClient) GetAllStatsBrief ¶
func (ipvs *IpvsClient) GetAllStatsBrief() (map[string]StatsIntf, error)
func (*IpvsClient) GetPoolForService ¶
func (ipvs *IpvsClient) GetPoolForService(svc Service) (Pool, error)
func (*IpvsClient) GetPools ¶
func (ipvs *IpvsClient) GetPools() ([]Pool, error)
func (*IpvsClient) Init ¶
func (ipvs *IpvsClient) Init() error
func (*IpvsClient) UpdateDest ¶
func (*IpvsClient) UpdateDestPort ¶
func (*IpvsClient) UpdateFWMDest ¶
func (*IpvsClient) UpdateFWMDestFWD ¶
type MessageType ¶
type MessageType struct { Name2key map[string]int Key2name map[int]string Key2attrListType map[int]AttrListType Family uint16 }
Struct, which describes how generic netlink message for particular family could looks like
func CreateMsgType ¶
func CreateMsgType(alist []AttrListTuple, familyId uint16) MessageType
Routine, which helps us to create global dict of msg types
func (*MessageType) DeserializeGNLMsg ¶
func (mt *MessageType) DeserializeGNLMsg(sMsg []byte) (GNLMessage, error)
func (*MessageType) InitGNLMessageStr ¶
func (mt *MessageType) InitGNLMessageStr(cmnd string, flags uint16) (GNLMessage, error)
func (*MessageType) InitMessageType ¶
func (mt *MessageType) InitMessageType(alist []AttrListTuple, familyId uint16)
func (*MessageType) SerializeGNLMsg ¶
func (mt *MessageType) SerializeGNLMsg(msg GNLMessage) ([]byte, error)
type NLSocket ¶
func (*NLSocket) Execute ¶
func (nlSock *NLSocket) Execute(msg GNLMessage) error
func (*NLSocket) Query ¶
func (nlSock *NLSocket) Query(msg GNLMessage) ([]GNLMessage, error)
func (*NLSocket) ResolveFamily ¶
func (nlSock *NLSocket) ResolveFamily(family NulStringType) (*U16Type, error)
type NulStringType ¶
type NulStringType string
func FromProtoNum ¶
func FromProtoNum(pnum U16Type) NulStringType
func (*NulStringType) Deserialize ¶
func (ns *NulStringType) Deserialize(buf []byte) error
func (NulStringType) Serialize ¶
func (ns NulStringType) Serialize() ([]byte, error)
func (*NulStringType) Val ¶
func (ns *NulStringType) Val()
type Pool ¶
func (*Pool) InitFromAttrList ¶
type Service ¶
type Stats ¶
type Stats struct { Conns uint32 Inpkts uint32 Outpkts uint32 Inbytes uint64 Outbytes uint64 Cps uint32 Inpps uint32 Outpps uint32 Inbps uint32 Outbps uint32 }
func (*Stats) InitFromAttrList ¶
type Stats64 ¶
type Stats64 struct { Conns uint64 Inpkts uint64 Outpkts uint64 Inbytes uint64 Outbytes uint64 Cps uint64 Inpps uint64 Outpps uint64 Inbps uint64 Outbps uint64 }
func (*Stats64) InitFromAttrList ¶
type StatsIntf ¶
func GetStatsFromAttrList ¶
func GetStatsFromAttrList(attrList *AttrListType) StatsIntf
type U16Type ¶
type U16Type uint16
func ToProtoNum ¶
func ToProtoNum(proto NulStringType) U16Type
func (*U16Type) Deserialize ¶
Click to show internal directories.
Click to hide internal directories.