diff -Naur libreswan-3.25-orig/include/pluto_constants.h libreswan-3.25/include/pluto_constants.h
--- libreswan-3.25-orig/include/pluto_constants.h 2018-06-27 11:42:26.000000000 -0400
+++ libreswan-3.25/include/pluto_constants.h 2019-02-23 20:46:36.030789127 -0500
@@ -421,6 +421,7 @@
IMPAIR_REPLAY_DUPLICATES_IX, /* replay duplicates of each incoming packet */
IMPAIR_REPLAY_FORWARD_IX, /* replay all earlier packets old-to-new */
IMPAIR_REPLAY_BACKWARD_IX, /* replay all earlier packets new-to-old */
+ IMPAIR_IKEv1_DEL_WITH_NOTIFY_IX, /* causes pluto send send IKE Delete with additional bogus Notify */
IMPAIR_REPLAY_ENCRYPTED_IX, /* replay encrypted packets */
IMPAIR_CORRUPT_ENCRYPTED_IX, /* corrupts the encrypted packet so that the decryption fails */
@@ -480,6 +481,7 @@
#define IMPAIR_REPLAY_DUPLICATES LELEM(IMPAIR_REPLAY_DUPLICATES_IX)
#define IMPAIR_REPLAY_FORWARD LELEM(IMPAIR_REPLAY_FORWARD_IX)
#define IMPAIR_REPLAY_BACKWARD LELEM(IMPAIR_REPLAY_BACKWARD_IX)
+#define IMPAIR_IKEv1_DEL_WITH_NOTIFY LELEM(IMPAIR_IKEv1_DEL_WITH_NOTIFY_IX)
#define IMPAIR_REPLAY_ENCRYPTED LELEM(IMPAIR_REPLAY_ENCRYPTED_IX)
#define IMPAIR_CORRUPT_ENCRYPTED LELEM(IMPAIR_CORRUPT_ENCRYPTED_IX)
diff -Naur libreswan-3.25-orig/lib/libswan/impair.c libreswan-3.25/lib/libswan/impair.c
--- libreswan-3.25-orig/lib/libswan/impair.c 2018-06-27 11:42:26.000000000 -0400
+++ libreswan-3.25/lib/libswan/impair.c 2019-02-23 20:47:28.556333015 -0500
@@ -61,6 +61,7 @@
I(IMPAIR_REPLAY_DUPLICATES, "impair-replay-duplicates"),
I(IMPAIR_REPLAY_FORWARD, "impair-replay-forward"),
I(IMPAIR_REPLAY_BACKWARD, "impair-replay-backward"),
+ I(IMPAIR_IKEv1_DEL_WITH_NOTIFY, "impair-ikev1-del-with-notify"),
I(IMPAIR_REPLAY_ENCRYPTED, "impair-replay-encrypted"),
I(IMPAIR_CORRUPT_ENCRYPTED, "impair-corrupt-encrypted"),
diff -Naur libreswan-3.25-orig/programs/pluto/ikev1_main.c libreswan-3.25/programs/pluto/ikev1_main.c
--- libreswan-3.25-orig/programs/pluto/ikev1_main.c 2018-06-27 11:42:26.000000000 -0400
+++ libreswan-3.25/programs/pluto/ikev1_main.c 2019-02-23 20:44:30.295457365 -0500
@@ -2489,14 +2489,36 @@
said ? ISAKMP_NEXT_NONE : ISAKMP_NEXT_D;
isad.isad_spisize = sizeof(ipsec_spi_t);
isad.isad_protoid = ns->proto;
-
isad.isad_nospi = 1;
+
+ if (DBGP(IMPAIR_IKEv1_DEL_WITH_NOTIFY))
+ isad.isad_np = ISAKMP_NEXT_N; /* Notify */
+
passert(out_struct(&isad, &isakmp_delete_desc, &r_hdr_pbs,
&del_pbs));
passert(out_raw(&ns->spi, sizeof(ipsec_spi_t),
&del_pbs,
"delete payload"));
close_output_pbs(&del_pbs);
+
+ if (DBGP(IMPAIR_IKEv1_DEL_WITH_NOTIFY)) {
+ pb_stream cruft_pbs;
+
+ libreswan_log("IMPAIR: adding bogus Notify payload after IKE Delete payload");
+ struct isakmp_notification isan = {
+ .isan_np = ISAKMP_NEXT_NONE,
+ .isan_doi = ISAKMP_DOI_IPSEC,
+ .isan_protoid = PROTO_ISAKMP,
+ .isan_spisize = COOKIE_SIZE * 2,
+ .isan_type = INVALID_PAYLOAD_TYPE,
+ };
+
+ passert(out_struct(&isan, &isakmp_notification_desc, &r_hdr_pbs,
+ &cruft_pbs));
+ passert(out_raw(&ns->spi, sizeof(ipsec_spi_t), &cruft_pbs,
+ "notify payload"));
+ close_output_pbs(&cruft_pbs);
+ }
}
}
@@ -2743,7 +2765,9 @@
rc->policy &= ~POLICY_UP;
if (!shared_phase1_connection(rc)) {
flush_pending_by_connection(rc);
+ /* This also deletes the IKE SA, clear pointer */
delete_states_by_connection(rc, FALSE);
+ md->st = NULL;
}
reset_cur_connection();
}