Patchwork clarify code intent

login
register
mail settings
Submitter Mathieu Lacage
Date Sept. 18, 2008, 5:07 p.m.
Message ID <1221757668.23007.12.camel@ns-test>
Download mbox | patch
Permalink /patch/540/
State Rejected
Headers show

Comments

Mathieu Lacage - Sept. 18, 2008, 5:07 p.m.
hi,

The attached patch hopefully clarifies the intent of the unix_bind
function in net/unix/af_unix.c. That 'feature' (the ability to delegate
the endpoint allocation to the kernel with bind by sending a
sockaddr_un.sun_family = AF_UNIX rather than have to wait until the
autobind is triggered by a later call to send) would be nice to document
in the unix '7' manpage but, I have no idea where these are maintained.
I also have no idea whether that specific 'feature' is common among
other unixes. It is quite useful though.

Mathieu
David Miller - Sept. 18, 2008, 11:36 p.m.
From: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Date: Thu, 18 Sep 2008 10:07:48 -0700

> The attached patch hopefully clarifies the intent of the unix_bind
> function in net/unix/af_unix.c.

I've rejected this patch over and over in the past, and nothing
has happened to change my mind since then.

----------------------------------------
Subject: Re: [PATCH,TRIVIAL] AF_UNIX, accept() and addrlen
From: David Miller <davem@davemloft.net>
To: samuel.thibault@ens-lyon.org
Cc: mtk.manpages@gmail.com, mtk.manpages@googlemail.com,
 andi@firstfloor.org, linux-kernel@vger.kernel.org
Date: Sat, 26 Apr 2008 22:54:32 -0700 (PDT)
X-Mailer: Mew version 5.2 on Emacs 22.1 / Mule 5.0 (SAKAKI)

From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Sat, 26 Apr 2008 02:44:45 +0100

> AF_UNIX: make unix_getname use sizeof(sunaddr->sun_family) instead of
> sizeof(short).
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

This is just syntactic masterbation, sa_family_t is typedef'd
"unsigned short".

No system on planet earth providing the BSD sockets API uses
anything other than uint16_t or unsigned short for this.

Sorry, I'm not applying this.
Mathieu Lacage - Sept. 18, 2008, 11:53 p.m.
On Thu, 2008-09-18 at 16:36 -0700, David Miller wrote:

> This is just syntactic masterbation, sa_family_t is typedef'd
> "unsigned short".

Would you take a patch to remove sa_family_t from the kernel code and
headers ? Otherwise, I suspect that you can understand that it is a bit
hard for others to figure out where it is appropriate to use it and
where it is not.

regards,
Mathieu
David Miller - Sept. 18, 2008, 11:59 p.m.
From: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Date: Thu, 18 Sep 2008 16:53:40 -0700

> On Thu, 2008-09-18 at 16:36 -0700, David Miller wrote:
> 
> > This is just syntactic masterbation, sa_family_t is typedef'd
> > "unsigned short".
> 
> Would you take a patch to remove sa_family_t from the kernel code and
> headers ? Otherwise, I suspect that you can understand that it is a bit
> hard for others to figure out where it is appropriate to use it and
> where it is not.

No, that would break older userspace.
Andi Kleen - Sept. 23, 2008, 12:29 a.m.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr> writes:

> The attached patch hopefully clarifies the intent of the unix_bind
> function in net/unix/af_unix.c. That 'feature' (the ability to delegate
> the endpoint allocation to the kernel with bind by sending a
> sockaddr_un.sun_family = AF_UNIX rather than have to wait until the
> autobind is triggered by a later call to send) would be nice to document
> in the unix '7' manpage but, I have no idea where these are maintained.

They are maintained by the manpage maintainer mtk.manpages@googlemail.com

-Andi
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 015606b..efa725e 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -777,7 +777,7 @@  static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	if (sunaddr->sun_family != AF_UNIX)
 		goto out;
 
-	if (addr_len==sizeof(short)) {
+	if (addr_len==sizeof(sa_family_t)) {
 		err = unix_autobind(sock);
 		goto out;
 	}