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