Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ebpfCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Teichmann
ebpfCAT
Merge requests
!14
allow running ebpf XDP on the network driver
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
allow running ebpf XDP on the network driver
fastxdp
into
master
Overview
0
Commits
1
Pipelines
1
Changes
3
Merged
Martin Teichmann
requested to merge
fastxdp
into
master
2 years ago
Overview
0
Commits
1
Pipelines
1
Changes
3
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
91d49228
1 commit,
2 years ago
3 files
+
53
−
24
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
ebpfcat/ebpf.rst
+
17
−
4
Options
@@ -47,15 +47,28 @@ for synchronization::
Once attached, our little program will be executed each time a packet
arrives on the interface. We can read the result in a loop::
for i in range(10
0
):
for i in range(10):
await sleep(0.1)
print("packets arrived so far:", c.count)
With ``attach`` the program is attached indefinitely on the interface,
even beyond the end of the program. Use ``detach`` to detach it, or you
may use the async contextmanager ``run`` to detach automatically, as in::
async with c.run("eth0"):
await sleep(1)
print("packets arrived so far:", c.count)
Note that here we access the member variable ``count`` from user space.
While generating EBPF, the code generator knows it needs to write out
commands to access that variable from EBPF, once accessed outside of
generation context, we access it from the user side.
Both ``attach`` and ``detach`` have an additional parameter ``flags`` to
choose in which mode to attach the program, use ``XDPFlags.SKB_MODE`` (the
default) to use the generic kernel driver, or ``XDPFlags.DRV_MODE`` to let
the interface device driver run the program.
For reference, this is the full example:
.. literalinclude:: /examples/count.py
@@ -158,11 +171,11 @@ race conditions.
Fixed-point arithmetic
~~~~~~~~~~~~~~~~~~~~~~
as a bonus beyond standard ebpf, we support fixed-point values as a type `
x
`.
as a bonus beyond standard ebpf, we support fixed-point values as a type `
`x`
`.
Within ebpf they are calculated as per-10000, so a 0.2 is represented as
20000. From outside, the variables seem to be doubles. Vaguely following
Python, all true divisions `
/
` result in a fixed-point result, while all
floor divisions `//` result in a standard integer. Some examples:
Python, all true divisions `
`/`
` result in a fixed-point result, while all
floor divisions
`
`//`
`
result in a standard integer. Some examples:
:
class FixedPoint(EPBF):
array_map = ArrayMap()
Loading