Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24270
b: refs/heads/master
c: 17f834b
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Mar 27, 2006
1 parent f96a093 commit 0af1bcc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 11 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: d4d11ea9d6d6fcfaa66fbd10fd4a8d43aa575597
refs/heads/master: 17f834b6d2e0b102ab53d73ba44d5dbb34c38f90
74 changes: 64 additions & 10 deletions trunk/net/sunrpc/auth_gss/svcauth_gss.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ struct rsc {

static struct cache_head *rsc_table[RSC_HASHMAX];
static struct cache_detail rsc_cache;
static struct rsc *rsc_lookup(struct rsc *item, int set);
static struct rsc *rsc_update(struct rsc *new, struct rsc *old);
static struct rsc *rsc_lookup(struct rsc *item);

static void rsc_free(struct rsc *rsci)
{
Expand All @@ -372,15 +373,21 @@ rsc_hash(struct rsc *rsci)
return hash_mem(rsci->handle.data, rsci->handle.len, RSC_HASHBITS);
}

static inline int
rsc_match(struct rsc *new, struct rsc *tmp)
static int
rsc_match(struct cache_head *a, struct cache_head *b)
{
struct rsc *new = container_of(a, struct rsc, h);
struct rsc *tmp = container_of(b, struct rsc, h);

return netobj_equal(&new->handle, &tmp->handle);
}

static inline void
rsc_init(struct rsc *new, struct rsc *tmp)
static void
rsc_init(struct cache_head *cnew, struct cache_head *ctmp)
{
struct rsc *new = container_of(cnew, struct rsc, h);
struct rsc *tmp = container_of(ctmp, struct rsc, h);

new->handle.len = tmp->handle.len;
tmp->handle.len = 0;
new->handle.data = tmp->handle.data;
Expand All @@ -389,9 +396,12 @@ rsc_init(struct rsc *new, struct rsc *tmp)
new->cred.cr_group_info = NULL;
}

static inline void
rsc_update(struct rsc *new, struct rsc *tmp)
static void
update_rsc(struct cache_head *cnew, struct cache_head *ctmp)
{
struct rsc *new = container_of(cnew, struct rsc, h);
struct rsc *tmp = container_of(ctmp, struct rsc, h);

new->mechctx = tmp->mechctx;
tmp->mechctx = NULL;
memset(&new->seqdata, 0, sizeof(new->seqdata));
Expand All @@ -400,6 +410,16 @@ rsc_update(struct rsc *new, struct rsc *tmp)
tmp->cred.cr_group_info = NULL;
}

static struct cache_head *
rsc_alloc(void)
{
struct rsc *rsci = kmalloc(sizeof(*rsci), GFP_KERNEL);
if (rsci)
return &rsci->h;
else
return NULL;
}

static int rsc_parse(struct cache_detail *cd,
char *mesg, int mlen)
{
Expand All @@ -425,6 +445,10 @@ static int rsc_parse(struct cache_detail *cd,
if (expiry == 0)
goto out;

rscp = rsc_lookup(&rsci);
if (!rscp)
goto out;

/* uid, or NEGATIVE */
rv = get_int(&mesg, &rsci.cred.cr_uid);
if (rv == -EINVAL)
Expand Down Expand Up @@ -480,12 +504,14 @@ static int rsc_parse(struct cache_detail *cd,
gss_mech_put(gm);
}
rsci.h.expiry_time = expiry;
rscp = rsc_lookup(&rsci, 1);
rscp = rsc_update(&rsci, rscp);
status = 0;
out:
rsc_free(&rsci);
if (rscp)
rsc_put(&rscp->h, &rsc_cache);
else
status = -ENOMEM;
return status;
}

Expand All @@ -496,9 +522,37 @@ static struct cache_detail rsc_cache = {
.name = "auth.rpcsec.context",
.cache_put = rsc_put,
.cache_parse = rsc_parse,
.match = rsc_match,
.init = rsc_init,
.update = update_rsc,
.alloc = rsc_alloc,
};

static DefineSimpleCacheLookup(rsc, rsc);
static struct rsc *rsc_lookup(struct rsc *item)
{
struct cache_head *ch;
int hash = rsc_hash(item);

ch = sunrpc_cache_lookup(&rsc_cache, &item->h, hash);
if (ch)
return container_of(ch, struct rsc, h);
else
return NULL;
}

static struct rsc *rsc_update(struct rsc *new, struct rsc *old)
{
struct cache_head *ch;
int hash = rsc_hash(new);

ch = sunrpc_cache_update(&rsc_cache, &new->h,
&old->h, hash);
if (ch)
return container_of(ch, struct rsc, h);
else
return NULL;
}


static struct rsc *
gss_svc_searchbyctx(struct xdr_netobj *handle)
Expand All @@ -509,7 +563,7 @@ gss_svc_searchbyctx(struct xdr_netobj *handle)
memset(&rsci, 0, sizeof(rsci));
if (dup_to_netobj(&rsci.handle, handle->data, handle->len))
return NULL;
found = rsc_lookup(&rsci, 0);
found = rsc_lookup(&rsci);
rsc_free(&rsci);
if (!found)
return NULL;
Expand Down

0 comments on commit 0af1bcc

Please sign in to comment.