Skip to contentSkip to conversation

clarify code intent

PATCH Mathieu Lacage 3 participants 5 messages Sep 18, 2008 – Sep 23, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

net/unix/af_unix.c +1 -1
index 015606b..efa725e 100644
@@ -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;
 	}
maintainer
#1 lore raw

From: Mathieu Lacage <[email protected]>
Date: Thu, 18 Sep 2008 10:07:48 -0700

Quoted 2 lines

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 <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected]
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 <[email protected]>
Date: Sat, 26 Apr 2008 02:44:45 +0100

Quoted 4 lines

AF_UNIX: make unix_getname use sizeof(sunaddr->sun_family) instead of sizeof(short).

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.

#2 lore raw
Quoted 2 lines · David Miller

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

maintainer
#3 lore raw

From: Mathieu Lacage <[email protected]>
Date: Thu, 18 Sep 2008 16:53:40 -0700

Quoted 9 lines · David Miller
Quoted 3 lines

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.

#4 lore raw
In reply to Mathieu Lacage
Quoted 6 lines · Mathieu Lacage

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 [email protected]

-Andi