Skip to content
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

separation bpf and binary in Makefile&provides bpf2go outputs files #971

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lec-bit
Copy link
Contributor

@lec-bit lec-bit commented Oct 19, 2024

What type of PR is this?
/kind enhancement

What this PR does / why we need it:
1.Separate compilation of data and control plane
2.Provide the bpf2go file to the code warehouse and adjust the directory so that subsequent open source packages can be imported.Since the directory has been adjusted, all files will have some changes.
Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevin-wangzefeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

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.

I would like to separate workload bpf2go as well

//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockopsWorkload ../workload/sockops.c -- -I../workload/include -I../../include -I../probes -DKERNEL_VERSION_HIGHER_5_13_0=1
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshXDPAuth ../workload/xdp.c -- -I../workload/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=1
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSendmsg ../workload/sendmsg.c -- -I../workload/include -I../../include -DKERNEL_VERSION_HIGHER_5_13_0=1
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -output-dir normal/bpf2go -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSock ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=1
Copy link
Member

Choose a reason for hiding this comment

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

/bpf2go seems redudant

Suggested change
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -output-dir normal/bpf2go -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSock ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=1
//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -output-dir normal -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSock ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If “/bpf2go“” does not exist, the package cannot be imported.

Copy link
Member

Choose a reason for hiding this comment

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

why? I couldnot quite understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont know cleanly, but i delete /bpf2go ,it dosen't work, I guess "package bpf2go" in go files, so the file need to be same

Copy link
Member

Choose a reason for hiding this comment

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

nit: If i understand correctly package name bpf2go can be different from dir name

bpf2go tool provide flags to set different pkg names
https://github.com/cilium/ebpf/blob/main/cmd/bpf2go/main.go#L108-L109

@lec-bit
Copy link
Contributor Author

lec-bit commented Oct 21, 2024

ok, i will separate workload bpf2go

I would like to separate workload bpf2go as well

Makefile Outdated
.PHONY: all data daemon
all: data daemon

data:
Copy link
Member

Choose a reason for hiding this comment

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

The name is confusing, this seems building bpf-prog, how about bpf-prog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not only bpf-prog, also deserialization.so kmesh.ko and bpf-prog

Copy link
Member

Choose a reason for hiding this comment

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

I think any name is better and concrete than data.

How about separating build ko and bpf

Makefile Outdated
$(call printlog, BUILD, "kernel")
$(QUIET) make -C kernel/ko_src

daemon:
Copy link
Member

Choose a reason for hiding this comment

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

This is not only daemon, it also includes other I would still call this all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about call this controller?

@lec-bit lec-bit force-pushed the separate branch 2 times, most recently from b781932 to 35472cd Compare October 21, 2024 09:14
Signed-off-by: lec-bit <[email protected]>
Signed-off-by: lec-bit <[email protected]>
Makefile Outdated
$(call printlog, BUILD, "kernel")
$(QUIET) make -C kernel/ko_src

controller:
Copy link
Member

Choose a reason for hiding this comment

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

not controller, we have cni, mda, etc

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.

I think we can use gen-check to detect any generated file correctly generated

@hzxuzhonghu
Copy link
Member

Please update the pr title as well

Signed-off-by: lec-bit <[email protected]>
@lec-bit lec-bit changed the title separation separation bpf and binary in Makefile&provides bpf2go outputs files Oct 24, 2024
@lec-bit
Copy link
Contributor Author

lec-bit commented Oct 24, 2024

I think we can use gen-check to detect any generated file correctly generated

The xxx.go file is fine, mainly because it needs to embed an .o file, but we didn't provide the .o file into the code repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants