package ringbuf
import "github.com/cilium/ebpf/ringbuf"
Package ringbuf allows interacting with Linux BPF ring buffer.
BPF allows submitting custom events to a BPF ring buffer map set up by userspace. This is very useful to push things like packet samples from BPF to a daemon running in user space.
Index ¶
- Variables
- type Reader
- func NewReader(ringbufMap *ebpf.Map) (*Reader, error)
- func (r *Reader) BufferSize() int
- func (r *Reader) Close() error
- func (r *Reader) Read() (Record, error)
- func (r *Reader) ReadInto(rec *Record) error
- func (r *Reader) SetDeadline(t time.Time)
- type Record
Variables ¶
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader allows reading bpf_ringbuf_output from user space.
func NewReader ¶
NewReader creates a new BPF ringbuf reader.
func (*Reader) BufferSize ¶
BufferSize returns the size in bytes of the ring buffer
func (*Reader) Close ¶
Close frees resources used by the reader.
It interrupts calls to Read.
func (*Reader) Read ¶
Read the next record from the BPF ringbuf.
Returns os.ErrClosed if Close is called on the Reader, or os.ErrDeadlineExceeded if a deadline was set and no valid entry was present. A producer might use BPF_RB_NO_WAKEUP which may cause the deadline to expire but a valid entry will be present.
func (*Reader) ReadInto ¶
ReadInto is like Read except that it allows reusing Record and associated buffers.
func (*Reader) SetDeadline ¶
SetDeadline controls how long Read and ReadInto will block waiting for samples.
Passing a zero time.Time will remove the deadline.
type Record ¶
type Record struct { RawSample []byte // The minimum number of bytes remaining in the ring buffer after this Record has been read. Remaining int }
Source Files ¶
- Version
- v0.13.0
- Published
- Feb 15, 2024
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 4 hours ago –
Tools for package owners.