benesv / rpms / libreswan

Forked from rpms/libreswan 4 years ago
Clone

Blame libreswan-3.25-relax-delete.patch

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