bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pflocal socket bug


From: Svante Signell
Subject: Re: pflocal socket bug
Date: Fri, 11 Sep 2015 19:50:21 +0200

On Fri, 2015-09-11 at 17:43 +0200, Samuel Thibault wrote:
> Svante Signell, le Fri 11 Sep 2015 17:42:19 +0200, a écrit :
> > It seems like EADDRNOTAVAIL is an appropriate error,
> 
> It is appropriate according to POSIX.
> 
> > Otherwise I can create a patch for the socklog package. WDYT?
> 
> That makes sense since POSIX allows it.

Well, the Linux manpage for connect says:
EADDRNOTAVAIL
(Internet domain sockets) The socket referred to by sockfd had not
previously been bound to an address and, upon attempting to bind it to
an ephemeral port, it was determined that all port numbers in the
ephemeral port range are currently in use. See the discussion
of /proc/sys/net/ipv4/ip_local_port_range in ip(7).
Note the comment: (Internet domain sockets), i.e. AF_INET not AF_UNIX.
ECONNREFUSED
  No-one listening on the remote address.

While POSIX says:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html
[EADDRNOTAVAIL]
        The specified address is not available from the local machine.
[ECONNREFUSED]
        The target address was not listening for connections or refused
        the connection request.

To me the best explanation is "No-one listening on the remote address."
and "The target address was not listening for connections or refused the
connection request." Additionally it is related to connect() by the
error name itself.

The Hurd patch is very simple:
--- pflocal/socket.c~    2015-09-11 19:46:33.000000000 +0200
+++ pflocal/socket.c    2015-09-11 19:44:33.000000000 +0200
@@ -118,6 +118,8 @@
     return EOPNOTSUPP;
 
   err = addr_get_sock (addr, &peer);
+  if (err == EADDRNOTAVAIL)
+    err = ECONNREFUSED;--- pflocal/socket.c    2015-09-11
19:46:33.000000000 +0200
+++ pflocal/socket.c    2015-09-11 19:44:33.000000000 +0200
@@ -118,6 +118,8 @@
     return EOPNOTSUPP;
 
   err = addr_get_sock (addr, &peer);
+  if (err == EADDRNOTAVAIL)
+    err = ECONNREFUSED;
   if (!err)
     {
       struct sock *sock = user->sock;

   if (!err)
     {
       struct sock *sock = user->sock;

Additionally the following removes the declaration warning:
--- pflocal/sock.h~     2015-09-11 16:28:10.000000000 +0200
+++ pflocal/sock.h      2015-09-11 19:28:46.000000000 +0200
@@ -84,6 +84,9 @@
   struct connq *connect_queue;
 };
 
+/* Bind SOCK to ADDR.  */
+error_t sock_bind (struct sock *sock, struct addr *addr);
+
 /* Socket flags */
 #define PFLOCAL_SOCK_CONNECTED         0x1 /* A connected
connection-oriented sock. */
 #define PFLOCAL_SOCK_NONBLOCK          0x2 /* Don't block on I/O.  */
@@ -154,9 +157,6 @@
 /* Return a new user port on SOCK in PORT.  */
 error_t sock_create_port (struct sock *sock, mach_port_t *port);
 
-/* Bind SOCK to ADDR.  */
-error_t sock_bind (struct sock *sock, struct addr *addr);
-
 /* Returns SOCK's address in ADDR, with an additional reference added.
If
    SOCK doesn't currently have an address, one is fabricated first.  */
 error_t sock_get_addr (struct sock *sock, struct addr **addr);

Why not align to other OSes?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]