summaryrefslogtreecommitdiff
path: root/Kernel/Net
AgeCommit message (Collapse)Author
2021-12-11Kernel: Remove unused String.h includesHendiadyoin1
This makes searching for not yet OOM safe interfaces a bit easier.
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-12-05Kernel: Mark kernel smart-pointer classes as [[nodiscard]]Sam Atkins
And cast the unused return values to void.
2021-12-05Kernel: Implement the SO_DONTROUTE SOL_SOCKET-level optionIdan Horowitz
2021-12-05Kernel: Implement the SO_ACCEPTCONN SOL_SOCKET-level optionIdan Horowitz
2021-12-05Kernel: Stub out the SO_DEBUG SOL_SOCKET-level optionIdan Horowitz
2021-12-05Kernel: Add support for the MSG_WAITALL sys$recvmsg flagIdan Horowitz
2021-12-05Kernel: Add support for the MSG_DONTROUTE sys$sendmsg flagIdan Horowitz
2021-12-05Kernel: Return EINVAL on unsupported LocalSocket ioctlIdan Horowitz
ENOTTY is used to signify that no ioctl interface is provided at all, but LocalSockets do support the FIONREAD ioctl.
2021-11-16Kernel: Use static_ptr_cast to convert between Userspace<T*> typesAndrew Kaster
Some calls of copy_to_user were converting Userspace<T*> to Userspace<U*> via the implicit conversion to FlatPtr. Change them to use the static_ptr_cast overload that is designed to express this conversion
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK: Make Vector::try_* functions return ErrorOr<void>Andreas Kling
Instead of signalling allocation failure with a bool return value (false), we now use ErrorOr<void> and return ENOMEM as appropriate. This allows us to use TRY() and MUST() with Vector. :^)
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-10-31Kernel: Clarify ambiguous {File,Description}::absolute_pathBen Wiederhake
Found due to smelly code in InodeFile::absolute_path. In particular, this replaces the following misleading methods: File::absolute_path This method *never* returns an actual path, and if called on an InodeFile (which is impossible), it would VERIFY_NOT_REACHED(). OpenFileDescription::try_serialize_absolute_path OpenFileDescription::absolute_path These methods do not guarantee to return an actual path (just like the other method), and just like Custody::absolute_path they do not guarantee accuracy. In particular, just renaming the method made a TOCTOU bug obvious. The new method signatures use KResultOr, just like try_serialize_absolute_path() already did.
2021-10-28Kernel+LibC: Add support for the IPv4 TOS field via the IP_TOS sockoptIdan Horowitz
2021-10-28Kernel: Fix accidental memory over-read in getsockopt(IP_TTL)Idan Horowitz
We were accidentally casting the pointer to m_ttl from an u8* to an int* which resulted in copying of 3 extra unrelated bytes (which turned out to be padding in this case).
2021-10-18Kernel/Net: Generate interface name near construction pointLiav A
This change allows the Kernel to actually construct other interfaces besides the E1000 type. This solves a breakage that was introduced recently because of move semantics. A couple of points on this patch: 1. In current situation, we can waste time to create a KString and throw it for nothing. This patch ensures we only create it near construction point so we know we actually need it. 2. It's very likely to assume that non-x86 machines will expose network device with a device tree (or with ACPI). The raspberry pi machine is a good example of that. Therefore, each driver should explicitly ask the correct interface name generation method, and this patch simplifies this pattern greatly, especially in a case where the same network device can appear as a PCI device or as device in another bus type on the same platform target. For example, the (in)famous ne2000 device can be used either as a PCI device or as an ISA device, depending on the model. 3. In my opinion, it seems much more readable to construct the name near calling point of the object constructor than to just pass it with move semantics.
2021-10-08Kernel: Fix -Wunreachable-code warnings from clangNico Weber
2021-10-03Kernel: Use `operator ""sv` in all class_name() implementationsBrian Gianforcaro
Previously there was a mix of returning plain strings and returning explicit string views using `operator ""sv`. This change switches them all to standardized on `operator ""sv` as it avoids a call to strlen.
2021-10-01Kernel: Switch RTL8168NetworkAdapter::possible_device_name to StringViewBrian Gianforcaro
There is no need to allocate a `AK::String` for the device name, when the list of devices is entirely static.
2021-10-01Kernel: Convert network adapter names to Kernel::KStringBrian Gianforcaro
Another step of incremental progress of removing `AK::String` from the kernel, to harden against OOM.
2021-10-01Kernel: Move x86 IO instructions code into the x86 specific folderLiav A
2021-10-01Kernel: Fix a few typosNico Weber
2021-09-30Kernel: Implement getsockopt(SO_TYPE)Rodrigo Tobar
This is easy to implement, and is required by some applications like python's ssl module.
2021-09-29Kernel/PCI: Remove Address from enumeration callbackLiav A
If we need that address, we can always get it from the DeviceIdentifier.
2021-09-29Kernel/PCI: Cache interrupt line and interrupt pin of a deviceLiav A
This allows us to remove the PCI::get_interrupt_line API function. As a result, this removes a bunch of not so great patterns that we used to cache PCI interrupt line in many IRQHandler derived classes instead of just using interrupt_number method of IRQHandler class.
2021-09-29Kernel/PCI: Propagate usage of DeviceIdentifier everywhereLiav A
This allows us to remove a bunch of PCI API functions, and instead to leverage the cached data from DeviceIdentifier object in many places.
2021-09-29Kernel: Rename two PCI componentsLiav A
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
2021-09-29Kernel/PCI: Cache more details about PCI devices when enumerating themLiav A
There's no good reason to fetch these values each time we need them.
2021-09-18Kernel/Net: Enable usage of RTL8168E and RTL8168H in RTL8168 driverLiav A
I tested both (version 15 and 30 of the RTL8168 chipset) with PCI- passthrough of these cards, and they seem to work just fine with the driver.
2021-09-16Kernel: Use move to avoid unnecessary ref/unref of network device RefPtrBrian Gianforcaro
Flagged by pvs-studio as a potential perf optimization.
2021-09-16Kernel: Make IPv4SocketTuple operator== by referenceBrian Gianforcaro
No reason for this to copy when comparing equality.
2021-09-16Kernel: Weakly hold on to the file in LocalSocketsin-ack
Because we were holding a strong ref to the OpenFileDescription in LocalSocket and a strong ref to the LocalSocket in Inode, we were creating a reference cycle in the event of the socket being cleaned up after the file description did (i.e. unlinking the file before closing the socket), because the file description never got destructed.
2021-09-16Kernel: Drop the receive buffer when socket enters the TimeWait statesin-ack
The TimeWait state is intended to prevent another socket from taking the address tuple in case any packets are still in transit after the final close. Since this state never delivers packets to userspace, it doesn't make sense to keep the receive buffer around.
2021-09-15Kernel: Use move semantics in sys$sendfd()Andreas Kling
Avoid an unnecessary NonnullRefPtr<OpenFileDescription> copy.
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10Kernel: Fix null dereference in IPv4Socket::receive_packet_buffered()Andreas Kling
This was a mistake in the move away from KBuffer-as-a-value type. We need to check `packet` here, not `packet->data`. Regressed in b300f9aa2fd11796e63b5029008b33a1ae735928. Fixes #9888.
2021-09-08Kernel: Add KBuffer::bytes() and use itAndreas Kling
(Instead of hand-wrapping { data(), size() } in a bunch of places.)
2021-09-07Kernel: Remove KBuffer::try_copy() in favor of try_create_with_bytes()Andreas Kling
These were already equivalent, so let's only have one of them.
2021-09-07Kernel: Convert KBuffer::copy() => KBuffer::try_copy()Andreas Kling
This was a weird KBuffer API that assumed failure was impossible. This patch converts it to a modern KResultOr<NonnullOwnPtr<KBuffer>> API and updates the two clients to the new style.
2021-09-07Kernel: Make KBuffer::try_create_with_size() return KResultOrAndreas Kling
This allows us to use TRY() in a lot of new places.
2021-09-07Kernel: TCPSocket always has a scratch bufferAndreas Kling
Let's encode this in the constructor signature.
2021-09-07Kernel/Net: Add a special SOCKET_TRY() and use it in socket codeAndreas Kling
Sockets remember their last error code in the SO_ERROR field, so we need to take special care to remember this when returning an error. This patch adds a SOCKET_TRY() that works like TRY() but also calls set_so_error() on the failure path. There's probably a lot more code that should be using this, but that's outside the scope of this patch.
2021-09-07Kernel: Use TRY() some more in SocketAndreas Kling
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: Make DoubleBuffer::try() return KResultOrAndreas Kling
This tidies up error propagation in a number of places.
2021-09-07Kernel: Rename FileDescription => OpenFileDescriptionAndreas Kling
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
2021-09-07Kernel: Store process names as KStringAndreas Kling
2021-09-07Kernel: Make UserOrKernelBuffer return KResult from read/write/memsetAndreas Kling
This allows us to simplify a whole bunch of call sites with TRY(). :^)
2021-09-07Kernel/PCI: Simplify the entire subsystemLiav A
A couple of things were changed: 1. Semantic changes - PCI segments are now called PCI domains, to better match what they are really. It's also the name that Linux gave, and it seems that Wikipedia also uses this name. We also remove PCI::ChangeableAddress, because it was used in the past but now it's no longer being used. 2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as they made a bunch of unnecessary complexity. Instead, Windowed access is removed entirely (this was tested, but never was benchmarked), so we are left with IO access and memory access options. The memory access option is essentially mapping the PCI bus (from the chosen PCI domain), to virtual memory as-is. This means that unless needed, at any time, there is only one PCI bus being mapped, and this is changed if access to another PCI bus in the same PCI domain is needed. For now, we don't support mapping of different PCI buses from different PCI domains at the same time, because basically it's still a non-issue for most machines out there. 2. OOM-safety is increased, especially when constructing the Access object. It means that we pre-allocating any needed resources, and we try to find PCI domains (if requested to initialize memory access) after we attempt to construct the Access object, so it's possible to fail at this point "gracefully". 3. All PCI API functions are now separated into a different header file, which means only "clients" of the PCI subsystem API will need to include that header file. 4. Functional changes - we only allow now to enumerate the bus after a hardware scan. This means that the old method "enumerate_hardware" is removed, so, when initializing an Access object, the initializing function must call rescan on it to force it to find devices. This makes it possible to fail rescan, and also to defer it after construction from both OOM-safety terms and hotplug capabilities.