v2

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

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)
)
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 MaxEntries = 512000
View Source
const ValueSize = 64

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:      2,
	UpdatedByBPF: true,
}

Functions

func MapMemIter

func MapMemIter(m MapMem) maps.IterCallback

MapMemIter returns maps.MapIter that loads the provided MapMem

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 Leg

type Leg struct {
	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 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

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

func (Value) ReverseNATKey

func (e Value) ReverseNATKey() Key

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

Jump to

Keyboard shortcuts

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