-
Notifications
You must be signed in to change notification settings - Fork 132
adapt 6.6 #1520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lec-bit
wants to merge
3
commits into
kmesh-net:main
Choose a base branch
from
lec-bit:new-kernel-6.6-1103
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,321
−160
Open
adapt 6.6 #1520
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ | ||
| /* Copyright Authors of Kmesh */ | ||
|
|
||
| #include "../../config/kmesh_marcos_def.h" | ||
| #include <linux/in.h> | ||
| #include <stddef.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <linux/bpf.h> | ||
| #include <sys/socket.h> | ||
| #include <bpf/bpf_helpers.h> | ||
| #include <bpf/bpf_endian.h> | ||
| #include "map_config.h" | ||
|
|
||
| #include "errno.h" | ||
|
|
||
| struct bpf_mem_ptr { | ||
| void *ptr; | ||
| __u32 size; | ||
| }; | ||
|
|
||
| #define KMESH_MODULE_ULP_NAME "kmesh_defer" | ||
|
|
||
| extern int bpf_parse_header_msg_func(void *src, int src__sz) __ksym; | ||
| extern int bpf_km_header_strnstr_func(void *ctx, int ctx__sz, const char *key, int key__sz, const char *subptr) __ksym; | ||
| extern int bpf_km_header_strncmp_func(const char *key, int key__sz, const char *target, int target__sz, int opt) __ksym; | ||
| extern int bpf_setsockopt_func(void *bpf_mem, int bpf_mem__sz, int optname, const char *optval, int optval__sz) __ksym; | ||
| extern int bpf_getsockopt_func(void *bpf_mem, int bpf_mem__sz, int optname, char *optval, int optval__sz) __ksym; | ||
|
|
||
| #define bpf_km_header_strncmp bpf_km_header_strncmp_func | ||
|
|
||
| static int bpf_km_header_strnstr(void *ctx, const char *key, int key__sz, const char *subptr, int subptr__sz) | ||
| { | ||
| struct bpf_mem_ptr msg_tmp = {.ptr = ctx, .size = sizeof(struct bpf_sock_addr)}; | ||
| return bpf_km_header_strnstr_func(&msg_tmp, sizeof(struct bpf_mem_ptr), key, key__sz, subptr); | ||
| } | ||
|
|
||
| static int bpf_parse_header_msg(struct bpf_sock_addr *ctx) | ||
| { | ||
| struct bpf_mem_ptr msg_tmp = {.ptr = ctx, .size = sizeof(struct bpf_sock_addr)}; | ||
| return bpf_parse_header_msg_func(&msg_tmp, sizeof(struct bpf_mem_ptr)); | ||
| } | ||
|
|
||
| // Due to the limitation of bpf verifier, optval and optval__sz are required to correspond. | ||
| // The strnlen function cannot be used here, so the string is redefined. | ||
| static int bpf_km_setsockopt(struct bpf_sock_addr *ctx, int level, int optname, const char *optval, int optval__sz) | ||
| { | ||
| const char kmesh_module_ulp_name[] = KMESH_MODULE_ULP_NAME; | ||
| if (level != IPPROTO_TCP || optval__sz != sizeof(kmesh_module_ulp_name)) | ||
| return -1; | ||
|
|
||
| struct bpf_mem_ptr msg_tmp = {.ptr = ctx, .size = sizeof(struct bpf_sock_addr)}; | ||
| return bpf_setsockopt_func( | ||
| &msg_tmp, sizeof(struct bpf_mem_ptr), optname, (void *)kmesh_module_ulp_name, sizeof(kmesh_module_ulp_name)); | ||
| } | ||
|
|
||
| static int bpf_km_getsockopt(struct bpf_sock_addr *ctx, int level, int optname, char *optval, int optval__sz) | ||
| { | ||
| if (level != IPPROTO_TCP) { | ||
| return -1; | ||
| } | ||
| struct bpf_mem_ptr msg_tmp = {.ptr = ctx, .size = sizeof(struct bpf_sock_addr)}; | ||
| return bpf_getsockopt_func(&msg_tmp, sizeof(struct bpf_mem_ptr), optname, (void *)optval, optval__sz); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls define macros in
bpf_helper_defs_ext.h