Convert pcbinfo and inpcb mutexes to rwlocks, and modify macros to
explicitly select write locking for all use of the inpcb mutex. Update some pcbinfo lock assertions to assert locked rather than write-locked, although in practice almost all uses of the pcbinfo rwlock main exclusive, and all instances of inpcb lock acquisition are exclusive. This change should introduce (ideally) little functional change. However, it lays the groundwork for significantly increased parallelism in the TCP/IP code. MFC after: 3 months Tested by: kris (superset of committered patch)
This commit is contained in:
parent
f55f27f862
commit
8501a69cc9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178285
@ -2915,7 +2915,7 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
|
||||
pd->lookup.pid = NO_PID; /* XXX: revisit */
|
||||
#ifdef __FreeBSD__
|
||||
if (inp_arg != NULL) {
|
||||
INP_LOCK_ASSERT(inp_arg);
|
||||
INP_WLOCK_ASSERT(inp_arg);
|
||||
if (inp_arg->inp_socket) {
|
||||
pd->lookup.uid = inp_arg->inp_socket->so_cred->cr_uid;
|
||||
pd->lookup.gid =
|
||||
@ -3018,15 +3018,15 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
|
||||
return (-1);
|
||||
}
|
||||
#ifdef __FreeBSD__
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_socket == NULL) || (inp->inp_socket->so_cred == NULL)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(pi);
|
||||
return (-1);
|
||||
}
|
||||
pd->lookup.uid = inp->inp_socket->so_cred->cr_uid;
|
||||
pd->lookup.gid = inp->inp_socket->so_cred->cr_groups[0];
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(pi);
|
||||
#else
|
||||
pd->lookup.uid = inp->inp_socket->so_euid;
|
||||
|
@ -336,9 +336,9 @@ copy_data(const struct mbuf *m, int offset, int len, struct uio *uio)
|
||||
static void
|
||||
cxgb_wait_dma_completion(struct toepcb *toep)
|
||||
{
|
||||
struct mtx *lock;
|
||||
struct rwlock *lock;
|
||||
|
||||
lock = &toep->tp_tp->t_inpcb->inp_mtx;
|
||||
lock = &toep->tp_tp->t_inpcb->inp_lock;
|
||||
inp_wlock(toep->tp_tp->t_inpcb);
|
||||
cv_wait_unlock(&toep->tp_cv, lock);
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ static struct witness_order_list_entry order_lists[] = {
|
||||
/*
|
||||
* Multicast - protocol locks before interface locks, after UDP locks.
|
||||
*/
|
||||
{ "udpinp", &lock_class_mtx_sleep },
|
||||
{ "udpinp", &lock_class_rw },
|
||||
{ "in_multi_mtx", &lock_class_mtx_sleep },
|
||||
{ "igmp_mtx", &lock_class_mtx_sleep },
|
||||
{ "if_addr_mtx", &lock_class_mtx_sleep },
|
||||
@ -360,15 +360,15 @@ static struct witness_order_list_entry order_lists[] = {
|
||||
/*
|
||||
* UDP/IP
|
||||
*/
|
||||
{ "udp", &lock_class_mtx_sleep },
|
||||
{ "udpinp", &lock_class_mtx_sleep },
|
||||
{ "udp", &lock_class_rw },
|
||||
{ "udpinp", &lock_class_rw },
|
||||
{ "so_snd", &lock_class_mtx_sleep },
|
||||
{ NULL, NULL },
|
||||
/*
|
||||
* TCP/IP
|
||||
*/
|
||||
{ "tcp", &lock_class_mtx_sleep },
|
||||
{ "tcpinp", &lock_class_mtx_sleep },
|
||||
{ "tcp", &lock_class_rw },
|
||||
{ "tcpinp", &lock_class_rw },
|
||||
{ "so_snd", &lock_class_mtx_sleep },
|
||||
{ NULL, NULL },
|
||||
/*
|
||||
|
@ -651,7 +651,7 @@ inp_change_source_filter(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
|
||||
out_locked:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -667,11 +667,11 @@ inp_findmoptions(struct inpcb *inp)
|
||||
struct in_mfilter *imfp;
|
||||
size_t idx;
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_moptions != NULL)
|
||||
return (inp->inp_moptions);
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
imo = (struct ip_moptions *)malloc(sizeof(*imo), M_IPMOPTS,
|
||||
M_WAITOK);
|
||||
@ -698,7 +698,7 @@ inp_findmoptions(struct inpcb *inp)
|
||||
}
|
||||
imo->imo_mfilters = imfp;
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_moptions != NULL) {
|
||||
free(imfp, M_IPMSOURCE);
|
||||
free(immp, M_IPMOPTS);
|
||||
@ -762,12 +762,12 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
int error;
|
||||
size_t idx;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
imo = inp->inp_moptions;
|
||||
KASSERT(imo != NULL, ("%s: null ip_moptions", __func__));
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
error = sooptcopyin(sopt, &msfr, sizeof(struct __msfilterreq),
|
||||
sizeof(struct __msfilterreq));
|
||||
@ -781,7 +781,7 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
if (ifp == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
/*
|
||||
* Lookup group on the socket.
|
||||
@ -789,7 +789,7 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
gsa = (sockunion_t *)&msfr.msfr_group;
|
||||
idx = imo_match_group(imo, ifp, &gsa->sa);
|
||||
if (idx == -1 || imo->imo_mfilters == NULL) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (EADDRNOTAVAIL);
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
}
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
if (tss != NULL) {
|
||||
error = copyout(tss, msfr.msfr_srcs,
|
||||
@ -855,7 +855,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
int error, optval;
|
||||
u_char coptval;
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
imo = inp->inp_moptions;
|
||||
/*
|
||||
* If socket is neither of type SOCK_RAW or SOCK_DGRAM,
|
||||
@ -864,7 +864,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
if (inp->inp_socket->so_proto->pr_protocol == IPPROTO_DIVERT ||
|
||||
(inp->inp_socket->so_proto->pr_type != SOCK_RAW &&
|
||||
inp->inp_socket->so_proto->pr_type != SOCK_DGRAM)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
optval = imo->imo_multicast_vif;
|
||||
else
|
||||
optval = -1;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof(int));
|
||||
break;
|
||||
|
||||
@ -894,7 +894,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
}
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (sopt->sopt_valsize == sizeof(struct ip_mreqn)) {
|
||||
error = sooptcopyout(sopt, &mreqn,
|
||||
sizeof(struct ip_mreqn));
|
||||
@ -909,7 +909,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
optval = coptval = IP_DEFAULT_MULTICAST_TTL;
|
||||
else
|
||||
optval = coptval = imo->imo_multicast_ttl;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (sopt->sopt_valsize == sizeof(u_char))
|
||||
error = sooptcopyout(sopt, &coptval, sizeof(u_char));
|
||||
else
|
||||
@ -921,7 +921,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
optval = coptval = IP_DEFAULT_MULTICAST_LOOP;
|
||||
else
|
||||
optval = coptval = imo->imo_multicast_loop;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (sopt->sopt_valsize == sizeof(u_char))
|
||||
error = sooptcopyout(sopt, &coptval, sizeof(u_char));
|
||||
else
|
||||
@ -931,14 +931,14 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
case IP_MSFILTER:
|
||||
if (imo == NULL) {
|
||||
error = EADDRNOTAVAIL;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else {
|
||||
error = inp_get_source_filters(inp, sopt);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = ENOPROTOOPT;
|
||||
break;
|
||||
}
|
||||
@ -1192,14 +1192,14 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
|
||||
* to prevent a lock order reversal.
|
||||
*/
|
||||
--imo->imo_num_memberships;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
in_delmulti(inm);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
|
||||
out_locked:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1382,7 +1382,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
|
||||
imo->imo_num_memberships--;
|
||||
|
||||
out_locked:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1454,7 +1454,7 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
|
||||
imo = inp_findmoptions(inp);
|
||||
imo->imo_multicast_ifp = ifp;
|
||||
imo->imo_multicast_addr.s_addr = INADDR_ANY;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -1545,7 +1545,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
* in order to satisfy a malloc request.
|
||||
* We will re-take it before changing socket state.
|
||||
*/
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
#ifdef DIAGNOSTIC
|
||||
if (bootverbose) {
|
||||
printf("%s: loading %lu source list entries\n",
|
||||
@ -1646,7 +1646,7 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
* Re-take the inp lock; we are changing socket state.
|
||||
*/
|
||||
pkss = kss;
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
for (i = 0; i < msfr.msfr_nsrcs; i++, pkss++) {
|
||||
memcpy(&(pnims[i]->ims_addr), pkss,
|
||||
sizeof(struct sockaddr_storage));
|
||||
@ -1661,11 +1661,11 @@ inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
|
||||
/*
|
||||
* Update the filter mode on the socket before releasing the inpcb.
|
||||
*/
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
imf->imf_fmode = msfr.msfr_fmode;
|
||||
|
||||
out_locked:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1716,7 +1716,7 @@ inp_setmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
imo = inp_findmoptions(inp);
|
||||
imo->imo_multicast_vif = vifi;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1753,7 +1753,7 @@ inp_setmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
imo = inp_findmoptions(inp);
|
||||
imo->imo_multicast_ttl = ttl;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1782,7 +1782,7 @@ inp_setmoptions(struct inpcb *inp, struct sockopt *sopt)
|
||||
}
|
||||
imo = inp_findmoptions(inp);
|
||||
imo->imo_multicast_loop = !!loop;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
|
||||
if (ip6_auto_flowlabel)
|
||||
inp->inp_flags |= IN6P_AUTOFLOWLABEL;
|
||||
#endif
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
|
||||
|
||||
#if defined(IPSEC) || defined(MAC)
|
||||
@ -235,7 +235,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred)
|
||||
int anonport, error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (inp->inp_lport != 0 || inp->inp_laddr.s_addr != INADDR_ANY)
|
||||
return (EINVAL);
|
||||
@ -278,7 +278,11 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
|
||||
int error, prison = 0;
|
||||
int dorandom;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
/*
|
||||
* Because no actual state changes occur here, a write global write
|
||||
* lock on the pcbinfo isn't required.
|
||||
*/
|
||||
INP_INFO_LOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
if (TAILQ_EMPTY(&in_ifaddrhead)) /* XXX broken! */
|
||||
@ -484,7 +488,7 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred)
|
||||
int anonport, error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
lport = inp->inp_lport;
|
||||
laddr = inp->inp_laddr.s_addr;
|
||||
@ -546,7 +550,11 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
|
||||
u_short lport, fport;
|
||||
int error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
/*
|
||||
* Because a global state change doesn't actually occur here, a read
|
||||
* lock is sufficient.
|
||||
*/
|
||||
INP_INFO_LOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
|
||||
if (oinpp != NULL)
|
||||
@ -666,7 +674,7 @@ in_pcbdisconnect(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
inp->inp_faddr.s_addr = INADDR_ANY;
|
||||
inp->inp_fport = 0;
|
||||
@ -695,8 +703,9 @@ in_pcbfree(struct inpcb *inp)
|
||||
struct inpcbinfo *ipi = inp->inp_pcbinfo;
|
||||
|
||||
KASSERT(inp->inp_socket == NULL, ("in_pcbfree: inp_socket != NULL"));
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(ipi);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef IPSEC
|
||||
ipsec4_delete_pcbpolicy(inp);
|
||||
@ -712,7 +721,7 @@ in_pcbfree(struct inpcb *inp)
|
||||
#ifdef MAC
|
||||
mac_inpcb_destroy(inp);
|
||||
#endif
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
uma_zfree(ipi->ipi_zone, inp);
|
||||
}
|
||||
|
||||
@ -727,7 +736,7 @@ in_pcbdrop(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
inp->inp_vflag |= INP_DROPPED;
|
||||
if (inp->inp_lport) {
|
||||
@ -771,10 +780,10 @@ in_getsockaddr(struct socket *so, struct sockaddr **nam)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in_getsockaddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
port = inp->inp_lport;
|
||||
addr = inp->inp_laddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
*nam = in_sockaddr(port, &addr);
|
||||
return 0;
|
||||
@ -790,10 +799,10 @@ in_getpeeraddr(struct socket *so, struct sockaddr **nam)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in_getpeeraddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
port = inp->inp_fport;
|
||||
addr = inp->inp_faddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
*nam = in_sockaddr(port, &addr);
|
||||
return 0;
|
||||
@ -807,20 +816,20 @@ in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr faddr, int errno,
|
||||
|
||||
INP_INFO_WLOCK(pcbinfo);
|
||||
LIST_FOREACH_SAFE(inp, pcbinfo->ipi_listhead, inp_list, inp_temp) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
#ifdef INET6
|
||||
if ((inp->inp_vflag & INP_IPV4) == 0) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (inp->inp_faddr.s_addr != faddr.s_addr ||
|
||||
inp->inp_socket == NULL) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
if ((*notify)(inp, errno))
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_WUNLOCK(pcbinfo);
|
||||
}
|
||||
@ -834,7 +843,7 @@ in_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
|
||||
INP_INFO_RLOCK(pcbinfo);
|
||||
LIST_FOREACH(inp, pcbinfo->ipi_listhead, inp_list) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
imo = inp->inp_moptions;
|
||||
if ((inp->inp_vflag & INP_IPV4) &&
|
||||
imo != NULL) {
|
||||
@ -860,7 +869,7 @@ in_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
}
|
||||
imo->imo_num_memberships -= gap;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(pcbinfo);
|
||||
}
|
||||
@ -882,7 +891,7 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
|
||||
int wildcard;
|
||||
u_short lport = lport_arg;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_INFO_LOCK_ASSERT(pcbinfo);
|
||||
|
||||
if (!wild_okay) {
|
||||
struct inpcbhead *head;
|
||||
@ -989,7 +998,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr,
|
||||
struct inpcb *inp;
|
||||
u_short fport = fport_arg, lport = lport_arg;
|
||||
|
||||
INP_INFO_RLOCK_ASSERT(pcbinfo);
|
||||
INP_INFO_LOCK_ASSERT(pcbinfo);
|
||||
|
||||
/*
|
||||
* First look for an exact match.
|
||||
@ -1064,7 +1073,7 @@ in_pcbinshash(struct inpcb *inp)
|
||||
u_int32_t hashkey_faddr;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef INET6
|
||||
if (inp->inp_vflag & INP_IPV6)
|
||||
@ -1118,7 +1127,7 @@ in_pcbrehash(struct inpcb *inp)
|
||||
u_int32_t hashkey_faddr;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef INET6
|
||||
if (inp->inp_vflag & INP_IPV6)
|
||||
@ -1143,7 +1152,7 @@ in_pcbremlists(struct inpcb *inp)
|
||||
struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
|
||||
if (inp->inp_lport) {
|
||||
@ -1173,11 +1182,11 @@ in_pcbsosetlabel(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in_pcbsosetlabel: so->so_pcb == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
SOCK_LOCK(so);
|
||||
mac_inpcb_sosetlabel(so, inp);
|
||||
SOCK_UNLOCK(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1205,28 +1214,28 @@ void
|
||||
inp_wlock(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
}
|
||||
|
||||
void
|
||||
inp_wunlock(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
|
||||
void
|
||||
inp_rlock(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
}
|
||||
|
||||
void
|
||||
inp_runlock(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
|
||||
#ifdef INVARIANTS
|
||||
@ -1234,7 +1243,7 @@ void
|
||||
inp_lock_assert(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -36,9 +36,14 @@
|
||||
#include <sys/queue.h>
|
||||
#include <sys/_lock.h>
|
||||
#include <sys/_mutex.h>
|
||||
#include <sys/_rwlock.h>
|
||||
|
||||
#include <net/route.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/rwlock.h>
|
||||
#endif
|
||||
|
||||
#define in6pcb inpcb /* for KAME src sync over BSD*'s */
|
||||
#define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
|
||||
struct inpcbpolicy;
|
||||
@ -171,7 +176,7 @@ struct inpcb {
|
||||
struct inpcbport *inp_phd; /* head of this list */
|
||||
#define inp_zero_size offsetof(struct inpcb, inp_gencnt)
|
||||
inp_gen_t inp_gencnt; /* generation count of this instance */
|
||||
struct mtx inp_mtx;
|
||||
struct rwlock inp_lock;
|
||||
|
||||
#define in6p_faddr inp_inc.inc6_faddr
|
||||
#define in6p_laddr inp_inc.inc6_laddr
|
||||
@ -264,7 +269,7 @@ struct inpcbinfo {
|
||||
* or freed.
|
||||
*/
|
||||
u_quad_t ipi_gencnt;
|
||||
struct mtx ipi_mtx;
|
||||
struct rwlock ipi_lock;
|
||||
|
||||
/*
|
||||
* vimage 1
|
||||
@ -274,12 +279,16 @@ struct inpcbinfo {
|
||||
};
|
||||
|
||||
#define INP_LOCK_INIT(inp, d, t) \
|
||||
mtx_init(&(inp)->inp_mtx, (d), (t), MTX_DEF | MTX_RECURSE | MTX_DUPOK)
|
||||
#define INP_LOCK_DESTROY(inp) mtx_destroy(&(inp)->inp_mtx)
|
||||
#define INP_LOCK(inp) mtx_lock(&(inp)->inp_mtx)
|
||||
#define INP_UNLOCK(inp) mtx_unlock(&(inp)->inp_mtx)
|
||||
#define INP_LOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_OWNED)
|
||||
#define INP_UNLOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_NOTOWNED)
|
||||
rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE | RW_DUPOK)
|
||||
#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock)
|
||||
#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock)
|
||||
#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock)
|
||||
#define INP_RUNLOCK(inp) rw_runlock(&(inp)->inp_lock)
|
||||
#define INP_WUNLOCK(inp) rw_wunlock(&(inp)->inp_lock)
|
||||
#define INP_LOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_LOCKED)
|
||||
#define INP_RLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_RLOCKED)
|
||||
#define INP_WLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_WLOCKED)
|
||||
#define INP_UNLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_UNLOCKED)
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
@ -311,15 +320,16 @@ inp_unlock_assert(struct inpcb *inp __unused)
|
||||
|
||||
|
||||
#define INP_INFO_LOCK_INIT(ipi, d) \
|
||||
mtx_init(&(ipi)->ipi_mtx, (d), NULL, MTX_DEF | MTX_RECURSE)
|
||||
#define INP_INFO_LOCK_DESTROY(ipi) mtx_destroy(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_WLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
|
||||
#define INP_INFO_WLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
|
||||
#define INP_INFO_UNLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_NOTOWNED)
|
||||
rw_init_flags(&(ipi)->ipi_lock, (d), RW_RECURSE)
|
||||
#define INP_INFO_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_lock)
|
||||
#define INP_INFO_RLOCK(ipi) rw_rlock(&(ipi)->ipi_lock)
|
||||
#define INP_INFO_WLOCK(ipi) rw_wlock(&(ipi)->ipi_lock)
|
||||
#define INP_INFO_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_lock)
|
||||
#define INP_INFO_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_lock)
|
||||
#define INP_INFO_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_LOCKED)
|
||||
#define INP_INFO_RLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_RLOCKED)
|
||||
#define INP_INFO_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_WLOCKED)
|
||||
#define INP_INFO_UNLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_UNLOCKED)
|
||||
|
||||
#define INP_PCBHASH(faddr, lport, fport, mask) \
|
||||
(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
|
||||
|
@ -268,7 +268,7 @@ divert_packet(struct mbuf *m, int incoming)
|
||||
nport = htons((u_int16_t)divert_info(mtag));
|
||||
INP_INFO_RLOCK(&divcbinfo);
|
||||
LIST_FOREACH(inp, &divcb, inp_list) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
/* XXX why does only one socket match? */
|
||||
if (inp->inp_lport == nport) {
|
||||
sa = inp->inp_socket;
|
||||
@ -280,10 +280,10 @@ divert_packet(struct mbuf *m, int incoming)
|
||||
sa = NULL; /* force mbuf reclaim below */
|
||||
} else
|
||||
sorwakeup_locked(sa);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&divcbinfo);
|
||||
if (sa == NULL) {
|
||||
@ -356,7 +356,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
|
||||
dt->info |= IP_FW_DIVERT_OUTPUT_FLAG;
|
||||
INP_INFO_WLOCK(&divcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
/*
|
||||
* Don't allow both user specified and setsockopt options,
|
||||
* and don't allow packet length sizes that will crash
|
||||
@ -364,7 +364,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
|
||||
if (((ip->ip_hl != (sizeof (*ip) >> 2)) && inp->inp_options) ||
|
||||
((u_short)ntohs(ip->ip_len) > m->m_pkthdr.len)) {
|
||||
error = EINVAL;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&divcbinfo);
|
||||
m_freem(m);
|
||||
} else {
|
||||
@ -405,7 +405,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
|
||||
if (options == NULL)
|
||||
error = ENOBUFS;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&divcbinfo);
|
||||
if (error == ENOBUFS) {
|
||||
m_freem(m);
|
||||
@ -480,7 +480,7 @@ div_attach(struct socket *so, int proto, struct thread *td)
|
||||
inp->inp_ip_p = proto;
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
inp->inp_flags |= INP_HDRINCL;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ div_detach(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("div_detach: inp == NULL"));
|
||||
INP_INFO_WLOCK(&divcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
in_pcbdetach(inp);
|
||||
in_pcbfree(inp);
|
||||
INP_INFO_WUNLOCK(&divcbinfo);
|
||||
@ -517,9 +517,9 @@ div_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
return EAFNOSUPPORT;
|
||||
((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY;
|
||||
INP_INFO_WLOCK(&divcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
error = in_pcbbind(inp, nam, td->td_ucred);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&divcbinfo);
|
||||
return error;
|
||||
}
|
||||
@ -531,9 +531,9 @@ div_shutdown(struct socket *so)
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("div_shutdown: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
socantsendmore(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -615,11 +615,11 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
INP_INFO_RLOCK(&divcbinfo);
|
||||
for (inp = LIST_FIRST(divcbinfo.ipi_listhead), i = 0; inp && i < n;
|
||||
inp = LIST_NEXT(inp, inp_list)) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt &&
|
||||
cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
|
||||
inp_list[i++] = inp;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&divcbinfo);
|
||||
n = i;
|
||||
@ -627,7 +627,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
error = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
inp = inp_list[i];
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xinpcb xi;
|
||||
bzero(&xi, sizeof(xi));
|
||||
@ -636,10 +636,10 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
bcopy(inp, &xi.xi_inp, sizeof *inp);
|
||||
if (inp->inp_socket)
|
||||
sotoxsocket(inp->inp_socket, &xi.xi_socket);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = SYSCTL_OUT(req, &xi, sizeof xi);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
if (!error) {
|
||||
/*
|
||||
|
@ -1974,7 +1974,7 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
|
||||
* up the PCB, we can use the one that was supplied.
|
||||
*/
|
||||
if (inp && *lookup == 0) {
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
if (inp->inp_socket != NULL) {
|
||||
fill_ugid_cache(inp, ugp);
|
||||
*lookup = 1;
|
||||
@ -2008,12 +2008,12 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
|
||||
dst_ip, htons(dst_port),
|
||||
wildcard, NULL);
|
||||
if (pcb != NULL) {
|
||||
INP_LOCK(pcb);
|
||||
INP_WLOCK(pcb);
|
||||
if (pcb->inp_socket != NULL) {
|
||||
fill_ugid_cache(pcb, ugp);
|
||||
*lookup = 1;
|
||||
}
|
||||
INP_UNLOCK(pcb);
|
||||
INP_WUNLOCK(pcb);
|
||||
}
|
||||
INP_INFO_RUNLOCK(pi);
|
||||
if (*lookup == 0) {
|
||||
|
@ -589,7 +589,7 @@ ip_pcbopts(struct inpcb *inp, int optname, struct mbuf *m)
|
||||
struct mbuf **pcbopt;
|
||||
u_char opt;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
pcbopt = &inp->inp_options;
|
||||
|
||||
|
@ -130,7 +130,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
|
||||
}
|
||||
|
||||
if (inp != NULL)
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (opt) {
|
||||
len = 0;
|
||||
@ -844,9 +844,9 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
m_free(m);
|
||||
break;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
error = ip_pcbopts(inp, sopt->sopt_name, m);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -883,12 +883,12 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
break;
|
||||
|
||||
#define OPTSET(bit) do { \
|
||||
INP_LOCK(inp); \
|
||||
INP_WLOCK(inp); \
|
||||
if (optval) \
|
||||
inp->inp_flags |= bit; \
|
||||
else \
|
||||
inp->inp_flags &= ~bit; \
|
||||
INP_UNLOCK(inp); \
|
||||
INP_WUNLOCK(inp); \
|
||||
} while (0)
|
||||
|
||||
case IP_RECVOPTS:
|
||||
@ -955,7 +955,7 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
if (error)
|
||||
break;
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
switch (optval) {
|
||||
case IP_PORTRANGE_DEFAULT:
|
||||
inp->inp_flags &= ~(INP_LOWPORT);
|
||||
@ -976,7 +976,7 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
|
||||
#ifdef IPSEC
|
||||
|
@ -155,7 +155,7 @@ raw_append(struct inpcb *last, struct ip *ip, struct mbuf *n)
|
||||
{
|
||||
int policyfail = 0;
|
||||
|
||||
INP_LOCK_ASSERT(last);
|
||||
INP_WLOCK_ASSERT(last);
|
||||
|
||||
#ifdef IPSEC
|
||||
/* check AH/ESP integrity. */
|
||||
@ -209,10 +209,10 @@ rip_input(struct mbuf *m, int off)
|
||||
ripsrc.sin_addr = ip->ip_src;
|
||||
last = NULL;
|
||||
LIST_FOREACH(inp, &ripcb, inp_list) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_ip_p && inp->inp_ip_p != proto) {
|
||||
docontinue:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
#ifdef INET6
|
||||
@ -236,14 +236,14 @@ rip_input(struct mbuf *m, int off)
|
||||
if (n != NULL)
|
||||
(void) raw_append(last, ip, n);
|
||||
/* XXX count dropped packet */
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
}
|
||||
last = inp;
|
||||
}
|
||||
if (last != NULL) {
|
||||
if (raw_append(last, ip, m) != 0)
|
||||
ipstat.ips_delivered--;
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
} else {
|
||||
m_freem(m);
|
||||
ipstat.ips_noproto++;
|
||||
@ -278,7 +278,7 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
||||
if (m == NULL)
|
||||
return(ENOBUFS);
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
ip = mtod(m, struct ip *);
|
||||
ip->ip_tos = inp->inp_ip_tos;
|
||||
if (inp->inp_flags & INP_DONTFRAG)
|
||||
@ -299,12 +299,12 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
||||
m_freem(m);
|
||||
return(EMSGSIZE);
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
ip = mtod(m, struct ip *);
|
||||
if (jailed(inp->inp_socket->so_cred)) {
|
||||
if (ip->ip_src.s_addr !=
|
||||
htonl(prison_getip(inp->inp_socket->so_cred))) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
m_freem(m);
|
||||
return (EPERM);
|
||||
}
|
||||
@ -315,7 +315,7 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
||||
&& inp->inp_options)
|
||||
|| (ip->ip_len > m->m_pkthdr.len)
|
||||
|| (ip->ip_len < (ip->ip_hl << 2))) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
m_freem(m);
|
||||
return EINVAL;
|
||||
}
|
||||
@ -335,7 +335,7 @@ rip_output(struct mbuf *m, struct socket *so, u_long dst)
|
||||
|
||||
error = ip_output(m, inp->inp_options, NULL, flags,
|
||||
inp->inp_moptions, inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ rip_attach(struct socket *so, int proto, struct thread *td)
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
inp->inp_ip_p = proto;
|
||||
inp->inp_ip_ttl = ip_defttl;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ rip_detach(struct socket *so)
|
||||
("rip_detach: not closed"));
|
||||
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (so == ip_mrouter && ip_mrouter_done)
|
||||
ip_mrouter_done();
|
||||
if (ip_rsvp_force_done)
|
||||
@ -652,7 +652,7 @@ static void
|
||||
rip_dodisconnect(struct socket *so, struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
inp->inp_faddr.s_addr = INADDR_ANY;
|
||||
SOCK_LOCK(so);
|
||||
@ -669,9 +669,9 @@ rip_abort(struct socket *so)
|
||||
KASSERT(inp != NULL, ("rip_abort: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
rip_dodisconnect(so, inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
}
|
||||
|
||||
@ -684,9 +684,9 @@ rip_close(struct socket *so)
|
||||
KASSERT(inp != NULL, ("rip_close: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
rip_dodisconnect(so, inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
}
|
||||
|
||||
@ -701,9 +701,9 @@ rip_disconnect(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("rip_disconnect: inp == NULL"));
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
rip_dodisconnect(so, inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return (0);
|
||||
}
|
||||
@ -734,9 +734,9 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_laddr = addr->sin_addr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return 0;
|
||||
}
|
||||
@ -757,10 +757,10 @@ rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("rip_connect: inp == NULL"));
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_faddr = addr->sin_addr;
|
||||
soisconnected(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return 0;
|
||||
}
|
||||
@ -772,9 +772,9 @@ rip_shutdown(struct socket *so)
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("rip_shutdown: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
socantsendmore(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -847,17 +847,17 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
|
||||
if (inp_list == 0)
|
||||
return ENOMEM;
|
||||
|
||||
|
||||
INP_INFO_RLOCK(&ripcbinfo);
|
||||
for (inp = LIST_FIRST(ripcbinfo.ipi_listhead), i = 0; inp && i < n;
|
||||
inp = LIST_NEXT(inp, inp_list)) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt &&
|
||||
cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0) {
|
||||
/* XXX held references? */
|
||||
inp_list[i++] = inp;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&ripcbinfo);
|
||||
n = i;
|
||||
@ -865,7 +865,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
error = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
inp = inp_list[i];
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xinpcb xi;
|
||||
bzero(&xi, sizeof(xi));
|
||||
@ -874,10 +874,10 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
bcopy(inp, &xi.xi_inp, sizeof *inp);
|
||||
if (inp->inp_socket)
|
||||
sotoxsocket(inp->inp_socket, &xi.xi_socket);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = SYSCTL_OUT(req, &xi, sizeof xi);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
if (!error) {
|
||||
/*
|
||||
|
@ -476,7 +476,7 @@ tcp_input(struct mbuf *m, int off0)
|
||||
rstreason = BANDLIM_RST_CLOSEDPORT;
|
||||
goto dropwithreset;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
#ifdef IPSEC
|
||||
#ifdef INET6
|
||||
@ -533,7 +533,7 @@ tcp_input(struct mbuf *m, int off0)
|
||||
}
|
||||
|
||||
#ifdef MAC
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
if (mac_inpcb_check_deliver(inp, m))
|
||||
goto dropunlock;
|
||||
#endif
|
||||
@ -631,9 +631,9 @@ tcp_input(struct mbuf *m, int off0)
|
||||
* Unlock the listen socket, lock the newly
|
||||
* created socket and update the tp variable.
|
||||
*/
|
||||
INP_UNLOCK(inp); /* listen socket */
|
||||
INP_WUNLOCK(inp); /* listen socket */
|
||||
inp = sotoinpcb(so);
|
||||
INP_LOCK(inp); /* new connection */
|
||||
INP_WLOCK(inp); /* new connection */
|
||||
tp = intotcpcb(inp);
|
||||
KASSERT(tp->t_state == TCPS_SYN_RECEIVED,
|
||||
("%s: ", __func__));
|
||||
@ -853,7 +853,7 @@ tcp_input(struct mbuf *m, int off0)
|
||||
dropunlock:
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
if (inp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
drop:
|
||||
INP_INFO_UNLOCK_ASSERT(&tcbinfo);
|
||||
@ -886,7 +886,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
thflags = th->th_flags;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN",
|
||||
__func__));
|
||||
KASSERT(tp->t_state != TCPS_TIME_WAIT, ("%s: TCPS_TIME_WAIT",
|
||||
@ -1330,7 +1330,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
|
||||
KASSERT(headlocked, ("%s: trimthenstep6: head not locked",
|
||||
__func__));
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* Advance th->th_seq to correspond to first data byte.
|
||||
@ -1938,7 +1938,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
process_ACK:
|
||||
KASSERT(headlocked, ("%s: process_ACK: head not locked",
|
||||
__func__));
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
acked = th->th_ack - tp->snd_una;
|
||||
tcpstat.tcps_rcvackpack++;
|
||||
@ -2121,7 +2121,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
|
||||
step6:
|
||||
KASSERT(headlocked, ("%s: step6: head not locked", __func__));
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* Update window information.
|
||||
@ -2207,7 +2207,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
}
|
||||
dodata: /* XXX */
|
||||
KASSERT(headlocked, ("%s: dodata: head not locked", __func__));
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* Process the segment text, merging it into the TCP sequencing queue,
|
||||
@ -2350,12 +2350,12 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
KASSERT(headlocked == 0, ("%s: check_delack: head locked",
|
||||
__func__));
|
||||
INP_INFO_UNLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
if (tp->t_flags & TF_DELACK) {
|
||||
tp->t_flags &= ~TF_DELACK;
|
||||
tcp_timer_activate(tp, TT_DELACK, tcp_delacktime);
|
||||
}
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
return;
|
||||
|
||||
dropafterack:
|
||||
@ -2390,7 +2390,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
(void) tcp_output(tp);
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
m_freem(m);
|
||||
return;
|
||||
|
||||
@ -2400,7 +2400,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
tcp_dropwithreset(m, th, tp, tlen, rstreason);
|
||||
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
if (headlocked)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
@ -2415,7 +2415,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
|
||||
&tcp_savetcp, 0);
|
||||
#endif
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
if (headlocked)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
m_freem(m);
|
||||
@ -2437,7 +2437,7 @@ tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp,
|
||||
#endif
|
||||
|
||||
if (tp != NULL) {
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
}
|
||||
|
||||
/* Don't bother if destination was broadcast/multicast. */
|
||||
@ -2589,7 +2589,7 @@ tcp_pulloutofband(struct socket *so, struct tcphdr *th, struct mbuf *m,
|
||||
char *cp = mtod(m, caddr_t) + cnt;
|
||||
struct tcpcb *tp = sototcpcb(so);
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
tp->t_iobc = *cp;
|
||||
tp->t_oobflags |= TCPOOB_HAVEDATA;
|
||||
@ -2616,7 +2616,7 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt)
|
||||
{
|
||||
int delta;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
tcpstat.tcps_rttupdated++;
|
||||
tp->t_rttupdated++;
|
||||
@ -2736,7 +2736,7 @@ tcp_mss(struct tcpcb *tp, int offer)
|
||||
const size_t min_protoh = sizeof(struct tcpiphdr);
|
||||
#endif
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/* Initialize. */
|
||||
#ifdef INET6
|
||||
@ -3006,7 +3006,7 @@ tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th)
|
||||
tcp_seq onxt = tp->snd_nxt;
|
||||
u_long ocwnd = tp->snd_cwnd;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
tcp_timer_activate(tp, TT_REXMT, 0);
|
||||
tp->t_rtttime = 0;
|
||||
|
@ -152,7 +152,7 @@ tcp_output(struct tcpcb *tp)
|
||||
isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
|
||||
#endif
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* Determine length of data that should be transmitted,
|
||||
|
@ -131,7 +131,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
|
||||
struct socket *so = tp->t_inpcb->inp_socket;
|
||||
int flags;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* XXX: tcp_reass() is rather inefficient with its data structures
|
||||
|
@ -160,7 +160,7 @@ tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_start, tcp_seq rcv_end)
|
||||
struct sackblk head_blk, saved_blks[MAX_SACK_BLKS];
|
||||
int num_head, num_saved, i;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/* Check arguments. */
|
||||
KASSERT(SEQ_LT(rcv_start, rcv_end), ("rcv_start < rcv_end"));
|
||||
@ -240,7 +240,7 @@ tcp_clean_sackreport(struct tcpcb *tp)
|
||||
{
|
||||
int i;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
tp->rcv_numsacks = 0;
|
||||
for (i = 0; i < MAX_SACK_BLKS; i++)
|
||||
tp->sackblks[i].start = tp->sackblks[i].end=0;
|
||||
@ -347,7 +347,7 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack)
|
||||
struct sackblk sack, sack_blocks[TCP_MAX_SACK + 1], *sblkp;
|
||||
int i, j, num_sack_blks;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
num_sack_blks = 0;
|
||||
/*
|
||||
@ -544,7 +544,7 @@ tcp_free_sackholes(struct tcpcb *tp)
|
||||
{
|
||||
struct sackhole *q;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
while ((q = TAILQ_FIRST(&tp->snd_holes)) != NULL)
|
||||
tcp_sackhole_remove(tp, q);
|
||||
tp->sackhint.sack_bytes_rexmit = 0;
|
||||
@ -567,7 +567,7 @@ tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th)
|
||||
{
|
||||
int num_segs = 1;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
tcp_timer_activate(tp, TT_REXMT, 0);
|
||||
tp->t_rtttime = 0;
|
||||
/* Send one or 2 segments based on how much new data was acked. */
|
||||
@ -591,7 +591,7 @@ tcp_sack_output_debug(struct tcpcb *tp, int *sack_bytes_rexmt)
|
||||
{
|
||||
struct sackhole *p;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
*sack_bytes_rexmt = 0;
|
||||
TAILQ_FOREACH(p, &tp->snd_holes, scblink) {
|
||||
if (SEQ_LT(p->rxmit, p->end)) {
|
||||
@ -629,7 +629,7 @@ tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt)
|
||||
{
|
||||
struct sackhole *hole = NULL;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
*sack_bytes_rexmt = tp->sackhint.sack_bytes_rexmit;
|
||||
hole = tp->sackhint.nexthole;
|
||||
if (hole == NULL || SEQ_LT(hole->rxmit, hole->end))
|
||||
@ -654,7 +654,7 @@ tcp_sack_adjust(struct tcpcb *tp)
|
||||
{
|
||||
struct sackhole *p, *cur = TAILQ_FIRST(&tp->snd_holes);
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
if (cur == NULL)
|
||||
return; /* No holes */
|
||||
if (SEQ_GEQ(tp->snd_nxt, tp->snd_fack))
|
||||
|
@ -332,7 +332,7 @@ tcpip_fillheaders(struct inpcb *inp, void *ip_ptr, void *tcp_ptr)
|
||||
{
|
||||
struct tcphdr *th = (struct tcphdr *)tcp_ptr;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef INET6
|
||||
if ((inp->inp_vflag & INP_IPV6) != 0) {
|
||||
@ -438,7 +438,7 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
|
||||
if (tp != NULL) {
|
||||
inp = tp->t_inpcb;
|
||||
KASSERT(inp != NULL, ("tcp control block w/o inpcb"));
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
} else
|
||||
inp = NULL;
|
||||
|
||||
@ -525,7 +525,7 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
|
||||
* Packet is associated with a socket, so allow the
|
||||
* label of the response to reflect the socket label.
|
||||
*/
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
mac_inpcb_create_mbuf(inp, m);
|
||||
} else {
|
||||
/*
|
||||
@ -648,7 +648,7 @@ tcp_drop(struct tcpcb *tp, int errno)
|
||||
struct socket *so = tp->t_inpcb->inp_socket;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
if (TCPS_HAVERCVDSYN(tp->t_state)) {
|
||||
tp->t_state = TCPS_CLOSED;
|
||||
@ -672,7 +672,7 @@ tcp_discardcb(struct tcpcb *tp)
|
||||
int isipv6 = (inp->inp_vflag & INP_IPV6) != 0;
|
||||
#endif /* INET6 */
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/*
|
||||
* Make sure that all of our timers are stopped before we
|
||||
@ -770,7 +770,7 @@ tcp_close(struct tcpcb *tp)
|
||||
struct socket *so;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/* Notify any offload devices of listener close */
|
||||
if (tp->t_state == TCPS_LISTEN)
|
||||
@ -784,7 +784,7 @@ tcp_close(struct tcpcb *tp)
|
||||
KASSERT(so->so_state & SS_PROTOREF,
|
||||
("tcp_close: !SS_PROTOREF"));
|
||||
inp->inp_vflag &= ~INP_SOCKREF;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
ACCEPT_LOCK();
|
||||
SOCK_LOCK(so);
|
||||
so->so_state &= ~SS_PROTOREF;
|
||||
@ -815,7 +815,7 @@ tcp_drain(void)
|
||||
LIST_FOREACH(inpb, tcbinfo.ipi_listhead, inp_list) {
|
||||
if (inpb->inp_vflag & INP_TIMEWAIT)
|
||||
continue;
|
||||
INP_LOCK(inpb);
|
||||
INP_WLOCK(inpb);
|
||||
if ((tcpb = intotcpcb(inpb)) != NULL) {
|
||||
while ((te = LIST_FIRST(&tcpb->t_segq))
|
||||
!= NULL) {
|
||||
@ -827,7 +827,7 @@ tcp_drain(void)
|
||||
}
|
||||
tcp_clean_sackreport(tcpb);
|
||||
}
|
||||
INP_UNLOCK(inpb);
|
||||
INP_WUNLOCK(inpb);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
}
|
||||
@ -847,7 +847,7 @@ tcp_notify(struct inpcb *inp, int error)
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if ((inp->inp_vflag & INP_TIMEWAIT) ||
|
||||
(inp->inp_vflag & INP_DROPPED))
|
||||
@ -942,7 +942,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
INP_INFO_RLOCK(&tcbinfo);
|
||||
for (inp = LIST_FIRST(tcbinfo.ipi_listhead), i = 0; inp != NULL && i
|
||||
< n; inp = LIST_NEXT(inp, inp_list)) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
/*
|
||||
* XXX: This use of cr_cansee(), introduced with
|
||||
@ -961,7 +961,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
if (error == 0)
|
||||
inp_list[i++] = inp;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
n = i;
|
||||
@ -969,7 +969,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
error = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
inp = inp_list[i];
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xtcpcb xt;
|
||||
void *inp_ppcb;
|
||||
@ -993,10 +993,10 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
xt.xt_socket.xso_protocol = IPPROTO_TCP;
|
||||
}
|
||||
xt.xt_inp.inp_gencnt = inp->inp_gencnt;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = SYSCTL_OUT(req, &xt, sizeof xt);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
}
|
||||
if (!error) {
|
||||
@ -1042,7 +1042,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
|
||||
error = ENOENT;
|
||||
goto outunlocked;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_socket == NULL) {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
@ -1052,7 +1052,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
|
||||
goto out;
|
||||
cru2x(inp->inp_socket->so_cred, &xuc);
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
outunlocked:
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
if (error == 0)
|
||||
@ -1106,7 +1106,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
|
||||
error = ENOENT;
|
||||
goto outunlocked;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_socket == NULL) {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
@ -1116,7 +1116,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
|
||||
goto out;
|
||||
cru2x(inp->inp_socket->so_cred, &xuc);
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
outunlocked:
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
if (error == 0)
|
||||
@ -1181,7 +1181,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
|
||||
inp = in_pcblookup_hash(&tcbinfo, faddr, th->th_dport,
|
||||
ip->ip_src, th->th_sport, 0, NULL);
|
||||
if (inp != NULL) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (!(inp->inp_vflag & INP_TIMEWAIT) &&
|
||||
!(inp->inp_vflag & INP_DROPPED) &&
|
||||
!(inp->inp_socket == NULL)) {
|
||||
@ -1230,7 +1230,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
|
||||
}
|
||||
}
|
||||
if (inp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else {
|
||||
inc.inc_fport = th->th_dport;
|
||||
inc.inc_lport = th->th_sport;
|
||||
@ -1381,7 +1381,7 @@ tcp_new_isn(struct tcpcb *tp)
|
||||
u_int32_t md5_buffer[4];
|
||||
tcp_seq new_isn;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
ISN_LOCK();
|
||||
/* Seed if this is the first use, reseed if requested. */
|
||||
@ -1452,7 +1452,7 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno)
|
||||
struct tcpcb *tp;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if ((inp->inp_vflag & INP_TIMEWAIT) ||
|
||||
(inp->inp_vflag & INP_DROPPED))
|
||||
@ -1487,7 +1487,7 @@ tcp_mtudisc(struct inpcb *inp, int errno)
|
||||
int isipv6;
|
||||
#endif /* INET6 */
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
if ((inp->inp_vflag & INP_TIMEWAIT) ||
|
||||
(inp->inp_vflag & INP_DROPPED))
|
||||
return (inp);
|
||||
@ -1752,7 +1752,7 @@ tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq)
|
||||
u_long bwnd;
|
||||
int save_ticks;
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
/*
|
||||
* If inflight_enable is disabled in the middle of a tcp connection,
|
||||
@ -2045,7 +2045,7 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
|
||||
break;
|
||||
}
|
||||
if (inp != NULL) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & INP_TIMEWAIT) {
|
||||
/*
|
||||
* XXXRW: There currently exists a state where an
|
||||
@ -2057,15 +2057,15 @@ sysctl_drop(SYSCTL_HANDLER_ARGS)
|
||||
if (tw != NULL)
|
||||
tcp_twclose(tw, 0);
|
||||
else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else if (!(inp->inp_vflag & INP_DROPPED) &&
|
||||
!(inp->inp_socket->so_options & SO_ACCEPTCONN)) {
|
||||
tp = intotcpcb(inp);
|
||||
tp = tcp_drop(tp, ECONNABORTED);
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else
|
||||
error = ESRCH;
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
|
@ -670,7 +670,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
|
||||
#endif
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
/* Insert new socket into PCB hash list. */
|
||||
inp->inp_inc.inc_isipv6 = sc->sc_inc.inc_isipv6;
|
||||
@ -817,13 +817,13 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
|
||||
tp->snd_cwnd = tp->t_maxseg;
|
||||
tcp_timer_activate(tp, TT_KEEP, tcp_keepinit);
|
||||
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
tcpstat.tcps_accepts++;
|
||||
return (so);
|
||||
|
||||
abort:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
abort2:
|
||||
if (so != NULL)
|
||||
soabort(so);
|
||||
@ -987,7 +987,7 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
||||
struct syncache scs;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp); /* listen socket */
|
||||
INP_WLOCK_ASSERT(inp); /* listen socket */
|
||||
KASSERT((th->th_flags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN,
|
||||
("%s: unexpected tcp flags", __func__));
|
||||
|
||||
@ -1014,13 +1014,13 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
|
||||
|
||||
#ifdef MAC
|
||||
if (mac_syncache_init(&maclabel) != 0) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
goto done;
|
||||
} else
|
||||
mac_syncache_create(maclabel, inp);
|
||||
#endif
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
|
||||
/*
|
||||
|
@ -166,11 +166,11 @@ tcp_timer_delack(void *xtp)
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_delack)
|
||||
|| !callout_active(&tp->t_timers->tt_delack)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return;
|
||||
}
|
||||
callout_deactivate(&tp->t_timers->tt_delack);
|
||||
@ -178,7 +178,7 @@ tcp_timer_delack(void *xtp)
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
tcpstat.tcps_delack++;
|
||||
(void) tcp_output(tp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -208,11 +208,11 @@ tcp_timer_2msl(void *xtp)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
tcp_free_sackholes(tp);
|
||||
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_2msl) ||
|
||||
!callout_active(&tp->t_timers->tt_2msl)) {
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
@ -247,7 +247,7 @@ tcp_timer_2msl(void *xtp)
|
||||
PRU_SLOWTIMO);
|
||||
#endif
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
||||
@ -276,10 +276,10 @@ tcp_timer_keep(void *xtp)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_keep)
|
||||
|| !callout_active(&tp->t_timers->tt_keep)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
@ -324,7 +324,7 @@ tcp_timer_keep(void *xtp)
|
||||
tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
|
||||
PRU_SLOWTIMO);
|
||||
#endif
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
|
||||
@ -338,7 +338,7 @@ tcp_timer_keep(void *xtp)
|
||||
PRU_SLOWTIMO);
|
||||
#endif
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(tp->t_inpcb);
|
||||
INP_WUNLOCK(tp->t_inpcb);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
||||
@ -366,10 +366,10 @@ tcp_timer_persist(void *xtp)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_persist)
|
||||
|| !callout_active(&tp->t_timers->tt_persist)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
@ -404,7 +404,7 @@ tcp_timer_persist(void *xtp)
|
||||
tcp_trace(TA_USER, ostate, tp, NULL, NULL, PRU_SLOWTIMO);
|
||||
#endif
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
||||
@ -435,10 +435,10 @@ tcp_timer_rexmt(void * xtp)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_vflag & INP_DROPPED) || callout_pending(&tp->t_timers->tt_rexmt)
|
||||
|| !callout_active(&tp->t_timers->tt_rexmt)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return;
|
||||
}
|
||||
@ -560,7 +560,7 @@ tcp_timer_rexmt(void * xtp)
|
||||
PRU_SLOWTIMO);
|
||||
#endif
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (headlocked)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
@ -186,12 +186,12 @@ tcp_twstart(struct tcpcb *tp)
|
||||
struct socket *so;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_tw_2msl_reset(). */
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (nolocaltimewait && in_localip(inp->inp_faddr)) {
|
||||
tp = tcp_close(tp);
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ tcp_twstart(struct tcpcb *tp)
|
||||
if (tw == NULL) {
|
||||
tp = tcp_close(tp);
|
||||
if (tp != NULL)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -267,13 +267,13 @@ tcp_twstart(struct tcpcb *tp)
|
||||
KASSERT(so->so_state & SS_PROTOREF,
|
||||
("tcp_twstart: !SS_PROTOREF"));
|
||||
inp->inp_vflag &= ~INP_SOCKREF;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
ACCEPT_LOCK();
|
||||
SOCK_LOCK(so);
|
||||
so->so_state &= ~SS_PROTOREF;
|
||||
sofree(so);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -328,7 +328,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
|
||||
|
||||
/* tcbinfo lock required for tcp_twclose(), tcp_tw_2msl_reset(). */
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/*
|
||||
* XXXRW: Time wait state for inpcb has been recycled, but inpcb is
|
||||
@ -441,11 +441,11 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
|
||||
tcp_respond(NULL,
|
||||
mtod(m, void *), th, m, seq, 0, TH_RST|TH_ACK);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (0);
|
||||
|
||||
drop:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
m_freem(m);
|
||||
return (0);
|
||||
}
|
||||
@ -469,7 +469,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
|
||||
KASSERT((inp->inp_vflag & INP_TIMEWAIT), ("tcp_twclose: !timewait"));
|
||||
KASSERT(intotw(inp) == tw, ("tcp_twclose: inp_ppcb != tw"));
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo); /* tcp_tw_2msl_stop(). */
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
tw->tw_inpcb = NULL;
|
||||
tcp_tw_2msl_stop(tw);
|
||||
@ -486,7 +486,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
|
||||
*/
|
||||
if (inp->inp_vflag & INP_SOCKREF) {
|
||||
inp->inp_vflag &= ~INP_SOCKREF;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
ACCEPT_LOCK();
|
||||
SOCK_LOCK(so);
|
||||
KASSERT(so->so_state & SS_PROTOREF,
|
||||
@ -499,7 +499,7 @@ tcp_twclose(struct tcptw *tw, int reuse)
|
||||
* inpcb need to be left around to be handled by
|
||||
* tcp_usr_detach() later.
|
||||
*/
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
} else {
|
||||
#ifdef INET6
|
||||
@ -532,7 +532,7 @@ tcp_twrespond(struct tcptw *tw, int flags)
|
||||
int isipv6 = inp->inp_inc.inc_isipv6;
|
||||
#endif
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == NULL)
|
||||
@ -615,7 +615,7 @@ tcp_tw_2msl_reset(struct tcptw *tw, int rearm)
|
||||
{
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(tw->tw_inpcb);
|
||||
INP_WLOCK_ASSERT(tw->tw_inpcb);
|
||||
if (rearm)
|
||||
TAILQ_REMOVE(&twq_2msl, tw, tw_2msl);
|
||||
tw->tw_time = ticks + 2 * tcp_msl;
|
||||
@ -640,7 +640,7 @@ tcp_tw_2msl_scan(int reuse)
|
||||
tw = TAILQ_FIRST(&twq_2msl);
|
||||
if (tw == NULL || (!reuse && tw->tw_time > ticks))
|
||||
break;
|
||||
INP_LOCK(tw->tw_inpcb);
|
||||
INP_WLOCK(tw->tw_inpcb);
|
||||
tcp_twclose(tw, reuse);
|
||||
if (reuse)
|
||||
return (tw);
|
||||
|
@ -160,7 +160,7 @@ tcp_detach(struct socket *so, struct inpcb *inp)
|
||||
#endif
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
KASSERT(so->so_pcb == inp, ("tcp_detach: so_pcb != inp"));
|
||||
KASSERT(inp->inp_socket == so, ("tcp_detach: inp_socket != so"));
|
||||
@ -201,7 +201,7 @@ tcp_detach(struct socket *so, struct inpcb *inp)
|
||||
else
|
||||
#endif
|
||||
in_pcbdetach(inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -253,7 +253,7 @@ tcp_usr_detach(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_detach: inp == NULL"));
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
KASSERT(inp->inp_socket != NULL,
|
||||
("tcp_usr_detach: inp_socket == NULL"));
|
||||
tcp_detach(so, inp);
|
||||
@ -286,7 +286,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_bind: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -296,7 +296,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = in_pcbbind(inp, nam, td->td_ucred);
|
||||
out:
|
||||
TCPDEBUG2(PRU_BIND);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
|
||||
return (error);
|
||||
@ -326,7 +326,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp6_usr_bind: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -352,7 +352,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = in6_pcbbind(inp, nam, td->td_ucred);
|
||||
out:
|
||||
TCPDEBUG2(PRU_BIND);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -372,7 +372,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_listen: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -392,7 +392,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_LISTEN);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -409,7 +409,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp6_usr_listen: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -432,7 +432,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_LISTEN);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -469,7 +469,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_connect: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -481,7 +481,7 @@ tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = tcp_output_connect(so, nam);
|
||||
out:
|
||||
TCPDEBUG2(PRU_CONNECT);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -510,7 +510,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp6_usr_connect: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
@ -542,7 +542,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_CONNECT);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -570,7 +570,7 @@ tcp_usr_disconnect(struct socket *so)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_disconnect: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNRESET;
|
||||
goto out;
|
||||
@ -580,7 +580,7 @@ tcp_usr_disconnect(struct socket *so)
|
||||
tcp_disconnect(tp);
|
||||
out:
|
||||
TCPDEBUG2(PRU_DISCONNECT);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -606,7 +606,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL"));
|
||||
INP_INFO_RLOCK(&tcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNABORTED;
|
||||
goto out;
|
||||
@ -624,7 +624,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_ACCEPT);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&tcbinfo);
|
||||
if (error == 0)
|
||||
*nam = in_sockaddr(port, &addr);
|
||||
@ -649,7 +649,7 @@ tcp6_usr_accept(struct socket *so, struct sockaddr **nam)
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp6_usr_accept: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNABORTED;
|
||||
goto out;
|
||||
@ -673,7 +673,7 @@ tcp6_usr_accept(struct socket *so, struct sockaddr **nam)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_ACCEPT);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (error == 0) {
|
||||
if (v4)
|
||||
*nam = in6_v4mapsin6_sockaddr(port, &addr);
|
||||
@ -698,7 +698,7 @@ tcp_usr_shutdown(struct socket *so)
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNRESET;
|
||||
goto out;
|
||||
@ -711,7 +711,7 @@ tcp_usr_shutdown(struct socket *so)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_SHUTDOWN);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
|
||||
return (error);
|
||||
@ -730,7 +730,7 @@ tcp_usr_rcvd(struct socket *so, int flags)
|
||||
TCPDEBUG0;
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNRESET;
|
||||
goto out;
|
||||
@ -741,7 +741,7 @@ tcp_usr_rcvd(struct socket *so, int flags)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_RCVD);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -780,7 +780,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
}
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_send: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
if (control)
|
||||
m_freem(control);
|
||||
@ -899,7 +899,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
|
||||
out:
|
||||
TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB :
|
||||
((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND));
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (headlocked)
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (error);
|
||||
@ -919,7 +919,7 @@ tcp_usr_abort(struct socket *so)
|
||||
KASSERT(inp != NULL, ("tcp_usr_abort: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
KASSERT(inp->inp_socket != NULL,
|
||||
("tcp_usr_abort: inp_socket == NULL"));
|
||||
|
||||
@ -939,7 +939,7 @@ tcp_usr_abort(struct socket *so)
|
||||
SOCK_UNLOCK(so);
|
||||
inp->inp_vflag |= INP_SOCKREF;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
||||
@ -957,7 +957,7 @@ tcp_usr_close(struct socket *so)
|
||||
KASSERT(inp != NULL, ("tcp_usr_close: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&tcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
KASSERT(inp->inp_socket != NULL,
|
||||
("tcp_usr_close: inp_socket == NULL"));
|
||||
|
||||
@ -978,7 +978,7 @@ tcp_usr_close(struct socket *so)
|
||||
SOCK_UNLOCK(so);
|
||||
inp->inp_vflag |= INP_SOCKREF;
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
}
|
||||
|
||||
@ -995,7 +995,7 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags)
|
||||
TCPDEBUG0;
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_usr_rcvoob: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
error = ECONNRESET;
|
||||
goto out;
|
||||
@ -1020,7 +1020,7 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags)
|
||||
|
||||
out:
|
||||
TCPDEBUG2(PRU_RCVOOB);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1086,7 +1086,7 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
|
||||
int error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (inp->inp_lport == 0) {
|
||||
error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
|
||||
@ -1141,7 +1141,7 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
|
||||
int error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (inp->inp_lport == 0) {
|
||||
error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred);
|
||||
@ -1205,7 +1205,7 @@ static void
|
||||
tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
|
||||
{
|
||||
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
bzero(ti, sizeof(*ti));
|
||||
|
||||
ti->tcpi_state = tp->t_state;
|
||||
@ -1239,10 +1239,10 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
|
||||
* has to revalidate that the connection is still valid for the socket
|
||||
* option.
|
||||
*/
|
||||
#define INP_LOCK_RECHECK(inp) do { \
|
||||
INP_LOCK(inp); \
|
||||
#define INP_WLOCK_RECHECK(inp) do { \
|
||||
INP_WLOCK(inp); \
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) { \
|
||||
INP_UNLOCK(inp); \
|
||||
INP_WUNLOCK(inp); \
|
||||
return (ECONNRESET); \
|
||||
} \
|
||||
tp = intotcpcb(inp); \
|
||||
@ -1259,15 +1259,15 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
error = 0;
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("tcp_ctloutput: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (sopt->sopt_level != IPPROTO_TCP) {
|
||||
#ifdef INET6
|
||||
if (INP_CHECK_SOCKAF(so, AF_INET6)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = ip6_ctloutput(so, sopt);
|
||||
} else {
|
||||
#endif /* INET6 */
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = ip_ctloutput(so, sopt);
|
||||
#ifdef INET6
|
||||
}
|
||||
@ -1275,7 +1275,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
return (error);
|
||||
}
|
||||
if (inp->inp_vflag & (INP_TIMEWAIT | INP_DROPPED)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (ECONNRESET);
|
||||
}
|
||||
|
||||
@ -1284,29 +1284,29 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
switch (sopt->sopt_name) {
|
||||
#ifdef TCP_SIGNATURE
|
||||
case TCP_MD5SIG:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyin(sopt, &optval, sizeof optval,
|
||||
sizeof optval);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
INP_LOCK_RECHECK(inp);
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
if (optval > 0)
|
||||
tp->t_flags |= TF_SIGNATURE;
|
||||
else
|
||||
tp->t_flags &= ~TF_SIGNATURE;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
#endif /* TCP_SIGNATURE */
|
||||
case TCP_NODELAY:
|
||||
case TCP_NOOPT:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyin(sopt, &optval, sizeof optval,
|
||||
sizeof optval);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
INP_LOCK_RECHECK(inp);
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
switch (sopt->sopt_name) {
|
||||
case TCP_NODELAY:
|
||||
opt = TF_NODELAY;
|
||||
@ -1323,49 +1323,49 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
tp->t_flags |= opt;
|
||||
else
|
||||
tp->t_flags &= ~opt;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
|
||||
case TCP_NOPUSH:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyin(sopt, &optval, sizeof optval,
|
||||
sizeof optval);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
INP_LOCK_RECHECK(inp);
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
if (optval)
|
||||
tp->t_flags |= TF_NOPUSH;
|
||||
else {
|
||||
tp->t_flags &= ~TF_NOPUSH;
|
||||
error = tcp_output(tp);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
|
||||
case TCP_MAXSEG:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyin(sopt, &optval, sizeof optval,
|
||||
sizeof optval);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
INP_LOCK_RECHECK(inp);
|
||||
INP_WLOCK_RECHECK(inp);
|
||||
if (optval > 0 && optval <= tp->t_maxseg &&
|
||||
optval + 40 >= tcp_minmss)
|
||||
tp->t_maxseg = optval;
|
||||
else
|
||||
error = EINVAL;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
break;
|
||||
|
||||
case TCP_INFO:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = EINVAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = ENOPROTOOPT;
|
||||
break;
|
||||
}
|
||||
@ -1377,38 +1377,38 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
#ifdef TCP_SIGNATURE
|
||||
case TCP_MD5SIG:
|
||||
optval = (tp->t_flags & TF_SIGNATURE) ? 1 : 0;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case TCP_NODELAY:
|
||||
optval = tp->t_flags & TF_NODELAY;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||
break;
|
||||
case TCP_MAXSEG:
|
||||
optval = tp->t_maxseg;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||
break;
|
||||
case TCP_NOOPT:
|
||||
optval = tp->t_flags & TF_NOOPT;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||
break;
|
||||
case TCP_NOPUSH:
|
||||
optval = tp->t_flags & TF_NOPUSH;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||
break;
|
||||
case TCP_INFO:
|
||||
tcp_fill_info(tp, &ti);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = sooptcopyout(sopt, &ti, sizeof ti);
|
||||
break;
|
||||
default:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = ENOPROTOOPT;
|
||||
break;
|
||||
}
|
||||
@ -1416,7 +1416,7 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#undef INP_LOCK_RECHECK
|
||||
#undef INP_WLOCK_RECHECK
|
||||
|
||||
/*
|
||||
* tcp_sendspace and tcp_recvspace are the default send and receive window
|
||||
@ -1484,7 +1484,7 @@ tcp_attach(struct socket *so)
|
||||
return (ENOBUFS);
|
||||
}
|
||||
tp->t_state = TCPS_CLOSED;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&tcbinfo);
|
||||
return (0);
|
||||
}
|
||||
@ -1504,7 +1504,7 @@ tcp_disconnect(struct tcpcb *tp)
|
||||
struct socket *so = inp->inp_socket;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/*
|
||||
* Neither tcp_close() nor tcp_drop() should return NULL, as the
|
||||
@ -1542,7 +1542,7 @@ tcp_usrclosed(struct tcpcb *tp)
|
||||
{
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(&tcbinfo);
|
||||
INP_LOCK_ASSERT(tp->t_inpcb);
|
||||
INP_WLOCK_ASSERT(tp->t_inpcb);
|
||||
|
||||
switch (tp->t_state) {
|
||||
case TCPS_LISTEN:
|
||||
|
@ -195,7 +195,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
|
||||
struct sockaddr_in6 udp_in6;
|
||||
#endif
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef IPSEC
|
||||
/* Check AH/ESP integrity. */
|
||||
@ -412,7 +412,7 @@ udp_input(struct mbuf *m, int off)
|
||||
inp->inp_fport != uh->uh_sport)
|
||||
continue;
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
/*
|
||||
* Handle socket delivery policy for any-source
|
||||
@ -469,7 +469,7 @@ udp_input(struct mbuf *m, int off)
|
||||
}
|
||||
}
|
||||
if (blocked != 0) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -480,7 +480,7 @@ udp_input(struct mbuf *m, int off)
|
||||
if (n != NULL)
|
||||
udp_append(last, ip, n, iphlen +
|
||||
sizeof(struct udphdr), &udp_in);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
}
|
||||
last = inp;
|
||||
/*
|
||||
@ -507,7 +507,7 @@ udp_input(struct mbuf *m, int off)
|
||||
}
|
||||
udp_append(last, ip, m, iphlen + sizeof(struct udphdr),
|
||||
&udp_in);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
return;
|
||||
}
|
||||
@ -546,17 +546,17 @@ udp_input(struct mbuf *m, int off)
|
||||
/*
|
||||
* Check the minimum TTL for socket.
|
||||
*/
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_ip_minttl && inp->inp_ip_minttl > ip->ip_ttl)
|
||||
goto badheadlocked;
|
||||
udp_append(inp, ip, m, iphlen + sizeof(struct udphdr), &udp_in);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
return;
|
||||
|
||||
badheadlocked:
|
||||
if (inp)
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
badunlocked:
|
||||
m_freem(m);
|
||||
@ -570,6 +570,8 @@ struct inpcb *
|
||||
udp_notify(struct inpcb *inp, int errno)
|
||||
{
|
||||
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
inp->inp_socket->so_error = errno;
|
||||
sorwakeup(inp->inp_socket);
|
||||
sowwakeup(inp->inp_socket);
|
||||
@ -610,11 +612,11 @@ udp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
|
||||
inp = in_pcblookup_hash(&udbinfo, faddr, uh->uh_dport,
|
||||
ip->ip_src, uh->uh_sport, 0, NULL);
|
||||
if (inp != NULL) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_socket != NULL) {
|
||||
udp_notify(inp, inetctlerrmap[cmd]);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
} else
|
||||
@ -672,11 +674,11 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
INP_INFO_RLOCK(&udbinfo);
|
||||
for (inp = LIST_FIRST(udbinfo.ipi_listhead), i = 0; inp && i < n;
|
||||
inp = LIST_NEXT(inp, inp_list)) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt &&
|
||||
cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
|
||||
inp_list[i++] = inp;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
n = i;
|
||||
@ -684,7 +686,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
error = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
inp = inp_list[i];
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_gencnt <= gencnt) {
|
||||
struct xinpcb xi;
|
||||
bzero(&xi, sizeof(xi));
|
||||
@ -694,10 +696,10 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
|
||||
if (inp->inp_socket)
|
||||
sotoxsocket(inp->inp_socket, &xi.xi_socket);
|
||||
xi.xi_inp.inp_gencnt = inp->inp_gencnt;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
error = SYSCTL_OUT(req, &xi, sizeof xi);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
if (!error) {
|
||||
/*
|
||||
@ -840,7 +842,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
|
||||
unlock_udbinfo = 1;
|
||||
} else
|
||||
unlock_udbinfo = 0;
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
#ifdef MAC
|
||||
mac_inpcb_create_mbuf(inp, m);
|
||||
@ -971,11 +973,11 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
error = ip_output(m, inp->inp_options, NULL, ipflags,
|
||||
inp->inp_moptions, inp);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (error);
|
||||
|
||||
release:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
if (unlock_udbinfo)
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
m_freem(m);
|
||||
@ -990,13 +992,13 @@ udp_abort(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_abort: inp == NULL"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||
in_pcbdisconnect(inp);
|
||||
inp->inp_laddr.s_addr = INADDR_ANY;
|
||||
soisdisconnected(so);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
}
|
||||
|
||||
@ -1022,7 +1024,7 @@ udp_attach(struct socket *so, int proto, struct thread *td)
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
inp->inp_vflag |= INP_IPV4;
|
||||
inp->inp_ip_ttl = ip_defttl;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1035,9 +1037,9 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_bind: inp == NULL"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
error = in_pcbbind(inp, nam, td->td_ucred);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -1050,13 +1052,13 @@ udp_close(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_close: inp == NULL"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||
in_pcbdisconnect(inp);
|
||||
inp->inp_laddr.s_addr = INADDR_ANY;
|
||||
soisdisconnected(so);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
}
|
||||
|
||||
@ -1070,9 +1072,9 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_connect: inp == NULL"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (EISCONN);
|
||||
}
|
||||
@ -1082,7 +1084,7 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = in_pcbconnect(inp, nam, td->td_ucred);
|
||||
if (error == 0)
|
||||
soisconnected(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -1097,7 +1099,7 @@ udp_detach(struct socket *so)
|
||||
KASSERT(inp->inp_faddr.s_addr == INADDR_ANY,
|
||||
("udp_detach: not disconnected"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
in_pcbdetach(inp);
|
||||
in_pcbfree(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
@ -1111,10 +1113,10 @@ udp_disconnect(struct socket *so)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_disconnect: inp == NULL"));
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_faddr.s_addr == INADDR_ANY) {
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
INP_UNLOCK(inp);
|
||||
return (ENOTCONN);
|
||||
}
|
||||
|
||||
@ -1123,7 +1125,7 @@ udp_disconnect(struct socket *so)
|
||||
SOCK_LOCK(so);
|
||||
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
||||
SOCK_UNLOCK(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (0);
|
||||
}
|
||||
@ -1146,9 +1148,9 @@ udp_shutdown(struct socket *so)
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("udp_shutdown: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
socantsendmore(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1891,10 +1891,10 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
|
||||
INP_INFO_RLOCK(&ripcbinfo);
|
||||
LIST_FOREACH(in6p, &ripcb, inp_list) {
|
||||
INP_LOCK(in6p);
|
||||
INP_WLOCK(in6p);
|
||||
if ((in6p->inp_vflag & INP_IPV6) == 0) {
|
||||
docontinue:
|
||||
INP_UNLOCK(in6p);
|
||||
INP_WUNLOCK(in6p);
|
||||
continue;
|
||||
}
|
||||
if (in6p->in6p_ip6_nxt != IPPROTO_ICMPV6)
|
||||
@ -1965,7 +1965,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
sorwakeup_locked(last->in6p_socket);
|
||||
opts = NULL;
|
||||
}
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
}
|
||||
last = in6p;
|
||||
}
|
||||
@ -2003,7 +2003,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
|
||||
SOCKBUF_UNLOCK(&last->in6p_socket->so_rcv);
|
||||
} else
|
||||
sorwakeup_locked(last->in6p_socket);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
} else {
|
||||
m_freem(m);
|
||||
ip6stat.ip6s_delivered--;
|
||||
|
@ -122,7 +122,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
|
||||
int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (!in6_ifaddr) /* XXX broken! */
|
||||
return (EADDRNOTAVAIL);
|
||||
@ -288,7 +288,7 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam,
|
||||
int scope_ambiguous = 0;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (nam->sa_len != sizeof (*sin6))
|
||||
return (EINVAL);
|
||||
@ -354,7 +354,7 @@ in6_pcbconnect(register struct inpcb *inp, struct sockaddr *nam,
|
||||
int error;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/*
|
||||
* Call inner routine, to assign local interface address.
|
||||
@ -396,7 +396,7 @@ in6_pcbdisconnect(struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
bzero((caddr_t)&inp->in6p_faddr, sizeof(inp->in6p_faddr));
|
||||
inp->inp_fport = 0;
|
||||
@ -421,7 +421,7 @@ in6_pcbfree(struct inpcb *inp)
|
||||
|
||||
KASSERT(inp->inp_socket == NULL, ("in6_pcbfree: inp_socket != NULL"));
|
||||
INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef IPSEC
|
||||
if (inp->in6p_sp != NULL)
|
||||
@ -440,7 +440,7 @@ in6_pcbfree(struct inpcb *inp)
|
||||
#ifdef MAC
|
||||
mac_inpcb_destroy(inp);
|
||||
#endif
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
uma_zfree(ipi->ipi_zone, inp);
|
||||
}
|
||||
|
||||
@ -489,10 +489,10 @@ in6_getsockaddr(struct socket *so, struct sockaddr **nam)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in6_getsockaddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
port = inp->inp_lport;
|
||||
addr = inp->in6p_laddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
*nam = in6_sockaddr(port, &addr);
|
||||
return 0;
|
||||
@ -508,10 +508,10 @@ in6_getpeeraddr(struct socket *so, struct sockaddr **nam)
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in6_getpeeraddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
port = inp->inp_fport;
|
||||
addr = inp->in6p_faddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
|
||||
*nam = in6_sockaddr(port, &addr);
|
||||
return 0;
|
||||
@ -611,9 +611,9 @@ in6_pcbnotify(struct inpcbinfo *pcbinfo, struct sockaddr *dst,
|
||||
errno = inet6ctlerrmap[cmd];
|
||||
INP_INFO_WLOCK(pcbinfo);
|
||||
LIST_FOREACH_SAFE(inp, pcbinfo->ipi_listhead, inp_list, inp_temp) {
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_vflag & INP_IPV6) == 0) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -654,16 +654,16 @@ in6_pcbnotify(struct inpcbinfo *pcbinfo, struct sockaddr *dst,
|
||||
!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr,
|
||||
&sa6_src.sin6_addr)) ||
|
||||
(fport && inp->inp_fport != fport)) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
continue;
|
||||
}
|
||||
|
||||
do_notify:
|
||||
if (notify) {
|
||||
if ((*notify)(inp, errno))
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
} else
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
}
|
||||
INP_INFO_WUNLOCK(pcbinfo);
|
||||
}
|
||||
@ -765,7 +765,7 @@ in6_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
|
||||
INP_INFO_RLOCK(pcbinfo);
|
||||
LIST_FOREACH(in6p, pcbinfo->ipi_listhead, inp_list) {
|
||||
INP_LOCK(in6p);
|
||||
INP_WLOCK(in6p);
|
||||
im6o = in6p->in6p_moptions;
|
||||
if ((in6p->inp_vflag & INP_IPV6) &&
|
||||
im6o) {
|
||||
@ -792,7 +792,7 @@ in6_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp)
|
||||
}
|
||||
}
|
||||
}
|
||||
INP_UNLOCK(in6p);
|
||||
INP_WUNLOCK(in6p);
|
||||
}
|
||||
INP_INFO_RUNLOCK(pcbinfo);
|
||||
}
|
||||
@ -839,7 +839,7 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr,
|
||||
u_short fport = fport_arg, lport = lport_arg;
|
||||
int faith;
|
||||
|
||||
INP_INFO_RLOCK_ASSERT(pcbinfo);
|
||||
INP_INFO_LOCK_ASSERT(pcbinfo);
|
||||
|
||||
if (faithprefix_p != NULL)
|
||||
faith = (*faithprefix_p)(laddr);
|
||||
|
@ -763,7 +763,7 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred)
|
||||
struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
|
||||
|
||||
INP_INFO_WLOCK_ASSERT(pcbinfo);
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
/* XXX: this is redundant when called from in6_pcbbind */
|
||||
if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0)
|
||||
|
@ -154,10 +154,10 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
|
||||
INP_INFO_RLOCK(&ripcbinfo);
|
||||
LIST_FOREACH(in6p, &ripcb, inp_list) {
|
||||
INP_LOCK(in6p);
|
||||
INP_WLOCK(in6p);
|
||||
if ((in6p->in6p_vflag & INP_IPV6) == 0) {
|
||||
docontinue:
|
||||
INP_UNLOCK(in6p);
|
||||
INP_WUNLOCK(in6p);
|
||||
continue;
|
||||
}
|
||||
if (in6p->in6p_ip6_nxt &&
|
||||
@ -207,7 +207,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
sorwakeup(last->in6p_socket);
|
||||
opts = NULL;
|
||||
}
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
}
|
||||
last = in6p;
|
||||
}
|
||||
@ -220,7 +220,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
ipsec6stat.in_polvio++;
|
||||
ip6stat.ip6s_delivered--;
|
||||
/* do not inject data into pcb */
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
} else
|
||||
#endif /* IPSEC */
|
||||
if (last) {
|
||||
@ -237,7 +237,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
|
||||
rip6stat.rip6s_fullsock++;
|
||||
} else
|
||||
sorwakeup(last->in6p_socket);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
} else {
|
||||
rip6stat.rip6s_nosock++;
|
||||
if (m->m_flags & M_MCAST)
|
||||
@ -335,7 +335,7 @@ rip6_output(m, va_alist)
|
||||
va_end(ap);
|
||||
|
||||
in6p = sotoin6pcb(so);
|
||||
INP_LOCK(in6p);
|
||||
INP_WLOCK(in6p);
|
||||
|
||||
dst = &dstsock->sin6_addr;
|
||||
if (control) {
|
||||
@ -465,7 +465,7 @@ rip6_output(m, va_alist)
|
||||
ip6_clearpktopts(&opt, -1);
|
||||
m_freem(control);
|
||||
}
|
||||
INP_UNLOCK(in6p);
|
||||
INP_WUNLOCK(in6p);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ rip6_attach(struct socket *so, int proto, struct thread *td)
|
||||
inp->in6p_cksum = -1;
|
||||
inp->in6p_icmp6filt = filter;
|
||||
ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ rip6_detach(struct socket *so)
|
||||
ip6_mrouter_done();
|
||||
/* xxx: RSVP */
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->in6p_icmp6filt) {
|
||||
FREE(inp->in6p_icmp6filt, M_PCB);
|
||||
inp->in6p_icmp6filt = NULL;
|
||||
@ -656,9 +656,9 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
return (EADDRNOTAVAIL);
|
||||
}
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
inp->in6p_laddr = addr->sin6_addr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return 0;
|
||||
}
|
||||
@ -694,13 +694,13 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
return(error);
|
||||
|
||||
INP_INFO_WLOCK(&ripcbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
/* Source address selection. XXX: need pcblookup? */
|
||||
in6a = in6_selectsrc(addr, inp->in6p_outputopts,
|
||||
inp->in6p_moptions, NULL,
|
||||
&inp->in6p_laddr, &ifp, &error);
|
||||
if (in6a == NULL) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return (error ? error : EADDRNOTAVAIL);
|
||||
}
|
||||
@ -708,14 +708,14 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
/* XXX: see above */
|
||||
if (ifp && scope_ambiguous &&
|
||||
(error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) {
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return(error);
|
||||
}
|
||||
inp->in6p_faddr = addr->sin6_addr;
|
||||
inp->in6p_laddr = *in6a;
|
||||
soisconnected(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&ripcbinfo);
|
||||
return 0;
|
||||
}
|
||||
@ -727,9 +727,9 @@ rip6_shutdown(struct socket *so)
|
||||
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("rip6_shutdown: inp == NULL"));
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
socantsendmore(so);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off,
|
||||
struct socket *so;
|
||||
struct mbuf *opts;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
#ifdef IPSEC
|
||||
/* Check AH/ESP integrity. */
|
||||
@ -277,9 +277,9 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
|
||||
struct mbuf *n;
|
||||
|
||||
if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
|
||||
INP_LOCK(last);
|
||||
INP_WLOCK(last);
|
||||
udp6_append(last, n, off, &fromsa);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
}
|
||||
}
|
||||
last = inp;
|
||||
@ -306,9 +306,9 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
|
||||
udpstat.udps_noportmcast++;
|
||||
goto badheadlocked;
|
||||
}
|
||||
INP_LOCK(last);
|
||||
INP_WLOCK(last);
|
||||
udp6_append(last, m, off, &fromsa);
|
||||
INP_UNLOCK(last);
|
||||
INP_WUNLOCK(last);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
return (IPPROTO_DONE);
|
||||
}
|
||||
@ -343,9 +343,9 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
|
||||
icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
|
||||
return (IPPROTO_DONE);
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
udp6_append(inp, m, off, &fromsa);
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
return (IPPROTO_DONE);
|
||||
|
||||
@ -453,7 +453,7 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
return (ENOENT);
|
||||
}
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_socket == NULL) {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
@ -463,7 +463,7 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
|
||||
goto out;
|
||||
cru2x(inp->inp_socket->so_cred, &xuc);
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(&udbinfo);
|
||||
if (error == 0)
|
||||
error = SYSCTL_OUT(req, &xuc, sizeof(struct xucred));
|
||||
@ -492,7 +492,7 @@ udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6,
|
||||
int flags;
|
||||
struct sockaddr_in6 tmp;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
|
||||
if (addr6) {
|
||||
/* addr6 has been validated in udp6_send(). */
|
||||
@ -708,13 +708,13 @@ udp6_abort(struct socket *so)
|
||||
#endif
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||
in6_pcbdisconnect(inp);
|
||||
inp->in6p_laddr = in6addr_any;
|
||||
soisdisconnected(so);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
}
|
||||
|
||||
@ -752,7 +752,7 @@ udp6_attach(struct socket *so, int proto, struct thread *td)
|
||||
* which may match an IPv4-mapped IPv6 address.
|
||||
*/
|
||||
inp->inp_ip_ttl = ip_defttl;
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -766,7 +766,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
KASSERT(inp != NULL, ("udp6_bind: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
inp->inp_vflag &= ~INP_IPV4;
|
||||
inp->inp_vflag |= INP_IPV6;
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
|
||||
@ -790,7 +790,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
|
||||
error = in6_pcbbind(inp, nam, td->td_ucred);
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -813,13 +813,13 @@ udp6_close(struct socket *so)
|
||||
}
|
||||
#endif
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||
in6_pcbdisconnect(inp);
|
||||
inp->in6p_laddr = in6addr_any;
|
||||
soisdisconnected(so);
|
||||
}
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
}
|
||||
|
||||
@ -833,7 +833,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
KASSERT(inp != NULL, ("udp6_connect: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
|
||||
struct sockaddr_in6 *sin6_p;
|
||||
|
||||
@ -870,7 +870,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
soisconnected(so);
|
||||
}
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (error);
|
||||
}
|
||||
@ -884,7 +884,7 @@ udp6_detach(struct socket *so)
|
||||
KASSERT(inp != NULL, ("udp6_detach: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
in6_pcbdetach(inp);
|
||||
in6_pcbfree(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
@ -900,7 +900,7 @@ udp6_disconnect(struct socket *so)
|
||||
KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
|
||||
#ifdef INET
|
||||
if (inp->inp_vflag & INP_IPV4) {
|
||||
@ -922,7 +922,7 @@ udp6_disconnect(struct socket *so)
|
||||
/* XXXRW: so_state locking? */
|
||||
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (0);
|
||||
}
|
||||
@ -938,7 +938,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m,
|
||||
KASSERT(inp != NULL, ("udp6_send: inp == NULL"));
|
||||
|
||||
INP_INFO_WLOCK(&udbinfo);
|
||||
INP_LOCK(inp);
|
||||
INP_WLOCK(inp);
|
||||
if (addr) {
|
||||
if (addr->sa_len != sizeof(struct sockaddr_in6)) {
|
||||
error = EINVAL;
|
||||
@ -991,12 +991,12 @@ udp6_send(struct socket *so, int flags, struct mbuf *m,
|
||||
#endif
|
||||
error = udp6_output(inp, m, addr, control, td);
|
||||
out:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
return (error);
|
||||
|
||||
bad:
|
||||
INP_UNLOCK(inp);
|
||||
INP_WUNLOCK(inp);
|
||||
INP_INFO_WUNLOCK(&udbinfo);
|
||||
m_freem(m);
|
||||
return (error);
|
||||
|
@ -649,7 +649,7 @@ audit_arg_file(struct proc *p, struct file *fp)
|
||||
so->so_proto->pr_protocol;
|
||||
SOCK_UNLOCK(so);
|
||||
pcb = (struct inpcb *)so->so_pcb;
|
||||
INP_LOCK(pcb);
|
||||
INP_WLOCK(pcb);
|
||||
ar->k_ar.ar_arg_sockinfo.so_raddr =
|
||||
pcb->inp_faddr.s_addr;
|
||||
ar->k_ar.ar_arg_sockinfo.so_laddr =
|
||||
@ -658,7 +658,7 @@ audit_arg_file(struct proc *p, struct file *fp)
|
||||
pcb->inp_fport;
|
||||
ar->k_ar.ar_arg_sockinfo.so_lport =
|
||||
pcb->inp_lport;
|
||||
INP_UNLOCK(pcb);
|
||||
INP_WUNLOCK(pcb);
|
||||
ARG_SET_VALID(ar, ARG_SOCKINFO);
|
||||
}
|
||||
break;
|
||||
|
@ -201,7 +201,7 @@ mac_inpcb_create_mbuf(struct inpcb *inp, struct mbuf *m)
|
||||
{
|
||||
struct label *mlabel;
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
mlabel = mac_mbuf_to_label(m);
|
||||
|
||||
MAC_PERFORM(inpcb_create_mbuf, inp, inp->inp_label, m, mlabel);
|
||||
@ -306,7 +306,7 @@ void
|
||||
mac_inpcb_sosetlabel(struct socket *so, struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
SOCK_LOCK_ASSERT(so);
|
||||
MAC_PERFORM(inpcb_sosetlabel, so, so->so_label, inp, inp->inp_label);
|
||||
}
|
||||
@ -376,7 +376,7 @@ void
|
||||
mac_syncache_create(struct label *label, struct inpcb *inp)
|
||||
{
|
||||
|
||||
INP_LOCK_ASSERT(inp);
|
||||
INP_WLOCK_ASSERT(inp);
|
||||
MAC_PERFORM(syncache_create, label, inp);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user