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

refactor(net): the big network rebuild #977

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
40d9375
ready for merge in master (#964)
Samuka007 Oct 10, 2024
4e4ce68
updates uevent and make fmt
val213 Oct 11, 2024
178486f
新增CommonAttrGroup,基本支持sysfs下各种类型设备的uevent属性文件的读测试
val213 Oct 13, 2024
e67348c
修改net设备的uevent内容,使之与Linux语义一致
val213 Oct 13, 2024
49000bc
删除无用注释
val213 Oct 14, 2024
38d161c
feat: 支持 sysfs下 block, char, Net, rtc, tty 等类型设备的 uevent 文件读操作 (#973)
val213 Oct 14, 2024
b781eaa
Merge remote-tracking branch 'upstream/feat-network-rebuild' into uev…
val213 Oct 14, 2024
2e98aea
Merge remote-tracking branch 'upstream/feat-network-rebuild' into fea…
Samuka007 Oct 14, 2024
7cebb88
can ctrl-c interupt from blocking accept
Samuka007 Oct 14, 2024
8fe49e1
make fmt
Samuka007 Oct 14, 2024
bca536e
clean debug messages
Samuka007 Oct 14, 2024
9a1fe0f
Merge pull request #974 from Samuka007:feat-network-rebuild
Samuka007 Oct 14, 2024
63ccb53
merge master
Samuka007 Oct 14, 2024
91f24d4
Merge pull request #976 from Samuka007/feat-network-rebuild
Samuka007 Oct 14, 2024
d7be7de
清理积弊,不必要的动态分发和智能指针
val213 Oct 15, 2024
4a2b593
remove uevent and netlink
val213 Oct 16, 2024
7025b76
fmt
val213 Oct 16, 2024
b9f04fc
merge upstream
val213 Oct 16, 2024
886504f
remove uevent test
val213 Oct 16, 2024
10e62c7
Merge pull request #980 from val213/feat-network-rebuild
Samuka007 Oct 16, 2024
4736fad
重新组织代码分布
Samuka007 Oct 16, 2024
ce8026c
merge upstream/net
Samuka007 Oct 16, 2024
de148a1
remove unused imports
Samuka007 Oct 16, 2024
b9f27f4
fix it back to old syscall printing style
Samuka007 Oct 17, 2024
ddad6b1
regulate naming to posix
Samuka007 Oct 17, 2024
251e1bc
todo: socket close 及 port 接触占用
Samuka007 Oct 17, 2024
6c812d2
fix: format check
Samuka007 Oct 17, 2024
7cd11b4
feat: remove syscall prettier printing (#988)
Samuka007 Oct 17, 2024
149fc83
remove unnecessary warnings and impls
Samuka007 Oct 17, 2024
c9806be
loopback assign single ip, remove unnecessary comments
Samuka007 Oct 17, 2024
acd3485
fmt
Samuka007 Oct 17, 2024
954dd0a
Merge remote-tracking branch 'upstream/feat-network-rebuild'
Samuka007 Oct 17, 2024
7ead4a0
Merge pull request #992 from Samuka007/feat-network-rebuild
Samuka007 Oct 17, 2024
15cedf3
去除virtio_blk, virtio_net expect错误处理,直接返回错误
1037827920 Oct 17, 2024
bb23a04
Merge pull request #995 from 1037827920/patch-fix-virtio_error_handle
Samuka007 Oct 17, 2024
acfceaa
fix: 修复网卡顺序的bug (#996)
smallcjy Oct 20, 2024
a303dd0
fix: ipv6, AddressFamily有转换问题。
Samuka007 Oct 21, 2024
e0c7255
Merge remote-tracking branch 'upstream/feat-network-rebuild' into fea…
Samuka007 Oct 21, 2024
bca5197
make fmt
Samuka007 Oct 21, 2024
8189cb1
Merge pull request #1004 from Samuka007/feat-network-rebuild
Samuka007 Oct 21, 2024
fad1c09
feat(net): 实现unix抽象地址空间 (#1017)
smallcjy Oct 28, 2024
055c144
feat(doc):添加网络子系统模块 (#1020)
smallcjy Oct 30, 2024
ff13f9f
fix(net): TCP Resources and add syscall print, change to use latest s…
Samuka007 Nov 7, 2024
2b180c4
debug and add socket option level print
Samuka007 Nov 8, 2024
4e8c71b
fix: fix udp and run dog in udp
smallcjy Nov 11, 2024
7411864
Merge pull request #1041 from smallcjy:fix-udp
Samuka007 Nov 13, 2024
d675513
Merge branch 'DragonOS-Community:feat-network-rebuild' into feat-netw…
Samuka007 Nov 13, 2024
aaf9a5f
turn off syscall printing, remove unused imports and make fmt
Samuka007 Nov 13, 2024
e4115c9
turn off syscall printings
Samuka007 Nov 13, 2024
1a04676
merge main
Samuka007 Nov 13, 2024
bd5f713
Merge pull request #1048 from Samuka007/feat-network-rebuild
Samuka007 Nov 15, 2024
f438808
纸糊忙等tcp connecting,尚不明确连接可用的机制。
Samuka007 Nov 20, 2024
dab9a7a
turn off syscall
Samuka007 Nov 20, 2024
14c2143
Merge branch 'master' into feat-network-rebuild
fslongjin Nov 27, 2024
b749598
fix: 修正IfaceCommon的bounds字段的锁使用问题&调度问题
fslongjin Nov 27, 2024
57e0b2e
feat(socket): 实现shutdown系统调用的基础结构并启用相关方法
xiaolin2004 Nov 28, 2024
bbea79e
feat(socket): 添加shutdown方法并实现ShutdownTemp的TryFrom转换
xiaolin2004 Nov 28, 2024
0896c33
Merge pull request #1064 from fslongjin:patch-fix-a-locking-problem
Samuka007 Nov 28, 2024
b9c07e0
Merge remote-tracking branch 'origin/master' into patch-merge-master-…
fslongjin Nov 29, 2024
0e62017
fmt
fslongjin Nov 29, 2024
1848f09
Merge pull request #1068 from fslongjin/patch-merge-master-1129
fslongjin Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
kernel/cpu_arch/index
kernel/container/index
kernel/libs/index
kernel/net/index
kernel/trace/index


Expand Down
8 changes: 8 additions & 0 deletions docs/kernel/net/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
网络子系统
====================================
DragonOS 网络子系统

.. toctree::
:maxdepth: 1

unix
22 changes: 22 additions & 0 deletions docs/kernel/net/unix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# UNIX

## unix socket

unix - 用于进程间通信的socket


## 描述

AF_UNIX socket family 用于在同一台机器中的不同进程之间的通信(IPC)。unix socket地址现支持绑定文件地址,未支持绑定abstract namespace抽象命名空间。

目前unix 域中合法的socket type有:SOCK_STREAM, 提供stream-oriented socket,可靠有序传输消息;SOCK_SEQPACKET,提供connection-oriented,消息边界和按发送顺序交付消息保证的socket。

### unix stream socket 进程通信描述

unix stream socket 提供进程间流式传输消息的功能。假设对端进程作为服务端,本端进程作为客户端。进程间使用stream socket通信过程如下:

分别在对端进程和本端进程创建socket,服务端需要bind地址,客户端不必须bind地址。通信过程类似tcp三次握手流程:服务端调用listen系统调用进入监听状态,监听服务端bind的地址;客户端调用connect系统调用连接服务端地址;服务端调用accept系统调用接受来自客户端的连接,返回建立连接的新的socket。成功建立连接后可以调用write\send\sendto\sendmsg进行写操作,调用read\recv\recvfrom\recvmsg进行读操作。目前尚未支持非阻塞式读写,默认为阻塞式读写。读写完毕后调用close系统调用关闭socket连接。

### unix seqpacket socket 进程通信描述


2 changes: 1 addition & 1 deletion kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ linkme = "=0.3.27"
num = { version = "=0.4.0", default-features = false }
num-derive = "=0.3"
num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num-traits.git", rev="1597c1c", default-features = false }
smoltcp = { version = "=0.11.0", default-features = false, features = ["log", "alloc", "socket-raw", "socket-udp", "socket-tcp", "socket-icmp", "socket-dhcpv4", "socket-dns", "proto-ipv4", "proto-ipv6"]}
smoltcp = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/smoltcp.git", rev = "3e61c909fd540d05575068d16dc4574e196499ed", default-features = false, features = ["log", "alloc", "socket-raw", "socket-udp", "socket-tcp", "socket-icmp", "socket-dhcpv4", "socket-dns", "proto-ipv4", "proto-ipv6"]}
system_error = { path = "crates/system_error" }
uefi = { version = "=0.26.0", features = ["alloc"] }
uefi-raw = "=0.5.0"
Expand Down
70 changes: 52 additions & 18 deletions kernel/src/arch/x86_64/syscall/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
arch::{
ipc::signal::X86_64SignalArch,
syscall::nr::{SYS_ARCH_PRCTL, SYS_RT_SIGRETURN},
syscall::nr::{SysCall, SYS_ARCH_PRCTL, SYS_RT_SIGRETURN},
CurrentIrqArch,
},
exception::InterruptArch,
Expand All @@ -11,7 +11,6 @@ use crate::{
process::ProcessManager,
syscall::{Syscall, SYS_SCHED},
};
use log::debug;
use system_error::SystemError;

use super::{
Expand Down Expand Up @@ -53,7 +52,7 @@ macro_rules! syscall_return {

if $show {
let pid = ProcessManager::current_pcb().pid();
debug!("syscall return:pid={:?},ret= {:?}\n", pid, ret as isize);
log::debug!("[SYS] [Pid: {:?}] [Retn: {:?}]", pid, ret as i64);
}

unsafe {
Expand All @@ -63,6 +62,24 @@ macro_rules! syscall_return {
}};
}

macro_rules! normal_syscall_return {
($val:expr, $regs:expr, $show:expr) => {{
let ret = $val;

if $show {
let pid = ProcessManager::current_pcb().pid();
log::debug!("[SYS] [Pid: {:?}] [Retn: {:?}]", pid, ret);
}

$regs.rax = ret.unwrap_or_else(|e| e.to_posix_errno() as usize) as u64;

unsafe {
CurrentIrqArch::interrupt_disable();
}
return;
}};
}

#[no_mangle]
pub extern "sysv64" fn syscall_handler(frame: &mut TrapFrame) {
let syscall_num = frame.rax as usize;
Expand All @@ -87,15 +104,37 @@ pub extern "sysv64" fn syscall_handler(frame: &mut TrapFrame) {
];
mfence();
let pid = ProcessManager::current_pcb().pid();
let show = false;
// let show = if syscall_num != SYS_SCHED && pid.data() >= 7 {
// true
// } else {
// false
// };

if show {
debug!("syscall: pid: {:?}, num={:?}\n", pid, syscall_num);
let mut show = (syscall_num != SYS_SCHED) && (pid.data() >= 7);
// false;

let to_print = SysCall::try_from(syscall_num);
if let Ok(to_print) = to_print {
use SysCall::*;
match to_print {
SYS_ACCEPT | SYS_ACCEPT4 | SYS_BIND | SYS_CONNECT | SYS_SHUTDOWN | SYS_LISTEN => {
// show &= false;
}
SYS_RECVFROM | SYS_SENDTO | SYS_SENDMSG | SYS_RECVMSG => {
show &= false;
}
SYS_SOCKET | SYS_GETSOCKNAME | SYS_GETPEERNAME | SYS_SOCKETPAIR | SYS_SETSOCKOPT
| SYS_GETSOCKOPT => {
show &= false;
}
SYS_OPEN | SYS_OPENAT | SYS_CREAT | SYS_CLOSE => {
show &= false;
}
SYS_READ | SYS_WRITE | SYS_READV | SYS_WRITEV | SYS_PREAD64 | SYS_PWRITE64
| SYS_PREADV | SYS_PWRITEV | SYS_PREADV2 => {
show &= false;
}
_ => {
show &= false;
}
}
if show {
log::debug!("[SYS] [Pid: {:?}] [Call: {:?}]", pid, to_print);
}
}

// Arch specific syscall
Expand All @@ -108,12 +147,7 @@ pub extern "sysv64" fn syscall_handler(frame: &mut TrapFrame) {
);
}
SYS_ARCH_PRCTL => {
syscall_return!(
Syscall::arch_prctl(args[0], args[1])
.unwrap_or_else(|e| e.to_posix_errno() as usize),
frame,
show
);
normal_syscall_return!(Syscall::arch_prctl(args[0], args[1]), frame, show);
Samuka007 marked this conversation as resolved.
Show resolved Hide resolved
}
_ => {}
}
Expand Down
Loading
Loading