From 51f88cb00d0ab221223b6eea1bc28e133e9d282a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 1 May 2021 00:03:33 +0200 Subject: [PATCH] Kernel/IPv4: Unbreak raw socket (port allocation failing is OK) Raw sockets don't need a local port, so we shouldn't fail operations if allocation yields an ENOPROTOOPT. I'm not in love with the factoring here, just patching up the bug. --- Kernel/Net/IPv4Socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index ef316b5d8a..d59a327a8b 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -109,7 +109,7 @@ KResult IPv4Socket::bind(Userspace user_address, socklen_t addr KResult IPv4Socket::listen(size_t backlog) { Locker locker(lock()); - if (auto result = allocate_local_port_if_needed(); result.is_error()) + if (auto result = allocate_local_port_if_needed(); result.is_error() && result.error() != -ENOPROTOOPT) return result.error(); set_backlog(backlog); @@ -198,7 +198,7 @@ KResultOr IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer& if (m_local_address.to_u32() == 0) m_local_address = routing_decision.adapter->ipv4_address(); - if (auto result = allocate_local_port_if_needed(); result.is_error()) + if (auto result = allocate_local_port_if_needed(); result.is_error() && result.error() != -ENOPROTOOPT) return result.error(); dbgln_if(IPV4_SOCKET_DEBUG, "sendto: destination={}:{}", m_peer_address, m_peer_port);