aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorAndre Oppermann <andre@FreeBSD.org>2012-10-29 12:14:57 +0000
committerAndre Oppermann <andre@FreeBSD.org>2012-10-29 12:14:57 +0000
commitfdd1b7f52a5a57cb4e0652ddd6cc77e019ca6b0a (patch)
treeb5360a7cfc266971e2a0c41bdbccc667b06c07c9 /sys/kern/uipc_socket.c
parent2ef2a0863788623722de0758716108002ada5316 (diff)
downloadsrc-fdd1b7f52a5a57cb4e0652ddd6cc77e019ca6b0a.tar.gz
src-fdd1b7f52a5a57cb4e0652ddd6cc77e019ca6b0a.zip
Add logging for socket attach failures in sonewconn() during accept(2).
Include the pointer to the PCB so it can be attributed to a particular application by corresponding it to "netstat -A" output. MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=242306
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 1943c5dac0e2..e6b7bac93236 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -135,6 +135,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/jail.h>
+#include <sys/syslog.h>
#include <net/vnet.h>
@@ -500,16 +501,24 @@ sonewconn(struct socket *head, int connstatus)
over = (head->so_qlen > 3 * head->so_qlimit / 2);
ACCEPT_UNLOCK();
#ifdef REGRESSION
- if (regression_sonewconn_earlytest && over)
+ if (regression_sonewconn_earlytest && over) {
#else
- if (over)
+ if (over) {
#endif
+ log(LOG_DEBUG, "%s: pcb %p: Listen queue overflow: "
+ "%i already in queue awaiting acceptance\n",
+ __func__, head->so_pcb, over);
return (NULL);
+ }
VNET_ASSERT(head->so_vnet != NULL, ("%s:%d so_vnet is NULL, head=%p",
__func__, __LINE__, head));
so = soalloc(head->so_vnet);
- if (so == NULL)
+ if (so == NULL) {
+ log(LOG_DEBUG, "%s: pcb %p: New socket allocation failure: "
+ "limit reached or out of memory\n",
+ __func__, head->so_pcb);
return (NULL);
+ }
if ((head->so_options & SO_ACCEPTFILTER) != 0)
connstatus = 0;
so->so_head = head;
@@ -526,9 +535,16 @@ sonewconn(struct socket *head, int connstatus)
knlist_init_mtx(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv));
knlist_init_mtx(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd));
VNET_SO_ASSERT(head);
- if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) ||
- (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
+ if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat)) {
+ sodealloc(so);
+ log(LOG_DEBUG, "%s: pcb %p: soreserve() failed\n",
+ __func__, head->so_pcb);
+ return (NULL);
+ }
+ if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
sodealloc(so);
+ log(LOG_DEBUG, "%s: pcb %p: pru_attach() failed\n",
+ __func__, head->so_pcb);
return (NULL);
}
so->so_rcv.sb_lowat = head->so_rcv.sb_lowat;