Remove pcbinfo locking from in_setsockaddr() and in_setpeeraddr();
holding the inpcb lock is sufficient to prevent races in reading the address and port, as both the inpcb lock and pcbinfo lock are required to change the address/port. Improve consistency of spelling in assertions about inp != NULL. MFC after: 3 months
This commit is contained in:
parent
08414eb70c
commit
2a5f091dc3
@ -759,14 +759,13 @@ in_setsockaddr(struct socket *so, struct sockaddr **nam,
|
||||
struct in_addr addr;
|
||||
in_port_t port;
|
||||
|
||||
INP_INFO_RLOCK(pcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in_setsockaddr: so_pcb == NULL"));
|
||||
KASSERT(inp != NULL, ("in_setsockaddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
port = inp->inp_lport;
|
||||
addr = inp->inp_laddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(pcbinfo);
|
||||
|
||||
*nam = in_sockaddr(port, &addr);
|
||||
return 0;
|
||||
@ -783,14 +782,13 @@ in_setpeeraddr(struct socket *so, struct sockaddr **nam,
|
||||
struct in_addr addr;
|
||||
in_port_t port;
|
||||
|
||||
INP_INFO_RLOCK(pcbinfo);
|
||||
inp = sotoinpcb(so);
|
||||
KASSERT(inp != NULL, ("in_setpeeraddr: so_pcb == NULL"));
|
||||
KASSERT(inp != NULL, ("in_setpeeraddr: inp == NULL"));
|
||||
|
||||
INP_LOCK(inp);
|
||||
port = inp->inp_fport;
|
||||
addr = inp->inp_faddr;
|
||||
INP_UNLOCK(inp);
|
||||
INP_INFO_RUNLOCK(pcbinfo);
|
||||
|
||||
*nam = in_sockaddr(port, &addr);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user