Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109444
b: refs/heads/master
c: 37b08e3
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Sep 3, 2008
1 parent d2bef6a commit e1c729d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 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: 06770843c2f0f929a6e0c758dc433902a01aabfb
refs/heads/master: 37b08e34a98c664bea86e3fae718ac45a46b7276
32 changes: 23 additions & 9 deletions trunk/net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,13 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
{
unsigned int h;
struct hlist_node *entry;
struct xfrm_state *x, *x0;
struct xfrm_state *x, *x0, *to_put;
int acquire_in_progress = 0;
int error = 0;
struct xfrm_state *best = NULL;

to_put = NULL;

spin_lock_bh(&xfrm_state_lock);
h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family);
hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) {
Expand Down Expand Up @@ -833,7 +835,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
if (tmpl->id.spi &&
(x0 = __xfrm_state_lookup(daddr, tmpl->id.spi,
tmpl->id.proto, family)) != NULL) {
xfrm_state_put(x0);
to_put = x0;
error = -EEXIST;
goto out;
}
Expand All @@ -849,7 +851,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid);
if (error) {
x->km.state = XFRM_STATE_DEAD;
xfrm_state_put(x);
to_put = x;
x = NULL;
goto out;
}
Expand All @@ -870,7 +872,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
xfrm_hash_grow_check(x->bydst.next != NULL);
} else {
x->km.state = XFRM_STATE_DEAD;
xfrm_state_put(x);
to_put = x;
x = NULL;
error = -ESRCH;
}
Expand All @@ -881,6 +883,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
else
*err = acquire_in_progress ? -EAGAIN : error;
spin_unlock_bh(&xfrm_state_lock);
if (to_put)
xfrm_state_put(to_put);
return x;
}

Expand Down Expand Up @@ -1067,18 +1071,20 @@ static struct xfrm_state *__xfrm_find_acq_byseq(u32 seq);

int xfrm_state_add(struct xfrm_state *x)
{
struct xfrm_state *x1;
struct xfrm_state *x1, *to_put;
int family;
int err;
int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY);

family = x->props.family;

to_put = NULL;

spin_lock_bh(&xfrm_state_lock);

x1 = __xfrm_state_locate(x, use_spi, family);
if (x1) {
xfrm_state_put(x1);
to_put = x1;
x1 = NULL;
err = -EEXIST;
goto out;
Expand All @@ -1088,7 +1094,7 @@ int xfrm_state_add(struct xfrm_state *x)
x1 = __xfrm_find_acq_byseq(x->km.seq);
if (x1 && ((x1->id.proto != x->id.proto) ||
xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) {
xfrm_state_put(x1);
to_put = x1;
x1 = NULL;
}
}
Expand All @@ -1110,6 +1116,9 @@ int xfrm_state_add(struct xfrm_state *x)
xfrm_state_put(x1);
}

if (to_put)
xfrm_state_put(to_put);

return err;
}
EXPORT_SYMBOL(xfrm_state_add);
Expand Down Expand Up @@ -1269,10 +1278,12 @@ EXPORT_SYMBOL(xfrm_state_migrate);

int xfrm_state_update(struct xfrm_state *x)
{
struct xfrm_state *x1;
struct xfrm_state *x1, *to_put;
int err;
int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY);

to_put = NULL;

spin_lock_bh(&xfrm_state_lock);
x1 = __xfrm_state_locate(x, use_spi, x->props.family);

Expand All @@ -1281,7 +1292,7 @@ int xfrm_state_update(struct xfrm_state *x)
goto out;

if (xfrm_state_kern(x1)) {
xfrm_state_put(x1);
to_put = x1;
err = -EEXIST;
goto out;
}
Expand All @@ -1295,6 +1306,9 @@ int xfrm_state_update(struct xfrm_state *x)
out:
spin_unlock_bh(&xfrm_state_lock);

if (to_put)
xfrm_state_put(to_put);

if (err)
return err;

Expand Down

0 comments on commit e1c729d

Please sign in to comment.