Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38369
b: refs/heads/master
c: 7b2b1fe
h: refs/heads/master
i:
  38367: 413cead
v: v3
  • Loading branch information
Greg Banks authored and Linus Torvalds committed Oct 4, 2006
1 parent 84c283b commit 83bead3
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fce1456a19f5c08b688c29f00ef90fdfa074c79b
refs/heads/master: 7b2b1fee30df7e2165525cd03f7d1d01a3a56794
11 changes: 11 additions & 0 deletions trunk/include/linux/sunrpc/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
kref_put(&h->ref, cd->cache_put);
}

static inline int cache_valid(struct cache_head *h)
{
/* If an item has been unhashed pending removal when
* the refcount drops to 0, the expiry_time will be
* set to 0. We don't want to consider such items
* valid in this context even though CACHE_VALID is
* set.
*/
return (h->expiry_time != 0 && test_bit(CACHE_VALID, &h->flags));
}

extern int cache_check(struct cache_detail *detail,
struct cache_head *h, struct cache_req *rqstp);
extern void cache_flush(void);
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/sunrpc/svcauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ extern struct auth_domain *auth_domain_find(char *name);
extern struct auth_domain *auth_unix_lookup(struct in_addr addr);
extern int auth_unix_forget_old(struct auth_domain *dom);
extern void svcauth_unix_purge(void);
extern void svcauth_unix_info_release(void *);

static inline unsigned long hash_str(char *name, int bits)
{
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/sunrpc/svcsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ struct svc_sock {
int sk_reclen; /* length of record */
int sk_tcplen; /* current read length */
time_t sk_lastrecv; /* time of last received request */

/* cache of various info for TCP sockets */
void *sk_info_authunix;
};

/*
Expand Down
47 changes: 44 additions & 3 deletions trunk/net/sunrpc/svcauth_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/seq_file.h>
#include <linux/hash.h>
#include <linux/string.h>
#include <net/sock.h>

#define RPCDBG_FACILITY RPCDBG_AUTH

Expand Down Expand Up @@ -375,6 +376,44 @@ void svcauth_unix_purge(void)
cache_purge(&ip_map_cache);
}

static inline struct ip_map *
ip_map_cached_get(struct svc_rqst *rqstp)
{
struct ip_map *ipm = rqstp->rq_sock->sk_info_authunix;
if (ipm != NULL) {
if (!cache_valid(&ipm->h)) {
/*
* The entry has been invalidated since it was
* remembered, e.g. by a second mount from the
* same IP address.
*/
rqstp->rq_sock->sk_info_authunix = NULL;
cache_put(&ipm->h, &ip_map_cache);
return NULL;
}
cache_get(&ipm->h);
}
return ipm;
}

static inline void
ip_map_cached_put(struct svc_rqst *rqstp, struct ip_map *ipm)
{
struct svc_sock *svsk = rqstp->rq_sock;

if (svsk->sk_sock->type == SOCK_STREAM && svsk->sk_info_authunix == NULL)
svsk->sk_info_authunix = ipm; /* newly cached, keep the reference */
else
cache_put(&ipm->h, &ip_map_cache);
}

void
svcauth_unix_info_release(void *info)
{
struct ip_map *ipm = info;
cache_put(&ipm->h, &ip_map_cache);
}

static int
svcauth_unix_set_client(struct svc_rqst *rqstp)
{
Expand All @@ -384,8 +423,10 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
if (rqstp->rq_proc == 0)
return SVC_OK;

ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class,
rqstp->rq_addr.sin_addr);
ipm = ip_map_cached_get(rqstp);
if (ipm == NULL)
ipm = ip_map_lookup(rqstp->rq_server->sv_program->pg_class,
rqstp->rq_addr.sin_addr);

if (ipm == NULL)
return SVC_DENIED;
Expand All @@ -400,7 +441,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
case 0:
rqstp->rq_client = &ipm->m_client->h;
kref_get(&rqstp->rq_client->ref);
cache_put(&ipm->h, &ip_map_cache);
ip_map_cached_put(rqstp, ipm);
break;
}
return SVC_OK;
Expand Down
2 changes: 2 additions & 0 deletions trunk/net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,8 @@ svc_delete_socket(struct svc_sock *svsk)
sockfd_put(svsk->sk_sock);
else
sock_release(svsk->sk_sock);
if (svsk->sk_info_authunix != NULL)
svcauth_unix_info_release(svsk->sk_info_authunix);
kfree(svsk);
} else {
spin_unlock_bh(&serv->sv_lock);
Expand Down

0 comments on commit 83bead3

Please sign in to comment.