Files
vpp-maglev/internal/vpp/binapi/lb/lb.ba.go
Pim van Pelt d3c5c86037 VPP load-balancer dataplane integration: state, sync, and global conf
This commit wires maglevd through to VPP's LB plugin end-to-end, using
locally-generated GoVPP bindings for the newer v2 API messages.

VPP binapi (vendored)
- New package internal/vpp/binapi/ containing lb, lb_types, ip_types, and
  interface_types, generated from a local VPP build (~/src/vpp) via a new
  'make vpp-binapi' target. GoVPP v0.12.0 upstream lacks the v2 messages we
  need (lb_conf_get, lb_add_del_vip_v2, lb_add_del_as_v2, lb_as_v2_dump,
  lb_as_set_weight), so we commit the generated output in-tree.
- All generated files go through our loggedChannel wrapper; every VPP API
  send/receive is recorded at DEBUG via slog (vpp-api-send / vpp-api-recv /
  vpp-api-send-multi / vpp-api-recv-multi) so the full wire-level trail is
  auditable. NewAPIChannel is unexported — callers must use c.apiChannel().

Read path: GetLBState{All,VIP}
- GetLBStateAll returns a full snapshot (global conf + every VIP with its
  attached application servers).
- GetLBStateVIP looks up a single VIP by (prefix, protocol, port) and
  returns (nil, nil) when the VIP doesn't exist in VPP. This is the
  efficient path for targeted updates on a busy LB.
- Helpers factored out: getLBConf, dumpAllVIPs, dumpASesForVIP, lookupVIP,
  vipFromDetails.

Write path: SyncLBState{All,VIP}
- SyncLBStateAll reconciles every configured frontend with VPP: creates
  missing VIPs, removes stale ones (with AS flush), and reconciles AS
  membership and weights within VIPs that exist on both sides.
- SyncLBStateVIP targets a single frontend by name. Never removes VIPs.
  Returns ErrFrontendNotFound (wrapped with the name) when the frontend
  isn't in config, so callers can use errors.Is.
- Shared reconcileVIP helper does the per-VIP AS diff; removeVIP is used
  only by the full-sync pass.
- LbAddDelVipV2 requests always set NewFlowsTableLength=1024. The .api
  default=1024 annotation is only applied by VAT/CLI parsers, not wire-
  level marshalling — sending 0 caused VPP to vec_validate with mask
  0xFFFFFFFF and OOM-panic.
- Pool semantics: backends in the primary (first) pool of a frontend get
  their configured weight; backends in secondary pools get weight 0. All
  backends are installed so higher layers can flip weights on failover
  without add/remove churn.
- Every individual change emits a DEBUG slog (vpp-lbsync-vip-add/del,
  vpp-lbsync-as-add/del, vpp-lbsync-as-weight). Start/done INFO logs
  carry a scope=all|vip label plus aggregate counts.

Global conf push: SetLBConf
- New SetLBConf(cfg) sends lb_conf with ipv4-src, ipv6-src, sticky-buckets,
  and flow-timeout. Called automatically on VPP (re)connect and after
  every config reload (via doReloadConfig). Results are cached on the
  Client so redundant pushes are silently skipped — only actual changes
  produce a vpp-lb-conf-set INFO log line.

Periodic drift reconciliation
- vpp.Client.lbSyncLoop runs in a goroutine tied to each VPP connection's
  lifetime. Its first tick is immediate (startup and post-reconnect
  sync quickly); subsequent ticks fire every vpp.lb.sync-interval from
  config (default 30s). Purpose: catch drift if something/someone
  modifies VPP state by hand. The loop uses a ConfigSource interface
  (satisfied by checker.Checker via its new Config() accessor) to avoid
  an import cycle with the checker package.

Config schema additions (maglev.vpp.lb)
- sync-interval: positive Go duration, default 30s.
- ipv4-src-address: REQUIRED. Used as the outer source for GRE4 encap
  to application servers. Missing this is a hard semantic error —
  maglevd --check exits 2 and the daemon refuses to start. VPP GRE
  needs a source address and every VIP we program uses GRE, so there
  is no meaningful config without it.
- ipv6-src-address: REQUIRED. Same treatment as ipv4-src-address.
- sticky-buckets-per-core: default 65536, must be a power of 2.
- flow-timeout: default 40s, must be a whole number of seconds in [1s, 120s].
- VPP validation runs at the end of convert() so structural errors in
  healthchecks/backends/frontends surface first — operators fix those,
  then get the VPP-specific requirements.

gRPC API
- New GetVPPLBState RPC returning VPPLBState: global conf + VIPs with
  ASes. Mirrors the read-path but strips fields irrelevant to our
  GRE-only deployment (srv_type, dscp, target_port).
- New SyncVPPLBState RPC with optional frontend_name. Unset → full sync
  (may remove stale VIPs). Set → single-VIP sync (never removes).
  Returns codes.NotFound for unknown frontends, codes.Unavailable when
  VPP integration is disabled or disconnected.

maglevc (CLI)
- New 'show vpp lbstate' command displaying the LB plugin state. VPP-only
  fields the dataplane irrelevant to GRE are suppressed. Per-AS lines use
  a key-value format ("address X  weight Y  flow-table-buckets Z")
  instead of a tabwriter column, which avoids the ANSI-color alignment
  issue we hit with mixed label/data rows.
- New 'sync vpp lbstate [<name>]' command. Without a name, triggers a
  full reconciliation; with a name, targets one frontend.
- Previous 'show vpp lb' renamed to 'show vpp lbstate' for consistency
  with the new sync command.

Test fixtures
- validConfig and all ad-hoc config_test.go fixtures that reach the end
  of convert() now include the two required vpp.lb src addresses.
- tests/01-maglevd/maglevd-lab/maglev.yaml gains a vpp.lb section so the
  robot integration tests can still load the config.
- cmd/maglevc/tree_test.go gains expected paths for the new commands.

Docs
- config-guide.md: new 'vpp' section in the basic structure, detailed
  vpp.lb field reference, noting ipv4/ipv6 src addresses as REQUIRED
  (hard error) with no defaults; example config updated.
- user-guide.md: documented 'show vpp info', 'show vpp lbstate',
  'sync vpp lbstate [<name>]', new --vpp-api-addr and --vpp-stats-addr
  flags, the vpp-lb-conf-set log line, and corrected the pause/resume
  description to reflect that pause cancels the probe goroutine.
- debian/maglev.yaml: example config gains a vpp.lb block with src
  addresses and commented optional overrides.
2026-04-12 10:58:44 +02:00

1416 lines
49 KiB
Go

// Code generated by GoVPP's binapi-generator. DO NOT EDIT.
// Package lb contains generated bindings for API file lb.api.
//
// Contents:
// - 26 messages
package lb
import (
interface_types "git.ipng.ch/ipng/vpp-maglev/internal/vpp/binapi/interface_types"
ip_types "git.ipng.ch/ipng/vpp-maglev/internal/vpp/binapi/ip_types"
lb_types "git.ipng.ch/ipng/vpp-maglev/internal/vpp/binapi/lb_types"
api "go.fd.io/govpp/api"
codec "go.fd.io/govpp/codec"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the GoVPP api package it is being compiled against.
// A compilation error at this line likely means your copy of the
// GoVPP api package needs to be updated.
const _ = api.GoVppAPIPackageIsVersion2
const (
APIFile = "lb"
APIVersion = "1.2.0"
VersionCrc = 0x853a5710
)
// Add an application server for a given VIP
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port.
// - as_address - The application server address (IPv4 in lower order 32 bits).
// - is_del - The AS should be removed.
// - is_flush - The sessions related to this AS should be flushed.
//
// LbAddDelAs defines message 'lb_add_del_as'.
type LbAddDelAs struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
AsAddress ip_types.Address `binapi:"address,name=as_address" json:"as_address,omitempty"`
IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"`
IsFlush bool `binapi:"bool,name=is_flush" json:"is_flush,omitempty"`
}
func (m *LbAddDelAs) Reset() { *m = LbAddDelAs{} }
func (*LbAddDelAs) GetMessageName() string { return "lb_add_del_as" }
func (*LbAddDelAs) GetCrcString() string { return "35d72500" }
func (*LbAddDelAs) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelAs) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
size += 1 // m.AsAddress.Af
size += 1 * 16 // m.AsAddress.Un
size += 1 // m.IsDel
size += 1 // m.IsFlush
return size
}
func (m *LbAddDelAs) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
buf.EncodeUint8(uint8(m.AsAddress.Af))
buf.EncodeBytes(m.AsAddress.Un.XXX_UnionData[:], 16)
buf.EncodeBool(m.IsDel)
buf.EncodeBool(m.IsFlush)
return buf.Bytes(), nil
}
func (m *LbAddDelAs) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
m.AsAddress.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.AsAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.IsDel = buf.DecodeBool()
m.IsFlush = buf.DecodeBool()
return nil
}
// LbAddDelAsReply defines message 'lb_add_del_as_reply'.
type LbAddDelAsReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelAsReply) Reset() { *m = LbAddDelAsReply{} }
func (*LbAddDelAsReply) GetMessageName() string { return "lb_add_del_as_reply" }
func (*LbAddDelAsReply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelAsReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelAsReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelAsReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelAsReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Add/del an application server for a given VIP, with explicit weight
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port.
// - as_address - The application server address.
// - weight - bucket weight 0-100 (default 100).
// - is_del - The AS should be removed.
// - is_flush - The sessions related to this AS should be flushed.
//
// LbAddDelAsV2 defines message 'lb_add_del_as_v2'.
type LbAddDelAsV2 struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
AsAddress ip_types.Address `binapi:"address,name=as_address" json:"as_address,omitempty"`
Weight uint8 `binapi:"u8,name=weight,default=100" json:"weight,omitempty"`
IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"`
IsFlush bool `binapi:"bool,name=is_flush" json:"is_flush,omitempty"`
}
func (m *LbAddDelAsV2) Reset() { *m = LbAddDelAsV2{} }
func (*LbAddDelAsV2) GetMessageName() string { return "lb_add_del_as_v2" }
func (*LbAddDelAsV2) GetCrcString() string { return "2f1d3b0e" }
func (*LbAddDelAsV2) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelAsV2) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
size += 1 // m.AsAddress.Af
size += 1 * 16 // m.AsAddress.Un
size += 1 // m.Weight
size += 1 // m.IsDel
size += 1 // m.IsFlush
return size
}
func (m *LbAddDelAsV2) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
buf.EncodeUint8(uint8(m.AsAddress.Af))
buf.EncodeBytes(m.AsAddress.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Weight)
buf.EncodeBool(m.IsDel)
buf.EncodeBool(m.IsFlush)
return buf.Bytes(), nil
}
func (m *LbAddDelAsV2) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
m.AsAddress.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.AsAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Weight = buf.DecodeUint8()
m.IsDel = buf.DecodeBool()
m.IsFlush = buf.DecodeBool()
return nil
}
// LbAddDelAsV2Reply defines message 'lb_add_del_as_v2_reply'.
type LbAddDelAsV2Reply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelAsV2Reply) Reset() { *m = LbAddDelAsV2Reply{} }
func (*LbAddDelAsV2Reply) GetMessageName() string { return "lb_add_del_as_v2_reply" }
func (*LbAddDelAsV2Reply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelAsV2Reply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelAsV2Reply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelAsV2Reply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelAsV2Reply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Enable/disable NAT4 feature on the interface
// - is_add - true if add, false if delete
// - sw_if_index - software index of the interface
//
// LbAddDelIntfNat4 defines message 'lb_add_del_intf_nat4'.
type LbAddDelIntfNat4 struct {
IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
}
func (m *LbAddDelIntfNat4) Reset() { *m = LbAddDelIntfNat4{} }
func (*LbAddDelIntfNat4) GetMessageName() string { return "lb_add_del_intf_nat4" }
func (*LbAddDelIntfNat4) GetCrcString() string { return "47d6e753" }
func (*LbAddDelIntfNat4) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelIntfNat4) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.IsAdd
size += 4 // m.SwIfIndex
return size
}
func (m *LbAddDelIntfNat4) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeBool(m.IsAdd)
buf.EncodeUint32(uint32(m.SwIfIndex))
return buf.Bytes(), nil
}
func (m *LbAddDelIntfNat4) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.IsAdd = buf.DecodeBool()
m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
return nil
}
// LbAddDelIntfNat4Reply defines message 'lb_add_del_intf_nat4_reply'.
type LbAddDelIntfNat4Reply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelIntfNat4Reply) Reset() { *m = LbAddDelIntfNat4Reply{} }
func (*LbAddDelIntfNat4Reply) GetMessageName() string { return "lb_add_del_intf_nat4_reply" }
func (*LbAddDelIntfNat4Reply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelIntfNat4Reply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelIntfNat4Reply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelIntfNat4Reply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelIntfNat4Reply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Enable/disable NAT6 feature on the interface
// - is_add - true if add, false if delete
// - sw_if_index - software index of the interface
//
// LbAddDelIntfNat6 defines message 'lb_add_del_intf_nat6'.
type LbAddDelIntfNat6 struct {
IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"`
SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"`
}
func (m *LbAddDelIntfNat6) Reset() { *m = LbAddDelIntfNat6{} }
func (*LbAddDelIntfNat6) GetMessageName() string { return "lb_add_del_intf_nat6" }
func (*LbAddDelIntfNat6) GetCrcString() string { return "47d6e753" }
func (*LbAddDelIntfNat6) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelIntfNat6) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.IsAdd
size += 4 // m.SwIfIndex
return size
}
func (m *LbAddDelIntfNat6) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeBool(m.IsAdd)
buf.EncodeUint32(uint32(m.SwIfIndex))
return buf.Bytes(), nil
}
func (m *LbAddDelIntfNat6) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.IsAdd = buf.DecodeBool()
m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32())
return nil
}
// LbAddDelIntfNat6Reply defines message 'lb_add_del_intf_nat6_reply'.
type LbAddDelIntfNat6Reply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelIntfNat6Reply) Reset() { *m = LbAddDelIntfNat6Reply{} }
func (*LbAddDelIntfNat6Reply) GetMessageName() string { return "lb_add_del_intf_nat6_reply" }
func (*LbAddDelIntfNat6Reply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelIntfNat6Reply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelIntfNat6Reply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelIntfNat6Reply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelIntfNat6Reply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Add a virtual address (or prefix)
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port. (0) means 'all-port VIP'
// - encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4).
// - dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only).
// - type - service type(applicable in NAT4/NAT6 mode only).
// - target_port - Pod's port corresponding to specific service(applicable in NAT4/NAT6 mode only).
// - node_port - Node's port(applicable in NAT4/NAT6 mode only).
// - new_flows_table_length - Size of the new connections flow table used
// for this VIP (must be power of 2).
// - is_del - The VIP should be removed.
//
// LbAddDelVip defines message 'lb_add_del_vip'.
type LbAddDelVip struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"`
Dscp uint8 `binapi:"u8,name=dscp" json:"dscp,omitempty"`
Type lb_types.LbSrvType `binapi:"lb_srv_type,name=type" json:"type,omitempty"`
TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"`
NodePort uint16 `binapi:"u16,name=node_port" json:"node_port,omitempty"`
NewFlowsTableLength uint32 `binapi:"u32,name=new_flows_table_length,default=1024" json:"new_flows_table_length,omitempty"`
IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"`
}
func (m *LbAddDelVip) Reset() { *m = LbAddDelVip{} }
func (*LbAddDelVip) GetMessageName() string { return "lb_add_del_vip" }
func (*LbAddDelVip) GetCrcString() string { return "6fa569c7" }
func (*LbAddDelVip) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelVip) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
size += 4 // m.Encap
size += 1 // m.Dscp
size += 4 // m.Type
size += 2 // m.TargetPort
size += 2 // m.NodePort
size += 4 // m.NewFlowsTableLength
size += 1 // m.IsDel
return size
}
func (m *LbAddDelVip) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
buf.EncodeUint32(uint32(m.Encap))
buf.EncodeUint8(m.Dscp)
buf.EncodeUint32(uint32(m.Type))
buf.EncodeUint16(m.TargetPort)
buf.EncodeUint16(m.NodePort)
buf.EncodeUint32(m.NewFlowsTableLength)
buf.EncodeBool(m.IsDel)
return buf.Bytes(), nil
}
func (m *LbAddDelVip) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
m.Encap = lb_types.LbEncapType(buf.DecodeUint32())
m.Dscp = buf.DecodeUint8()
m.Type = lb_types.LbSrvType(buf.DecodeUint32())
m.TargetPort = buf.DecodeUint16()
m.NodePort = buf.DecodeUint16()
m.NewFlowsTableLength = buf.DecodeUint32()
m.IsDel = buf.DecodeBool()
return nil
}
// LbAddDelVipReply defines message 'lb_add_del_vip_reply'.
type LbAddDelVipReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelVipReply) Reset() { *m = LbAddDelVipReply{} }
func (*LbAddDelVipReply) GetMessageName() string { return "lb_add_del_vip_reply" }
func (*LbAddDelVipReply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelVipReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelVipReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelVipReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelVipReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Add a virtual address (or prefix)
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port. (0) means 'all-port VIP'
// - encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4).
// - dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only).
// - type - service type(applicable in NAT4/NAT6 mode only).
// - target_port - Pod's port corresponding to specific service(applicable in NAT4/NAT6 mode only).
// - node_port - Node's port(applicable in NAT4/NAT6 mode only).
// - new_flows_table_length - Size of the new connections flow table used
// for this VIP (must be power of 2).
// - src_ip_sticky - source ip based sticky session.
// - is_del - The VIP should be removed.
//
// LbAddDelVipV2 defines message 'lb_add_del_vip_v2'.
type LbAddDelVipV2 struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"`
Dscp uint8 `binapi:"u8,name=dscp" json:"dscp,omitempty"`
Type lb_types.LbSrvType `binapi:"lb_srv_type,name=type" json:"type,omitempty"`
TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"`
NodePort uint16 `binapi:"u16,name=node_port" json:"node_port,omitempty"`
NewFlowsTableLength uint32 `binapi:"u32,name=new_flows_table_length,default=1024" json:"new_flows_table_length,omitempty"`
SrcIPSticky bool `binapi:"bool,name=src_ip_sticky" json:"src_ip_sticky,omitempty"`
IsDel bool `binapi:"bool,name=is_del" json:"is_del,omitempty"`
}
func (m *LbAddDelVipV2) Reset() { *m = LbAddDelVipV2{} }
func (*LbAddDelVipV2) GetMessageName() string { return "lb_add_del_vip_v2" }
func (*LbAddDelVipV2) GetCrcString() string { return "7c520e0f" }
func (*LbAddDelVipV2) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAddDelVipV2) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
size += 4 // m.Encap
size += 1 // m.Dscp
size += 4 // m.Type
size += 2 // m.TargetPort
size += 2 // m.NodePort
size += 4 // m.NewFlowsTableLength
size += 1 // m.SrcIPSticky
size += 1 // m.IsDel
return size
}
func (m *LbAddDelVipV2) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
buf.EncodeUint32(uint32(m.Encap))
buf.EncodeUint8(m.Dscp)
buf.EncodeUint32(uint32(m.Type))
buf.EncodeUint16(m.TargetPort)
buf.EncodeUint16(m.NodePort)
buf.EncodeUint32(m.NewFlowsTableLength)
buf.EncodeBool(m.SrcIPSticky)
buf.EncodeBool(m.IsDel)
return buf.Bytes(), nil
}
func (m *LbAddDelVipV2) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
m.Encap = lb_types.LbEncapType(buf.DecodeUint32())
m.Dscp = buf.DecodeUint8()
m.Type = lb_types.LbSrvType(buf.DecodeUint32())
m.TargetPort = buf.DecodeUint16()
m.NodePort = buf.DecodeUint16()
m.NewFlowsTableLength = buf.DecodeUint32()
m.SrcIPSticky = buf.DecodeBool()
m.IsDel = buf.DecodeBool()
return nil
}
// LbAddDelVipV2Reply defines message 'lb_add_del_vip_v2_reply'.
type LbAddDelVipV2Reply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAddDelVipV2Reply) Reset() { *m = LbAddDelVipV2Reply{} }
func (*LbAddDelVipV2Reply) GetMessageName() string { return "lb_add_del_vip_v2_reply" }
func (*LbAddDelVipV2Reply) GetCrcString() string { return "e8d4e804" }
func (*LbAddDelVipV2Reply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAddDelVipV2Reply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAddDelVipV2Reply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAddDelVipV2Reply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// lb_as_details
// - as - AS detail record
//
// LbAsDetails defines message 'lb_as_details'.
type LbAsDetails struct {
Vip lb_types.LbVip `binapi:"lb_vip,name=vip" json:"vip,omitempty"`
AppSrv ip_types.Address `binapi:"address,name=app_srv" json:"app_srv,omitempty"`
Flags uint8 `binapi:"u8,name=flags" json:"flags,omitempty"`
InUseSince uint32 `binapi:"u32,name=in_use_since" json:"in_use_since,omitempty"`
}
func (m *LbAsDetails) Reset() { *m = LbAsDetails{} }
func (*LbAsDetails) GetMessageName() string { return "lb_as_details" }
func (*LbAsDetails) GetCrcString() string { return "8d24c29e" }
func (*LbAsDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAsDetails) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Vip.Pfx.Address.Af
size += 1 * 16 // m.Vip.Pfx.Address.Un
size += 1 // m.Vip.Pfx.Len
size += 1 // m.Vip.Protocol
size += 2 // m.Vip.Port
size += 1 // m.AppSrv.Af
size += 1 * 16 // m.AppSrv.Un
size += 1 // m.Flags
size += 4 // m.InUseSince
return size
}
func (m *LbAsDetails) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Vip.Pfx.Address.Af))
buf.EncodeBytes(m.Vip.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Vip.Pfx.Len)
buf.EncodeUint8(uint8(m.Vip.Protocol))
buf.EncodeUint16(m.Vip.Port)
buf.EncodeUint8(uint8(m.AppSrv.Af))
buf.EncodeBytes(m.AppSrv.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Flags)
buf.EncodeUint32(m.InUseSince)
return buf.Bytes(), nil
}
func (m *LbAsDetails) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Vip.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Vip.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Vip.Pfx.Len = buf.DecodeUint8()
m.Vip.Protocol = ip_types.IPProto(buf.DecodeUint8())
m.Vip.Port = buf.DecodeUint16()
m.AppSrv.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.AppSrv.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Flags = buf.DecodeUint8()
m.InUseSince = buf.DecodeUint32()
return nil
}
// dump AS list per VIP or all ASs for all VIPs
// - pfx - ip prefix and length.
// - protocol - tcp or udp.
// - port - destination port.
//
// LbAsDump defines message 'lb_as_dump'.
type LbAsDump struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
}
func (m *LbAsDump) Reset() { *m = LbAsDump{} }
func (*LbAsDump) GetMessageName() string { return "lb_as_dump" }
func (*LbAsDump) GetCrcString() string { return "1063f819" }
func (*LbAsDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAsDump) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
return size
}
func (m *LbAsDump) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
return buf.Bytes(), nil
}
func (m *LbAsDump) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
return nil
}
// Set the weight of an existing application server
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port.
// - as_address - The application server address.
// - weight - new bucket weight 0-100.
//
// LbAsSetWeight defines message 'lb_as_set_weight'.
type LbAsSetWeight struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
AsAddress ip_types.Address `binapi:"address,name=as_address" json:"as_address,omitempty"`
Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"`
}
func (m *LbAsSetWeight) Reset() { *m = LbAsSetWeight{} }
func (*LbAsSetWeight) GetMessageName() string { return "lb_as_set_weight" }
func (*LbAsSetWeight) GetCrcString() string { return "2c72979e" }
func (*LbAsSetWeight) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAsSetWeight) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
size += 1 // m.AsAddress.Af
size += 1 * 16 // m.AsAddress.Un
size += 1 // m.Weight
return size
}
func (m *LbAsSetWeight) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
buf.EncodeUint8(uint8(m.AsAddress.Af))
buf.EncodeBytes(m.AsAddress.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Weight)
return buf.Bytes(), nil
}
func (m *LbAsSetWeight) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
m.AsAddress.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.AsAddress.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Weight = buf.DecodeUint8()
return nil
}
// LbAsSetWeightReply defines message 'lb_as_set_weight_reply'.
type LbAsSetWeightReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbAsSetWeightReply) Reset() { *m = LbAsSetWeightReply{} }
func (*LbAsSetWeightReply) GetMessageName() string { return "lb_as_set_weight_reply" }
func (*LbAsSetWeightReply) GetCrcString() string { return "e8d4e804" }
func (*LbAsSetWeightReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAsSetWeightReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbAsSetWeightReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbAsSetWeightReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// lb_as_v2_details
// - vip - the VIP this AS belongs to
// - app_srv - AS address
// - flags - AS flags
// - in_use_since - timestamp of last use
// - weight - bucket weight (0-100)
//
// LbAsV2Details defines message 'lb_as_v2_details'.
type LbAsV2Details struct {
Vip lb_types.LbVip `binapi:"lb_vip,name=vip" json:"vip,omitempty"`
AppSrv ip_types.Address `binapi:"address,name=app_srv" json:"app_srv,omitempty"`
Flags uint8 `binapi:"u8,name=flags" json:"flags,omitempty"`
InUseSince uint32 `binapi:"u32,name=in_use_since" json:"in_use_since,omitempty"`
Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"`
NumBuckets uint32 `binapi:"u32,name=num_buckets" json:"num_buckets,omitempty"`
}
func (m *LbAsV2Details) Reset() { *m = LbAsV2Details{} }
func (*LbAsV2Details) GetMessageName() string { return "lb_as_v2_details" }
func (*LbAsV2Details) GetCrcString() string { return "90064aae" }
func (*LbAsV2Details) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbAsV2Details) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Vip.Pfx.Address.Af
size += 1 * 16 // m.Vip.Pfx.Address.Un
size += 1 // m.Vip.Pfx.Len
size += 1 // m.Vip.Protocol
size += 2 // m.Vip.Port
size += 1 // m.AppSrv.Af
size += 1 * 16 // m.AppSrv.Un
size += 1 // m.Flags
size += 4 // m.InUseSince
size += 1 // m.Weight
size += 4 // m.NumBuckets
return size
}
func (m *LbAsV2Details) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Vip.Pfx.Address.Af))
buf.EncodeBytes(m.Vip.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Vip.Pfx.Len)
buf.EncodeUint8(uint8(m.Vip.Protocol))
buf.EncodeUint16(m.Vip.Port)
buf.EncodeUint8(uint8(m.AppSrv.Af))
buf.EncodeBytes(m.AppSrv.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Flags)
buf.EncodeUint32(m.InUseSince)
buf.EncodeUint8(m.Weight)
buf.EncodeUint32(m.NumBuckets)
return buf.Bytes(), nil
}
func (m *LbAsV2Details) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Vip.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Vip.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Vip.Pfx.Len = buf.DecodeUint8()
m.Vip.Protocol = ip_types.IPProto(buf.DecodeUint8())
m.Vip.Port = buf.DecodeUint16()
m.AppSrv.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.AppSrv.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Flags = buf.DecodeUint8()
m.InUseSince = buf.DecodeUint32()
m.Weight = buf.DecodeUint8()
m.NumBuckets = buf.DecodeUint32()
return nil
}
// dump AS list per VIP or all ASs for all VIPs, with weights
// - pfx - ip prefix and length.
// - protocol - tcp or udp.
// - port - destination port.
//
// LbAsV2Dump defines message 'lb_as_v2_dump'.
type LbAsV2Dump struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
}
func (m *LbAsV2Dump) Reset() { *m = LbAsV2Dump{} }
func (*LbAsV2Dump) GetMessageName() string { return "lb_as_v2_dump" }
func (*LbAsV2Dump) GetCrcString() string { return "1063f819" }
func (*LbAsV2Dump) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbAsV2Dump) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
return size
}
func (m *LbAsV2Dump) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
return buf.Bytes(), nil
}
func (m *LbAsV2Dump) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
return nil
}
// Configure Load-Balancer global parameters (unlike the CLI, both ip4_src_address and ip6_src_address need to be specified.
// - ip4_src_address - IPv4 address to be used as source for IPv4 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only).
// - ip6_src_address - IPv6 address to be used as source for IPv6 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only).
// - sticky_buckets_per_core - Number of buckets *per worker thread* in the
// established flow table (must be power of 2).
// - flow_timeout - Time in seconds after which, if no packet is received
// for a given flow, the flow is removed from the established flow table.
//
// LbConf defines message 'lb_conf'.
type LbConf struct {
IP4SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=ip4_src_address" json:"ip4_src_address,omitempty"`
IP6SrcAddress ip_types.IP6Address `binapi:"ip6_address,name=ip6_src_address" json:"ip6_src_address,omitempty"`
StickyBucketsPerCore uint32 `binapi:"u32,name=sticky_buckets_per_core,default=4294967295" json:"sticky_buckets_per_core,omitempty"`
FlowTimeout uint32 `binapi:"u32,name=flow_timeout,default=4294967295" json:"flow_timeout,omitempty"`
}
func (m *LbConf) Reset() { *m = LbConf{} }
func (*LbConf) GetMessageName() string { return "lb_conf" }
func (*LbConf) GetCrcString() string { return "56cd3261" }
func (*LbConf) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbConf) Size() (size int) {
if m == nil {
return 0
}
size += 1 * 4 // m.IP4SrcAddress
size += 1 * 16 // m.IP6SrcAddress
size += 4 // m.StickyBucketsPerCore
size += 4 // m.FlowTimeout
return size
}
func (m *LbConf) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeBytes(m.IP4SrcAddress[:], 4)
buf.EncodeBytes(m.IP6SrcAddress[:], 16)
buf.EncodeUint32(m.StickyBucketsPerCore)
buf.EncodeUint32(m.FlowTimeout)
return buf.Bytes(), nil
}
func (m *LbConf) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
copy(m.IP4SrcAddress[:], buf.DecodeBytes(4))
copy(m.IP6SrcAddress[:], buf.DecodeBytes(16))
m.StickyBucketsPerCore = buf.DecodeUint32()
m.FlowTimeout = buf.DecodeUint32()
return nil
}
// Get Load-Balancer global parameters
// LbConfGet defines message 'lb_conf_get'.
type LbConfGet struct{}
func (m *LbConfGet) Reset() { *m = LbConfGet{} }
func (*LbConfGet) GetMessageName() string { return "lb_conf_get" }
func (*LbConfGet) GetCrcString() string { return "51077d14" }
func (*LbConfGet) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbConfGet) Size() (size int) {
if m == nil {
return 0
}
return size
}
func (m *LbConfGet) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
return buf.Bytes(), nil
}
func (m *LbConfGet) Unmarshal(b []byte) error {
return nil
}
// Reply for lb_conf_get
// - retval - return code
// - ip4_src_address - IPv4 source address used for encapsulated traffic.
// - ip6_src_address - IPv6 source address used for encapsulated traffic.
// - sticky_buckets_per_core - Number of buckets per worker thread in the
// established session table.
// - flow_timeout - Time in seconds after which, if no packet is received
// for a given session, the session is removed from the established session table.
//
// LbConfGetReply defines message 'lb_conf_get_reply'.
type LbConfGetReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
IP4SrcAddress ip_types.IP4Address `binapi:"ip4_address,name=ip4_src_address" json:"ip4_src_address,omitempty"`
IP6SrcAddress ip_types.IP6Address `binapi:"ip6_address,name=ip6_src_address" json:"ip6_src_address,omitempty"`
StickyBucketsPerCore uint32 `binapi:"u32,name=sticky_buckets_per_core" json:"sticky_buckets_per_core,omitempty"`
FlowTimeout uint32 `binapi:"u32,name=flow_timeout" json:"flow_timeout,omitempty"`
}
func (m *LbConfGetReply) Reset() { *m = LbConfGetReply{} }
func (*LbConfGetReply) GetMessageName() string { return "lb_conf_get_reply" }
func (*LbConfGetReply) GetCrcString() string { return "923427ac" }
func (*LbConfGetReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbConfGetReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
size += 1 * 4 // m.IP4SrcAddress
size += 1 * 16 // m.IP6SrcAddress
size += 4 // m.StickyBucketsPerCore
size += 4 // m.FlowTimeout
return size
}
func (m *LbConfGetReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
buf.EncodeBytes(m.IP4SrcAddress[:], 4)
buf.EncodeBytes(m.IP6SrcAddress[:], 16)
buf.EncodeUint32(m.StickyBucketsPerCore)
buf.EncodeUint32(m.FlowTimeout)
return buf.Bytes(), nil
}
func (m *LbConfGetReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
copy(m.IP4SrcAddress[:], buf.DecodeBytes(4))
copy(m.IP6SrcAddress[:], buf.DecodeBytes(16))
m.StickyBucketsPerCore = buf.DecodeUint32()
m.FlowTimeout = buf.DecodeUint32()
return nil
}
// LbConfReply defines message 'lb_conf_reply'.
type LbConfReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbConfReply) Reset() { *m = LbConfReply{} }
func (*LbConfReply) GetMessageName() string { return "lb_conf_reply" }
func (*LbConfReply) GetCrcString() string { return "e8d4e804" }
func (*LbConfReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbConfReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbConfReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbConfReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Flush a given vip
// - pfx - ip prefix and length
// - protocol - tcp or udp.
// - port - destination port.
//
// LbFlushVip defines message 'lb_flush_vip'.
type LbFlushVip struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
}
func (m *LbFlushVip) Reset() { *m = LbFlushVip{} }
func (*LbFlushVip) GetMessageName() string { return "lb_flush_vip" }
func (*LbFlushVip) GetCrcString() string { return "1063f819" }
func (*LbFlushVip) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbFlushVip) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.Protocol
size += 2 // m.Port
return size
}
func (m *LbFlushVip) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
return buf.Bytes(), nil
}
func (m *LbFlushVip) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
return nil
}
// LbFlushVipReply defines message 'lb_flush_vip_reply'.
type LbFlushVipReply struct {
Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"`
}
func (m *LbFlushVipReply) Reset() { *m = LbFlushVipReply{} }
func (*LbFlushVipReply) GetMessageName() string { return "lb_flush_vip_reply" }
func (*LbFlushVipReply) GetCrcString() string { return "e8d4e804" }
func (*LbFlushVipReply) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbFlushVipReply) Size() (size int) {
if m == nil {
return 0
}
size += 4 // m.Retval
return size
}
func (m *LbFlushVipReply) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeInt32(m.Retval)
return buf.Bytes(), nil
}
func (m *LbFlushVipReply) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Retval = buf.DecodeInt32()
return nil
}
// Reply all configured vip
// - vip - all vip addrs.
//
// LbVipDetails defines message 'lb_vip_details'.
type LbVipDetails struct {
Vip lb_types.LbVip `binapi:"lb_vip,name=vip" json:"vip,omitempty"`
Encap lb_types.LbEncapType `binapi:"lb_encap_type,name=encap" json:"encap,omitempty"`
Dscp ip_types.IPDscp `binapi:"ip_dscp,name=dscp" json:"dscp,omitempty"`
SrvType lb_types.LbSrvType `binapi:"lb_srv_type,name=srv_type" json:"srv_type,omitempty"`
TargetPort uint16 `binapi:"u16,name=target_port" json:"target_port,omitempty"`
FlowTableLength uint16 `binapi:"u16,name=flow_table_length" json:"flow_table_length,omitempty"`
}
func (m *LbVipDetails) Reset() { *m = LbVipDetails{} }
func (*LbVipDetails) GetMessageName() string { return "lb_vip_details" }
func (*LbVipDetails) GetCrcString() string { return "1329ec9b" }
func (*LbVipDetails) GetMessageType() api.MessageType {
return api.ReplyMessage
}
func (m *LbVipDetails) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Vip.Pfx.Address.Af
size += 1 * 16 // m.Vip.Pfx.Address.Un
size += 1 // m.Vip.Pfx.Len
size += 1 // m.Vip.Protocol
size += 2 // m.Vip.Port
size += 4 // m.Encap
size += 1 // m.Dscp
size += 4 // m.SrvType
size += 2 // m.TargetPort
size += 2 // m.FlowTableLength
return size
}
func (m *LbVipDetails) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Vip.Pfx.Address.Af))
buf.EncodeBytes(m.Vip.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Vip.Pfx.Len)
buf.EncodeUint8(uint8(m.Vip.Protocol))
buf.EncodeUint16(m.Vip.Port)
buf.EncodeUint32(uint32(m.Encap))
buf.EncodeUint8(uint8(m.Dscp))
buf.EncodeUint32(uint32(m.SrvType))
buf.EncodeUint16(m.TargetPort)
buf.EncodeUint16(m.FlowTableLength)
return buf.Bytes(), nil
}
func (m *LbVipDetails) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Vip.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Vip.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Vip.Pfx.Len = buf.DecodeUint8()
m.Vip.Protocol = ip_types.IPProto(buf.DecodeUint8())
m.Vip.Port = buf.DecodeUint16()
m.Encap = lb_types.LbEncapType(buf.DecodeUint32())
m.Dscp = ip_types.IPDscp(buf.DecodeUint8())
m.SrvType = lb_types.LbSrvType(buf.DecodeUint32())
m.TargetPort = buf.DecodeUint16()
m.FlowTableLength = buf.DecodeUint16()
return nil
}
// Dump all vips
// LbVipDump defines message 'lb_vip_dump'.
type LbVipDump struct {
Pfx ip_types.AddressWithPrefix `binapi:"address_with_prefix,name=pfx" json:"pfx,omitempty"`
PfxMatcher ip_types.PrefixMatcher `binapi:"prefix_matcher,name=pfx_matcher" json:"pfx_matcher,omitempty"`
Protocol uint8 `binapi:"u8,name=protocol,default=255" json:"protocol,omitempty"`
Port uint16 `binapi:"u16,name=port" json:"port,omitempty"`
}
func (m *LbVipDump) Reset() { *m = LbVipDump{} }
func (*LbVipDump) GetMessageName() string { return "lb_vip_dump" }
func (*LbVipDump) GetCrcString() string { return "56110cb7" }
func (*LbVipDump) GetMessageType() api.MessageType {
return api.RequestMessage
}
func (m *LbVipDump) Size() (size int) {
if m == nil {
return 0
}
size += 1 // m.Pfx.Address.Af
size += 1 * 16 // m.Pfx.Address.Un
size += 1 // m.Pfx.Len
size += 1 // m.PfxMatcher.Le
size += 1 // m.PfxMatcher.Ge
size += 1 // m.Protocol
size += 2 // m.Port
return size
}
func (m *LbVipDump) Marshal(b []byte) ([]byte, error) {
if b == nil {
b = make([]byte, m.Size())
}
buf := codec.NewBuffer(b)
buf.EncodeUint8(uint8(m.Pfx.Address.Af))
buf.EncodeBytes(m.Pfx.Address.Un.XXX_UnionData[:], 16)
buf.EncodeUint8(m.Pfx.Len)
buf.EncodeUint8(m.PfxMatcher.Le)
buf.EncodeUint8(m.PfxMatcher.Ge)
buf.EncodeUint8(m.Protocol)
buf.EncodeUint16(m.Port)
return buf.Bytes(), nil
}
func (m *LbVipDump) Unmarshal(b []byte) error {
buf := codec.NewBuffer(b)
m.Pfx.Address.Af = ip_types.AddressFamily(buf.DecodeUint8())
copy(m.Pfx.Address.Un.XXX_UnionData[:], buf.DecodeBytes(16))
m.Pfx.Len = buf.DecodeUint8()
m.PfxMatcher.Le = buf.DecodeUint8()
m.PfxMatcher.Ge = buf.DecodeUint8()
m.Protocol = buf.DecodeUint8()
m.Port = buf.DecodeUint16()
return nil
}
func init() { file_lb_binapi_init() }
func file_lb_binapi_init() {
api.RegisterMessage((*LbAddDelAs)(nil), "lb_add_del_as_35d72500")
api.RegisterMessage((*LbAddDelAsReply)(nil), "lb_add_del_as_reply_e8d4e804")
api.RegisterMessage((*LbAddDelAsV2)(nil), "lb_add_del_as_v2_2f1d3b0e")
api.RegisterMessage((*LbAddDelAsV2Reply)(nil), "lb_add_del_as_v2_reply_e8d4e804")
api.RegisterMessage((*LbAddDelIntfNat4)(nil), "lb_add_del_intf_nat4_47d6e753")
api.RegisterMessage((*LbAddDelIntfNat4Reply)(nil), "lb_add_del_intf_nat4_reply_e8d4e804")
api.RegisterMessage((*LbAddDelIntfNat6)(nil), "lb_add_del_intf_nat6_47d6e753")
api.RegisterMessage((*LbAddDelIntfNat6Reply)(nil), "lb_add_del_intf_nat6_reply_e8d4e804")
api.RegisterMessage((*LbAddDelVip)(nil), "lb_add_del_vip_6fa569c7")
api.RegisterMessage((*LbAddDelVipReply)(nil), "lb_add_del_vip_reply_e8d4e804")
api.RegisterMessage((*LbAddDelVipV2)(nil), "lb_add_del_vip_v2_7c520e0f")
api.RegisterMessage((*LbAddDelVipV2Reply)(nil), "lb_add_del_vip_v2_reply_e8d4e804")
api.RegisterMessage((*LbAsDetails)(nil), "lb_as_details_8d24c29e")
api.RegisterMessage((*LbAsDump)(nil), "lb_as_dump_1063f819")
api.RegisterMessage((*LbAsSetWeight)(nil), "lb_as_set_weight_2c72979e")
api.RegisterMessage((*LbAsSetWeightReply)(nil), "lb_as_set_weight_reply_e8d4e804")
api.RegisterMessage((*LbAsV2Details)(nil), "lb_as_v2_details_90064aae")
api.RegisterMessage((*LbAsV2Dump)(nil), "lb_as_v2_dump_1063f819")
api.RegisterMessage((*LbConf)(nil), "lb_conf_56cd3261")
api.RegisterMessage((*LbConfGet)(nil), "lb_conf_get_51077d14")
api.RegisterMessage((*LbConfGetReply)(nil), "lb_conf_get_reply_923427ac")
api.RegisterMessage((*LbConfReply)(nil), "lb_conf_reply_e8d4e804")
api.RegisterMessage((*LbFlushVip)(nil), "lb_flush_vip_1063f819")
api.RegisterMessage((*LbFlushVipReply)(nil), "lb_flush_vip_reply_e8d4e804")
api.RegisterMessage((*LbVipDetails)(nil), "lb_vip_details_1329ec9b")
api.RegisterMessage((*LbVipDump)(nil), "lb_vip_dump_56110cb7")
}
// Messages returns list of all messages in this module.
func AllMessages() []api.Message {
return []api.Message{
(*LbAddDelAs)(nil),
(*LbAddDelAsReply)(nil),
(*LbAddDelAsV2)(nil),
(*LbAddDelAsV2Reply)(nil),
(*LbAddDelIntfNat4)(nil),
(*LbAddDelIntfNat4Reply)(nil),
(*LbAddDelIntfNat6)(nil),
(*LbAddDelIntfNat6Reply)(nil),
(*LbAddDelVip)(nil),
(*LbAddDelVipReply)(nil),
(*LbAddDelVipV2)(nil),
(*LbAddDelVipV2Reply)(nil),
(*LbAsDetails)(nil),
(*LbAsDump)(nil),
(*LbAsSetWeight)(nil),
(*LbAsSetWeightReply)(nil),
(*LbAsV2Details)(nil),
(*LbAsV2Dump)(nil),
(*LbConf)(nil),
(*LbConfGet)(nil),
(*LbConfGetReply)(nil),
(*LbConfReply)(nil),
(*LbFlushVip)(nil),
(*LbFlushVipReply)(nil),
(*LbVipDetails)(nil),
(*LbVipDump)(nil),
}
}