Blame SOURCES/libreswan-3.25-relax-delete.patch

a307e3
diff --git a/programs/pluto/state.c b/programs/pluto/state.c
a307e3
index 7b33145..a3bcc3c 100644
a307e3
--- a/programs/pluto/state.c
a307e3
+++ b/programs/pluto/state.c
a307e3
@@ -3155,27 +3155,40 @@ void ISAKMP_SA_established(const struct state *pst)
a307e3
 			d = next;
a307e3
 		}
a307e3
 
a307e3
-		if (c->newest_isakmp_sa != SOS_NOBODY &&
a307e3
-			c->newest_isakmp_sa != pst->st_serialno) {
a307e3
-				struct state *old_p1 = state_by_serialno(c->newest_isakmp_sa);
a307e3
+		/*
a307e3
+		 * This only affects IKEv2, since we don't store any
a307e3
+		 * received INITIAL_CONTACT for IKEv1.
a307e3
+		 * We don't do this on IKEv1, because it seems to
a307e3
+		 * confuse various third parties (Windows, Cisco VPN 300,
a307e3
+		 * and juniper
a307e3
+		 * likely because this would be called before the IPsec SA
a307e3
+		 * of QuickMode is installed, so the remote endpoints view
a307e3
+		 * this IKE SA still as the active one?
a307e3
+		 */
a307e3
+		if (pst->st_seen_initialc) {
a307e3
 
a307e3
-				DBG(DBG_CONTROL, DBG_log("deleting replaced IKE state for %s",
a307e3
-					old_p1->st_connection->name));
a307e3
-				old_p1->st_suppress_del_notify = TRUE;
a307e3
-				event_force(EVENT_SA_EXPIRE, old_p1);
a307e3
-		}
a307e3
+			if (c->newest_isakmp_sa != SOS_NOBODY &&
a307e3
+				c->newest_isakmp_sa != pst->st_serialno) {
a307e3
+					struct state *old_p1 = state_by_serialno(c->newest_isakmp_sa);
a307e3
 
a307e3
-		if (pst->st_seen_initialc && (c->newest_ipsec_sa != SOS_NOBODY))
a307e3
-		{
a307e3
-			struct state *old_p2 = state_by_serialno(c->newest_ipsec_sa);
a307e3
-			struct connection *d = old_p2 == NULL ? NULL : old_p2->st_connection;
a307e3
+					DBG(DBG_CONTROL, DBG_log("deleting replaced IKE state for %s",
a307e3
+						old_p1->st_connection->name));
a307e3
+					old_p1->st_suppress_del_notify = TRUE;
a307e3
+					event_force(EVENT_SA_EXPIRE, old_p1);
a307e3
+			}
a307e3
 
a307e3
-			if (c == d && same_id(&c->spd.that.id, &d->spd.that.id))
a307e3
+			if (c->newest_ipsec_sa != SOS_NOBODY)
a307e3
 			{
a307e3
-				DBG(DBG_CONTROL, DBG_log("Initial Contact received, deleting old state #%lu from connection '%s'",
a307e3
-					c->newest_ipsec_sa, c->name));
a307e3
-				old_p2->st_suppress_del_notify = TRUE;
a307e3
-				event_force(EVENT_SA_EXPIRE, old_p2);
a307e3
+				struct state *old_p2 = state_by_serialno(c->newest_ipsec_sa);
a307e3
+				struct connection *d = old_p2 == NULL ? NULL : old_p2->st_connection;
a307e3
+
a307e3
+				if (c == d && same_id(&c->spd.that.id, &d->spd.that.id))
a307e3
+				{
a307e3
+					DBG(DBG_CONTROL, DBG_log("Initial Contact received, deleting old state #%lu from connection '%s'",
a307e3
+						c->newest_ipsec_sa, c->name));
a307e3
+					old_p2->st_suppress_del_notify = TRUE;
a307e3
+					event_force(EVENT_SA_EXPIRE, old_p2);
a307e3
+				}
a307e3
 			}
a307e3
 		}
a307e3