Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GNS3_unikernel_testbed
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
Container 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
NGUYEN Do Duc Anh
GNS3_unikernel_testbed
Commits
f2aa8a9d
Commit
f2aa8a9d
authored
3 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
ebpf do not allow to read a static array with a variable
parent
f128b0f8
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
ubuntu_intermediate/inter_op_ebpf.c
+9
-2
9 additions, 2 deletions
ubuntu_intermediate/inter_op_ebpf.c
with
9 additions
and
2 deletions
ubuntu_intermediate/inter_op_ebpf.c
+
9
−
2
View file @
f2aa8a9d
...
...
@@ -6,7 +6,7 @@
#define SUBNET_BASE __constant_htonl(0xAC103C00)
#define REPLACE_PROBABILITY 90
const
__be32
ALTERNATE_IPS
[]
=
{
__constant_htonl
(
0x7B640202
)};
const
__be32
ALTERNATE_IPS
[]
=
{
__constant_htonl
(
0x7B640202
)
,
__constant_htonl
(
0x7B640303
)
};
#define NUM_ALTERNATE_IPS (sizeof(ALTERNATE_IPS) / sizeof(ALTERNATE_IPS[0]))
BPF_ARRAY
(
alt_ip_index
,
__u32
,
1
);
// Single-element array to store index
...
...
@@ -295,7 +295,14 @@ int inter_op_ebpf(struct xdp_md *ctx)
{
// Replace destination IP
__u32
original_ip
=
ip
->
daddr
;
__u32
new_ip
=
ALTERNATE_IPS
[
current_index
];
__u32
new_ip
;
for
(
int
i
=
0
;
i
<
NUM_ALTERNATE_IPS
;
i
++
)
{
if
(
i
==
current_index
)
{
new_ip
=
ALTERNATE_IPS
[
i
];
// Verifier allows (unrolled)
}
}
ip
->
daddr
=
new_ip
;
// Optional: log the replacement
...
...
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