This directory contains source code for BCC, a toolkit for creating small
BCC is a toolkit for creating efficient kernel tracing and manipulation
programs that can be dynamically loaded into a Linux kernel.
programs, and includes several useful tools and examples. It makes use of eBPF
(Extended Berkeley Packet Filters), a new feature that was first added to
Linux 3.15. Much of what BCC uses requires Linux 4.1 and above.
eBPF was [described by](https://lkml.org/lkml/2015/4/14/232) Ingo Molnár as:
> One of the more interesting features in this cycle is the ability to attach eBPF programs (user-defined, sandboxed bytecode executed by the kernel) to kprobes. This allows user-defined instrumentation on a live kernel image that can never crash, hang or interfere with the kernel negatively.
BCC makes writing eBPF programs easier to do, with kernel instrumentation in C,
and a front-end in Python. It is suited for many tasks, including advanced
performance analysis and network traffic control.
## Screenshot
This example traces a disk I/O kernel function, and populates an in-kernel
power-of-2 histogram of the I/O size. For efficiency, only the histogram
- examples/[tc_neighbor_sharing.py](examples/tc_neighbor_sharing.py) examples/[tc_neighbor_sharing.c](examples/tc_neighbor_sharing.c): Per-IP classification and rate limiting.
- examples/[tunnel_monitor/](examples/tunnel_monitor): Efficiently monitor traffic flows in and out of an interface. [Example video](https://www.youtube.com/watch?v=yYy3Cwce02k).
- examples/[vlan_learning.py](examples/vlan_learning.py) examples/[vlan_learning.c](examples/vlan_learning.c): Demux Ethernet traffic into worker veth+namespaces.
## Motivation
## Motivation
BPF guarantees that the programs loaded into the kernel cannot crash, and
BPF guarantees that the programs loaded into the kernel cannot crash, and
...
@@ -46,11 +116,11 @@ The features of this toolkit include:
...
@@ -46,11 +116,11 @@ The features of this toolkit include:
In the future, more bindings besides python will likely be supported. Feel free
In the future, more bindings besides python will likely be supported. Feel free
to add support for the language of your choice and send a pull request!
to add support for the language of your choice and send a pull request!
## Examples
## Tutorial
This toolchain is currently composed of two parts: a C wrapper around LLVM, and
The BCC toolchain is currently composed of two parts: a C wrapper around LLVM,
a Python API to interact with the running program. Later, we will go into more
and a Python API to interact with the running program. Later, we will go into