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.
This commit is contained in:
Andreas Kling 2021-05-01 00:03:33 +02:00
parent 8fac7a1d5d
commit 51f88cb00d
Notes: sideshowbarker 2024-07-18 18:51:04 +09:00

View file

@ -109,7 +109,7 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> 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<size_t> 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);