v3

package
v1.11.0-cni-plu...-271081e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VoCreated   int = 0
	VoLastSeen  int = 8
	VoType      int = 16
	VoFlags     int = 17
	VoFlags2    int = 23
	VoRevKey    int = 24
	VoLegAB     int = 24
	VoLegBA     int = 48
	VoOrigIP    int = 76
	VoOrigPort  int = 80
	VoOrigSPort int = 82
	VoOrigSIP   int = 84
	VoTunIP     int = 72
	VoNATSPort  int = 40
)
View Source
const (
	TypeNormal uint8 = iota
	TypeNATForward
	TypeNATReverse

	FlagNATOut    uint16 = (1 << 0)
	FlagNATFwdDsr uint16 = (1 << 1)
	FlagNATNPFwd  uint16 = (1 << 2)
	FlagSkipFIB   uint16 = (1 << 3)
	FlagReserved4 uint16 = (1 << 4)
	FlagReserved5 uint16 = (1 << 5)
	FlagExtLocal  uint16 = (1 << 6)
	FlagViaNATIf  uint16 = (1 << 7)
	FlagSrcDstBA  uint16 = (1 << 8)
	FlagHostPSNAT uint16 = (1 << 9)
	FlagSvcSelf   uint16 = (1 << 10)
	FlagNPLoop    uint16 = (1 << 11)
	FlagNPRemote  uint16 = (1 << 12)
	FlagNoDSR     uint16 = (1 << 13)
)
View Source
const (
	VoCreatedV6   int = 0
	VoLastSeenV6  int = 8
	VoTypeV6      int = 16
	VoFlagsV6     int = 17
	VoFlags2V6    int = 23
	VoRevKeyV6    int = 24
	VoLegABV6     int = 24
	VoLegBAV6     int = 48
	VoTunIPV6     int = 72
	VoOrigIPV6    int = VoTunIPV6 + 16
	VoOrigPortV6  int = VoOrigIPV6 + 16
	VoOrigSPortV6 int = VoOrigPortV6 + 2
	VoOrigSIPV6   int = VoOrigSPortV6 + 2
	VoNATSPortV6  int = VoRevKeyV6 + KeyV6Size
)
View Source
const KeySize = 16
struct calico_ct_key {
  uint32_t protocol;
  __be32 addr_a, addr_b; // NBO
  uint16_t port_a, port_b; // HBO
};
View Source
const KeyV6Size = 40
struct calico_ct_key {
  uint32_t protocol;
  __be32 addr_a, addr_b; // NBO
  uint16_t port_a, port_b; // HBO
};
View Source
const MaxEntries = 512000
View Source
const ValueSize = 88
View Source
const ValueV6Size = 128

Variables

View Source
var MapParams = maps.MapParameters{
	Type:         "hash",
	KeySize:      KeySize,
	ValueSize:    ValueSize,
	MaxEntries:   MaxEntries,
	Name:         "cali_v4_ct",
	Flags:        unix.BPF_F_NO_PREALLOC,
	Version:      3,
	UpdatedByBPF: true,
}
View Source
var MapParamsV6 = maps.MapParameters{
	Type:         "hash",
	KeySize:      KeyV6Size,
	ValueSize:    ValueV6Size,
	MaxEntries:   MaxEntries,
	Name:         "cali_v6_ct",
	Flags:        unix.BPF_F_NO_PREALLOC,
	Version:      3,
	UpdatedByBPF: true,
}

Functions

func MapMemIter

func MapMemIter(m MapMem) func(k, v []byte)

MapMemIter returns maps.MapIter that loads the provided MapMem

func MapMemIterV6

func MapMemIterV6(m MapMemV6) func(k, v []byte)

MapMemIterV6 returns maps.MapIter that loads the provided MapMemV6

Types

type EntryData

type EntryData struct {
	A2B       Leg
	B2A       Leg
	OrigDst   net.IP
	OrigSrc   net.IP
	OrigPort  uint16
	OrigSPort uint16
	TunIP     net.IP
}

func (EntryData) Established

func (data EntryData) Established() bool

func (EntryData) FINsSeen

func (data EntryData) FINsSeen() bool

func (EntryData) FINsSeenDSR

func (data EntryData) FINsSeenDSR() bool

func (EntryData) RSTSeen

func (data EntryData) RSTSeen() bool

type Key

type Key [KeySize]byte

func NewKey

func NewKey(proto uint8, ipA net.IP, portA uint16, ipB net.IP, portB uint16) Key

func (Key) AddrA

func (k Key) AddrA() net.IP

func (Key) AddrB

func (k Key) AddrB() net.IP

func (Key) AsBytes

func (k Key) AsBytes() []byte

func (Key) PortA

func (k Key) PortA() uint16

func (Key) PortB

func (k Key) PortB() uint16

func (Key) Proto

func (k Key) Proto() uint8

func (Key) String

func (k Key) String() string

func (Key) Upgrade

func (k Key) Upgrade() maps.Upgradable

type KeyInterface

type KeyInterface interface {
	Proto() uint8
	AddrA() net.IP
	PortA() uint16
	AddrB() net.IP
	PortB() uint16
	String() string
	AsBytes() []byte
}

func KeyFromBytes

func KeyFromBytes(k []byte) KeyInterface

func KeyV6FromBytes

func KeyV6FromBytes(k []byte) KeyInterface

type KeyV6

type KeyV6 [KeyV6Size]byte

func NewKeyV6

func NewKeyV6(proto uint8, ipA net.IP, portA uint16, ipB net.IP, portB uint16) KeyV6

func (KeyV6) AddrA

func (k KeyV6) AddrA() net.IP

func (KeyV6) AddrB

func (k KeyV6) AddrB() net.IP

func (KeyV6) AsBytes

func (k KeyV6) AsBytes() []byte

func (KeyV6) PortA

func (k KeyV6) PortA() uint16

func (KeyV6) PortB

func (k KeyV6) PortB() uint16

func (KeyV6) Proto

func (k KeyV6) Proto() uint8

func (KeyV6) String

func (k KeyV6) String() string

func (KeyV6) Upgrade

func (k KeyV6) Upgrade() maps.Upgradable

type Leg

type Leg struct {
	Bytes    uint64
	Packets  uint32
	Seqno    uint32
	SynSeen  bool
	AckSeen  bool
	FinSeen  bool
	RstSeen  bool
	Approved bool
	Opener   bool
	Ifindex  uint32
}

func (Leg) AsBytes

func (leg Leg) AsBytes() []byte

AsBytes returns Leg serialized as a slice of bytes

func (Leg) Flags

func (leg Leg) Flags() uint32

type MapMem

type MapMem map[Key]Value

func LoadMapMem

func LoadMapMem(m maps.Map) (MapMem, error)

LoadMapMem loads ConntrackMap into memory

type MapMemV6

type MapMemV6 map[KeyV6]ValueV6

func LoadMapMemV6

func LoadMapMemV6(m maps.Map) (MapMemV6, error)

LoadMapMem loads ConntrackMap into memory

type Value

type Value [ValueSize]byte

func NewValueNATForward

func NewValueNATForward(created, lastSeen time.Duration, flags uint16, revKey Key) Value

NewValueNATForward creates a new Value of type TypeNATForward for the given arguments and the reverse key

func NewValueNATReverse

func NewValueNATReverse(created, lastSeen time.Duration, flags uint16, legA, legB Leg,
	tunnelIP, origIP net.IP, origPort uint16) Value

NewValueNATReverse creates a new Value of type TypeNATReverse for the given arguments and reverse parameters

func NewValueNATReverseSNAT

func NewValueNATReverseSNAT(created, lastSeen time.Duration, flags uint16, legA, legB Leg,
	tunnelIP, origIP, origSrcIP net.IP, origPort uint16) Value

NewValueNATReverseSNAT in addition to NewValueNATReverse sets the orig source IP

func NewValueNormal

func NewValueNormal(created, lastSeen time.Duration, flags uint16, legA, legB Leg) Value

NewValueNormal creates a new Value of type TypeNormal based on the given parameters

func (Value) AsBytes

func (e Value) AsBytes() []byte

AsBytes returns the value as slice of bytes

func (Value) Created

func (e Value) Created() int64

func (Value) Data

func (e Value) Data() EntryData

func (Value) Flags

func (e Value) Flags() uint16

func (Value) IsForwardDSR

func (e Value) IsForwardDSR() bool

func (Value) LastSeen

func (e Value) LastSeen() int64

func (Value) NATSPort

func (e Value) NATSPort() uint16

NATSPort returns the port to SNAT to, valid only if Type() is TypeNATForward.

func (Value) OrigIP

func (e Value) OrigIP() net.IP

OrigIP returns the original destination IP, valid only if Type() is TypeNormal or TypeNATReverse

func (Value) OrigPort

func (e Value) OrigPort() uint16

OrigPort returns the original destination port, valid only if Type() is TypeNormal or TypeNATReverse

func (Value) OrigSPort

func (e Value) OrigSPort() uint16

OrigSPort returns the original source port, valid only if Type() is TypeNATReverse and if the value returned is non-zero.

func (Value) OrigSrcIP

func (e Value) OrigSrcIP() net.IP

OrigSrcIP returns the original source IP.

func (Value) ReverseNATKey

func (e Value) ReverseNATKey() KeyInterface

func (*Value) SetLegA2B

func (e *Value) SetLegA2B(leg Leg)

func (*Value) SetLegB2A

func (e *Value) SetLegB2A(leg Leg)

func (*Value) SetNATSport

func (e *Value) SetNATSport(sport uint16)

func (*Value) SetOrigSport

func (e *Value) SetOrigSport(sport uint16)

func (Value) String

func (e Value) String() string

func (Value) Type

func (e Value) Type() uint8

func (Value) Upgrade

func (e Value) Upgrade() maps.Upgradable

type ValueInterface

type ValueInterface interface {
	Created() int64
	LastSeen() int64
	Type() uint8
	Flags() uint16
	OrigIP() net.IP
	OrigPort() uint16
	OrigSPort() uint16
	NATSPort() uint16
	OrigSrcIP() net.IP
	ReverseNATKey() KeyInterface
	AsBytes() []byte
	Data() EntryData
	IsForwardDSR() bool
	String() string
}

func ValueFromBytes

func ValueFromBytes(v []byte) ValueInterface

func ValueV6FromBytes

func ValueV6FromBytes(v []byte) ValueInterface

type ValueV6

type ValueV6 [ValueV6Size]byte

func NewValueV6NATForward

func NewValueV6NATForward(created, lastSeen time.Duration, flags uint16, revKey KeyV6) ValueV6

NewValueV6NATForward creates a new ValueV6 of type TypeNATForward for the given arguments and the reverse key

func NewValueV6NATReverse

func NewValueV6NATReverse(created, lastSeen time.Duration, flags uint16, legA, legB Leg,
	tunnelIP, origIP net.IP, origPort uint16) ValueV6

NewValueV6NATReverse creates a new ValueV6 of type TypeNATReverse for the given arguments and reverse parameters

func NewValueV6NATReverseSNAT

func NewValueV6NATReverseSNAT(created, lastSeen time.Duration, flags uint16, legA, legB Leg,
	tunnelIP, origIP, origSrcIP net.IP, origPort uint16) ValueV6

NewValueV6NATReverseSNAT in addition to NewValueV6NATReverse sets the orig source IP

func NewValueV6Normal

func NewValueV6Normal(created, lastSeen time.Duration, flags uint16, legA, legB Leg) ValueV6

NewValueV6Normal creates a new ValueV6 of type TypeNormal based on the given parameters

func (ValueV6) AsBytes

func (e ValueV6) AsBytes() []byte

AsBytes returns the value as slice of bytes

func (ValueV6) Created

func (e ValueV6) Created() int64

func (ValueV6) Data

func (e ValueV6) Data() EntryData

func (ValueV6) Flags

func (e ValueV6) Flags() uint16

func (ValueV6) IsForwardDSR

func (e ValueV6) IsForwardDSR() bool

func (ValueV6) LastSeen

func (e ValueV6) LastSeen() int64

func (ValueV6) NATSPort

func (e ValueV6) NATSPort() uint16

NATSPort returns the port to SNAT to, valid only if Type() is TypeNATForward.

func (ValueV6) OrigIP

func (e ValueV6) OrigIP() net.IP

OrigIP returns the original destination IP, valid only if Type() is TypeNormal or TypeNATReverse

func (ValueV6) OrigPort

func (e ValueV6) OrigPort() uint16

OrigPort returns the original destination port, valid only if Type() is TypeNormal or TypeNATReverse

func (ValueV6) OrigSPort

func (e ValueV6) OrigSPort() uint16

OrigSPort returns the original source port, valid only if Type() is TypeNATReverse and if the value returned is non-zero.

func (ValueV6) OrigSrcIP

func (e ValueV6) OrigSrcIP() net.IP

OrigSrcIP returns the original source IP.

func (ValueV6) ReverseNATKey

func (e ValueV6) ReverseNATKey() KeyInterface

func (*ValueV6) SetLegA2B

func (e *ValueV6) SetLegA2B(leg Leg)

func (*ValueV6) SetLegB2A

func (e *ValueV6) SetLegB2A(leg Leg)

func (*ValueV6) SetNATSport

func (e *ValueV6) SetNATSport(sport uint16)

func (*ValueV6) SetOrigSport

func (e *ValueV6) SetOrigSport(sport uint16)

func (ValueV6) String

func (e ValueV6) String() string

func (ValueV6) Type

func (e ValueV6) Type() uint8

func (ValueV6) Upgrade

func (e ValueV6) Upgrade() maps.Upgradable

Jump to

Keyboard shortcuts

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