api

package
v0.0.0-...-c34bea4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 0-128 are reserved for BPF datapath events
	MessageTypeUnspec = iota

	// MessageTypeDrop is a BPF datapath notification carrying a DropNotify
	// which corresponds to drop_notify defined in bpf/lib/drop.h
	MessageTypeDrop

	// MessageTypeDebug is a BPF datapath notification carrying a DebugMsg
	// which corresponds to debug_msg defined in bpf/lib/dbg.h
	MessageTypeDebug

	// MessageTypeCapture is a BPF datapath notification carrying a DebugCapture
	// which corresponds to debug_capture_msg defined in bpf/lib/dbg.h
	MessageTypeCapture

	// MessageTypeTrace is a BPF datapath notification carrying a TraceNotify
	// which corresponds to trace_notify defined in bpf/lib/trace.h
	MessageTypeTrace

	// MessageTypePolicyVerdict is a BPF datapath notification carrying a PolicyVerdictNotify
	// which corresponds to policy_verdict_notify defined in bpf/lib/policy_log.h
	MessageTypePolicyVerdict

	// MessageTypeRecCapture is a BPF datapath notification carrying a RecorderCapture
	// which corresponds to capture_msg defined in bpf/lib/pcap.h
	MessageTypeRecCapture

	// MessageTypeAccessLog contains a pkg/proxy/accesslog.LogRecord
	MessageTypeAccessLog = 129

	// MessageTypeAgent is an agent notification carrying a AgentNotify
	MessageTypeAgent = 130
)

Must be synchronized with <bpf/lib/common.h>

View Source
const (
	MessageTypeNameDrop          = "drop"
	MessageTypeNameDebug         = "debug"
	MessageTypeNameCapture       = "capture"
	MessageTypeNameTrace         = "trace"
	MessageTypeNameL7            = "l7"
	MessageTypeNameAgent         = "agent"
	MessageTypeNamePolicyVerdict = "policy-verdict"
	MessageTypeNameRecCapture    = "recorder"
)
View Source
const (
	TraceToLxc = iota
	TraceToProxy
	TraceToHost
	TraceToStack
	TraceToOverlay
	TraceFromLxc
	TraceFromProxy
	TraceFromHost
	TraceFromStack
	TraceFromOverlay
	TraceFromNetwork
	TraceToNetwork
)

Must be synchronized with <bpf/lib/trace.h>

View Source
const (
	// PolicyIngress is the value of Flags&PolicyNotifyFlagDirection for ingress traffic
	PolicyIngress = 1

	// PolicyEgress is the value of Flags&PolicyNotifyFlagDirection for egress traffic
	PolicyEgress = 2

	// PolicyMatchNone is the value of MatchType indicatating no policy match
	PolicyMatchNone = 0

	// PolicyMatchL3Only is the value of MatchType indicating a L3-only match
	PolicyMatchL3Only = 1

	// PolicyMatchL3L4 is the value of MatchType indicating a L3+L4 match
	PolicyMatchL3L4 = 2

	// PolicyMatchL4Only is the value of MatchType indicating a L4-only match
	PolicyMatchL4Only = 3

	// PolicyMatchAll is the value of MatchType indicating an allow-all match
	PolicyMatchAll = 4
)

Variables

View Source
var AgentNotifications = map[AgentNotification]string{
	AgentNotifyUnspec:                    "unspecified",
	AgentNotifyGeneric:                   "Message",
	AgentNotifyStart:                     "Cilium agent started",
	AgentNotifyEndpointRegenerateSuccess: "Endpoint regenerated",
	AgentNotifyEndpointCreated:           "Endpoint created",
	AgentNotifyEndpointDeleted:           "Endpoint deleted",
	AgentNotifyEndpointRegenerateFail:    "Failed endpoint regeneration",
	AgentNotifyIPCacheDeleted:            "IPCache entry deleted",
	AgentNotifyIPCacheUpserted:           "IPCache entry upserted",
	AgentNotifyPolicyUpdated:             "Policy updated",
	AgentNotifyPolicyDeleted:             "Policy deleted",
	AgentNotifyServiceDeleted:            "Service deleted",
	AgentNotifyServiceUpserted:           "Service upserted",
}

AgentNotifications is a map of all supported agent notification types.

View Source
var DropInvalid uint8 = 2

DropInvalid is the Invalid packet reason.

View Source
var DropMin uint8 = 130

DropMin numbers less than this are non-drop reason codes

View Source
var TraceObservationPoints = map[uint8]string{
	TraceToLxc:       "to-endpoint",
	TraceToProxy:     "to-proxy",
	TraceToHost:      "to-host",
	TraceToStack:     "to-stack",
	TraceToOverlay:   "to-overlay",
	TraceToNetwork:   "to-network",
	TraceFromLxc:     "from-endpoint",
	TraceFromProxy:   "from-proxy",
	TraceFromHost:    "from-host",
	TraceFromStack:   "from-stack",
	TraceFromOverlay: "from-overlay",
	TraceFromNetwork: "from-network",
}

TraceObservationPoints is a map of all supported trace observation points

Functions

func DropReason

func DropReason(reason uint8) string

DropReason prints the drop reason in a human readable string

func MessageTypeName

func MessageTypeName(typ int) string

MessageTypeName returns the name for a message type or the numeric value if the name can't be found

func TraceObservationPoint

func TraceObservationPoint(obsPoint uint8) string

TraceObservationPoint returns the name of a trace observation point

Types

type AgentNotification

type AgentNotification uint32

AgentNotification specifies the type of agent notification

const (
	AgentNotifyUnspec AgentNotification = iota
	AgentNotifyGeneric
	AgentNotifyStart
	AgentNotifyEndpointRegenerateSuccess
	AgentNotifyEndpointRegenerateFail
	AgentNotifyPolicyUpdated
	AgentNotifyPolicyDeleted
	AgentNotifyEndpointCreated
	AgentNotifyEndpointDeleted
	AgentNotifyIPCacheUpserted
	AgentNotifyIPCacheDeleted
	AgentNotifyServiceUpserted
	AgentNotifyServiceDeleted
)

type AgentNotify

type AgentNotify struct {
	Type AgentNotification
	Text string
}

AgentNotify is a notification from the agent. The notification is stored in its JSON-encoded representation

func (*AgentNotify) DumpInfo

func (n *AgentNotify) DumpInfo()

DumpInfo dumps an agent notification

func (*AgentNotify) DumpJSON

func (n *AgentNotify) DumpJSON()

DumpJSON prints notification in json format

type AgentNotifyMessage

type AgentNotifyMessage struct {
	Type         AgentNotification
	Notification interface{}
}

AgentNotifyMessage is a notification from the agent. It is similar to AgentNotify, but the notification is an unencoded struct. See the *Message constructors in this package for possible values.

func EndpointCreateMessage

EndpointCreateMessage constructs an agent notification message for endpoint creation

func EndpointDeleteMessage

EndpointDeleteMessage constructs an agent notification message for endpoint deletion

func EndpointRegenMessage

func EndpointRegenMessage(e notifications.RegenNotificationInfo, err error) AgentNotifyMessage

EndpointRegenMessage constructs an agent notification message for endpoint regeneration

func IPCacheDeletedMessage

func IPCacheDeletedMessage(cidr string, id uint32, oldID *uint32, hostIP net.IP, oldHostIP net.IP,
	encryptKey uint8, namespace, podName string) AgentNotifyMessage

IPCacheDeletedMessage constructs an agent notification message for ipcache deletions

func IPCacheUpsertedMessage

func IPCacheUpsertedMessage(cidr string, id uint32, oldID *uint32, hostIP net.IP, oldHostIP net.IP,
	encryptKey uint8, namespace, podName string) AgentNotifyMessage

IPCacheUpsertedMessage constructs an agent notification message for ipcache upsertions

func PolicyDeleteMessage

func PolicyDeleteMessage(deleted int, labels []string, revision uint64) AgentNotifyMessage

PolicyDeleteMessage constructs an agent notification message for policy deletion

func PolicyUpdateMessage

func PolicyUpdateMessage(numRules int, labels []string, revision uint64) AgentNotifyMessage

PolicyUpdateMessage constructs an agent notification message for policy updates

func ServiceDeleteMessage

func ServiceDeleteMessage(id uint32) AgentNotifyMessage

ServiceDeleteMessage constructs an agent notification message for service deletions

func ServiceUpsertMessage

func ServiceUpsertMessage(
	id uint32,
	frontend ServiceUpsertNotificationAddr,
	backends []ServiceUpsertNotificationAddr,
	svcType, svcTrafficPolicy, svcName, svcNamespace string,
) AgentNotifyMessage

ServiceUpsertMessage constructs an agent notification message for service upserts

func StartMessage

func StartMessage(t time.Time) AgentNotifyMessage

StartMessage constructs an agent notification message when the agent starts

func (*AgentNotifyMessage) ToJSON

func (m *AgentNotifyMessage) ToJSON() (AgentNotify, error)

ToJSON encodes a AgentNotifyMessage to its JSON-based AgentNotify representation

type EndpointNotification

type EndpointNotification struct {
	EndpointRegenNotification
	PodName   string `json:"pod-name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
}

EndpointNotification structures the endpoint create or delete notification

type EndpointRegenNotification

type EndpointRegenNotification struct {
	ID     uint64   `json:"id,omitempty"`
	Labels []string `json:"labels,omitempty"`
	Error  string   `json:"error,omitempty"`
}

EndpointRegenNotification structures regeneration notification

type IPCacheNotification

type IPCacheNotification struct {
	CIDR        string  `json:"cidr"`
	Identity    uint32  `json:"id"`
	OldIdentity *uint32 `json:"old-id,omitempty"`

	HostIP    net.IP `json:"host-ip,omitempty"`
	OldHostIP net.IP `json:"old-host-ip,omitempty"`

	EncryptKey uint8  `json:"encrypt-key"`
	Namespace  string `json:"namespace,omitempty"`
	PodName    string `json:"pod-name,omitempty"`
}

IPCacheNotification structures ipcache change notifications

type MessageTypeFilter

type MessageTypeFilter []int

func (*MessageTypeFilter) Contains

func (m *MessageTypeFilter) Contains(typ int) bool

func (*MessageTypeFilter) Set

func (m *MessageTypeFilter) Set(value string) error

func (*MessageTypeFilter) String

func (m *MessageTypeFilter) String() string

func (*MessageTypeFilter) Type

func (m *MessageTypeFilter) Type() string

type PolicyMatchType

type PolicyMatchType int

func (PolicyMatchType) String

func (m PolicyMatchType) String() string

type PolicyUpdateNotification

type PolicyUpdateNotification struct {
	Labels    []string `json:"labels,omitempty"`
	Revision  uint64   `json:"revision,omitempty"`
	RuleCount int      `json:"rule_count"`
}

PolicyUpdateNotification structures update notification

type ServiceDeleteNotification

type ServiceDeleteNotification struct {
	ID uint32 `json:"id"`
}

ServiceDeleteNotification structures service delete notifications

type ServiceUpsertNotification

type ServiceUpsertNotification struct {
	ID uint32 `json:"id"`

	Frontend ServiceUpsertNotificationAddr   `json:"frontend-address"`
	Backends []ServiceUpsertNotificationAddr `json:"backend-addresses"`

	Type          string `json:"type,omitempty"`
	TrafficPolicy string `json:"traffic-policy,omitempty"`

	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,,omitempty"`
}

ServiceUpsertNotification structures service upsert notifications

type ServiceUpsertNotificationAddr

type ServiceUpsertNotificationAddr struct {
	IP   net.IP `json:"ip"`
	Port uint16 `json:"port"`
}

ServiceUpsertNotificationAddr is part of ServiceUpsertNotification

type TimeNotification

type TimeNotification struct {
	Time string `json:"time"`
}

TimeNotification structures agent start notification

Jump to

Keyboard shortcuts

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