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