Back to Cilium

Protocol Documentation

api/v1/datapathplugins/README.md

1.20.020.4 KB
Original Source

Protocol Documentation

<a name="top"></a>

Table of Contents

<a name="datapathplugins_datapathplugins-proto"></a>

<p align="right"><a href="#top">Top</a></p>

datapathplugins/datapathplugins.proto

<a name="datapathplugins-AttachmentContext"></a>

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.

FieldTypeLabelDescription
hostAttachmentContext.Host
lxcAttachmentContext.LXC
overlayAttachmentContext.Overlay
socketAttachmentContext.Socket
wireguardAttachmentContext.Wireguard
xdpAttachmentContext.XDP

<a name="datapathplugins-AttachmentContext-Host"></a>

AttachmentContext.Host

attachment context for bpf_host (netdev, cilium_host, cilium_net).

FieldTypeLabelDescription
ifaceAttachmentContext.InterfaceInfointerface that is being configured.

<a name="datapathplugins-AttachmentContext-InterfaceInfo"></a>

AttachmentContext.InterfaceInfo

InterfaceInfo contains information about a network interface.

FieldTypeLabelDescription
namestringname of the network interface.

<a name="datapathplugins-AttachmentContext-LXC"></a>

AttachmentContext.LXC

attachment context for bpf_lxc (containers).

FieldTypeLabelDescription
ifaceAttachmentContext.InterfaceInfointerface that is being configured.
pod_infoAttachmentContext.PodInfopod that is being configured.

<a name="datapathplugins-AttachmentContext-Overlay"></a>

AttachmentContext.Overlay

attachment context for bpf_overlay (vxlan/geneve).

FieldTypeLabelDescription
ifaceAttachmentContext.InterfaceInfointerface that is being configured.

<a name="datapathplugins-AttachmentContext-PodInfo"></a>

AttachmentContext.PodInfo

PodInfo contains information about a pod.

FieldTypeLabelDescription
namespacestringpod namespace.
namestringpod name.
container_namestringcontainer name.

<a name="datapathplugins-AttachmentContext-Socket"></a>

AttachmentContext.Socket

attachment context for bpf_sock (connect4,bind4,...)

<a name="datapathplugins-AttachmentContext-Wireguard"></a>

AttachmentContext.Wireguard

attachment context for bpf_wireguard (cilium_wg)

FieldTypeLabelDescription
ifaceAttachmentContext.InterfaceInfointerface that is being configured.

<a name="datapathplugins-AttachmentContext-XDP"></a>

AttachmentContext.XDP

attachment context for bpf_xdp (netdev)

FieldTypeLabelDescription
ifaceAttachmentContext.InterfaceInfointerface that is being configured.

<a name="datapathplugins-InstrumentCollectionRequest"></a>

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.

FieldTypeLabelDescription
collectionInstrumentCollectionRequest.Collection
attachment_contextAttachmentContext
configgoogle.protobuf.Anyconfig contains datapath configuration for this collection.
hooksInstrumentCollectionRequest.Hookrepeatedlist of hooks corresponding with those specified by the plugin in its PrepareHooks response.
pinsstringan 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.
cookiestringcookie matches the cookie provided in the plugin's PrepareHooks response.

<a name="datapathplugins-InstrumentCollectionRequest-Collection"></a>

InstrumentCollectionRequest.Collection

Program and map IDs in the collection

FieldTypeLabelDescription
programsInstrumentCollectionRequest.Collection.ProgramsEntryrepeatedprogram details for each programs in the collection.
mapsInstrumentCollectionRequest.Collection.MapsEntryrepeatedmap details for each map in the collection.

<a name="datapathplugins-InstrumentCollectionRequest-Collection-Map"></a>

InstrumentCollectionRequest.Collection.Map

FieldTypeLabelDescription
iduint32

<a name="datapathplugins-InstrumentCollectionRequest-Collection-MapsEntry"></a>

InstrumentCollectionRequest.Collection.MapsEntry

FieldTypeLabelDescription
keystring
valueInstrumentCollectionRequest.Collection.Map

<a name="datapathplugins-InstrumentCollectionRequest-Collection-Program"></a>

InstrumentCollectionRequest.Collection.Program

FieldTypeLabelDescription
iduint32

<a name="datapathplugins-InstrumentCollectionRequest-Collection-ProgramsEntry"></a>

InstrumentCollectionRequest.Collection.ProgramsEntry

FieldTypeLabelDescription
keystring
valueInstrumentCollectionRequest.Collection.Program

<a name="datapathplugins-InstrumentCollectionRequest-Hook"></a>

InstrumentCollectionRequest.Hook

FieldTypeLabelDescription
typeHookTypeposition of the hook relative to the target program.
targetstringname of the program that should be instrumented.
attach_targetInstrumentCollectionRequest.Hook.AttachTargetinfo necessary for loading freplace programs.
pin_pathstringplugin must pin the hook program to this pin path before responding to Cilium.

<a name="datapathplugins-InstrumentCollectionRequest-Hook-AttachTarget"></a>

InstrumentCollectionRequest.Hook.AttachTarget

FieldTypeLabelDescription
program_iduint32id of the target program.
subprog_namestringname of the hook's subprogram inside the target program.

<a name="datapathplugins-InstrumentCollectionResponse"></a>

InstrumentCollectionResponse

<a name="datapathplugins-PrepareCollectionRequest"></a>

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.

FieldTypeLabelDescription
collectionPrepareCollectionRequest.CollectionSpec
attachment_contextAttachmentContext
configgoogle.protobuf.Anyconfig contains datapath configuration for this collection.

<a name="datapathplugins-PrepareCollectionRequest-CollectionSpec"></a>

PrepareCollectionRequest.CollectionSpec

FieldTypeLabelDescription
programsPrepareCollectionRequest.CollectionSpec.ProgramsEntryrepeatedprogram details for each programs in the collection.
mapsPrepareCollectionRequest.CollectionSpec.MapsEntryrepeatedmap details for each map in the collection.

<a name="datapathplugins-PrepareCollectionRequest-CollectionSpec-MapSpec"></a>

PrepareCollectionRequest.CollectionSpec.MapSpec

FieldTypeLabelDescription
typeuint32
key_sizeuint32
value_sizeuint32
max_entriesuint32
flagsuint32
pin_typeuint32

<a name="datapathplugins-PrepareCollectionRequest-CollectionSpec-MapsEntry"></a>

PrepareCollectionRequest.CollectionSpec.MapsEntry

FieldTypeLabelDescription
keystring
valuePrepareCollectionRequest.CollectionSpec.MapSpec

<a name="datapathplugins-PrepareCollectionRequest-CollectionSpec-ProgramSpec"></a>

PrepareCollectionRequest.CollectionSpec.ProgramSpec

FieldTypeLabelDescription
typeuint32
attach_typeuint32
section_namestring
licensestring

<a name="datapathplugins-PrepareCollectionRequest-CollectionSpec-ProgramsEntry"></a>

PrepareCollectionRequest.CollectionSpec.ProgramsEntry

FieldTypeLabelDescription
keystring
valuePrepareCollectionRequest.CollectionSpec.ProgramSpec

<a name="datapathplugins-PrepareCollectionResponse"></a>

PrepareCollectionResponse

FieldTypeLabelDescription
hooksPrepareCollectionResponse.HookSpecrepeatedlist of hooks that should be added to the collection.
cookiestringcookie 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.

<a name="datapathplugins-PrepareCollectionResponse-HookSpec"></a>

PrepareCollectionResponse.HookSpec

FieldTypeLabelDescription
typeHookTypeposition of the hook relative to the target program.
targetstringname of the program that should be instrumented.
constraintsPrepareCollectionResponse.HookSpec.OrderingConstraintrepeatedconstraints 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.

<a name="datapathplugins-PrepareCollectionResponse-HookSpec-OrderingConstraint"></a>

PrepareCollectionResponse.HookSpec.OrderingConstraint

An OrderingConstraint is a constraint about where this hook should go at this hook point relative to other plugins' hooks.

FieldTypeLabelDescription
orderPrepareCollectionResponse.HookSpec.OrderingConstraint.Order
pluginstring

<a name="datapathplugins-HookType"></a>

HookType

NameNumberDescription
UNKNOWN0
PRE1pre hooks run before the main Cilium program.
POST2post hooks run after the main Cilium program.

<a name="datapathplugins-PrepareCollectionResponse-HookSpec-OrderingConstraint-Order"></a>

PrepareCollectionResponse.HookSpec.OrderingConstraint.Order

NameNumberDescription
UNKNOWN0
BEFORE1
AFTER2

<a name="datapathplugins-DatapathPlugin"></a>

DatapathPlugin

A DatapathPlugin interacts with Cilium's loader to augment or modify BPF collections as they are prepared for an attachment point.

Method NameRequest TypeResponse TypeDescription
PrepareCollectionPrepareCollectionRequestPrepareCollectionResponsePrepareCollection 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.
InstrumentCollectionInstrumentCollectionRequestInstrumentCollectionResponseInstrumentCollection 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 TypeNotesC++JavaPythonGoC#PHPRuby
<a name="double" /> doubledoubledoublefloatfloat64doublefloatFloat
<a name="float" /> floatfloatfloatfloatfloat32floatfloatFloat
<a name="int32" /> int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
<a name="int64" /> int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
<a name="uint32" /> uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
<a name="uint64" /> uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
<a name="sint32" /> sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
<a name="sint64" /> sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
<a name="fixed32" /> fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
<a name="fixed64" /> fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
<a name="sfixed32" /> sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
<a name="sfixed64" /> sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
<a name="bool" /> boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
<a name="string" /> stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
<a name="bytes" /> bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)