From 34473d63e22b785556847f90d1e1bb43b6124f6b Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 3 Apr 2006 11:57:12 +0000 Subject: Fix up locking surrounding tcp_drop sysctl: in the new world order, we don't free inpcbs until after the socket is closed, so we always need to unlock an inpcb after calling tcp_drop() on it. MFC after: 3 months --- sys/netinet/tcp_subr.c | 16 ++++++++-------- sys/netinet/tcp_timewait.c | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 8aab737..f64df61 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2339,15 +2339,15 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) } if (inp != NULL) { INP_LOCK(inp); - if ((tw = intotw(inp)) && - (inp->inp_vflag & INP_TIMEWAIT) != 0) { + if (inp->inp_vflag & INP_TIMEWAIT) { + tw = intotw(inp); tcp_twclose(tw, 0); - } else if ((tp = intotcpcb(inp)) && - ((inp->inp_socket->so_options & SO_ACCEPTCONN) == 0)) { - if (tcp_drop(tp, ECONNABORTED) != NULL) - INP_UNLOCK(inp); - } else - INP_UNLOCK(inp); + } else if (!(inp->inp_vflag & INP_DROPPED) && + !(inp->inp_socket->so_options & SO_ACCEPTCONN)) { + tp = intotcpcb(inp); + tcp_drop(tp, ECONNABORTED); + } + INP_UNLOCK(inp); } else error = ESRCH; INP_INFO_WUNLOCK(&tcbinfo); diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 8aab737..f64df61 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -2339,15 +2339,15 @@ sysctl_drop(SYSCTL_HANDLER_ARGS) } if (inp != NULL) { INP_LOCK(inp); - if ((tw = intotw(inp)) && - (inp->inp_vflag & INP_TIMEWAIT) != 0) { + if (inp->inp_vflag & INP_TIMEWAIT) { + tw = intotw(inp); tcp_twclose(tw, 0); - } else if ((tp = intotcpcb(inp)) && - ((inp->inp_socket->so_options & SO_ACCEPTCONN) == 0)) { - if (tcp_drop(tp, ECONNABORTED) != NULL) - INP_UNLOCK(inp); - } else - INP_UNLOCK(inp); + } else if (!(inp->inp_vflag & INP_DROPPED) && + !(inp->inp_socket->so_options & SO_ACCEPTCONN)) { + tp = intotcpcb(inp); + tcp_drop(tp, ECONNABORTED); + } + INP_UNLOCK(inp); } else error = ESRCH; INP_INFO_WUNLOCK(&tcbinfo); -- cgit v1.1