Make the path length of UNIX domain sockets

specified by a #define. Also, add a comment describing the historical context
for this length.

Reviewed by:	bz, jhb, kbowling (previous version)
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D24272
This commit is contained in:
Jonathan T. Looney 2020-04-14 15:27:24 +00:00 committed by Sebastian Huber
parent 86484e84d7
commit 09e5cb57a0
1 changed files with 9 additions and 1 deletions

View File

@ -43,13 +43,21 @@ typedef __sa_family_t sa_family_t;
#define _SA_FAMILY_T_DECLARED #define _SA_FAMILY_T_DECLARED
#endif #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. * Definitions for UNIX IPC domain.
*/ */
struct sockaddr_un { struct sockaddr_un {
unsigned char sun_len; /* sockaddr len including null */ unsigned char sun_len; /* sockaddr len including null */
sa_family_t sun_family; /* AF_UNIX */ sa_family_t sun_family; /* AF_UNIX */
char sun_path[104]; /* path name (gag) */ char sun_path[SUNPATHLEN]; /* path name (gag) */
}; };
#if __BSD_VISIBLE #if __BSD_VISIBLE