bpf

package
v0.0.0-...-8216aeb Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2016 Authors of Cilium

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	DBG_CAPTURE_UNSPEC = iota
	DBG_CAPTURE_FROM_LXC
	DBG_CAPTURE_FROM_NETDEV
	DBG_CAPTURE_FROM_OVERLAY
	DBG_CAPTURE_DELIVERY
	DBG_CAPTURE_FROM_LB
)
View Source
const (
	DBG_UNSPEC = iota
	DBG_GENERIC
	DBG_LOCAL_DELIVERY
	DBG_ENCAP
	DBG_LXC_FOUND
	DBG_POLICY_DENIED
	DBG_CT_LOOKUP
	DBG_CT_MATCH
	DBG_CT_CREATED
	DBG_ICMP6_HANDLE
	DBG_ICMP6_REQUEST
	DBG_ICMP6_NS
	DBG_ICMP6_TIME_EXCEEDED
	DBG_CT_VERDICT
	DBG_DECAP
	DBG_PORT_MAP
	DBG_ERROR_RET
	DBG_TO_HOST
	DBG_TO_STACK
	DBG_PKT_HASH
	DBG_LB_SERVICES_LOOKUP_FAIL
	DBG_LB_STATE_LOOKUP_FAIL
)
View Source
const (
	CT_NEW uint32 = iota
	CT_ESTABLISHED
	CT_REPLY
	CT_RELATED
)

must be in sync with <bpf/lib/conntrack.h>

View Source
const (
	CILIUM_NOTIFY_UNSPEC = iota
	CILIUM_NOTIFY_DROP
	CILIUM_DBG_MSG
	CILIUM_DBG_CAPTURE
)

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

View Source
const (
	DebugCaptureLen = 20
)
View Source
const (
	DropNotifyLen = 32
)
View Source
const (
	MAX_POLL_EVENTS = 32
)

Variables

This section is empty.

Functions

func CreateMap

func CreateMap(mapType int, keySize, valueSize, maxEntries uint32) (int, error)

CreateMap creates a Map of type mapType, with key size keySize, a value size of valueSize and the maximum amount of entries of maxEntries. mapType should be one of the bpf_map_type in "uapi/linux/bpf.h"

func CtInfo

func CtInfo(arg1 uint32, arg2 uint32) string

func CtState

func CtState(state uint32) string

func DeleteElement

func DeleteElement(fd int, key unsafe.Pointer) error

DeleteElement deletes the map element with the given key.

func Dissect

func Dissect(dissect bool, data []byte)

func DropReason

func DropReason(reason uint8) string

func GetNextKey

func GetNextKey(fd int, key, nextKey unsafe.Pointer) error

GetNextKey stores, in nextKey, the next key after the key of the map in fd.

func LookupElement

func LookupElement(fd int, key, value unsafe.Pointer) error

LookupElement looks up for the map value stored in fd with the given key. The value is stored in the value unsafe.Pointer.

func ObjGet

func ObjGet(pathname string) (int, error)

ObjGet reads the pathname and returns the map's fd read.

func ObjPin

func ObjPin(fd int, pathname string) error

ObjPin stores the map's fd in pathname.

func OpenOrCreateMap

func OpenOrCreateMap(path string, mapType int, keySize, valueSize, maxEntries uint32) (int, bool, error)

func UpdateElement

func UpdateElement(fd int, key, value unsafe.Pointer, flags uint64) error

UpdateElement updates the map in fd with the given value in the given key. The flags can have the following values (if you include "uapi/linux/bpf.h"): C.BPF_ANY to create new element or update existing; C.BPF_NOEXIST to create new element if it didn't exist; C.BPF_EXIST to update existing element.

Types

type DebugCapture

type DebugCapture struct {
	Type    uint8
	SubType uint8
	Source  uint16
	Hash    uint32
	Len     uint32
	OrigLen uint32
	Arg1    uint32
}

func (*DebugCapture) Dump

func (n *DebugCapture) Dump(dissect bool, data []byte, prefix string)

type DebugMsg

type DebugMsg struct {
	Type    uint8
	SubType uint8
	Source  uint16
	Hash    uint32
	Arg1    uint32
	Arg2    uint32
}

func (*DebugMsg) Dump

func (n *DebugMsg) Dump(data []byte, prefix string)

type DropNotify

type DropNotify struct {
	Type     uint8
	SubType  uint8
	Source   uint16
	Hash     uint32
	OrigLen  uint32
	CapLen   uint32
	SrcLabel uint32
	DstLabel uint32
	DstID    uint32
	Ifindex  uint32
}

func (*DropNotify) Dump

func (n *DropNotify) Dump(dissect bool, data []byte, prefix string)

type EPoll

type EPoll struct {
	// contains filtered or unexported fields
}

func (*EPoll) AddFD

func (ep *EPoll) AddFD(fd int, events uint32) error

func (*EPoll) Close

func (ep *EPoll) Close()

func (*EPoll) Poll

func (ep *EPoll) Poll(timeout int) (int, error)

type EventMap

type EventMap struct {
	// contains filtered or unexported fields
}

func (*EventMap) Close

func (e *EventMap) Close()

func (*EventMap) Update

func (e *EventMap) Update(ev *PerfEvent) error

type LostFunc

type LostFunc func(msg *PerfEventLost, cpu int)

type PerCpuEvents

type PerCpuEvents struct {
	// contains filtered or unexported fields
}

func NewPerCpuEvents

func NewPerCpuEvents(config *PerfEventConfig) (*PerCpuEvents, error)

func (*PerCpuEvents) CloseAll

func (e *PerCpuEvents) CloseAll() error

func (*PerCpuEvents) Poll

func (e *PerCpuEvents) Poll(timeout int) (int, error)

func (*PerCpuEvents) ReadAll

func (e *PerCpuEvents) ReadAll(receive ReceiveFunc, lost LostFunc) error

func (*PerCpuEvents) Stats

func (e *PerCpuEvents) Stats() (uint64, uint64)

type PerfEvent

type PerfEvent struct {
	Fd int
	// contains filtered or unexported fields
}

func PerfEventOpen

func PerfEventOpen(config *PerfEventConfig, pid int, cpu int, groupFD int, flags int) (*PerfEvent, error)

func (*PerfEvent) Close

func (e *PerfEvent) Close()

func (*PerfEvent) Disable

func (e *PerfEvent) Disable() error

func (*PerfEvent) Enable

func (e *PerfEvent) Enable() error

func (*PerfEvent) Mmap

func (e *PerfEvent) Mmap(pagesize int, npages int) error

func (*PerfEvent) Read

func (e *PerfEvent) Read(receive ReceiveFunc, lostFn LostFunc) error

type PerfEventConfig

type PerfEventConfig struct {
	NumCpus      int
	NumPages     int
	MapPath      string
	Type         int
	Config       int
	SampleType   int
	WakeupEvents int
}

func DefaultPerfEventConfig

func DefaultPerfEventConfig() *PerfEventConfig

type PerfEventHeader

type PerfEventHeader struct {
	Type      uint32
	Misc      uint16
	TotalSize uint16
}

Matching 'struct perf_event_header in <linux/perf_event.h>

type PerfEventLost

type PerfEventLost struct {
	PerfEventHeader
	Id   uint64
	Lost uint64
}

Matching 'struct perf_event_lost in kernel sources

type PerfEventSample

type PerfEventSample struct {
	PerfEventHeader
	Size uint32
	// contains filtered or unexported fields
}

Matching 'struct perf_event_sample in kernel sources

func (*PerfEventSample) DataCopy

func (e *PerfEventSample) DataCopy() []byte

func (*PerfEventSample) DataDirect

func (e *PerfEventSample) DataDirect() []byte

type ReceiveFunc

type ReceiveFunc func(msg *PerfEventSample, cpu int)

Jump to

Keyboard shortcuts

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