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
b2b9ee88
Commit
b2b9ee88
authored
4 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
factor out at SimpleComparison
parent
278acae1
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
ebpf.py
+36
-31
36 additions, 31 deletions
ebpf.py
with
36 additions
and
31 deletions
ebpf.py
+
36
−
31
View file @
b2b9ee88
...
...
@@ -26,37 +26,12 @@ def comparison(uposop, unegop, sposop=None, snegop=None):
sposop
=
uposop
snegop
=
unegop
def
ret
(
self
,
value
):
return
Comparison
(
self
.
ebpf
,
self
,
value
,
(
uposop
,
unegop
,
sposop
,
snegop
))
return
Simple
Comparison
(
self
.
ebpf
,
self
,
value
,
(
uposop
,
unegop
,
sposop
,
snegop
))
return
ret
class
Comparison
:
def
__init__
(
self
,
ebpf
,
left
,
right
,
opcode
):
self
.
ebpf
=
ebpf
self
.
left
=
left
self
.
right
=
right
self
.
opcode
=
opcode
self
.
invert
=
None
def
compare
(
self
,
negative
):
self
.
dst
,
_
,
lsigned
,
lfree
=
self
.
left
.
calculate
(
None
,
None
,
None
)
if
not
isinstance
(
self
.
right
,
int
):
self
.
src
,
_
,
rsigned
,
rfree
=
\
self
.
right
.
calculate
(
None
,
None
,
None
)
if
rsigned
!=
rsigned
:
raise
AssembleError
(
"
need same signedness for comparison
"
)
else
:
rfree
=
False
self
.
origin
=
len
(
self
.
ebpf
.
opcodes
)
self
.
ebpf
.
opcodes
.
append
(
None
)
self
.
opcode
=
self
.
opcode
[
negative
+
2
*
lsigned
]
if
lfree
:
self
.
ebpf
.
owners
.
discard
(
self
.
dst
)
if
rfree
:
self
.
ebpf
.
owners
.
discard
(
self
.
src
)
self
.
owners
=
self
.
ebpf
.
owners
.
copy
()
def
target
(
self
):
assert
self
.
ebpf
.
opcodes
[
self
.
origin
]
is
None
if
isinstance
(
self
.
right
,
int
):
...
...
@@ -101,11 +76,41 @@ class Comparison:
return
self
class
OrComparison
(
Comparison
):
class
SimpleComparison
(
Comparison
):
def
__init__
(
self
,
ebpf
,
left
,
right
,
opcode
):
self
.
ebpf
=
ebpf
self
.
left
=
left
self
.
right
=
right
self
.
opcode
=
opcode
self
.
invert
=
None
def
compare
(
self
,
negative
):
self
.
dst
,
_
,
lsigned
,
lfree
=
self
.
left
.
calculate
(
None
,
None
,
None
)
if
not
isinstance
(
self
.
right
,
int
):
self
.
src
,
_
,
rsigned
,
rfree
=
\
self
.
right
.
calculate
(
None
,
None
,
None
)
if
rsigned
!=
rsigned
:
raise
AssembleError
(
"
need same signedness for comparison
"
)
else
:
rfree
=
False
self
.
origin
=
len
(
self
.
ebpf
.
opcodes
)
self
.
ebpf
.
opcodes
.
append
(
None
)
self
.
opcode
=
self
.
opcode
[
negative
+
2
*
lsigned
]
if
lfree
:
self
.
ebpf
.
owners
.
discard
(
self
.
dst
)
if
rfree
:
self
.
ebpf
.
owners
.
discard
(
self
.
src
)
self
.
owners
=
self
.
ebpf
.
owners
.
copy
()
class
AndOrComparison
(
Comparison
):
def
compare
(
self
,
negative
):
self
.
left
.
compare
(
negative
)
self
.
right
.
compare
(
negative
)
def
target
(
self
):
self
.
left
.
target
()
self
.
right
.
target
()
def
binary
(
opcode
,
symetric
=
False
):
def
ret
(
self
,
value
):
...
...
@@ -186,13 +191,13 @@ class Sum(Binary):
return
super
().
__sub__
(
value
)
class
AndExpression
(
Binary
,
Comparison
):
class
AndExpression
(
Binary
,
Simple
Comparison
):
__and__
=
__rand__
=
comparison
(
0x45
,
None
)
__rand__
=
__and__
=
binary
(
0x54
,
True
)
def
__init__
(
self
,
ebpf
,
left
,
right
):
Binary
.
__init__
(
self
,
ebpf
,
left
,
right
,
0x54
)
Comparison
.
__init__
(
self
,
ebpf
,
left
,
right
,
0x45
)
Simple
Comparison
.
__init__
(
self
,
ebpf
,
left
,
right
,
0x45
)
self
.
opcode
=
(
0x45
,
None
,
0x45
,
None
)
def
compare
(
self
,
negative
):
...
...
@@ -392,7 +397,7 @@ class EBPF:
return
comp
def
jump
(
self
):
comp
=
Comparison
(
self
,
None
,
0
,
5
)
comp
=
Simple
Comparison
(
self
,
None
,
0
,
5
)
comp
.
origin
=
len
(
self
.
opcodes
)
comp
.
dst
=
0
comp
.
owners
=
self
.
owners
.
copy
()
...
...
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