api

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 7 Imported by: 59

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

	// 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"
)
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 DropInvalid uint8 = 2

DropInvalid is the Invalid packet reason.

View Source
var DropMin uint8 = 130

DropMin numbers below 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 EndpointCreateRepr added in v1.6.0

func EndpointCreateRepr(e notifications.RegenNotificationInfo) (string, error)

EndpointCreateRepr returns string representation of monitor notification

func EndpointDeleteRepr added in v1.6.0

func EndpointDeleteRepr(e notifications.RegenNotificationInfo) (string, error)

EndpointDeleteRepr returns string representation of monitor notification

func EndpointRegenRepr added in v1.5.0

func EndpointRegenRepr(e notifications.RegenNotificationInfo, err error) (string, error)

EndpointRegenRepr returns string representation of monitor notification

func IPCacheNotificationRepr added in v1.7.0

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

IPCacheNotificationRepr returns string representation of monitor notification

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 PolicyDeleteRepr added in v1.5.0

func PolicyDeleteRepr(deleted int, labels []string, revision uint64) (string, error)

PolicyDeleteRepr returns string representation of monitor notification

func PolicyUpdateRepr added in v1.5.0

func PolicyUpdateRepr(numRules int, labels []string, revision uint64) (string, error)

PolicyUpdateRepr returns string representation of monitor notification

func ServiceDeleteRepr added in v1.7.0

func ServiceDeleteRepr(
	id uint32,
) (string, error)

ServiceDeleteRepr returns string representation of monitor notification

func ServiceUpsertRepr added in v1.7.0

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

ServiceUpsertRepr returns string representation of monitor notification

func TimeRepr added in v1.5.0

func TimeRepr(t time.Time) (string, error)

TimeRepr returns string representation of monitor notification

func TraceObservationPoint

func TraceObservationPoint(obsPoint uint8) string

TraceObservationPoint returns the name of a trace observation point

func TraceObservationPointHasConnState added in v1.8.4

func TraceObservationPointHasConnState(obsPoint uint8) bool

TraceObservationPointHasConnState returns true if the observation point obsPoint populates the TraceNotify.Reason field with connection tracking information.

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

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 EndpointCreateNotification added in v1.6.0

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

EndpointCreateNotification structures the endpoint create notification

type EndpointDeleteNotification added in v1.6.0

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

EndpointDeleteNotification structures the an endpoint 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