summaryrefslogtreecommitdiff
path: root/Kernel/Net
AgeCommit message (Collapse)Author
2019-11-18IPv4: Disconnected non-blocking sockets were not signalling EOFAndreas Kling
After a socket has disconnected, we shouldn't return -EAGAIN. Instead we should allow userspace to read/recvfrom the socket until its packet queue has been exhausted. At that point, we now return 0, signalling EOF. It might be even better to start returning -ENOTCONN after signalling EOF once. I'm not sure how that should work, needs looking into.
2019-11-09Kernel+SystemMonitor: Publish can_read/write state for open filesAndreas Kling
The can_read() and can_write() states for file descriptions are now published in /proc, allowing SystemMonitor to display it.
2019-11-04Kernel: Make File's can_read/can_write take a const FileDescription&Andreas Kling
Asking a File if we could possibly read or write it will never mutate the asking FileDescription&, so it should be const.
2019-11-04IPv4: Non-blocking IPv4 sockets should return -EAGAIN in recvfrom()Andreas Kling
...if there are no packets in the receive queue.
2019-10-18Net: Put a bunch of socket debug logging behind FOO_DEBUGAndreas Kling
Also remove an unused Socket::listen() implementation.
2019-10-18Revert "Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing"Andreas Kling
This reverts commit 1cca5142afbd76833deedfdb238230ac53424855. This appears to be causing intermittent triple-faults and I don't know why yet, so I'll just revert it to keep the tree in decent shape.
2019-10-18Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ingAndreas Kling
Background: DoubleBuffer is a handy buffer class in the kernel that allows you to keep writing to it from the "outside" while the "inside" reads from it. It's used for things like LocalSocket and PTY's. Internally, it has a read buffer and a write buffer, but the two will swap places when the read buffer is exhausted (by reading from it.) Before this patch, it was internally implemented as two Vector<u8> that we would swap between when the reader side had exhausted the data in the read buffer. Now instead we preallocate a large KBuffer (64KB*2) on DoubleBuffer construction and use that throughout its lifetime. This removes all the kmalloc heap traffic caused by DoubleBuffers :^)
2019-10-17Kernel: Minor cleanup in TCPSocket::send_tcp_packet()Andreas Kling
2019-10-08Kernel: Delay moving accepted sockets to SetupState::Completed a bitAndreas Kling
Make sure we don't move accepted sockets to the Completed setup state until we've actually constructed a FileDescription for them. This is important, since this state transition will trigger connect() to unblock on the client side, and the client may try writing to the socket right away. This makes DNS lookups way more reliable since we don't just fail to write() right after connect()ing to LookupServer sometimes. :^)
2019-10-08Kernel: Don't put LocalSocket in SetupState::Completed in bind()Andreas Kling
This was causing connect() to unblock immediately for local sockets, since that's exactly what ConnectBlocker checks for. Instead, just move to SetupState::Completed when it's accept()ed.
2019-10-02Kernel: Add SIOCGIFHWADDR ioctl to get the MAC address of an adapterAndreas Kling
2019-09-30ByteBuffer: Remove pointer() in favor of data()Andreas Kling
We had two ways to get the data inside a ByteBuffer. That was silly.
2019-09-23IPv4: Implement socket ioctls SIOCGIFADDR and SIOCSIFADDRAndreas Kling
This allows userspace programs to get and set (superuser-only) the IPv4 address of a network adapter. :^)
2019-09-22LocalSocket: Teach recvfrom() how to block if needed, and simplify itAndreas Kling
If we can't already read when we enter recvfrom() on a LocalSocket, we'll now block the current thread until we can. Also added a buffer_for(FileDescription&) helper so that the client and server can share some of the code. :^)
2019-09-19IPv4: Support overriding the default TTL (64)Andreas Kling
Made getsockopt() and setsockopt() virtual so we can handle them in the various Socket subclasses. The subclasses map kinda nicely to "levels". This will allow us to implement things like "traceroute", although.. I spent some time trying to do that, but then hit a wall when it turned out that the user-mode networking in QEMU doesn't preserve TTL in the ICMP packets passing through.
2019-09-16Kernel: Move kmalloc() into a Kernel/Heap/ directoryAndreas Kling
2019-09-09RTL8139: Fix bogus (but harmless) TX buffer index in send_raw()Andreas Kling
This was getting fixed up by the loop that chooses the next TX buffer anyway, but let's do this correctly. Fixes #522.
2019-09-08Kernel: Use timeval_sub for TCP retransmissions and lower timer to 500msConrad Pankoff
2019-09-08Kernel: Handle listening socket disappearing during incoming handshakeConrad Pankoff
2019-09-08Kernel: Use a WeakPtr instead of a RefPtr for TCP socket originatorConrad Pankoff
2019-09-08Kernel: Put some network log messages behind debug flagsConrad Pankoff
2019-09-08Kernel: Send ACK/FIN in response to FIN packets on active connectionsConrad Pankoff
This is to work around our lack of a shutdown() implementation.
2019-09-08Kernel: Implement outgoing TCP retransmission and better ACK handlingConrad Pankoff
This approach is a bit naiive - whenever we send a packet out, we check to see if there are any other packets we should try to send. This works well enough for a busy connection but not very well for a quiet one. Ideally we would check for not-acked packets on some kind of timer, and use the length of this not-acked list as feedback to throttle the writes coming from userspace.
2019-09-08Kernel: Remember all ARP replies, even ones we didn't requestConrad Pankoff
This allows us to take advantage of unsolicited ARP replies, such as those that are emitted by many systems after their network interfaces are enabled, or after their DHCP client sets their IP. This also makes us a bit more vulnerable to ARP flooding, but we need some kind of eviction strategy anyway, so we can deal with that later.
2019-09-08Kernel: Don't mark incoming sockets as connected in NetworkTaskConrad Pankoff
An incoming socket should only be considered connected after a program has received it from accept(). Before that point, it's only "half" open, and it might not ever actually be served to a program. Socket::accept is where m_connected is correctly set.
2019-09-08Kernel: Hold socket back from accept() until it's fully set upConrad Pankoff
2019-09-08Kernel: Use RefPtr instead of SocketHandle for TCPSocket clientsConrad Pankoff
Using a SocketHandle takes a lock on the socket, which we don't want to do.
2019-09-08Kernel: Don't set sequence manually; send_tcp_packet will do itConrad Pankoff
2019-09-08Kernel: Make sure IPv4Socket is marked as listening in listen()Conrad Pankoff
2019-09-08Kernel: Don't increment ACK number without SYN, FIN, or dataConrad Pankoff
2019-09-08Kernel: Fix debug messages in IPv4SocketConrad Pankoff
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-09-03Kernel: Pad packets out to 64 bytes in rtl8139 driverConrad Pankoff
2019-09-03Kernel: Only set tx buffer address once in rtl8139 driverConrad Pankoff
2019-09-03Kernel: Reword some constants/comments in rtl8139 driver for clarityConrad Pankoff
2019-09-03Kernel: Use regular kmalloc for buffers in rtl8139 driverConrad Pankoff
2019-09-02Kernel: Don't allow non-superusers to bind TCP/UDP ports < 1024Andreas Kling
2019-08-29Kernel: Implement is_zero for RoutingDecisionConrad Pankoff
2019-08-29Kernel: Take a copy of MACAddress in RoutingDecisionConrad Pankoff
2019-08-29Kernel: Use a public member for NetworkAdapter on_receiveConrad Pankoff
2019-08-29Kernel: Add simple ARP routing layerConrad Pankoff
This replaces the previous placeholder routing layer with a real one! It's still very primitive, doesn't deal with things like timeouts very well, and will probably need several more iterations to support more normal networking things. I haven't confirmed that this works with anything other than the QEMU user networking layer, but I suspect that's what nearly everybody is using at this point, so that's the important target to keep working.
2019-08-29Kernel: Remove IP configuration from LoopbackAdapterConrad Pankoff
This is configured in NetworkTask_main now, so there's no need to do it here as well.
2019-08-29Kernel: Remove now-unused singleton methods from our network devicesConrad Pankoff
2019-08-29Kernel: Remove specific devices from network codeConrad Pankoff
By setting up the devices in init() and looping over the registered network adapters in NetworkTask_main, we can remove the remaining hard-coded adapter references from the network code. This also assigns IPs according to the default range supplied by QEMU in its slirp networking mode.
2019-08-29Kernel: Add const to packet data in send_raw callConrad Pankoff
2019-08-29Kernel: Add on_receive callback to NetworkAdapterConrad Pankoff
2019-08-29Kernel: Add netmask and gateway to NetworkAdapterConrad Pankoff
2019-08-29Kernel: Ask for all relevant IRQs in rtl8139 driverConrad Pankoff
2019-08-29Kernel: Ignore IPv6 packets; log unknown Ethernet payload typesConrad Pankoff
2019-08-29Kernel/AK: Add is_zero helpers for IP and MAC addressesConrad Pankoff