summaryrefslogtreecommitdiffstats
path: root/sys/contrib/pf
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/contrib/pf
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/contrib/pf')
-rw-r--r--sys/contrib/pf/net/pf.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/sys/contrib/pf/net/pf.c b/sys/contrib/pf/net/pf.c
index c1011be..7ac43da 100644
--- a/sys/contrib/pf/net/pf.c
+++ b/sys/contrib/pf/net/pf.c
@@ -2941,13 +2941,9 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
#ifdef __FreeBSD__
if (inp_arg != NULL) {
INP_LOCK_ASSERT(inp_arg);
- if (inp_arg->inp_socket) {
- pd->lookup.uid = inp_arg->inp_socket->so_cred->cr_uid;
- pd->lookup.gid =
- inp_arg->inp_socket->so_cred->cr_groups[0];
- return (1);
- } else
- return (-1);
+ pd->lookup.uid = inp_arg->inp_cred->cr_uid;
+ pd->lookup.gid = inp_arg->inp_cred->cr_groups[0];
+ return (1);
}
#endif
switch (pd->proto) {
@@ -3043,15 +3039,9 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd)
return (-1);
}
#ifdef __FreeBSD__
- INP_RLOCK(inp);
+ pd->lookup.uid = inp->inp_cred->cr_uid;
+ pd->lookup.gid = inp->inp_cred->cr_groups[0];
INP_INFO_RUNLOCK(pi);
- if ((inp->inp_socket == NULL) || (inp->inp_socket->so_cred == NULL)) {
- INP_RUNLOCK(inp);
- return (-1);
- }
- pd->lookup.uid = inp->inp_socket->so_cred->cr_uid;
- pd->lookup.gid = inp->inp_socket->so_cred->cr_groups[0];
- INP_RUNLOCK(inp);
#else
pd->lookup.uid = inp->inp_socket->so_euid;
pd->lookup.gid = inp->inp_socket->so_egid;
OpenPOWER on IntegriCloud