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
Commits
92ad6a33
Commit
92ad6a33
authored
9 months ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
be a bit more defensive reading from netlink
parent
61a751c7
No related branches found
No related tags found
No related merge requests found
Pipeline
#142425
passed
9 months ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/xdp.py
+22
-15
22 additions, 15 deletions
ebpfcat/xdp.py
with
22 additions
and
15 deletions
ebpfcat/xdp.py
+
22
−
15
View file @
92ad6a33
...
...
@@ -25,7 +25,7 @@ from contextlib import asynccontextmanager, contextmanager
import
os
from
socket
import
AF_NETLINK
,
NETLINK_ROUTE
,
if_nametoindex
import
socket
from
struct
import
pack
,
unpack
from
struct
import
pack
,
unpack
_from
from
.ebpf
import
EBPF
,
MemoryDesc
from
.bpf
import
ProgType
...
...
@@ -86,21 +86,28 @@ class XDRFD(DatagramProtocol):
transport
.
sendto
(
p
,
(
0
,
0
))
def
datagram_received
(
self
,
data
,
addr
):
pos
=
0
while
(
pos
<
len
(
data
)):
ln
,
type
,
flags
,
seq
,
pid
=
unpack
(
"
IHHII
"
,
data
[
pos
:
pos
+
16
])
if
type
==
3
:
# DONE
self
.
future
.
set_result
(
0
)
return
elif
type
==
2
:
# ERROR
errno
,
*
args
=
unpack
(
"
iIHHII
"
,
data
[
pos
+
16
:
pos
+
36
])
if
errno
!=
0
:
self
.
future
.
set_exception
(
OSError
(
errno
,
os
.
strerror
(
-
errno
)))
try
:
pos
=
0
while
(
pos
<
len
(
data
)):
ln
,
type
,
flags
,
seq
,
pid
=
unpack_from
(
"
IHHII
"
,
data
,
pos
)
if
type
==
3
:
# DONE
self
.
future
.
set_result
(
0
)
return
elif
type
==
2
:
# ERROR
errno
,
*
args
=
unpack_from
(
"
iIHHII
"
,
data
,
pos
+
16
)
if
errno
!=
0
:
self
.
future
.
set_exception
(
OSError
(
errno
,
os
.
strerror
(
-
errno
)))
return
if
flags
&
2
==
0
:
# not a multipart message
self
.
future
.
set_result
(
0
)
return
if
flags
&
2
==
0
:
# not a multipart message
self
.
future
.
set_result
(
0
)
return
pos
+=
ln
pos
+=
ln
self
.
future
.
set_exception
(
RuntimeError
(
"
Netlink response not understood
"
))
except
Exception
as
e
:
self
.
future
.
set_exception
(
e
)
raise
class
PacketArray
:
...
...
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