Index: sys/kern/uipc_socket.c =================================================================== --- sys/kern/uipc_socket.c +++ sys/kern/uipc_socket.c @@ -140,9 +140,12 @@ #include #include #include +#include +#include #include #include #include +#include #include #include @@ -589,6 +592,8 @@ struct socket *so; u_int over; + char descr[SUNPATHLEN + strlen("local") + 1]; + int descrlen, len; SOLISTEN_LOCK(head); over = (head->sol_qlen > 3 * head->sol_qlimit / 2); @@ -601,10 +606,79 @@ overcount++; if (ratecheck(&lastover, &overinterval)) { - log(LOG_DEBUG, "%s: pcb %p: Listen queue overflow: " + /* + * Try to print something descriptive about the + * socket for the error message. + */ + switch (head->so_proto->pr_domain->dom_family) { +#if defined(INET) || defined(INET6) +#ifdef INET + case AF_INET: +#endif +#ifdef INET6 + case AF_INET6: + if (head->so_proto->pr_domain->dom_family == + AF_INET6 || + (sotoinpcb(head)->inp_inc.inc_flags & + INC_ISIPV6)) { + descr[0] = '['; + ip6_sprintf(descr + 1, + &sotoinpcb(head)->inp_inc.inc6_laddr); + descrlen = strlen(descr); + descr[descrlen++] = ']'; + } else +#endif + { +#ifdef INET + inet_ntoa_r( + sotoinpcb(head)->inp_inc.inc_laddr, + descr); + descrlen = strlen(descr); +#endif + } + len = snprintf(descr + descrlen, + sizeof(descr) - descrlen, ":%hu (proto %u)", + ntohs(sotoinpcb(head)->inp_inc.inc_lport), + head->so_proto->pr_protocol); + if (len < 0 || descrlen + len >= sizeof(descr)) + descr[0] = '\0'; + break; +#endif /* INET || INET6 */ + case AF_UNIX: + strcpy(descr, "local:"); + if (sotounpcb(head)->unp_addr != NULL) + len = + sotounpcb(head)->unp_addr->sun_len - + offsetof(struct sockaddr_un, + sun_path); + else + len = 0; + if (len > 0) { + memcpy(descr + 6, + sotounpcb(head)->unp_addr->sun_path, + len); + descr[6 + len] = '\0'; + } else + strcat(descr, "(unknown)"); + break; + default: + descr[0] = '\0'; + break; + } + /* + * If we can't print something more specific, at least + * print the domain name. + */ + if (descr[0] == '\0') + snprintf(descr, sizeof(descr), "%s", + head->so_proto->pr_domain->dom_name ?: + "unknown"); + log(LOG_DEBUG, + "%s: pcb %p (%s): Listen queue overflow: " "%i already in queue awaiting acceptance " "(%d occurrences)\n", - __func__, head->so_pcb, head->sol_qlen, overcount); + __func__, head->so_pcb, descr, head->sol_qlen, + overcount); overcount = 0; } Index: sys/sys/un.h =================================================================== --- sys/sys/un.h +++ sys/sys/un.h @@ -43,13 +43,15 @@ #define _SA_FAMILY_T_DECLARED #endif +#define SUNPATHLEN 104 + /* * Definitions for UNIX IPC domain. */ struct sockaddr_un { unsigned char sun_len; /* sockaddr len including null */ sa_family_t sun_family; /* AF_UNIX */ - char sun_path[104]; /* path name (gag) */ + char sun_path[SUNPATHLEN]; /* path name (gag) */ }; #if __BSD_VISIBLE