Ver código fonte

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.
Andreas Kling 4 anos atrás
pai
commit
51f88cb00d
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      Kernel/Net/IPv4Socket.cpp

+ 2 - 2
Kernel/Net/IPv4Socket.cpp

@@ -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);