aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2006-04-22 19:10:02 +0000
committerRobert Watson <rwatson@FreeBSD.org>2006-04-22 19:10:02 +0000
commit6466b28a40fa5413e945eb2f5db0b8a7da8e3d14 (patch)
treefd7b7f28d6c54d3616a64c3c4ed4605cff8fd6b9 /sys/netinet/in_pcb.c
parent4b1ead982eda4d5cab5a484b23f41d3721da976c (diff)
downloadsrc-6466b28a40fa5413e945eb2f5db0b8a7da8e3d14.tar.gz
src-6466b28a40fa5413e945eb2f5db0b8a7da8e3d14.zip
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
Notes
Notes: svn path=/head/; revision=157965
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 20c56ed8b1ee..26602cc3cee5 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -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;