Files
vpp-maglev/internal/vpp/binapi/lb/lb.ba.go
Pim van Pelt 0049c2ae73 VPP reconciler: event-driven sync, pool failover, bug fixes
This commit wires the checker's state machine through to the VPP dataplane:
every backend state transition flows through a single code path that
recomputes the effective per-backend weight (with pool failover) and pushes
the result to VPP. Along the way several latent bugs in the state machine
and the sync path were fixed.

internal/vpp/reconciler.go (new)
- New Reconciler type subscribes to checker.Checker events and, on every
  transition, calls Client.SyncLBStateVIP for the affected frontend. This
  is the ONLY place in the codebase where backend state changes cause VPP
  calls — the "single path" discipline requested during design.
- Defines an EventSource interface (checker.Checker satisfies it) so the
  dependency direction stays vpp → checker; the checker never imports vpp.

internal/vpp/client.go
- Renamed ConfigSource → StateSource. The interface now has two methods:
  Config() and BackendState(name) — the reconciler and the desired-state
  builder both need live health state to compute effective weights.
- SetConfigSource → SetStateSource; internal cfgSrc field → stateSrc.
- New getStateSource() helper for internal locked access.
- lbSyncLoop still uses the state source for its periodic drift
  reconciliation; it's fully idempotent and runs the same code path as
  event-driven syncs.

internal/vpp/lbsync.go
- desiredAS grows a Flush bool so the mapping function can signal "on
  transition to weight 0, flush existing flow-table entries".
- asFromBackend is now the single source of truth for the state →
  (weight, flush) rule. Documented with a full truth table. Takes an
  activePool parameter so it can distinguish "up in active pool" from
  "up but standby".
- activePoolIndex(fe, states) implements priority failover: returns the
  index of the first pool containing any StateUp backend. pool[0] wins
  when at least one member is up; pool[1] takes over when pool[0] is
  empty; and so on. Defaults to 0 (unobservable, since all backends map
  to weight 0 when nothing is up).
- desiredFromFrontend snapshots backend states once, computes activePool,
  then walks every backend through asFromBackend. No more filtering on
  b.Enabled — disabled backends stay in the desired set so they keep
  their AS entry in VPP with weight=0. The previous filter caused delAS
  on disable, which destroyed the entry and broke enable afterwards.
- EffectiveWeights(fe, src) exported helper that returns the per-pool
  per-backend weight map for one frontend. Used by the gRPC GetFrontend
  handler and robot tests to observe failover without touching VPP.
- reconcileVIP computes flush at the weight-change call site:
    flush = desired.Flush && cur.Weight > 0 && desired.Weight == 0
  This ensures only the *transition* to disabled flushes sessions —
  steady-state syncs with already-zero weight skip the call entirely.
- setASWeight now plumbs IsFlush into lb_as_set_weight.

internal/vpp/lbsync_test.go (new)
- TestAsFromBackend: 15 cases locking down the truth table, including
  failover scenarios (up in standby pool, up promoted in pool[1]).
- TestActivePoolIndex: 8 cases covering pool[0]-has-up, pool[0]-all-down,
  all-disabled, all-paused, all-unknown, nothing-up-anywhere, and
  three-tier failover.
- TestDesiredFromFrontendFailover: 5 end-to-end scenarios wiring a fake
  StateSource through desiredFromFrontend and asserting the final
  per-IP weight map. Exercises the complete pipeline without VPP.

internal/checker/checker.go
- Added BackendState(name) (health.State, bool) — one-line method that
  satisfies vpp.StateSource. The checker is otherwise unchanged.
- EnableBackend rewritten to reuse the existing worker (parallel to
  ResumeBackend). The old code called startWorker which constructed a
  brand-new Backend via health.New, throwing away the transition
  history; the resulting 'backend-transition' log showed the bogus
  from=unknown,to=unknown. Now uses w.backend.Enable() to record a
  proper disabled→unknown transition and launches a fresh goroutine.
- Static (no-healthcheck) backends now fire their synthetic 'always up'
  pass on the first iteration of runProbe instead of sleeping 30s
  first. Previously static backends sat in StateUnknown for 30s after
  startup — useless for deterministic testing and surprising for
  operators. The fix is a simple first-iteration flag.

internal/health/state.go
- New Enable(maxHistory) method parallel to Disable. Transitions the
  backend from whatever state it's in (typically StateDisabled) to
  StateUnknown, resets the health counter to rise-1 so the expedited
  resolution kicks in on the first probe result, and emits a transition
  with code 'enabled'.

proto/maglev.proto
- PoolBackendInfo gains effective_weight: the state-aware weight that
  would be programmed into VPP (distinct from the configured weight in
  the YAML). Exposed via GetFrontend.

internal/grpcapi/server.go
- frontendToProto takes a vpp.StateSource, computes effective weights
  via vpp.EffectiveWeights, and populates PoolBackendInfo.EffectiveWeight.
- GetFrontend and SetFrontendPoolBackendWeight updated to pass the
  checker in.

cmd/maglevc/commands.go
- 'show frontends <name>' now renders every pool backend row as
    <name>  weight <cfg>  effective <eff>  [disabled]?
  so both values are always visible. The VPP-style key/value format
  avoids the ANSI-alignment pitfall we hit earlier and makes the output
  regex-parseable for robot tests.

cmd/maglevd/main.go
- Construct and start the Reconciler alongside the VPP client. Two
  extra lines, no other changes to startup.

tests/01-maglevd/maglevd-lab/maglev.yaml
- Two new static backends (static-primary, static-fallback) and a new
  failover-vip frontend with one backend per pool. No healthcheck, so
  the state machine resolves them to 'up' immediately via the synthetic
  pass. Used by the failover robot tests.

tests/01-maglevd/01-healthcheck.robot
- Three new test cases exercising pool failover end-to-end:
  1. primary up, secondary standby (initial state)
  2. disable primary → fallback takes over (effective weight flips)
  3. enable primary → fallback steps back
  All run without VPP: they scrape 'maglevc show frontends <name>' and
  regex-match the effective weight in the output. Deterministic and
  fast (~2s total) because the static backends don't probe.
- Two helper keywords: Static Backend Should Be Up and
  Effective Weight Should Be.

Net result: 16/16 robot tests pass. Backend state transitions now
flow through a single documented path (checker event → reconciler →
SyncLBStateVIP → desiredFromFrontend → asFromBackend → reconcileVIP →
setASWeight), and the pool failover / enable-after-disable / static-
backend-startup bugs are all fixed.
2026-04-12 12:40:09 +02:00

1421 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 = 0xac602d7b
)
// 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.
// - is_flush - The sessions related to this AS should be flushed.
//
// 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"`
IsFlush bool `binapi:"bool,name=is_flush" json:"is_flush,omitempty"`
}
func (m *LbAsSetWeight) Reset() { *m = LbAsSetWeight{} }
func (*LbAsSetWeight) GetMessageName() string { return "lb_as_set_weight" }
func (*LbAsSetWeight) GetCrcString() string { return "2d89bdbd" }
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
size += 1 // m.IsFlush
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)
buf.EncodeBool(m.IsFlush)
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()
m.IsFlush = buf.DecodeBool()
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_2d89bdbd")
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),
}
}