Documentation
¶
Index ¶
- Constants
- Variables
- type Attacher
- type AttacherFactory
- type MockProgram
- func (m *MockProgram) Attach() error
- func (m *MockProgram) AttachCallCount() int
- func (m *MockProgram) Close()
- func (m *MockProgram) Detach() error
- func (m *MockProgram) DetachCallCount() int
- func (m *MockProgram) IsAttached() bool
- func (m *MockProgram) Reset()
- func (m *MockProgram) SetAttachError(err error)
- func (m *MockProgram) SetDetachError(err error)
- type Program
Constants ¶
const ( // BPFMapPinPath is the directory where BPF maps are pinned BPFMapPinPath = "/sys/fs/bpf/azure-block-iptables" // EventCounterMapName is the name used for pinning the event counter map EventCounterMapName = "iptables_block_event_counter" // IptablesLegacyBlockProgramName is the name used for pinning the legacy iptables block program IptablesLegacyBlockProgramName = "iptables_legacy_block" // IptablesNftablesBlockProgramName is the name used for pinning the nftables block program IptablesNftablesBlockProgramName = "iptables_nftables_block" // NetNSPath is the path to the host network namespace NetNSPath = "/proc/self/ns/net" )
Variables ¶
var ErrEventCounterMapNotLoaded = errors.New("event counter map not loaded")
Functions ¶
This section is empty.
Types ¶
type Attacher ¶
type Attacher interface { // Attach attaches the BPF program to LSM hooks and pins the links and maps Attach() error // Unpins the links and maps (causes detachment) Detach() error // IsAttached returns true if the BPF program is currently attached IsAttached() bool // Close cleans up all resources Close() }
Attacher defines the interface for BPF program attachment operations. This interface allows for dependency injection and easier testing with mock implementations.
type AttacherFactory ¶
type AttacherFactory func() Attacher
AttacherFactory defines a function type for creating Attacher instances. This allows for easier dependency injection in applications.
type MockProgram ¶
type MockProgram struct {
// contains filtered or unexported fields
}
MockProgram provides a mock implementation of the Manager interface for testing.
func NewMockProgram ¶
func NewMockProgram() *MockProgram
NewMockProgram creates a new mock BPF program manager instance.
func (*MockProgram) Attach ¶
func (m *MockProgram) Attach() error
Attach simulates attaching the BPF program.
func (*MockProgram) AttachCallCount ¶
func (m *MockProgram) AttachCallCount() int
AttachCallCount returns the number of times Attach() was called.
func (*MockProgram) Detach ¶
func (m *MockProgram) Detach() error
Detach simulates detaching the BPF program.
func (*MockProgram) DetachCallCount ¶
func (m *MockProgram) DetachCallCount() int
DetachCallCount returns the number of times Detach() was called.
func (*MockProgram) IsAttached ¶
func (m *MockProgram) IsAttached() bool
IsAttached returns the mock's attached state.
func (*MockProgram) SetAttachError ¶
func (m *MockProgram) SetAttachError(err error)
SetAttachError sets the error to return from Attach() calls.
func (*MockProgram) SetDetachError ¶
func (m *MockProgram) SetDetachError(err error)
SetDetachError sets the error to return from Detach() calls.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program implements the Manager interface for real BPF program operations.
func (*Program) CreatePinPath ¶
CreatePinPath ensures the BPF map pin directory exists.
func (*Program) IsAttached ¶
IsAttached returns true if the BPF program is currently attached.