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

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