-
Notifications
You must be signed in to change notification settings - Fork 132
update new os patch for new kernel adapt #1251
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
1
commit into
kmesh-net:main
Choose a base branch
from
lec-bit:main
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.
+153
−688
Open
Changes from all commits
Commits
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
130 changes: 130 additions & 0 deletions
130
kernel/patches/5.10.0/0001-add-helper-strnstr-strncmp-parse_header_msg.patch
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,130 @@ | ||
| From 03cea45be513a52a0c57c022594d6a5e98450642 Mon Sep 17 00:00:00 2001 | ||
| From: zhangmingyi <[email protected]> | ||
| Date: Thu, 9 Jan 2025 07:27:31 +0000 | ||
| Subject: [PATCH 1/2] add helper strnstr strncmp parse_header_msg | ||
|
|
||
| User messages need to be parsed when the bpf link establishment | ||
| is delayed. add three helper func to parse and operate str. | ||
|
|
||
| Signed-off-by: zhangmingyi <[email protected]> | ||
| --- | ||
| include/uapi/linux/bpf.h | 3 ++ | ||
| net/core/filter.c | 67 ++++++++++++++++++++++++++++++++++ | ||
| tools/include/uapi/linux/bpf.h | 3 ++ | ||
| 3 files changed, 73 insertions(+) | ||
|
|
||
| diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h | ||
| index fcda8b986..bd2235fc4 100644 | ||
| --- a/include/uapi/linux/bpf.h | ||
| +++ b/include/uapi/linux/bpf.h | ||
| @@ -4051,6 +4051,9 @@ union bpf_attr { | ||
| FN(cpumask_op), \ | ||
| FN(cpus_share_cache), \ | ||
| FN(is_local_ipaddr), \ | ||
| + FN(km_header_strnstr), \ | ||
| + FN(km_header_strncmp), \ | ||
| + FN(parse_header_msg), \ | ||
| /* */ | ||
|
|
||
| /* integer value in 'imm' field of BPF_CALL instruction selects which helper | ||
| diff --git a/net/core/filter.c b/net/core/filter.c | ||
| index 431e778bb..4a5d944c9 100644 | ||
| --- a/net/core/filter.c | ||
| +++ b/net/core/filter.c | ||
| @@ -6986,6 +6986,67 @@ const struct bpf_func_proto bpf_sock_ops_get_sk_rx_dst_proto = { | ||
| }; | ||
|
|
||
| #endif /* CONFIG_INET */ | ||
| +typedef int (*bpf_parse_protocol_func)(struct bpf_sock_addr_kern* ctx); | ||
| +bpf_parse_protocol_func parse_protocol_func = NULL; | ||
| +EXPORT_SYMBOL(parse_protocol_func); | ||
| + | ||
| +typedef int (*bpf_km_header_strnstr_func)(struct bpf_sock_addr_kern *ctx, const char *key, int key_sz, const char *subptr, int subptr_sz); | ||
| +bpf_km_header_strnstr_func km_header_strnstr_func = NULL; | ||
| +EXPORT_SYMBOL(km_header_strnstr_func); | ||
| + | ||
| +typedef int (*bpf_km_header_strncmp_func)(const char *key, int key_sz, const char *target, int target_sz, int opt); | ||
| +bpf_km_header_strncmp_func km_header_strncmp_func = NULL; | ||
| +EXPORT_SYMBOL(km_header_strncmp_func); | ||
| + | ||
| +BPF_CALL_1(bpf_parse_header_msg, struct bpf_sock_addr_kern *, ctx) | ||
| +{ | ||
| + if (!parse_protocol_func) | ||
| + return -ENOTSUPP; | ||
| + return parse_protocol_func(ctx); | ||
| +} | ||
| + | ||
| +static const struct bpf_func_proto bpf_parse_header_msg_proto = { | ||
| + .func = bpf_parse_header_msg, | ||
| + .gpl_only = false, | ||
| + .ret_type = RET_INTEGER, | ||
| + .arg1_type = ARG_PTR_TO_CTX, | ||
| +}; | ||
| + | ||
| +BPF_CALL_5(bpf_km_header_strnstr, struct bpf_sock_addr_kern *, ctx, const char *, key, int , key_sz, const char *, subptr, int, subptr_sz) | ||
| +{ | ||
| + if (!km_header_strnstr_func) | ||
| + return -ENOTSUPP; | ||
| + return km_header_strnstr_func(ctx, key, key_sz, subptr, subptr_sz); | ||
| +} | ||
| + | ||
| +static const struct bpf_func_proto bpf_km_header_strnstr_proto = { | ||
| + .func = bpf_km_header_strnstr, | ||
| + .gpl_only = false, | ||
| + .ret_type = RET_INTEGER, | ||
| + .arg1_type = ARG_PTR_TO_CTX, | ||
| + .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY, | ||
| + .arg3_type = ARG_CONST_SIZE, | ||
| + .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY, | ||
| + .arg5_type = ARG_CONST_SIZE, | ||
| +}; | ||
| + | ||
| +BPF_CALL_5(bpf_km_header_strncmp, const char *, key, int , key_sz, const char *, target, int, target_sz, int, opt) | ||
| +{ | ||
| + if (!km_header_strncmp_func) | ||
| + return -ENOTSUPP; | ||
| + return km_header_strncmp_func(key, key_sz, target, target_sz, opt); | ||
| +} | ||
| + | ||
| +static const struct bpf_func_proto bpf_km_header_strncmp_proto = { | ||
| + .func = bpf_km_header_strncmp, | ||
| + .gpl_only = false, | ||
| + .ret_type = RET_INTEGER, | ||
| + .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY, | ||
| + .arg2_type = ARG_CONST_SIZE, | ||
| + .arg3_type = ARG_PTR_TO_MEM | MEM_RDONLY, | ||
| + .arg4_type = ARG_CONST_SIZE, | ||
| + .arg5_type = ARG_ANYTHING, | ||
| +}; | ||
|
|
||
| bool bpf_helper_changes_pkt_data(void *func) | ||
| { | ||
| @@ -7139,6 +7200,12 @@ sock_addr_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) | ||
| default: | ||
| return NULL; | ||
| } | ||
| + case BPF_FUNC_parse_header_msg: | ||
| + return &bpf_parse_header_msg_proto; | ||
| + case BPF_FUNC_km_header_strnstr: | ||
| + return &bpf_km_header_strnstr_proto; | ||
| + case BPF_FUNC_km_header_strncmp: | ||
| + return &bpf_km_header_strncmp_proto; | ||
| default: | ||
| return bpf_sk_base_func_proto(func_id); | ||
| } | ||
| diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h | ||
| index 588750c46..63069c2a8 100644 | ||
| --- a/tools/include/uapi/linux/bpf.h | ||
| +++ b/tools/include/uapi/linux/bpf.h | ||
| @@ -4051,6 +4051,9 @@ union bpf_attr { | ||
| FN(cpumask_op), \ | ||
| FN(cpus_share_cache), \ | ||
| FN(is_local_ipaddr), \ | ||
| + FN(km_header_strnstr), \ | ||
| + FN(km_header_strncmp), \ | ||
| + FN(parse_header_msg), \ | ||
| /* */ | ||
|
|
||
| /* integer value in 'imm' field of BPF_CALL instruction selects which helper | ||
| -- | ||
| 2.33.0 | ||
29 changes: 0 additions & 29 deletions
29
kernel/patches/5.10.0/0001-bpf-sockmap-add-extra-return-value-for-sockops.patch
This file was deleted.
Oops, something went wrong.
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
54 changes: 0 additions & 54 deletions
54
kernel/patches/5.10.0/0002-net-ipv4-A-new-bit-is-added-to-indicate-whether-to-d.patch
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
kernel/patches/5.10.0/0004-net-bpf-Add-a-writeable_tracepoint-to-inet_stream_co.patch
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
kernel/patches/5.10.0/0005-bpf-Introduces-a-new-state-to-identify-the-location-.patch
This file was deleted.
Oops, something went wrong.
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.
Why ARG_ANYTHING
Uh oh!
There was an error while loading. Please reload this page.
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.
opt and flags are generally used to use ARG_ANYTHING.
For example,