-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
feat: add ebpf support #912
base: feat-ebpf
Are you sure you want to change the base?
Conversation
add basic bpf map type. add basic perf type. update kprobe impl. add user app example.
@Chiichen @fslongjin 我重新整理了ebpf的提交代码,麻烦两位看看。 |
@@ -0,0 +1 @@ | |||
((prog-mode . ((lsp-rust-analyzer-linked-projects . ["Cargo.toml" "syscall_ebpf-ebpf/Cargo.toml"])))) |
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.
这个多余的文件需要删掉
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.
👌
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.
@Godones 简单描述下这个 PR 之后对 eBPF 的支持到了什么程度(基本/可用/完整支持),以及支持/不支持哪些功能
kernel/src/bpf/map/mod.rs
Outdated
fn lookup_elem(&self, _key: &[u8]) -> Result<Option<&[u8]>> { | ||
panic!("lookup_elem not implemented") | ||
} | ||
/// Update an element in the map. | ||
/// | ||
/// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_update_elem/ | ||
fn update_elem(&mut self, _key: &[u8], _value: &[u8], _flags: u64) -> Result<()> { | ||
panic!("update_elem not implemented") | ||
} | ||
/// Delete an element from the map. | ||
/// | ||
/// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_map_delete_elem/ | ||
fn delete_elem(&mut self, _key: &[u8]) -> Result<()> { | ||
panic!("delete_elem not implemented") | ||
} | ||
/// For each element in map, call callback_fn function with map, | ||
/// callback_ctx and other map-specific parameters. | ||
/// | ||
/// See https://ebpf-docs.dylanreimerink.nl/linux/helper-function/bpf_for_each_map_elem/ | ||
fn for_each_elem(&mut self, _cb: BpfCallBackFn, _ctx: &[u8], _flags: u64) -> Result<u32> { | ||
panic!("for_each_elem not implemented") | ||
} | ||
|
||
/// Get the next key in the map. If key is None, get the first key. | ||
/// | ||
/// Called from syscall | ||
fn get_next_key(&self, _key: Option<&[u8]>, _next_key: &mut [u8]) -> Result<()> { | ||
panic!("get_next_key not implemented") | ||
} | ||
|
||
/// Freeze the map. | ||
/// | ||
/// It's useful for .rodata maps. | ||
fn freeze(&self) -> Result<()> { | ||
panic!("freeze not implemented") | ||
} | ||
|
||
/// Get the first value pointer. | ||
fn first_value_ptr(&self) -> *const u8 { | ||
panic!("value_ptr not implemented") | ||
} |
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.
这里默认实现都是 panic,能确保上层不会调用未实现的方法吗,默认给空实现或者返回 SystemError::unsupported会比较安全吧
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.
这里是方便我初期实现debug都返回了panic,返回SystemError要合理一点
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.
我已经更新pr的描述,说明当前对eBPF程序的支持程度
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.
这一块文件映射的代码跟现在主线的代码应该有点出入,到时候合并主线之前再处理吧
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.
ok
最好能在内核文档里面写几个文档,描述你的设计&方案 |
与 @Godones 交流了一下,会在下次或者下下次社区会议上分享这个 PR 的工作内容,等会议结束后再合并一次主线(应该主要是文件映射那边有一些冲突要解决),再开始 review 这个 PR |
@Godones 已经合并了最新的主线,麻烦解决一下冲突,对齐一下主线的实现,我记得在mmap的实现那部分(ucontext)逻辑是有冲突的 |
可以 |
@Chiichen 似乎合并主线后无法通过CI? |
是的,我看应该是格式检查挂了,因为我在网页上解决的冲突,所以可能没有仔细去格式化,你就基于现有的分支代码解决冲突就可以了,应该格式化之后 ci 是不会挂的 |
@Chiichen 新的修改中主要是适配当前主线的mmap实现,以及修复了一些错误。由于主线的mmap并不能完全适用于所有文件的实现,我在 |
@Jomocool 麻烦帮忙看看mmap相关的修改 |
对eBPF支持程度(基本):
不支持的功能:
todo