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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
karaboDevices
ebpfCAT
Commits
496c0249
Commit
496c0249
authored
4 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
quickly document XDP
parent
72145d65
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/xdp.py
+6
-0
6 additions, 0 deletions
ebpfcat/xdp.py
with
6 additions
and
0 deletions
ebpfcat/xdp.py
+
6
−
0
View file @
496c0249
"""
support for XDP programs
"""
from
asyncio
import
DatagramProtocol
,
Future
,
get_event_loop
from
enum
import
Enum
from
contextlib
import
contextmanager
...
...
@@ -18,6 +19,8 @@ class XDPExitCode(Enum):
class
XDRFD
(
DatagramProtocol
):
"""
just implement enough of the NETLINK protocol to attach programs
"""
def
__init__
(
self
,
ifindex
,
fd
,
future
):
self
.
ifindex
=
ifindex
self
.
fd
=
fd
...
...
@@ -70,6 +73,7 @@ class XDRFD(DatagramProtocol):
class
PacketArray
:
"""
access a packet like a Python array
"""
def
__init__
(
self
,
ebpf
,
no
,
memory
):
self
.
ebpf
=
ebpf
self
.
no
=
no
...
...
@@ -123,12 +127,14 @@ class PacketSize:
class
XDP
(
EBPF
):
"""
the base class for XDP programs
"""
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
prog_type
=
ProgType
.
XDP
,
**
kwargs
)
self
.
packetSize
=
PacketSize
(
self
)
async
def
attach
(
self
,
network
):
"""
attach this program to a `network`
"""
ifindex
=
if_nametoindex
(
network
)
fd
,
_
=
self
.
load
(
log_level
=
1
)
future
=
Future
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment