netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [IPSEC] Remove redundant check in xfrm_state_add()
@ 2004-07-30 12:10 Herbert Xu
  2004-08-01  6:41 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Xu @ 2004-07-30 12:10 UTC (permalink / raw)
  To: David S. Miller, netdev

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

Hi Dave:

This is the patch referred to in the netlink_get_spi thread.

I was actually wrong about the reason for this patch though.  Firstly
it's the SPI check that is redundant and not the find_acq() call.
And it's redundant because of the find_acq() patch, not because
of the fact that this is in xfrm_state_add().

Now that find_acq() only returns SAs with SPIs, we don't need to
check this in xfrm_state_add() anymore.

We do still need the call though to clean up leftover larval states.

Another side-effect of the change is that we can move the existence
check above find_acq() since find_acq() will never return any SAs
matching the SPI we're trying to add (It doesn't need to because if
an SA with a matching SPI existed, it would've been returned by
state_lookup() already).

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 783 bytes --]

===== net/xfrm/xfrm_state.c 1.48 vs edited =====
--- 1.48/net/xfrm/xfrm_state.c	2004-07-30 21:16:40 +10:00
+++ edited/net/xfrm/xfrm_state.c	2004-07-30 22:07:01 +10:00
@@ -400,22 +400,16 @@
 	spin_lock_bh(&xfrm_state_lock);
 
 	x1 = afinfo->state_lookup(&x->id.daddr, x->id.spi, x->id.proto);
-	if (!x1) {
-		x1 = afinfo->find_acq(
-			x->props.mode, x->props.reqid, x->id.proto,
-			&x->id.daddr, &x->props.saddr, 0);
-		if (x1 && x1->id.spi != x->id.spi && x1->id.spi) {
-			xfrm_state_put(x1);
-			x1 = NULL;
-		}
-	}
-
-	if (x1 && x1->id.spi) {
+	if (x1) {
 		xfrm_state_put(x1);
 		x1 = NULL;
 		err = -EEXIST;
 		goto out;
 	}
+
+	x1 = afinfo->find_acq(
+		x->props.mode, x->props.reqid, x->id.proto,
+		&x->id.daddr, &x->props.saddr, 0);
 
 	__xfrm_state_insert(x);
 	err = 0;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [IPSEC] Remove redundant check in xfrm_state_add()
  2004-07-30 12:10 [IPSEC] Remove redundant check in xfrm_state_add() Herbert Xu
@ 2004-08-01  6:41 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-08-01  6:41 UTC (permalink / raw)
  To: Herbert Xu; +Cc: netdev

On Fri, 30 Jul 2004 22:10:56 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> This is the patch referred to in the netlink_get_spi thread.

Yep, looks good.  Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-01  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-30 12:10 [IPSEC] Remove redundant check in xfrm_state_add() Herbert Xu
2004-08-01  6:41 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).