inpcb: make in_pcbdisconnect() acquire the hash lock internally
Should be no functional change. Reviewed by: pouria, markj Differential Revision: https://reviews.freebsd.org/D55968
This commit is contained in:
@@ -1423,13 +1423,14 @@ in_pcbdisconnect(struct inpcb *inp)
|
|||||||
{
|
{
|
||||||
|
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo);
|
|
||||||
KASSERT(inp->inp_smr == SMR_SEQ_INVALID,
|
KASSERT(inp->inp_smr == SMR_SEQ_INVALID,
|
||||||
("%s: inp %p was already disconnected", __func__, inp));
|
("%s: inp %p was already disconnected", __func__, inp));
|
||||||
|
|
||||||
|
INP_HASH_WLOCK(inp->inp_pcbinfo);
|
||||||
in_pcbremhash(inp);
|
in_pcbremhash(inp);
|
||||||
CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp,
|
CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp,
|
||||||
inp_unconn_list);
|
inp_unconn_list);
|
||||||
|
INP_HASH_WUNLOCK(inp->inp_pcbinfo);
|
||||||
|
|
||||||
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
||||||
/* See the comment in in_pcbinshash(). */
|
/* See the comment in in_pcbinshash(). */
|
||||||
|
|||||||
@@ -1528,16 +1528,12 @@ void
|
|||||||
udp_abort(struct socket *so)
|
udp_abort(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp_abort: inp == NULL"));
|
KASSERT(inp != NULL, ("udp_abort: inp == NULL"));
|
||||||
INP_WLOCK(inp);
|
INP_WLOCK(inp);
|
||||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in_pcbdisconnect(inp);
|
in_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
soisdisconnected(so);
|
soisdisconnected(so);
|
||||||
}
|
}
|
||||||
INP_WUNLOCK(inp);
|
INP_WUNLOCK(inp);
|
||||||
@@ -1638,16 +1634,12 @@ static void
|
|||||||
udp_close(struct socket *so)
|
udp_close(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp_close: inp == NULL"));
|
KASSERT(inp != NULL, ("udp_close: inp == NULL"));
|
||||||
INP_WLOCK(inp);
|
INP_WLOCK(inp);
|
||||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in_pcbdisconnect(inp);
|
in_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
soisdisconnected(so);
|
soisdisconnected(so);
|
||||||
}
|
}
|
||||||
INP_WUNLOCK(inp);
|
INP_WUNLOCK(inp);
|
||||||
@@ -1710,9 +1702,7 @@ int
|
|||||||
udp_disconnect(struct socket *so)
|
udp_disconnect(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp_disconnect: inp == NULL"));
|
KASSERT(inp != NULL, ("udp_disconnect: inp == NULL"));
|
||||||
INP_WLOCK(inp);
|
INP_WLOCK(inp);
|
||||||
@@ -1720,9 +1710,7 @@ udp_disconnect(struct socket *so)
|
|||||||
INP_WUNLOCK(inp);
|
INP_WUNLOCK(inp);
|
||||||
return (ENOTCONN);
|
return (ENOTCONN);
|
||||||
}
|
}
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in_pcbdisconnect(inp);
|
in_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
SOCK_LOCK(so);
|
SOCK_LOCK(so);
|
||||||
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
||||||
SOCK_UNLOCK(so);
|
SOCK_UNLOCK(so);
|
||||||
|
|||||||
@@ -504,13 +504,14 @@ in6_pcbdisconnect(struct inpcb *inp)
|
|||||||
{
|
{
|
||||||
|
|
||||||
INP_WLOCK_ASSERT(inp);
|
INP_WLOCK_ASSERT(inp);
|
||||||
INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo);
|
|
||||||
KASSERT(inp->inp_smr == SMR_SEQ_INVALID,
|
KASSERT(inp->inp_smr == SMR_SEQ_INVALID,
|
||||||
("%s: inp %p was already disconnected", __func__, inp));
|
("%s: inp %p was already disconnected", __func__, inp));
|
||||||
|
|
||||||
|
INP_HASH_WLOCK(inp->inp_pcbinfo);
|
||||||
in_pcbremhash(inp);
|
in_pcbremhash(inp);
|
||||||
CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp,
|
CK_LIST_INSERT_HEAD(&inp->inp_pcbinfo->ipi_list_unconn, inp,
|
||||||
inp_unconn_list);
|
inp_unconn_list);
|
||||||
|
INP_HASH_WUNLOCK(inp->inp_pcbinfo);
|
||||||
|
|
||||||
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) {
|
||||||
/* See the comment in in_pcbinshash(). */
|
/* See the comment in in_pcbinshash(). */
|
||||||
|
|||||||
@@ -986,9 +986,7 @@ static void
|
|||||||
udp6_abort(struct socket *so)
|
udp6_abort(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp6_abort: inp == NULL"));
|
KASSERT(inp != NULL, ("udp6_abort: inp == NULL"));
|
||||||
|
|
||||||
@@ -1002,9 +1000,7 @@ udp6_abort(struct socket *so)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in6_pcbdisconnect(inp);
|
in6_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
soisdisconnected(so);
|
soisdisconnected(so);
|
||||||
}
|
}
|
||||||
INP_WUNLOCK(inp);
|
INP_WUNLOCK(inp);
|
||||||
@@ -1104,9 +1100,7 @@ static void
|
|||||||
udp6_close(struct socket *so)
|
udp6_close(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp6_close: inp == NULL"));
|
KASSERT(inp != NULL, ("udp6_close: inp == NULL"));
|
||||||
|
|
||||||
@@ -1119,9 +1113,7 @@ udp6_close(struct socket *so)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in6_pcbdisconnect(inp);
|
in6_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
soisdisconnected(so);
|
soisdisconnected(so);
|
||||||
}
|
}
|
||||||
INP_WUNLOCK(inp);
|
INP_WUNLOCK(inp);
|
||||||
@@ -1243,9 +1235,7 @@ static int
|
|||||||
udp6_disconnect(struct socket *so)
|
udp6_disconnect(struct socket *so)
|
||||||
{
|
{
|
||||||
struct inpcb *inp;
|
struct inpcb *inp;
|
||||||
struct inpcbinfo *pcbinfo;
|
|
||||||
|
|
||||||
pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol);
|
|
||||||
inp = sotoinpcb(so);
|
inp = sotoinpcb(so);
|
||||||
KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL"));
|
KASSERT(inp != NULL, ("udp6_disconnect: inp == NULL"));
|
||||||
|
|
||||||
@@ -1263,9 +1253,7 @@ udp6_disconnect(struct socket *so)
|
|||||||
return (ENOTCONN);
|
return (ENOTCONN);
|
||||||
}
|
}
|
||||||
|
|
||||||
INP_HASH_WLOCK(pcbinfo);
|
|
||||||
in6_pcbdisconnect(inp);
|
in6_pcbdisconnect(inp);
|
||||||
INP_HASH_WUNLOCK(pcbinfo);
|
|
||||||
SOCK_LOCK(so);
|
SOCK_LOCK(so);
|
||||||
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
so->so_state &= ~SS_ISCONNECTED; /* XXX */
|
||||||
SOCK_UNLOCK(so);
|
SOCK_UNLOCK(so);
|
||||||
|
|||||||
Reference in New Issue
Block a user