diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-04-03 11:57:12 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-04-03 11:57:12 +0000 |
commit | 34473d63e22b785556847f90d1e1bb43b6124f6b (patch) | |
tree | b84d04f778d7a8ba926e4f7e28a304dbd5109ca5 /sys | |
parent | 89f96065624cd9f84c37377fd81d4987b375bffb (diff) | |
download | FreeBSD-src-34473d63e22b785556847f90d1e1bb43b6124f6b.zip FreeBSD-src-34473d63e22b785556847f90d1e1bb43b6124f6b.tar.gz |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/tcp_subr.c | 16 | ||||
-rw-r--r-- | 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); |