Skip to content

refactor(net): the big network rebuild #977

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
wants to merge 81 commits into
base: master
Choose a base branch
from

Conversation

Samuka007
Copy link
Member

@Samuka007 Samuka007 commented Oct 14, 2024

  • 重构事件通知链
  • 使网络子系统更易读
  • 引入uevent/netlink socket
  • 使http_server可中断
  • 正确实现unix stream, seqpacket socket框架
  • 解决资源依赖导致的潜在死锁
  • 部分网络调用待完善
  • 未能正常运行test-backlog
  • 未引入路由子系统
  • close 时 解除 Port 占用 feat(net): 实现inet socket资源释放 #990
  • 实现shutdown逻辑 feat(net): 实现 socket shutdown 逻辑 #989
  • Address Family在转换到已有地址时,from_u16在2与10(INET6)上会返回None
  • Redis 未能正常使用客户端连接

一次自认为性价比并不十分高的网络子系统重构,但是辛苦 @val213 @smallcjy @1037827920 @Saga1718 的大力支持,愿意在三天两头构建不成功的网络重构分支下协助我一同完成重构。现网络重构分支已准备好合入主线!

Samuka007 and others added 14 commits October 10, 2024 17:53
uevent should be format

Enum of smoltcp socket should be optimized.

need to add interface for routing subsys

actix is still not abled to run.

clean some casual added code to other places
* 新增CommonAttrGroup,基本支持sysfs下各种类型设备的uevent属性文件的读测试

* 修改net设备的uevent内容,使之与Linux语义一致

* 删除无用注释
clean format, enable ctrl-c in accept blocking
feat: merge master and ready for pr in master
@Samuka007 Samuka007 requested a review from fslongjin October 14, 2024 12:45
@dragonosbot
Copy link

@Samuka007: no appropriate reviewer found, use r? to override

@github-actions github-actions bot added the enhancement New feature or request label Oct 14, 2024
@dragonosbot dragonosbot added A-driver Area: 驱动程序 A-fs Area: 文件系统 O-x86_64 Target: x86_64 S-等待审查 Status: 等待assignee以及相关方的审查。 labels Oct 14, 2024
@Samuka007 Samuka007 added the A-network Area: 网络子系统 label Oct 14, 2024
@Samuka007
Copy link
Member Author

r? @fslongjin @yuyi2439

Copy link
Member

@fslongjin fslongjin left a comment

Choose a reason for hiding this comment

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

需要添加文档

@dragonosbot dragonosbot added S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 and removed S-等待审查 Status: 等待assignee以及相关方的审查。 labels Oct 15, 2024
@Samuka007 Samuka007 marked this pull request as ready for review March 10, 2025 06:06
@dragonosbot
Copy link

设备驱动模型部分发生了更改,请进行审查

cc @fslongjin

@Samuka007
Copy link
Member Author

@dragonosbot review

@dragonosbot dragonosbot added S-等待审查 Status: 等待assignee以及相关方的审查。 and removed S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 labels Mar 10, 2025
@Samuka007 Samuka007 requested a review from fslongjin March 10, 2025 07:36
fslongjin and others added 7 commits March 11, 2025 09:06
- 修复`copy_process`函数对标志位处理不正确的bug
- init进程搜索列表中,支持为默认init程序传入参数

Signed-off-by: longjin <[email protected]>
* fix(process): 修复copy_process的一些bug & 支持默认init进程传参

- 修复`copy_process`函数对标志位处理不正确的bug
- init进程搜索列表中,支持为默认init程序传入参数

Signed-off-by: longjin <[email protected]>

* feat: 完善sys_reboot

- 校验magic number
- 支持多个cmd (具体内容未实现)

Signed-off-by: longjin <[email protected]>

---------

Signed-off-by: longjin <[email protected]>
* 几个结构体

* 通过vmx_init以及create_vm,create_vcpu部分TODO

* kvm_run完成一半

* 能够成功vmlaunch,但是在vmexit时候还有些问题未排查出来

* 解决了vmlaunch导致的cpu_reset的问题

* 整理代码

* 暂时性push到hyc仓库

* 修改内存虚拟化部分参数传入,解决死锁问题

* 初步完成ept映射.但不停EPT_VIOLATION

* 初步完成了EPT映射,但是读写内存还是有点问题

* fixme

* 更新了一些truncate到from_bits_unchecked的实现

* 完成内存虚拟化EPT_VIOLATION的映射

* fmt

* Remove /fixme from .gitignore

* Remove /fixme file

* Update kernel/src/init/init.rs

Co-authored-by: Samuel Dai <[email protected]>

* Update kernel/src/init/init.rs

Co-authored-by: Samuel Dai <[email protected]>

* 修改了注释格式,删除了附带的一些文件操作

* feat(syscall): 实现syscall restart (#1075)

能够在系统调用返回ERESTARTSYS时,信号处理结束后,自动重启系统调用.

TODO: 实现wait等需要restart_block的系统调用的重启

Signed-off-by: longjin <[email protected]>

* chore: update docker image version in script && update doc (#1076)

* chore: update docker image version in script

* chore: replace lots of spaces with newline in doc

* fix: 修复wait4系统调用部分语义与Linux不一致的问题 (#1080)

* fix: 修复wait4系统调用部分语义与Linux不一致的问题

解决wait不住/wait之后卡死的bug

---------

Signed-off-by: longjin <[email protected]>

* feat(fs/syscall): 实现fchdir系统调用 (#1081)

Signed-off-by: longjin <[email protected]>

* fix(mm): 修复fat文件系统的PageCache同步问题 (#1005)


---------

Co-authored-by: longjin <[email protected]>

* fix: 修正nographic启动时,控制台日志未能输出到文件的问题 (#1082)

Signed-off-by: longjin <[email protected]>

* fix(process): 修复copy_process的一些bug & 支持默认init进程传参 (#1083)

- 修复`copy_process`函数对标志位处理不正确的bug
- init进程搜索列表中,支持为默认init程序传入参数

Signed-off-by: longjin <[email protected]>

* feat: 完善sys_reboot (#1084)

* fix(process): 修复copy_process的一些bug & 支持默认init进程传参

- 修复`copy_process`函数对标志位处理不正确的bug
- init进程搜索列表中,支持为默认init程序传入参数

Signed-off-by: longjin <[email protected]>

* feat: 完善sys_reboot

- 校验magic number
- 支持多个cmd (具体内容未实现)

Signed-off-by: longjin <[email protected]>

---------

Signed-off-by: longjin <[email protected]>

* fix: 修复do_wait函数在wait所有子进程时,忘了释放锁就sleep的bug (#1089)

Signed-off-by: longjin <[email protected]>

* pull主线并且fmt

---------

Signed-off-by: longjin <[email protected]>
Co-authored-by: GnoCiYeH <[email protected]>
Co-authored-by: Samuel Dai <[email protected]>
Co-authored-by: LoGin <[email protected]>
Co-authored-by: LIU Yuwei <[email protected]>
Co-authored-by: MemoryShore <[email protected]>
修复split_pos 初始值错误导致原本应该被插入到链表末尾的定时器,插入到了链表头

Signed-off-by: longjin <[email protected]>
@Samuka007 Samuka007 force-pushed the feat-network-rebuild branch from dae1832 to a02f4c0 Compare March 11, 2025 01:11
Copy link
Member

@fslongjin fslongjin left a comment

Choose a reason for hiding this comment

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

dead code本质是未经测试&未使用的代码,不稳定且具有迷惑性
不是这样假装无事给他忽略的

Copy link
Member

@fslongjin fslongjin left a comment

Choose a reason for hiding this comment

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

日志还需要删一下,或者调整为trace级别。

Comment on lines +249 to +253
if has_events {
bound_socket.on_iface_events();
let _woke = bound_socket
.wait_queue()
.wakeup(Some(ProcessState::Blocked(true)));
Copy link
Member

Choose a reason for hiding this comment

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

这个是中断上下文内,然后涉及到的tcp那边有把inner的锁,没有lock_irqsave。这个不符合锁的安全规定。
导致http_server刷新多几次就有可能卡死死锁。由于涉及面比较广,tcp socket的inner全部都irq_save感觉不现实。这里可能需要解耦一下,或者加些无锁的结构去做

Comment on lines +257 to +263
// TODO: remove closed sockets
// let closed_sockets = self
// .closing_sockets
// .lock_irq_disabled()
// .extract_if(|closing_socket| closing_socket.is_closed())
// .collect::<Vec<_>>();
// drop(closed_sockets);
Copy link
Member

Choose a reason for hiding this comment

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

这里为什么注释掉了?

@Samuka007 Samuka007 force-pushed the feat-network-rebuild branch from b6cc375 to 2452957 Compare April 20, 2025 13:03
@Samuka007
Copy link
Member Author

New TODO: 需要完善 epoll 机制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: 驱动程序 A-fs Area: 文件系统 A-network Area: 网络子系统 O-x86_64 Target: x86_64 S-等待审查 Status: 等待assignee以及相关方的审查。 T-doc Relevant to the document team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] latest refactor中网络从阻塞中唤醒很慢
10 participants