Skip to content

adapt bpf2go files in new kernel #1273

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

Merged
merged 4 commits into from
Mar 17, 2025
Merged

Conversation

lec-bit
Copy link
Contributor

@lec-bit lec-bit commented Mar 13, 2025

What type of PR is this?
/kind feature

What this PR does / why we need it:
After the ads mode adopts the new kernel modification solution, some adaptability work is not fully considered and needs to be fixed:
1.bpf2go files no longer distinguish between enhanced and unenhanced, sockops files are now always required
2.In the sockops hook point, it is necessary to determine whether it is managed by kmesh. Previously, the sockops hook point added to the ko file would come in and set the state_cb tag》The is_kmesh_manage function of sockops in the workload is mentioned in kmesh_common.h
3.compilate kmesh.ko before the compilation run
Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Signed-off-by: lec-bit <[email protected]>
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 45.45455% with 18 lines in your changes missing coverage. Please review.

Project coverage is 44.84%. Comparing base (eeeb399) to head (4b98e44).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
pkg/bpf/ads/loader.go 41.93% 10 Missing and 8 partials ⚠️
Files with missing lines Coverage Δ
pkg/bpf/ads/sock_connection.go 56.52% <100.00%> (+1.05%) ⬆️
pkg/bpf/ads/sock_ops.go 57.95% <100.00%> (ø)
pkg/bpf/ads/loader.go 35.29% <41.93%> (+2.33%) ⬆️

... and 5 files with indirect coverage changes


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 f839eff...4b98e44. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: lec-bit <[email protected]>
Signed-off-by: lec-bit <[email protected]>
@lec-bit lec-bit changed the title delete bpf2go compile product adapt bpf2go files in new kernel Mar 14, 2025

err = bpf_map_update_elem(&map_of_manager, &key, &value, BPF_ANY);
if (err)
BPF_LOG(ERR, KMESH, "record ip failed!, err is %d\n", err);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
BPF_LOG(ERR, KMESH, "record ip failed!, err is %d\n", err);
BPF_LOG(ERR, KMESH, "record ip failed, err is %d\n", err);


int err = bpf_map_delete_elem(&map_of_manager, &key);
if (err && err != -ENOENT)
BPF_LOG(ERR, KMESH, "remove ip failed!, err is %d\n", err);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
BPF_LOG(ERR, KMESH, "remove ip failed!, err is %d\n", err);
BPF_LOG(ERR, KMESH, "remove ip failed, err is %d\n", err);

bpf2go.KmeshSockopsObjects
}

func Bpf2goLoadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Bpf2goLoadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
func loadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {

return spec, err
}

func Bpf2goLoadKmeshSockOps() (*ebpf.CollectionSpec, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Bpf2goLoadKmeshSockOps() (*ebpf.CollectionSpec, error) {
func loadKmeshSockOps() (*ebpf.CollectionSpec, error) {

bpf2go.KmeshSockopsObjects
}

func Bpf2goLoadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Bpf2goLoadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
func loadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {

return spec, err
}

func Bpf2goLoadKmeshSockOps() (*ebpf.CollectionSpec, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Bpf2goLoadKmeshSockOps() (*ebpf.CollectionSpec, error) {
func loadKmeshSockOps() (*ebpf.CollectionSpec, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The internal interface of bpf2go uses this name 'loadKmeshSockOps'. To avoid duplicate names, I add a prefix of bpf2go.

hzxuzhonghu
hzxuzhonghu previously approved these changes Mar 14, 2025
Copy link
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

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

The pull request process is described here

Needs approval from an approver in each of these files:

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

@kmesh-bot kmesh-bot merged commit bebaf18 into kmesh-net:main Mar 17, 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.

4 participants