|
|
b77cff |
diff -Naur libreswan-3.25-orig/include/pluto_constants.h libreswan-3.25/include/pluto_constants.h
|
|
|
b77cff |
--- libreswan-3.25-orig/include/pluto_constants.h 2019-05-02 10:54:07.265614654 -0400
|
|
|
b77cff |
+++ libreswan-3.25/include/pluto_constants.h 2019-05-02 10:55:42.634626504 -0400
|
|
|
b77cff |
@@ -152,6 +152,7 @@
|
|
|
b77cff |
EVENT_SD_WATCHDOG, /* update systemd's watchdog interval */
|
|
|
b77cff |
EVENT_PENDING_PHASE2, /* do not make pending phase2 wait forever */
|
|
|
b77cff |
EVENT_CHECK_CRLS, /* check/update CRLS */
|
|
|
b77cff |
+ EVENT_REVIVE_CONNS,
|
|
|
b77cff |
|
|
|
b77cff |
/* events associated with states */
|
|
|
b77cff |
|
|
|
b77cff |
@@ -203,6 +204,9 @@
|
|
|
b77cff |
#define EVENT_CRYPTO_TIMEOUT_DELAY RETRANSMIT_TIMEOUT_DEFAULT /* wait till the other side give up on us */
|
|
|
b77cff |
#define EVENT_PAM_TIMEOUT_DELAY RETRANSMIT_TIMEOUT_DEFAULT /* wait until this side give up on PAM */
|
|
|
b77cff |
|
|
|
b77cff |
+#define REVIVE_CONN_DELAY 5 /* seconds */
|
|
|
b77cff |
+#define REVIVE_CONN_DELAY_MAX 300 /* Do not delay more than 5 minutes per attempt */
|
|
|
b77cff |
+
|
|
|
b77cff |
/*
|
|
|
b77cff |
* operational importance of this cryptographic operation.
|
|
|
b77cff |
* this determines if the operation will be dropped (because the other
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/connections.c libreswan-3.25/programs/pluto/connections.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/connections.c 2019-05-02 10:54:07.265614654 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/connections.c 2019-05-02 10:55:42.635626515 -0400
|
|
|
b77cff |
@@ -4629,3 +4629,28 @@
|
|
|
b77cff |
c->name, prio));
|
|
|
b77cff |
return prio;
|
|
|
b77cff |
}
|
|
|
b77cff |
+
|
|
|
b77cff |
+/*
|
|
|
b77cff |
+ * If the connection contains a newer SA, return it.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+so_serial_t get_newer_sa_from_connection(struct state *st)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ struct connection *c = st->st_connection;
|
|
|
b77cff |
+ so_serial_t newest;
|
|
|
b77cff |
+
|
|
|
b77cff |
+ if (IS_IKE_SA(st)) {
|
|
|
b77cff |
+ newest = c->newest_isakmp_sa;
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("picked newest_isakmp_sa #%lu for #%lu",
|
|
|
b77cff |
+ newest, st->st_serialno));
|
|
|
b77cff |
+ } else {
|
|
|
b77cff |
+ newest = c->newest_ipsec_sa;
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("picked newest_ipsec_sa #%lu for #%lu",
|
|
|
b77cff |
+ newest, st->st_serialno));
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+
|
|
|
b77cff |
+ if (newest != SOS_NOBODY && newest > st->st_serialno) {
|
|
|
b77cff |
+ return newest;
|
|
|
b77cff |
+ } else {
|
|
|
b77cff |
+ return SOS_NOBODY;
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+}
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/connections.h libreswan-3.25/programs/pluto/connections.h
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/connections.h 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/connections.h 2019-05-02 10:57:22.626689082 -0400
|
|
|
b77cff |
@@ -343,6 +343,7 @@
|
|
|
b77cff |
u_int32_t statsval; /* track what we have told statsd */
|
|
|
b77cff |
u_int16_t nflog_group; /* NFLOG group - 0 means disabled */
|
|
|
b77cff |
msgid_t ike_window; /* IKE v2 window size 7296#section-2.3 */
|
|
|
b77cff |
+ int revive_delay;
|
|
|
b77cff |
};
|
|
|
b77cff |
|
|
|
b77cff |
extern void parse_mark_mask(const struct connection* c,int * mark, int * mask);
|
|
|
b77cff |
@@ -385,7 +386,7 @@
|
|
|
b77cff |
struct xfrm_user_sec_ctx_ike *uctx,
|
|
|
b77cff |
#endif
|
|
|
b77cff |
err_t why);
|
|
|
b77cff |
-extern void terminate_connection(const char *name);
|
|
|
b77cff |
+extern void terminate_connection(const char *name, bool quiet);
|
|
|
b77cff |
extern void release_connection(struct connection *c, bool relations);
|
|
|
b77cff |
extern void delete_connection(struct connection *c, bool relations);
|
|
|
b77cff |
extern void suppress_delete(struct connection *c);
|
|
|
b77cff |
@@ -539,3 +540,8 @@
|
|
|
b77cff |
extern bool idr_wildmatch(const struct connection *c, const struct id *b);
|
|
|
b77cff |
|
|
|
b77cff |
extern uint32_t calculate_sa_prio(const struct connection *c);
|
|
|
b77cff |
+
|
|
|
b77cff |
+so_serial_t get_newer_sa_from_connection(struct state *st);
|
|
|
b77cff |
+
|
|
|
b77cff |
+extern void flush_revival(const struct connection *c);
|
|
|
b77cff |
+
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/hostpair.c libreswan-3.25/programs/pluto/hostpair.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/hostpair.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/hostpair.c 2019-05-02 10:55:42.635626515 -0400
|
|
|
b77cff |
@@ -274,7 +274,7 @@
|
|
|
b77cff |
*/
|
|
|
b77cff |
passert(p == *pp);
|
|
|
b77cff |
|
|
|
b77cff |
- terminate_connection(p->name);
|
|
|
b77cff |
+ terminate_connection(p->name, FALSE);
|
|
|
b77cff |
p->interface = NULL; /* withdraw orientation */
|
|
|
b77cff |
|
|
|
b77cff |
*pp = p->hp_next; /* advance *pp */
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/initiate.c libreswan-3.25/programs/pluto/initiate.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/initiate.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/initiate.c 2019-05-02 10:55:42.640626568 -0400
|
|
|
b77cff |
@@ -148,7 +148,7 @@
|
|
|
b77cff |
c->interface->ip_dev->id_rname,
|
|
|
b77cff |
p->ip_dev->id_rname);
|
|
|
b77cff |
}
|
|
|
b77cff |
- terminate_connection(c->name);
|
|
|
b77cff |
+ terminate_connection(c->name, FALSE);
|
|
|
b77cff |
c->interface = NULL; /* withdraw orientation */
|
|
|
b77cff |
return FALSE;
|
|
|
b77cff |
}
|
|
|
b77cff |
@@ -401,7 +401,7 @@
|
|
|
b77cff |
{
|
|
|
b77cff |
/* This might delete c if CK_INSTANCE */
|
|
|
b77cff |
/* ??? is there a chance hp becomes dangling? */
|
|
|
b77cff |
- terminate_connection(d->name);
|
|
|
b77cff |
+ terminate_connection(d->name, FALSE);
|
|
|
b77cff |
}
|
|
|
b77cff |
d = next;
|
|
|
b77cff |
}
|
|
|
b77cff |
@@ -750,6 +750,12 @@
|
|
|
b77cff |
fmt_conn_instance(c, cib));
|
|
|
b77cff |
});
|
|
|
b77cff |
|
|
|
b77cff |
+ if (sr->routing == RT_ROUTED_PROSPECTIVE && eclipsable(sr)) {
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("route is eclipsed"));
|
|
|
b77cff |
+ sr->routing = RT_ROUTED_ECLIPSED;
|
|
|
b77cff |
+ eclipse_count++;
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+
|
|
|
b77cff |
idtoa(&sr->this.id, mycredentialstr, sizeof(mycredentialstr));
|
|
|
b77cff |
|
|
|
b77cff |
passert(c->policy & POLICY_OPPORTUNISTIC); /* can't initiate Road Warrior connections */
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/kernel.c libreswan-3.25/programs/pluto/kernel.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/kernel.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/kernel.c 2019-05-02 10:55:42.640626568 -0400
|
|
|
b77cff |
@@ -982,22 +982,11 @@
|
|
|
b77cff |
if (ro != NULL && !routes_agree(ro, c)) {
|
|
|
b77cff |
char cib[CONN_INST_BUF];
|
|
|
b77cff |
loglog(RC_LOG_SERIOUS,
|
|
|
b77cff |
- "cannot route -- route already in use for \"%s\"%s",
|
|
|
b77cff |
+ "cannot route -- route already in use for \"%s\"%s - but allowing anyway",
|
|
|
b77cff |
ro->name, fmt_conn_instance(ro, cib));
|
|
|
b77cff |
- /*
|
|
|
b77cff |
- * We ignore this if the stack supports overlapping, and this
|
|
|
b77cff |
- * connection was marked that overlapping is OK. Below we will
|
|
|
b77cff |
- * check the other eroute, ero.
|
|
|
b77cff |
- */
|
|
|
b77cff |
- if (!compatible_overlapping_connections(c, ero)) {
|
|
|
b77cff |
- /*
|
|
|
b77cff |
- * Another connection is already using the eroute.
|
|
|
b77cff |
- * TODO: NETKEY can do this?
|
|
|
b77cff |
- */
|
|
|
b77cff |
- return route_impossible;
|
|
|
b77cff |
- }
|
|
|
b77cff |
}
|
|
|
b77cff |
|
|
|
b77cff |
+
|
|
|
b77cff |
/* if there is an eroute for another connection, there is a problem */
|
|
|
b77cff |
if (ero != NULL && ero != c) {
|
|
|
b77cff |
/*
|
|
|
b77cff |
@@ -3080,7 +3069,8 @@
|
|
|
b77cff |
/* record unrouting */
|
|
|
b77cff |
if (route_installed) {
|
|
|
b77cff |
do {
|
|
|
b77cff |
- passert(!erouted(rosr->routing));
|
|
|
b77cff |
+ DBG(DBG_CONTROL,
|
|
|
b77cff |
+ DBG_log("ro name=%s, rosr->routing=%d", ro->name, rosr->routing));
|
|
|
b77cff |
rosr->routing = RT_UNROUTED;
|
|
|
b77cff |
|
|
|
b77cff |
/* no need to keep old value */
|
|
|
b77cff |
@@ -3292,6 +3282,14 @@
|
|
|
b77cff |
DBG(DBG_KERNEL,
|
|
|
b77cff |
DBG_log("set up incoming SA, ref=%u/%u", st->st_ref,
|
|
|
b77cff |
st->st_refhim));
|
|
|
b77cff |
+
|
|
|
b77cff |
+ /*
|
|
|
b77cff |
+ * We successfully installed an IPsec SA, meaning it is safe
|
|
|
b77cff |
+ * to clear our revival back-off delay. This is based on the
|
|
|
b77cff |
+ * assumption that an unwilling partner might complete an IKE
|
|
|
b77cff |
+ * SA to us, but won't complete an IPsec SA to us.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+ st->st_connection->revive_delay = 0;
|
|
|
b77cff |
}
|
|
|
b77cff |
|
|
|
b77cff |
if (rb == route_unnecessary)
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/kernel.h libreswan-3.25/programs/pluto/kernel.h
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/kernel.h 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/kernel.h 2019-05-02 10:55:42.640626568 -0400
|
|
|
b77cff |
@@ -421,14 +421,6 @@
|
|
|
b77cff |
#endif
|
|
|
b77cff |
);
|
|
|
b77cff |
|
|
|
b77cff |
-static inline bool compatible_overlapping_connections(const struct connection *a,
|
|
|
b77cff |
- const struct connection *b)
|
|
|
b77cff |
-{
|
|
|
b77cff |
- return kernel_ops->overlap_supported &&
|
|
|
b77cff |
- a != NULL && b != NULL &&
|
|
|
b77cff |
- a != b &&
|
|
|
b77cff |
- LIN(POLICY_OVERLAPIP, a->policy & b->policy);
|
|
|
b77cff |
-}
|
|
|
b77cff |
|
|
|
b77cff |
#ifdef KLIPS
|
|
|
b77cff |
extern const struct kernel_ops klips_kernel_ops;
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/pluto_constants.c libreswan-3.25/programs/pluto/pluto_constants.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/pluto_constants.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/pluto_constants.c 2019-05-02 10:55:42.636626526 -0400
|
|
|
b77cff |
@@ -121,6 +121,7 @@
|
|
|
b77cff |
"EVENT_SD_WATCHDOG",
|
|
|
b77cff |
"EVENT_PENDING_PHASE2",
|
|
|
b77cff |
"EVENT_CHECK_CRLS",
|
|
|
b77cff |
+ "EVENT_REVIVE_CONNS",
|
|
|
b77cff |
|
|
|
b77cff |
"EVENT_SO_DISCARD",
|
|
|
b77cff |
"EVENT_v1_RETRANSMIT",
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/rcv_whack.c libreswan-3.25/programs/pluto/rcv_whack.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/rcv_whack.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/rcv_whack.c 2019-05-02 10:55:42.636626526 -0400
|
|
|
b77cff |
@@ -380,8 +380,14 @@
|
|
|
b77cff |
* To make this more useful, in only this combination,
|
|
|
b77cff |
* delete will silently ignore the lack of the connection.
|
|
|
b77cff |
*/
|
|
|
b77cff |
- if (m->whack_delete)
|
|
|
b77cff |
- delete_connections_by_name(m->name, !m->whack_connection);
|
|
|
b77cff |
+ if (m->whack_delete) {
|
|
|
b77cff |
+ if (m->name == NULL) {
|
|
|
b77cff |
+ whack_log(RC_FATAL, "received whack command to delete a connection, but did not receive the connection name - ignored");
|
|
|
b77cff |
+ } else {
|
|
|
b77cff |
+ terminate_connection(m->name, TRUE);
|
|
|
b77cff |
+ delete_connections_by_name(m->name, !m->whack_connection);
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+ }
|
|
|
b77cff |
|
|
|
b77cff |
if (m->whack_deleteuser) {
|
|
|
b77cff |
DBG_log("received whack to delete connection by user %s",
|
|
|
b77cff |
@@ -573,7 +579,7 @@
|
|
|
b77cff |
}
|
|
|
b77cff |
|
|
|
b77cff |
if (m->whack_terminate)
|
|
|
b77cff |
- terminate_connection(m->name);
|
|
|
b77cff |
+ terminate_connection(m->name, TRUE);
|
|
|
b77cff |
|
|
|
b77cff |
if (m->whack_status)
|
|
|
b77cff |
show_status();
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/state.c libreswan-3.25/programs/pluto/state.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/state.c 2019-05-02 10:54:07.252614517 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/state.c 2019-05-02 10:56:28.447113336 -0400
|
|
|
b77cff |
@@ -77,6 +77,8 @@
|
|
|
b77cff |
#include "crypt_dh.h"
|
|
|
b77cff |
#include "hostpair.h"
|
|
|
b77cff |
|
|
|
b77cff |
+#include "kernel.h"
|
|
|
b77cff |
+
|
|
|
b77cff |
#include <nss.h>
|
|
|
b77cff |
#include <pk11pub.h>
|
|
|
b77cff |
#include <keyhi.h>
|
|
|
b77cff |
@@ -128,6 +130,115 @@
|
|
|
b77cff |
[STATE_UNDEFINED] = &state_undefined,
|
|
|
b77cff |
};
|
|
|
b77cff |
|
|
|
b77cff |
+/*
|
|
|
b77cff |
+ * Revival mechanism: keep track of connections
|
|
|
b77cff |
+ * that should be kept up, even though all their
|
|
|
b77cff |
+ * states have been deleted.
|
|
|
b77cff |
+ *
|
|
|
b77cff |
+ * We record the connection names.
|
|
|
b77cff |
+ * Each name is recorded only once.
|
|
|
b77cff |
+ *
|
|
|
b77cff |
+ * XXX: This functionality totally overlaps both "initiate" and
|
|
|
b77cff |
+ * "pending" and should be merged (howerver, this simple code might
|
|
|
b77cff |
+ * prove to be a better starting point).
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+
|
|
|
b77cff |
+struct revival {
|
|
|
b77cff |
+ char *name;
|
|
|
b77cff |
+ struct revival *next;
|
|
|
b77cff |
+};
|
|
|
b77cff |
+
|
|
|
b77cff |
+static struct revival *revivals = NULL;
|
|
|
b77cff |
+
|
|
|
b77cff |
+/*
|
|
|
b77cff |
+ * XXX: Return connection C's revival object's link, if found. If the
|
|
|
b77cff |
+ * connection C can't be found, then the address of the revival list's
|
|
|
b77cff |
+ * tail is returned. Perhaps, exiting the loop and returning NULL
|
|
|
b77cff |
+ * would be more obvious.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+static struct revival **find_revival(const struct connection *c)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ for (struct revival **rp = &revivals; ; rp = &(*rp)->next) {
|
|
|
b77cff |
+ if (*rp == NULL || streq((*rp)->name, c->name)) {
|
|
|
b77cff |
+ return rp;
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+}
|
|
|
b77cff |
+
|
|
|
b77cff |
+/*
|
|
|
b77cff |
+ * XXX: In addition to freeing RP (and killing the pointer), this
|
|
|
b77cff |
+ * "free" function has the side effect of unlinks RP from the revival
|
|
|
b77cff |
+ * list. Perhaps free*() isn't the best name.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+static void free_revival(struct revival **rp)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ struct revival *r = *rp;
|
|
|
b77cff |
+ *rp = r->next;
|
|
|
b77cff |
+ pfree(r->name);
|
|
|
b77cff |
+ pfree(r);
|
|
|
b77cff |
+}
|
|
|
b77cff |
+
|
|
|
b77cff |
+void flush_revival(const struct connection *c)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ struct revival **rp = find_revival(c);
|
|
|
b77cff |
+
|
|
|
b77cff |
+ if (*rp == NULL) {
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("flush revival: connection '%s' wasn't on the list",
|
|
|
b77cff |
+ c->name));
|
|
|
b77cff |
+ } else {
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("flush revival: connection '%s' revival flushed",
|
|
|
b77cff |
+ c->name));
|
|
|
b77cff |
+ free_revival(rp);
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+}
|
|
|
b77cff |
+
|
|
|
b77cff |
+static void add_revival(struct connection *c)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ if (*find_revival(c) == NULL) {
|
|
|
b77cff |
+ struct revival *r = alloc_thing(struct revival,
|
|
|
b77cff |
+ "revival struct");
|
|
|
b77cff |
+
|
|
|
b77cff |
+ r->name = clone_str(c->name, "revival conn name");
|
|
|
b77cff |
+ r->next = revivals;
|
|
|
b77cff |
+ revivals = r;
|
|
|
b77cff |
+ int delay = c->revive_delay;
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("add revival: connection '%s' added to the list and scheduled for %d seconds",
|
|
|
b77cff |
+ c->name, delay));
|
|
|
b77cff |
+ c->revive_delay = min(delay + REVIVE_CONN_DELAY,
|
|
|
b77cff |
+ REVIVE_CONN_DELAY_MAX);
|
|
|
b77cff |
+ /*
|
|
|
b77cff |
+ * XXX: Schedule the next revival using this
|
|
|
b77cff |
+ * connection's revival delay and not the most urgent
|
|
|
b77cff |
+ * connection's revival delay. Trying to fix this
|
|
|
b77cff |
+ * here just is annoying and probably of marginal
|
|
|
b77cff |
+ * benefit: it is something better handled with a
|
|
|
b77cff |
+ * proper connection event so that the event loop deal
|
|
|
b77cff |
+ * with all the math (this code would then be
|
|
|
b77cff |
+ * deleted); and would encroach even further on
|
|
|
b77cff |
+ * "initiate" and "pending" functionality.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+ event_schedule(EVENT_REVIVE_CONNS, deltatime(delay), NULL);
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+}
|
|
|
b77cff |
+
|
|
|
b77cff |
+void revive_conns(void)
|
|
|
b77cff |
+{
|
|
|
b77cff |
+ /*
|
|
|
b77cff |
+ * XXX: Revive all listed connections regardless of their
|
|
|
b77cff |
+ * DELAY. See note above in add_revival().
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+ while (revivals != NULL) {
|
|
|
b77cff |
+ libreswan_log("Initiating connection %s which received a Delete/Notify but must remain up per local policy",
|
|
|
b77cff |
+ revivals->name);
|
|
|
b77cff |
+ initiate_connection(revivals->name, NULL_FD, empty_lmod, empty_lmod, pcim_demand_crypto, NULL);
|
|
|
b77cff |
+ free_revival(&revivals);
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+}
|
|
|
b77cff |
+
|
|
|
b77cff |
+/* end of revival mechanism */
|
|
|
b77cff |
+
|
|
|
b77cff |
+
|
|
|
b77cff |
+
|
|
|
b77cff |
void lswlog_finite_state(struct lswlog *buf, const struct finite_state *fs)
|
|
|
b77cff |
{
|
|
|
b77cff |
if (fs == NULL) {
|
|
|
b77cff |
@@ -1156,6 +1267,23 @@
|
|
|
b77cff |
if (c->newest_isakmp_sa == st->st_serialno)
|
|
|
b77cff |
c->newest_isakmp_sa = SOS_NOBODY;
|
|
|
b77cff |
|
|
|
b77cff |
+ if ((c->policy & POLICY_UP) && IS_IKE_SA(st)) {
|
|
|
b77cff |
+ so_serial_t newer_sa = get_newer_sa_from_connection(st);
|
|
|
b77cff |
+
|
|
|
b77cff |
+ if (state_by_serialno(newer_sa) != NULL) {
|
|
|
b77cff |
+ /*
|
|
|
b77cff |
+ * Presumably this is an old state that has
|
|
|
b77cff |
+ * either been rekeyed or replaced.
|
|
|
b77cff |
+ */
|
|
|
b77cff |
+ DBG(DBG_CONTROL, DBG_log("IKE delete_state() for #%lu and connection '%s' that is supposed to remain up; not a problem - have newer #%lu",
|
|
|
b77cff |
+ st->st_serialno, c->name, newer_sa));
|
|
|
b77cff |
+ } else {
|
|
|
b77cff |
+ libreswan_log("deleting IKE SA for connection '%s' but connection is supposed to remain up; schedule EVENT_REVIVE_CONNS",
|
|
|
b77cff |
+ c->name);
|
|
|
b77cff |
+ add_revival(c);
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+ }
|
|
|
b77cff |
+
|
|
|
b77cff |
/*
|
|
|
b77cff |
* fake a state change here while we are still associated with a
|
|
|
b77cff |
* connection. Without this the state logging (when enabled) cannot
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/state.h libreswan-3.25/programs/pluto/state.h
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/state.h 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/state.h 2019-05-02 10:55:42.638626547 -0400
|
|
|
b77cff |
@@ -809,5 +809,5 @@
|
|
|
b77cff |
|
|
|
b77cff |
extern bool uniqueIDs; /* --uniqueids? */
|
|
|
b77cff |
extern void ISAKMP_SA_established(const struct state *pst);
|
|
|
b77cff |
-
|
|
|
b77cff |
+extern void revive_conns(void);
|
|
|
b77cff |
#endif /* _STATE_H */
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/terminate.c libreswan-3.25/programs/pluto/terminate.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/terminate.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/terminate.c 2019-05-02 10:55:42.638626547 -0400
|
|
|
b77cff |
@@ -90,7 +90,7 @@
|
|
|
b77cff |
return 1;
|
|
|
b77cff |
}
|
|
|
b77cff |
|
|
|
b77cff |
-void terminate_connection(const char *name)
|
|
|
b77cff |
+void terminate_connection(const char *name, bool quiet)
|
|
|
b77cff |
{
|
|
|
b77cff |
/*
|
|
|
b77cff |
* Loop because more than one may match (master and instances)
|
|
|
b77cff |
@@ -112,7 +112,8 @@
|
|
|
b77cff |
} else {
|
|
|
b77cff |
int count = foreach_connection_by_alias(name, terminate_a_connection, NULL);
|
|
|
b77cff |
if (count == 0) {
|
|
|
b77cff |
- loglog(RC_UNKNOWN_NAME,
|
|
|
b77cff |
+ if (!quiet)
|
|
|
b77cff |
+ loglog(RC_UNKNOWN_NAME,
|
|
|
b77cff |
"no such connection or aliased connection named \"%s\"", name);
|
|
|
b77cff |
} else {
|
|
|
b77cff |
loglog(RC_COMMENT, "terminated %d connections from aliased connection \"%s\"",
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/timer.c libreswan-3.25/programs/pluto/timer.c
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/timer.c 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/timer.c 2019-05-02 10:55:42.638626547 -0400
|
|
|
b77cff |
@@ -334,6 +334,7 @@
|
|
|
b77cff |
case EVENT_SD_WATCHDOG:
|
|
|
b77cff |
case EVENT_NAT_T_KEEPALIVE:
|
|
|
b77cff |
case EVENT_CHECK_CRLS:
|
|
|
b77cff |
+ case EVENT_REVIVE_CONNS:
|
|
|
b77cff |
passert(st == NULL);
|
|
|
b77cff |
break;
|
|
|
b77cff |
|
|
|
b77cff |
@@ -435,6 +436,10 @@
|
|
|
b77cff |
check_crls();
|
|
|
b77cff |
break;
|
|
|
b77cff |
|
|
|
b77cff |
+ case EVENT_REVIVE_CONNS:
|
|
|
b77cff |
+ revive_conns();
|
|
|
b77cff |
+ break;
|
|
|
b77cff |
+
|
|
|
b77cff |
case EVENT_v2_RELEASE_WHACK:
|
|
|
b77cff |
DBG(DBG_CONTROL, DBG_log("%s releasing whack for #%lu %s (sock=%d)",
|
|
|
b77cff |
enum_show(&timer_event_names, type),
|
|
|
b77cff |
diff -Naur libreswan-3.25-orig/programs/pluto/timer.h libreswan-3.25/programs/pluto/timer.h
|
|
|
b77cff |
--- libreswan-3.25-orig/programs/pluto/timer.h 2018-06-27 11:42:26.000000000 -0400
|
|
|
b77cff |
+++ libreswan-3.25/programs/pluto/timer.h 2019-05-02 10:55:42.638626547 -0400
|
|
|
b77cff |
@@ -47,4 +47,6 @@
|
|
|
b77cff |
#define delete_dpd_event(ST) delete_state_event((ST), &(ST)->st_dpd_event)
|
|
|
b77cff |
|
|
|
b77cff |
extern void timer_list(void);
|
|
|
b77cff |
+extern char *revive_conn;
|
|
|
b77cff |
+
|
|
|
b77cff |
#endif /* _TIMER_H */
|