Commit Graph

101 Commits

Author SHA1 Message Date
e216fc7798 Kernel: Fix port allocation endianness 2026-02-08 19:43:08 +02:00
c648ea12f2 Kernel: Cleanup and fix UNIX sockets
EPOLLOUT is now sent to the correct socket and buffer is now a ring
buffer to avoid unnecessary memmove on every packet
2026-02-08 19:38:28 +02:00
2e59373a1e Kernel: Fix non blocking sockets blocking :D 2026-02-08 19:33:28 +02:00
a51a81b6cd Kernel: Move {set,get}sockopt to sockets
Sockets can now actually implement socket options :D
2026-02-08 19:27:16 +02:00
ba6229b92d Kernel: Fix TCP accept bind address
I was accidentally binding the new socket to the target address instead
of the listening socket's address
2026-01-24 00:33:05 +02:00
f06e5d33e7 Kernel: Rework socket binding to an address
Sockets are no longer bound to an interface, but an ipv4 address. This
allows servers at 0.0.0.0 talk to multiple different interfaces
2025-12-31 19:28:55 +02:00
d60f12d3b8 Kernel: Add support for SCM_CREDENTIALS and fix recvmsg
recvmsg was broken when receiving into more than a single iovec
2025-11-18 05:40:36 +02:00
dd636ffcb2 Kernel: Add support for SA_SIGINFO 2025-11-17 05:26:07 +02:00
c700d9f714 Kernel: Implement connect for UDP socket 2025-11-17 05:26:07 +02:00
59cfc339b0 Kernel: Ignore MSG_NOSIGNAL and invalid flags 2025-11-17 05:26:07 +02:00
bb86520094 Kernel: Set message flags in UDP and TCP recvmsg 2025-11-13 04:20:53 +02:00
7b580b8f56 Kernel: Implement fd passing with SCM_RIGTHS 2025-11-12 00:06:36 +02:00
04d24bce70 Kernel/LibC: Implement {recv,send}msg as syscalls
This also removes the now old recvfrom and sendto syscalls. These are
now implemented as wrappers around recvmsg and sendmsg.

Also replace unnecessary spinlocks from unix socket with mutexes
2025-11-10 01:40:33 +02:00
0066b20413 Kernel: Fix spinlock leaks with unix sockets 2025-08-19 16:23:30 +03:00
ef6ee78fd1 Kernel/LibC: Implement chroot 2025-08-11 14:07:37 +03:00
5b587d199e Kernel/LibC: Implement FIONREAD for tcp and udp sockets 2025-08-10 19:57:31 +03:00
95cfac471a Kernel: Rename loopback adapter lo0 -> lo 2025-08-05 03:09:24 +03:00
6084aae603 Kernel: Add guard pages to kernel and userspace stacks 2025-07-02 23:12:36 +03:00
8a0269d29e Kernel: Remove kernel processes
Kernel can just use raw threads, pretty muchs the only thing that
process provides is syscalls which kernel threads of course don't
need.

Also this makes init process have pid 1 :D
2025-07-02 01:54:03 +03:00
4695fa061d Kernel: Don't panic if UNIX socket is already bound but deleted 2025-06-28 16:55:13 +03:00
125f8b591d Kernel: Don't crash if socket tries to reconnect
:D
2025-06-11 01:54:41 +03:00
e92f039a17 Kernel: Fix tcp sending with already sent unacknowledged bytes 2025-06-06 11:55:44 +03:00
66726090ec Kenrel: Fix TCP connection closing
If TCP socket was connected with connect() instead of accept() it would
never send FIN to other end when it was closed.
2025-06-06 11:10:29 +03:00
eecdad50a6 Kernel: Fix most of mutex + block race conditions
All block functions now take an optional mutex parameter that is
atomically unlocked instead of having the user unlock it before hand.
This prevents a ton of race conditions everywhere in the code!
2025-06-06 03:59:22 +03:00
96d5ed9cc7 Kernel: Fix E1000 driver interrupts
I have no idea why, but E1000 seems to be missing interrupts frequently
when clearing ICR only at the end of the interrupt handler
2025-06-06 03:45:35 +03:00
8812704601 Kernel: Make sure IPv4 and ARP packets are not missed
This is a really hacky solution but will do until i get atomic
unblocking with respect to locks
2025-06-05 22:03:15 +03:00
0f189d410e Kernel: Fix unix socket recv from
If connection on unix socket was closed and other end tries to recvfrom,
the thread would enter a fucked up state where it held the socket's
spinlock when returning to userspace.
2025-06-05 22:02:53 +03:00
bf41b448d6 Kernel: Fix TCP sending
- Fix race condition when adding packet to send buffer before other end
  has acknowledged it
- Allow sending multiple packets before receiving ACK for previous ones
2025-06-04 22:21:35 +03:00
943069b2a3 Kernel: Socket EPIPE and send SIGPIPE on write after hang up 2025-06-03 10:24:44 +03:00
692ba43182 Kernel: Fix spinlock bugs found by the new spinlock security 2025-06-01 13:48:03 +03:00
89c9bfd052 Kernel/LibC: Implement socketpair for UNIX sockets 2025-05-28 03:10:01 +03:00
12b93567f7 Kernel/LibC: Implement getpeername 2025-05-28 03:10:01 +03:00
2f37776614 Kernel: Notify epoll on new TCP connections 2025-05-28 03:10:01 +03:00
7f04b2c96c Kernel: Fix E1000 interrupt handling
E1000 does not support MSI-X and thus does not generate RxQ0 interrupts.
2025-05-28 03:10:01 +03:00
0e0d7016b3 Kernel: Rename has_hangup -> has_hungup 2025-05-17 12:39:23 +03:00
1bcd1edbf5 Kernel/LibC: Implement basic epoll
This implementation is on top of inodes instead of fds as linux does it.
If I start finding ports/software that relies on epoll allowing
duplicate inodes, I will do what linux does.

I'm probably missing multiple epoll_notify's which may cause hangs but
the system seems to work fine :dd:
2025-05-13 10:18:05 +03:00
8e0a56b49a Kernel: Implement loopback network interface 2025-05-13 10:16:21 +03:00
b853d29992 Kernel: Fix unix domain socket close detection 2025-04-22 08:36:44 +03:00
107b31a0b5 Kernel: Fix E1000{,E} driver for older qemu versions
This patch adds clearing of *Interrupt Cause Registers*, which allows
older qemu versions to send new interrupts. Apparently this is not
needed on newer releases.
2025-04-22 00:31:13 +03:00
1c44d24b76 Kernel: Fix TCP closing state machine 2025-04-21 20:02:32 +03:00
15045cc486 Kernel: Make nonblocking sockets unblocking :) 2025-04-05 18:42:02 +03:00
c9132d984b Kernel: Fix TCP window scaling 2025-04-05 18:40:23 +03:00
36026d4ec6 Kernel: Cleanup TCP and add basic window scaling support 2025-04-01 23:09:30 +03:00
2d0690ae2d Kernel: Cleanup most of syscalls dealing with files 2024-12-07 05:33:04 +02:00
c02de2580d Kernel: Add support for SIOCGIFNAME ioctl 2024-12-02 20:13:37 +02:00
2d11ce9669 Kernel: Fix interrupt system
I had not understood how MSIs work and I was unnecessarily routing them
through IOAPIC. This is not necessary and should not be done :D

Also MSIs were reserving interrupts that IOAPIC was capable of
generating. Now IOAPIC and MSIs use different set of interrupts so
IOAPIC can use more interrupts if needed.
2024-09-27 15:31:31 +03:00
d395cf38b7 Kernel: Binding to port 0 will always find unused port 2024-09-22 17:30:01 +03:00
23d6205659 Kernel: Move DEBUG_* macros to centralized Debug.h
This makes toggling debug info much easier
2024-09-20 11:00:07 +03:00
bc0acc6f44 Kernel: Validate network packet sizes before casting
This caused a lot of crashes on invalid packets :D
2024-09-20 10:46:59 +03:00
b8622f2b4b Kernel: Implement simple RTL8169 driver
This allows me to use internet when running banan-os on my hardware!
2024-09-19 22:58:03 +03:00