Skip to content

new kernel adapt#1198

Merged
kmesh-bot merged 7 commits intokmesh-net:mainfrom
lec-bit:new-kernel
Feb 25, 2025
Merged

new kernel adapt#1198
kmesh-bot merged 7 commits intokmesh-net:mainfrom
lec-bit:new-kernel

Conversation

@lec-bit
Copy link
Copy Markdown
Contributor

@lec-bit lec-bit commented Jan 16, 2025

What type of PR is this?
/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@hzxuzhonghu
Copy link
Copy Markdown
Member

Can you add some description what you are doing and why

@bitcoffeeiux
Copy link
Copy Markdown
Contributor

A proposal is required.

@lec-bit lec-bit force-pushed the new-kernel branch 3 times, most recently from 14bbc8e to 0a2d78f Compare January 17, 2025 03:01
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 70 lines in your changes missing coverage. Please review.

Project coverage is 44.64%. Comparing base (5f09731) to head (d950911).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
pkg/kolog/kolog.go 0.00% 69 Missing ⚠️
pkg/controller/controller.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
pkg/controller/controller.go 0.00% <0.00%> (ø)
pkg/kolog/kolog.go 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e5505b...d950911. Read the comment docs.

@bitcoffeeiux
Copy link
Copy Markdown
Contributor

A proposal is required.

proposal: #1202

if (strcmp(key, "All") == 0) {
msg = (struct bpf_mem_ptr *)(ctx->t_ctx);
if (strnstr(msg->ptr, subptr, subptr_len) != NULL) {
return 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use variables to indicate what 1 and 0 mean?

DEBUG,
ROUTER_CONFIG,
"match virtual_host, name=\"%s\"\n",
(char *)KMESH_GET_PTR_VAL(virt_host->name, char *));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of instructions occupied by BPF_LOG is very large, and printing logs within multiple nested loops can cause the total instruction count of the ebpf program to exceed 1,000,000 insn.
so I move it out of func

static __u64 (*bpf__strncmp)(const char *s1, __u32 s1_size, const char *s2) = (void *)174;
static long (*bpf_parse_header_msg)(struct bpf_mem_ptr *msg) = (void *)175;
static void *(*bpf_get_msg_header_element)(void *name) = (void *)176;
static int (*bpf_km_strnstr)(
Copy link
Copy Markdown
Contributor Author

@lec-bit lec-bit Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment needs to be supplemented and the usage needs to be defined.
The naming needs to be adjusted.


data = kmesh_protocol_data_search(key);
if (!data)
return 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value need modified.

if (!cur->parse_protocol_msg)
continue;
ret = cur->parse_protocol_msg(msg);
ret = cur->parse_protocol_msg(ctx);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CTX does not need to be transferred.


static const char kmesh_module_name[] = "kmesh_defer";

static char kmesh_module_name_get[16];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a macro to define

err = sk->sk_prot->connect(sk, (struct sockaddr *)&addr_in, sizeof(struct sockaddr_in));
inet_sk(sk)->bpf_defer_connect = 0;
err = sk->sk_prot->connect(sk, (struct sockaddr *)&uaddr, sizeof(struct sockaddr_in));
inet_sk(sk)->defer_connect = 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry needs to be allowed. The value is changed to line 113.

return -ENOMEM;
kmesh_defer_proto_ops = kmalloc(sizeof(struct proto_ops), GFP_ATOMIC);
if (!kmesh_defer_proto_ops)
return -ENOMEM;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

@lec-bit lec-bit force-pushed the new-kernel branch 3 times, most recently from 291dd6f to de3101a Compare February 18, 2025 07:20
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
#else // KMESH_ENABLE_HTTP
ret = listener_manager(ctx, listener, NULL);
ret = bpf_getsockopt(ctx, IPPROTO_TCP, TCP_ULP, (void *)kmesh_module_name_get, KMESH_MODULE_NAME_LEN);
if (ret != 0 || bpf__strncmp(kmesh_module_name_get, KMESH_MODULE_NAME_LEN, kmesh_module_name)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the bpf_getsockopt command is executed successfully, 0 should be returned. When the command is executed for the first time, the corresponding ulp model is not found. What should be the ret value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-22

return 0;
}
#endif
ret = listener_manager(ctx, listener, ctx);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of changing the third parameter from NULL to ctx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to modify it back after debugging, fixed

return 0;

if (bpf_strnstr(ptr, prefix, BPF_DATA_MAX_LEN) == NULL)
if (bpf_km_header_strnstr(ctx, uri, uri_len, prefix, BPF_DATA_MAX_LEN) == 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code style is unified. Generally, if (!bpf_km_header_strnstr(ctx, uri, uri_len, prefix, BPF_DATA_MAX_LEN)) is written in kernel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhzmy@126.com>
return time.Time{}, err
}

for _, line := range strings.Split(string(data), "\n") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to use bufio.NewScanner, read line by line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

case <-stopCh:
return
default:
line, err := reader.ReadString('\n')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can use scanner as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

hzxuzhonghu
hzxuzhonghu previously approved these changes Feb 25, 2025
Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Signed-off-by: lec-bit <glfhzmy@126.com>
Signed-off-by: lec-bit <glfhzmy@126.com>
@lec-bit
Copy link
Copy Markdown
Contributor Author

lec-bit commented Feb 25, 2025

/retest

@kmesh-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bitcoffeeiux, hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [bitcoffeeiux,hzxuzhonghu]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bitcoffeeiux
Copy link
Copy Markdown
Contributor

/lgtm

@kmesh-bot kmesh-bot added the lgtm label Feb 25, 2025
@kmesh-bot kmesh-bot merged commit ededfc7 into kmesh-net:main Feb 25, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants