summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/in6_pcb.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2008-10-04 15:06:34 +0000
committerbz <bz@FreeBSD.org>2008-10-04 15:06:34 +0000
commit77f80e067299bffd274515d2db4724fd7d914bec (patch)
tree798bd6e57445e0123df29550d1712a406a9067ef /sys/netinet6/in6_pcb.c
parent848f285a655e18bcbd21886fa35dbab3286b54e4 (diff)
downloadFreeBSD-src-77f80e067299bffd274515d2db4724fd7d914bec.zip
FreeBSD-src-77f80e067299bffd274515d2db4724fd7d914bec.tar.gz
Cache so_cred as inp_cred in the inpcb.
This means that inp_cred is always there, even after the socket has gone away. It also means that it is constant for the lifetime of the inp. Both facts lead to simpler code and possibly less locking. Suggested by: rwatson Reviewed by: rwatson MFC after: 6 weeks X-MFC Note: use a inp_pspare for inp_cred
Diffstat (limited to 'sys/netinet6/in6_pcb.c')
-rw-r--r--sys/netinet6/in6_pcb.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 404335b..d241f1e 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -189,7 +189,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
0))
return (EACCES);
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr) &&
- priv_check_cred(so->so_cred,
+ priv_check_cred(inp->inp_cred,
PRIV_NETINET_REUSEPORT, 0) != 0) {
t = in6_pcblookup_local(pcbinfo,
&sin6->sin6_addr, lport,
@@ -201,8 +201,8 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
(!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
!IN6_IS_ADDR_UNSPECIFIED(&t->in6p_laddr) ||
(t->inp_socket->so_options & SO_REUSEPORT)
- == 0) && (so->so_cred->cr_uid !=
- t->inp_socket->so_cred->cr_uid))
+ == 0) && (inp->inp_cred->cr_uid !=
+ t->inp_cred->cr_uid))
return (EADDRINUSE);
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 &&
IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
@@ -218,8 +218,8 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam,
(so->so_type != SOCK_STREAM ||
ntohl(t->inp_faddr.s_addr) ==
INADDR_ANY) &&
- (so->so_cred->cr_uid !=
- t->inp_socket->so_cred->cr_uid))
+ (inp->inp_cred->cr_uid !=
+ t->inp_cred->cr_uid))
return (EADDRINUSE);
}
}
@@ -323,7 +323,7 @@ in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam,
*/
*plocal_addr6 = in6_selectsrc(sin6, inp->in6p_outputopts,
inp, NULL,
- inp->inp_socket->so_cred,
+ inp->inp_cred,
&ifp, &error);
if (ifp && scope_ambiguous &&
(error = in6_setscope(&sin6->sin6_addr, ifp, NULL)) != 0) {
OpenPOWER on IntegriCloud