Protocol Documentation
Table of Contents
datapathplugins/datapathplugins.proto
AttachmentContext
AttachmentContext contains the context about the attachment point in question. It may carry endpoint-specific information used to determine which hooks to load or how to configure them.
Field |
Type |
Label |
Description |
|---|---|---|---|
host |
|||
lxc |
|||
overlay |
|||
socket |
|||
wireguard |
|||
xdp |
AttachmentContext.Host
attachment context for bpf_host (netdev, cilium_host, cilium_net).
Field |
Type |
Label |
Description |
|---|---|---|---|
iface |
interface that is being configured. |
AttachmentContext.InterfaceInfo
InterfaceInfo contains information about a network interface.
Field |
Type |
Label |
Description |
|---|---|---|---|
name |
name of the network interface. |
AttachmentContext.LXC
attachment context for bpf_lxc (containers).
Field |
Type |
Label |
Description |
|---|---|---|---|
iface |
interface that is being configured. |
||
pod_info |
pod that is being configured. |
AttachmentContext.Overlay
attachment context for bpf_overlay (vxlan/geneve).
Field |
Type |
Label |
Description |
|---|---|---|---|
iface |
interface that is being configured. |
AttachmentContext.PodInfo
PodInfo contains information about a pod.
Field |
Type |
Label |
Description |
|---|---|---|---|
namespace |
pod namespace. |
||
name |
pod name. |
||
container_name |
container name. |
AttachmentContext.Socket
attachment context for bpf_sock (connect4,bind4,…)
AttachmentContext.Wireguard
attachment context for bpf_wireguard (cilium_wg)
Field |
Type |
Label |
Description |
|---|---|---|---|
iface |
interface that is being configured. |
AttachmentContext.XDP
attachment context for bpf_xdp (netdev)
Field |
Type |
Label |
Description |
|---|---|---|---|
iface |
interface that is being configured. |
InstrumentCollectionRequest
Phase 2: Cilium has constructed and loaded the collection along with any dispatcher programs that are meant to replace existing entrypoints in the collection. Cilium sends a round of requests to any plugins that wanted to inject hooks in the prepare phase.
Field |
Type |
Label |
Description |
|---|---|---|---|
collection |
|||
attachment_context |
|||
config |
config contains datapath configuration for this collection. |
||
hooks |
repeated |
list of hooks corresponding with those specified by the plugin in its PrepareHooks response. |
|
pins |
an ephemeral per-request bpffs directory where a plugin can pin an arbitrary set of objects. The lifecycle of these pins will be bound to that of the attachment context. This is useful especially in cases where the plugin loads its own set of tail call programs accessible from the entrypoint hook program and want to make sure a PROG_ARRAY and the programs it contains remain intact even after the InstrumentCollection request returns. |
||
cookie |
cookie matches the cookie provided in the plugin’s PrepareHooks response. |
InstrumentCollectionRequest.Collection
Program and map IDs in the collection
Field |
Type |
Label |
Description |
|---|---|---|---|
programs |
repeated |
program details for each programs in the collection. |
|
maps |
repeated |
map details for each map in the collection. |
InstrumentCollectionRequest.Collection.Map
Field |
Type |
Label |
Description |
|---|---|---|---|
id |
InstrumentCollectionRequest.Collection.MapsEntry
Field |
Type |
Label |
Description |
|---|---|---|---|
key |
|||
value |
InstrumentCollectionRequest.Collection.Program
Field |
Type |
Label |
Description |
|---|---|---|---|
id |
InstrumentCollectionRequest.Collection.ProgramsEntry
Field |
Type |
Label |
Description |
|---|---|---|---|
key |
|||
value |
InstrumentCollectionRequest.Hook
Field |
Type |
Label |
Description |
|---|---|---|---|
type |
position of the hook relative to the target program. |
||
target |
name of the program that should be instrumented. |
||
attach_target |
info necessary for loading freplace programs. |
||
pin_path |
plugin must pin the hook program to this pin path before responding to Cilium. |
InstrumentCollectionRequest.Hook.AttachTarget
Field |
Type |
Label |
Description |
|---|---|---|---|
program_id |
id of the target program. |
||
subprog_name |
name of the hook’s subprogram inside the target program. |
InstrumentCollectionResponse
PrepareCollectionRequest
Phase 1: As Cilium loads and prepares a collection for a particular attachment point, it sends a PrepareHooksRequest to each plugin with context about the attachment point, collection, and its configuration. The plugin decides which hooks it would like to insert, where it would like to insert them, and informs Cilium in the PrepareHooksResponse.
Field |
Type |
Label |
Description |
|---|---|---|---|
collection |
|||
attachment_context |
|||
config |
config contains datapath configuration for this collection. |
PrepareCollectionRequest.CollectionSpec
Field |
Type |
Label |
Description |
|---|---|---|---|
programs |
repeated |
program details for each programs in the collection. |
|
maps |
repeated |
map details for each map in the collection. |
PrepareCollectionRequest.CollectionSpec.MapSpec
Field |
Type |
Label |
Description |
|---|---|---|---|
type |
|||
key_size |
|||
value_size |
|||
max_entries |
|||
flags |
|||
pin_type |
PrepareCollectionRequest.CollectionSpec.MapsEntry
Field |
Type |
Label |
Description |
|---|---|---|---|
key |
|||
value |
PrepareCollectionRequest.CollectionSpec.ProgramSpec
Field |
Type |
Label |
Description |
|---|---|---|---|
type |
|||
attach_type |
|||
section_name |
|||
license |
PrepareCollectionRequest.CollectionSpec.ProgramsEntry
Field |
Type |
Label |
Description |
|---|---|---|---|
key |
|||
value |
PrepareCollectionResponse
Field |
Type |
Label |
Description |
|---|---|---|---|
hooks |
repeated |
list of hooks that should be added to the collection. |
|
cookie |
cookie is an opaque string that will be passed in the subsequent InstrumentCollectionRequest related to this PrepareCollectionRequest. It may be used by plugins to associate the two requests or carry metadata between them. |
PrepareCollectionResponse.HookSpec
Field |
Type |
Label |
Description |
|---|---|---|---|
type |
position of the hook relative to the target program. |
||
target |
name of the program that should be instrumented. |
||
constraints |
repeated |
constraints is a list of ordering constraints for this hook. If other plugins want to place a hook at this same hook point, hooks from various plugins will be arranged in an order that respects all ordering constraints. |
PrepareCollectionResponse.HookSpec.OrderingConstraint
An OrderingConstraint is a constraint about where this hook should go at this hook point relative to other plugins’ hooks.
Field |
Type |
Label |
Description |
|---|---|---|---|
order |
|||
plugin |
HookType
Name |
Number |
Description |
|---|---|---|
UNKNOWN |
0 |
|
PRE |
1 |
pre hooks run before the main Cilium program. |
POST |
2 |
post hooks run after the main Cilium program. |
PrepareCollectionResponse.HookSpec.OrderingConstraint.Order
Name |
Number |
Description |
|---|---|---|
UNKNOWN |
0 |
|
BEFORE |
1 |
|
AFTER |
2 |
DatapathPlugin
A DatapathPlugin interacts with Cilium’s loader to augment or modify BPF collections as they are prepared for an attachment point.
Method Name |
Request Type |
Response Type |
Description |
|---|---|---|---|
PrepareCollection |
PrepareCollection happens before the BPF collection is loaded into the kernel. Cilium passes BPF collection details to the plugin and the plugin tells Cilium how it would like to modify the collection. |
||
InstrumentCollection |
InstrumentCollection happens after the BPF collection is loaded into the kernel. Cilium passes BPF collection details to the plugin along with details about hook attachment points it created in the prepare phase. The plugin loads its BPF programs and passes them back to Cilium to be attached to these hook points. |
Scalar Value Types
.proto Type |
Notes |
C++ |
Java |
Python |
Go |
C# |
PHP |
Ruby |
|---|---|---|---|---|---|---|---|---|
double |
double |
float |
float64 |
double |
float |
Float |
||
float |
float |
float |
float32 |
float |
float |
Float |
||
Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. |
int32 |
int |
int |
int32 |
int |
integer |
Bignum or Fixnum (as required) |
|
Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. |
int64 |
long |
int/long |
int64 |
long |
integer/string |
Bignum |
|
Uses variable-length encoding. |
uint32 |
int |
int/long |
uint32 |
uint |
integer |
Bignum or Fixnum (as required) |
|
Uses variable-length encoding. |
uint64 |
long |
int/long |
uint64 |
ulong |
integer/string |
Bignum or Fixnum (as required) |
|
Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. |
int32 |
int |
int |
int32 |
int |
integer |
Bignum or Fixnum (as required) |
|
Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. |
int64 |
long |
int/long |
int64 |
long |
integer/string |
Bignum |
|
Always four bytes. More efficient than uint32 if values are often greater than 2^28. |
uint32 |
int |
int |
uint32 |
uint |
integer |
Bignum or Fixnum (as required) |
|
Always eight bytes. More efficient than uint64 if values are often greater than 2^56. |
uint64 |
long |
int/long |
uint64 |
ulong |
integer/string |
Bignum |
|
Always four bytes. |
int32 |
int |
int |
int32 |
int |
integer |
Bignum or Fixnum (as required) |
|
Always eight bytes. |
int64 |
long |
int/long |
int64 |
long |
integer/string |
Bignum |
|
bool |
boolean |
boolean |
bool |
bool |
boolean |
TrueClass/FalseClass |
||
A string must always contain UTF-8 encoded or 7-bit ASCII text. |
string |
String |
str/unicode |
string |
string |
string |
String (UTF-8) |
|
May contain any arbitrary sequence of bytes. |
string |
ByteString |
str |
[]byte |
ByteString |
string |
String (ASCII-8BIT) |