summaryrefslogtreecommitdiff
path: root/Kernel/Net/NetworkTask.cpp
AgeCommit message (Collapse)Author
2021-09-07Kernel: Make TCPSocket client construction use KResultOr and TRY()Andreas Kling
We don't really have anywhere to propagate the error in NetworkTask at the moment, since it runs in its own kernel thread and has no direct userspace caller.
2021-09-07Kernel: Store process names as KStringAndreas Kling
2021-09-07Kernel: Avoid string creation for simple string comparisonBrian Gianforcaro
2021-09-06Kernel: Make kernel region allocators return KResultOr<NOP<Region>>Andreas Kling
This expands the reach of error propagation greatly throughout the kernel. Sadly, it also exposes the fact that we're allocating (and doing other fallible things) in constructors all over the place. This patch doesn't attempt to address that of course. That's work for our future selves.
2021-08-29Kernel: Rename Socket::lock() => Socket::mutex()Andreas Kling
"lock" is ambiguous (verb vs noun) while "mutex" is not.
2021-08-22Kernel: Rename ProtectedValue<T> => MutexProtected<T>Andreas Kling
Let's make it obvious what we're protecting it with.
2021-08-18Kernel: Fix a crash introduced by my TCP RST fixGunnar Beutner
2021-08-18Kernel: Don't respond to TCP RST packetsGunnar Beutner
As seen with GitHub Pages and probably lots of other hosts this might cause a loop if the peer decides to respond to our RST packet again.
2021-08-15Kernel: Convert TCP retransmit queue from HashTable to IntrusiveListAndreas Kling
2021-08-15Kernel: Convert IPv4 socket list from HashTable to IntrusiveListAndreas Kling
There was no reason whatsoever to use a HashTable here. IntrusiveList removes all the heap allocations and does everything more efficiently.
2021-08-14Kernel: Stop allowing implicit conversion from KResult to intAndreas Kling
This patch removes KResult::operator int() and deals with the fallout. This forces a lot of code to be more explicit in its handling of errors, greatly improving readability.
2021-08-07Kernel: Migrate TCP socket tables locking to ProtectedValueJean-Baptiste Boric
Note: TCPSocket::create_client() has a dubious locking process where the sockets by tuple table is first shared lock to check if the socket exists and bail out if it does, then unlocks, then exclusively locks to add the tuple. There could be a race condition where two client creation requests for the same tuple happen at the same time and both cleared the shared lock check. When in doubt, lock exclusively the whole time.
2021-08-07Kernel: Migrate IPv4 socket table locking to ProtectedValueJean-Baptiste Boric
2021-08-07Kernel: Move Mutex into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Add convenience values to the Memory::Region::Access enumAndreas Kling
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-03Kernel: Handle OOM when allocating Packet KBuffersBrian Gianforcaro
2021-08-03Kernel: Use normal initialization for TCPPacket instead of memsetBrian Gianforcaro
2021-08-02Kernel: Send RST/ACK if no socket is availablebrapru
Previously there was no way for Serenity to send a packet without an established socket connection, and there was no way to appropriately respond to a SYN packet on a non-listening port. This patch will respond to any non-established socket attempts with the appropraite RST/ACK, letting the client know to close the connection.
2021-08-02Kernel: Do not send delayed ack in response to RST/ACKbrapru
In accordance with RFC 793, if the receiver is in the SYN-SENT state it should respond to a RST by aborting the connection and immediately move to the CLOSED state. Previously the system would ACK all RST/ACKs, and the remote peer would just respond with more RST packets.
2021-08-02Kernel: Convert NetworkTask to east-const stylebrapru
2021-07-25Utilities: Support static assignment of the ARP tablebrapru
2021-07-25Kernel: Add update option to remove an entry from the ARP tablebrapru
Allows for specifying whether to set/delete an entry from the table.
2021-07-18Kernel: Rename Locker => MutexLockerAndreas Kling
2021-07-17Kernel: Rename Lock to MutexAndreas Kling
Let's be explicit about what kind of lock this is meant to be.
2021-06-09Kernel: Introduce the NetworkingManagement singletonLiav A
Instead of initializing network adapters in init.cpp, let's move that logic into a separate class to handle this. Also, it seems like a good idea to shift responsiblity on enumeration of network adapters after the boot process, so this singleton will take care of finding the appropriate network adapter when asked to with an IPv4 address or interface name. With this change being merged, we simplify the creation logic of NetworkAdapter derived classes, so we enumerate the PCI bus only once, searching for driver candidates when doing so, and we let each driver to test if it is resposible for the specified PCI device.
2021-06-04Kernel: Make sure we increment the TX counterGunnar Beutner
This was broken by b436dd1.
2021-06-03Kernel: Make sure outgoing ICMP packets have the correct checksumGunnar Beutner
The internet_checksum() function relies on the buffer - or at least the checksum field - to be all zeroes.
2021-05-28Kernel: Ignore duplicate SYN packetsGunnar Beutner
When receiving a SYN packet for a connection that's in the "SYN received" state we should ignore the duplicate SYN packet instead of closing the connection. This can happen when we didn't accept the connection in time and our peer has sent us another SYN packet because it thought that the initial SYN packet was lost.
2021-05-26Kernel: Avoid allocations when sending IP packetsGunnar Beutner
Previously we'd allocate buffers when sending packets. This patch avoids these allocations by using the NetworkAdapter's packet queue. At the same time this also avoids copying partially constructed packets in order to prepend Ethernet and/or IPv4 headers. It also properly truncates UDP and raw IP packets.
2021-05-15Kernel: Log unexpected TCP packet flags in NetworkTask handle_tcp()Brian Gianforcaro
Occasionally we'll see messages in the serial console like: handle_tcp: unexpected flags in FinWait1 state In these cases it would be nice to know what flags we are receiving that we aren't expecting.
2021-05-14Kernel: Try to retransmit lost TCP packetsGunnar Beutner
Previously we didn't retransmit lost TCP packets which would cause connections to hang if packets were lost. Also we now time out TCP connections after a number of retransmission attempts.
2021-05-14Kernel: Wake up NetworkTask every 500 millisecondsGunnar Beutner
This wakes up NetworkTask every 500 milliseconds so that it can send pending delayed TCP ACKs and isn't forced to send all of them early when it goes to sleep like it did before.
2021-05-14Kernel: Don't use delayed ACKs when establishing the connectionGunnar Beutner
When establishing the connection we should send ACKs right away so as to not delay the connection process. This didn't previously matter because we'd flush all delayed ACKs when NetworkTask waits for incoming packets.
2021-05-12Kernel: Outbound packets should use the source address from the socketGunnar Beutner
Previously we'd use the adapter's address as the source address when sending packets. Instead we should use the socket's bound local address.
2021-05-12Kernel: Coalesce TCP ACKsGunnar Beutner
Previously we'd send a TCP ACK for each TCP packet we received. This changes NetworkTask so that we send fewer TCP ACKs.
2021-05-12Kernel: Trigger TCP fast retransmission when we encounter lost packetsGunnar Beutner
When we receive a TCP packet with a sequence number that is not what we expected we have lost one or more packets. We can signal this to the sender by sending a TCP ACK with the previous ack number so that they can resend the missing TCP fragments.
2021-05-12Kernel: Don't process TCP packets out of orderGunnar Beutner
Previously we'd process TCP packets in whatever order we received them in. In the case where packets arrived out of order we'd end up passing garbage to the userspace process. This was most evident for TLS connections: courage:~ $ git clone https://github.com/SerenityOS/serenity Cloning into 'serenity'... remote: Enumerating objects: 178826, done. remote: Counting objects: 100% (1880/1880), done. remote: Compressing objects: 100% (907/907), done. error: RPC failed; curl 56 OpenSSL SSL_read: error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac, errno 0 error: 1918 bytes of body are still expected fetch-pack: unexpected disconnect while reading sideband packet fatal: early EOF fatal: fetch-pack: invalid index-pack output
2021-05-12Kernel: Avoid allocating KBuffers for TCP packetsGunnar Beutner
This avoids allocating a KBuffer for each incoming TCP packet.
2021-05-05Kernel: Implement IP multicast supportSergey Bugaev
An IP socket can now join a multicast group by using the IP_ADD_MEMBERSHIP sockopt, which will cause it to start receiving packets sent to the multicast address, even though this address does not belong to this host.
2021-04-30Kernel: Tear down connections when we receive an RST packetGunnar Beutner
2021-04-30Kernel: Record MAC addresses for incoming IPv4 packetsGunnar Beutner
This way we don't have to do ARP just to send packets back to an address which just sent us a packet.
2021-04-30Kernel: Avoid deadlock when trying to send packets from the NetworkTaskGunnar Beutner
fixes #6758
2021-04-27Kernel: Silence a few more network dbgln()sGunnar Beutner
2021-04-25Kernel: Remove the now defunct `LOCKER(..)` macro.Brian Gianforcaro
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-03Kernel: NetworkTask: Remove 10.0.2.x as default IP for NIC interfacesBrendan Coles
2021-03-12Kernel: Convert klog() => AK::Format in NetworkTaskAndreas Kling
2021-03-02Kernel: Make sockets use AK::TimeBen Wiederhake
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.