v1.15.2 Latest Latest

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0




This section is empty.


View Source
var (
	Protocols = map[string]uint8{
		"icmp":      1,
		"igmp":      2,
		"tcp":       6,
		"udp":       17,
		"ipv6-icmp": 58,


func CheckConntrackConnActive added in v1.4.0

func CheckConntrackConnActive(conn *Connection) bool

checkConntrackConnActive returns true if there are changes in connection's stats or TCP state, indicating that the connection is active.

func IsConnectionDying

func IsConnectionDying(conn *Connection) bool

func LookupProtocolMap added in v1.15.0

func LookupProtocolMap(name string) (uint8, error)

LookupProtocolMap returns protocol identifier given protocol name

func PolicyTypeToUint8

func PolicyTypeToUint8(policyType v1beta2.NetworkPolicyType) uint8

policyTypeToUint8 converts NetworkPolicy type to uint8

func RuleActionToUint8

func RuleActionToUint8(action string) uint8

RuleActionToUint8 converts network policy rule action to uint8.


type Connection

type Connection struct {
	// Fields from conntrack flows
	ID        uint32
	Timeout   uint32
	StartTime time.Time
	// For invalid and closed connections or deny connections: StopTime is the time when connection
	// was updated last.
	// For established connections: StopTime is latest time when it was polled.
	StopTime time.Time
	// LastExportTime is used to decide whether a connection is stale.
	LastExportTime time.Time
	IsActive       bool
	// IsPresent flag helps in cleaning up connections when they are not in conntrack table anymore.
	IsPresent bool
	// ReadyToDelete marks whether we can safely delete the connection from the connection map.
	ReadyToDelete      bool
	Zone               uint16
	Mark               uint32
	StatusFlag         uint32
	Labels, LabelsMask []byte
	// TODO: Have a separate field for protocol. No need to keep it in Tuple.
	FlowKey                        Tuple
	OriginalPackets, OriginalBytes uint64
	// Fields specific to Antrea
	SourcePodNamespace             string
	SourcePodName                  string
	DestinationPodNamespace        string
	DestinationPodName             string
	DestinationServicePortName     string
	OriginalDestinationAddress     netip.Addr
	OriginalDestinationPort        uint16
	IngressNetworkPolicyName       string
	IngressNetworkPolicyNamespace  string
	IngressNetworkPolicyType       uint8
	IngressNetworkPolicyRuleName   string
	IngressNetworkPolicyRuleAction uint8
	EgressNetworkPolicyName        string
	EgressNetworkPolicyNamespace   string
	EgressNetworkPolicyType        uint8
	EgressNetworkPolicyRuleName    string
	EgressNetworkPolicyRuleAction  uint8
	PrevPackets, PrevBytes         uint64
	// Fields specific to conntrack connections
	ReversePackets, ReverseBytes         uint64
	PrevReversePackets, PrevReverseBytes uint64
	TCPState                             string
	PrevTCPState                         string
	FlowType                             uint8
	EgressName                           string
	EgressIP                             string
	AppProtocolName                      string
	HttpVals                             string

type ConnectionKey

type ConnectionKey = Tuple

We use a type alias here, as a way to minimize code changes: ConnectionKey used to be its own type, and ConnectionKey values were generated from Tuple values. Because of changes to the Tuple type (net.IP -> netip.Addr), Tuple is now comparable and can be used as a map key directly.

func NewConnectionKey

func NewConnectionKey(conn *Connection) ConnectionKey

NewConnectionKey creates 5-tuple of flow as connection key

type ConnectionMapCallBack

type ConnectionMapCallBack func(key ConnectionKey, conn *Connection) error

type FlowExporterOptions added in v1.5.0

type FlowExporterOptions struct {
	FlowCollectorAddr      string
	FlowCollectorProto     string
	ActiveFlowTimeout      time.Duration
	IdleFlowTimeout        time.Duration
	StaleConnectionTimeout time.Duration
	PollInterval           time.Duration
	ConnectUplinkToBridge  bool

type ItemToExpire added in v1.4.0

type ItemToExpire struct {
	Conn             *Connection
	ActiveExpireTime time.Time
	IdleExpireTime   time.Time
	// Index in the priority queue (heap)
	Index int

type Tuple

type Tuple struct {
	SourceAddress      netip.Addr
	DestinationAddress netip.Addr
	Protocol           uint8
	SourcePort         uint16
	DestinationPort    uint16


Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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