ebpf

package
v1.7.0-community Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadBpf added in v0.3.0

func LoadBpf() (*ebpf.CollectionSpec, error)

LoadBpf returns the embedded CollectionSpec for Bpf.

func LoadBpfObjects added in v0.3.0

func LoadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error

LoadBpfObjects loads Bpf and converts it into a struct.

The following types are suitable as obj argument:

*BpfObjects
*BpfPrograms
*BpfMaps

See ebpf.CollectionSpec.LoadAndAssign documentation for details.

Types

type BpfDirectionT

type BpfDirectionT uint32
const (
	BpfDirectionTINGRESS       BpfDirectionT = 0
	BpfDirectionTEGRESS        BpfDirectionT = 1
	BpfDirectionTMAX_DIRECTION BpfDirectionT = 2
)

type BpfDnsFlowId added in v0.3.2

type BpfDnsFlowId struct {
	SrcPort  uint16
	DstPort  uint16
	SrcIp    [16]uint8
	DstIp    [16]uint8
	Id       uint16
	Protocol uint8
}

type BpfDnsRecordT added in v0.3.2

type BpfDnsRecordT struct {
	Id      uint16
	Flags   uint16
	Latency uint64
	Errno   uint8
}

type BpfFilterActionT

type BpfFilterActionT uint32
const (
	BpfFilterActionTACCEPT             BpfFilterActionT = 0
	BpfFilterActionTREJECT             BpfFilterActionT = 1
	BpfFilterActionTMAX_FILTER_ACTIONS BpfFilterActionT = 2
)

type BpfFilterKeyT

type BpfFilterKeyT struct {
	PrefixLen uint32
	IpData    [16]uint8
}

type BpfFilterValueT

type BpfFilterValueT struct {
	Protocol     uint8
	DstPortStart uint16
	DstPortEnd   uint16
	DstPort1     uint16
	DstPort2     uint16
	SrcPortStart uint16
	SrcPortEnd   uint16
	SrcPort1     uint16
	SrcPort2     uint16
	PortStart    uint16
	PortEnd      uint16
	Port1        uint16
	Port2        uint16
	IcmpType     uint8
	IcmpCode     uint8
	Direction    BpfDirectionT
	Action       BpfFilterActionT
	TcpFlags     BpfTcpFlagsT
	FilterDrops  uint8
	Ip           [16]uint8
}

type BpfFlowId added in v0.3.0

type BpfFlowId BpfFlowIdT

type BpfFlowIdT added in v0.3.0

type BpfFlowIdT struct {
	EthProtocol       uint16
	Direction         uint8
	SrcMac            [6]uint8
	DstMac            [6]uint8
	SrcIp             [16]uint8
	DstIp             [16]uint8
	SrcPort           uint16
	DstPort           uint16
	TransportProtocol uint8
	IcmpType          uint8
	IcmpCode          uint8
	IfIndex           uint32
}

type BpfFlowMetrics added in v0.3.0

type BpfFlowMetrics BpfFlowMetricsT

type BpfFlowMetricsT added in v0.3.0

type BpfFlowMetricsT struct {
	Packets          uint32
	Bytes            uint64
	StartMonoTimeTs  uint64
	EndMonoTimeTs    uint64
	Flags            uint16
	Errno            uint8
	Dscp             uint8
	PktDrops         BpfPktDropsT
	DnsRecord        BpfDnsRecordT
	FlowRtt          uint64
	NetworkEventsIdx uint8
	NetworkEvents    [4][8]uint8
}

type BpfFlowRecordT added in v0.3.0

type BpfFlowRecordT struct {
	Id      BpfFlowId
	Metrics BpfFlowMetrics
}

type BpfGlobalCountersKeyT

type BpfGlobalCountersKeyT uint32
const (
	BpfGlobalCountersKeyTHASHMAP_FLOWS_DROPPED_KEY           BpfGlobalCountersKeyT = 0
	BpfGlobalCountersKeyTFILTER_REJECT_KEY                   BpfGlobalCountersKeyT = 1
	BpfGlobalCountersKeyTFILTER_ACCEPT_KEY                   BpfGlobalCountersKeyT = 2
	BpfGlobalCountersKeyTFILTER_NOMATCH_KEY                  BpfGlobalCountersKeyT = 3
	BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_KEY              BpfGlobalCountersKeyT = 4
	BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_GROUPID_MISMATCH BpfGlobalCountersKeyT = 5
	BpfGlobalCountersKeyTNETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS BpfGlobalCountersKeyT = 6
	BpfGlobalCountersKeyTNETWORK_EVENTS_GOOD                 BpfGlobalCountersKeyT = 7
	BpfGlobalCountersKeyTMAX_DROPPED_FLOWS_KEY               BpfGlobalCountersKeyT = 8
)

type BpfMapSpecs added in v0.3.0

type BpfMapSpecs struct {
	AggregatedFlows *ebpf.MapSpec `ebpf:"aggregated_flows"`
	DirectFlows     *ebpf.MapSpec `ebpf:"direct_flows"`
	DnsFlows        *ebpf.MapSpec `ebpf:"dns_flows"`
	FilterMap       *ebpf.MapSpec `ebpf:"filter_map"`
	GlobalCounters  *ebpf.MapSpec `ebpf:"global_counters"`
	PacketRecord    *ebpf.MapSpec `ebpf:"packet_record"`
}

BpfMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type BpfMaps added in v0.3.0

type BpfMaps struct {
	AggregatedFlows *ebpf.Map `ebpf:"aggregated_flows"`
	DirectFlows     *ebpf.Map `ebpf:"direct_flows"`
	DnsFlows        *ebpf.Map `ebpf:"dns_flows"`
	FilterMap       *ebpf.Map `ebpf:"filter_map"`
	GlobalCounters  *ebpf.Map `ebpf:"global_counters"`
	PacketRecord    *ebpf.Map `ebpf:"packet_record"`
}

BpfMaps contains all maps after they have been loaded into the kernel.

It can be passed to LoadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*BpfMaps) Close added in v0.3.0

func (m *BpfMaps) Close() error

type BpfObjects added in v0.3.0

type BpfObjects struct {
	BpfPrograms
	BpfMaps
}

BpfObjects contains all objects after they have been loaded into the kernel.

It can be passed to LoadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*BpfObjects) Close added in v0.3.0

func (o *BpfObjects) Close() error

type BpfPktDropsT added in v0.3.2

type BpfPktDropsT struct {
	Packets         uint32
	Bytes           uint64
	LatestFlags     uint16
	LatestState     uint8
	LatestDropCause uint32
}

type BpfProgramSpecs added in v0.3.0

type BpfProgramSpecs struct {
	KfreeSkb                  *ebpf.ProgramSpec `ebpf:"kfree_skb"`
	RhNetworkEventsMonitoring *ebpf.ProgramSpec `ebpf:"rh_network_events_monitoring"`
	TcEgressFlowParse         *ebpf.ProgramSpec `ebpf:"tc_egress_flow_parse"`
	TcEgressPcaParse          *ebpf.ProgramSpec `ebpf:"tc_egress_pca_parse"`
	TcIngressFlowParse        *ebpf.ProgramSpec `ebpf:"tc_ingress_flow_parse"`
	TcIngressPcaParse         *ebpf.ProgramSpec `ebpf:"tc_ingress_pca_parse"`
	TcpRcvFentry              *ebpf.ProgramSpec `ebpf:"tcp_rcv_fentry"`
	TcpRcvKprobe              *ebpf.ProgramSpec `ebpf:"tcp_rcv_kprobe"`
	TcxEgressFlowParse        *ebpf.ProgramSpec `ebpf:"tcx_egress_flow_parse"`
	TcxEgressPcaParse         *ebpf.ProgramSpec `ebpf:"tcx_egress_pca_parse"`
	TcxIngressFlowParse       *ebpf.ProgramSpec `ebpf:"tcx_ingress_flow_parse"`
	TcxIngressPcaParse        *ebpf.ProgramSpec `ebpf:"tcx_ingress_pca_parse"`
}

BpfSpecs contains programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type BpfPrograms added in v0.3.0

type BpfPrograms struct {
	KfreeSkb                  *ebpf.Program `ebpf:"kfree_skb"`
	RhNetworkEventsMonitoring *ebpf.Program `ebpf:"rh_network_events_monitoring"`
	TcEgressFlowParse         *ebpf.Program `ebpf:"tc_egress_flow_parse"`
	TcEgressPcaParse          *ebpf.Program `ebpf:"tc_egress_pca_parse"`
	TcIngressFlowParse        *ebpf.Program `ebpf:"tc_ingress_flow_parse"`
	TcIngressPcaParse         *ebpf.Program `ebpf:"tc_ingress_pca_parse"`
	TcpRcvFentry              *ebpf.Program `ebpf:"tcp_rcv_fentry"`
	TcpRcvKprobe              *ebpf.Program `ebpf:"tcp_rcv_kprobe"`
	TcxEgressFlowParse        *ebpf.Program `ebpf:"tcx_egress_flow_parse"`
	TcxEgressPcaParse         *ebpf.Program `ebpf:"tcx_egress_pca_parse"`
	TcxIngressFlowParse       *ebpf.Program `ebpf:"tcx_ingress_flow_parse"`
	TcxIngressPcaParse        *ebpf.Program `ebpf:"tcx_ingress_pca_parse"`
}

BpfPrograms contains all programs after they have been loaded into the kernel.

It can be passed to LoadBpfObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*BpfPrograms) Close added in v0.3.0

func (p *BpfPrograms) Close() error

type BpfSpecs added in v0.3.0

type BpfSpecs struct {
	BpfProgramSpecs
	BpfMapSpecs
}

BpfSpecs contains maps and programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type BpfTcpFlagsT

type BpfTcpFlagsT uint32
const (
	BpfTcpFlagsTFIN_FLAG     BpfTcpFlagsT = 1
	BpfTcpFlagsTSYN_FLAG     BpfTcpFlagsT = 2
	BpfTcpFlagsTRST_FLAG     BpfTcpFlagsT = 4
	BpfTcpFlagsTPSH_FLAG     BpfTcpFlagsT = 8
	BpfTcpFlagsTACK_FLAG     BpfTcpFlagsT = 16
	BpfTcpFlagsTURG_FLAG     BpfTcpFlagsT = 32
	BpfTcpFlagsTECE_FLAG     BpfTcpFlagsT = 64
	BpfTcpFlagsTCWR_FLAG     BpfTcpFlagsT = 128
	BpfTcpFlagsTSYN_ACK_FLAG BpfTcpFlagsT = 256
	BpfTcpFlagsTFIN_ACK_FLAG BpfTcpFlagsT = 512
	BpfTcpFlagsTRST_ACK_FLAG BpfTcpFlagsT = 1024
)

Jump to

Keyboard shortcuts

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