Current-Users archive

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

sockaddr_un.sun_path length



Hi,

The sockaddr_un.sun_path length is currently fixed at
104 characters in NetBSD (as well as FreeBSD and
macOS, at least).  FreeBSD uses a 'define' for this
value, together with an explanatory comment, which I
find rather useful:

/*
 * Historically, (struct sockaddr) needed to fit
 * inside an mbuf.  For this reason, UNIX domain
 * sockets were therefore limited to 104 bytes. While
 * this limit is no longer necessary, it is kept for
 * binary compatibility reasons.
 */
#define	SUNPATHLEN	104

Any objections to adopting this for NetBSD?


Additionally, does anybody know why Linux chose 108
bytes?

-Jan
Index: un.h
===================================================================
RCS file: /cvsroot/src/sys/sys/un.h,v
retrieving revision 1.60
diff -u -p -r1.60 un.h
--- un.h	8 Aug 2021 20:54:49 -0000	1.60
+++ un.h	6 Nov 2023 21:55:37 -0000
@@ -44,12 +44,20 @@ typedef __sa_family_t	sa_family_t;
 #endif
 
 /*
+ * Historically, (struct sockaddr) needed to fit inside an mbuf.
+ * For this reason, UNIX domain sockets were therefore limited to
+ * 104 bytes. While this limit is no longer necessary, it is kept for
+ * binary compatibility reasons.
+ */
+#define	SUNPATHLEN	104
+
+/*
  * Definitions for UNIX IPC domain.
  */
 struct	sockaddr_un {
-	uint8_t		sun_len;	/* total sockaddr length */
-	sa_family_t	sun_family;	/* AF_LOCAL */
-	char		sun_path[104];	/* path name (gag) */
+	uint8_t		sun_len;		/* total sockaddr length */
+	sa_family_t	sun_family;		/* AF_LOCAL */
+	char		sun_path[SUNPATHLEN];	/* path name (gag) */
 };
 
 /*


Home | Main Index | Thread Index | Old Index