"still search for IKE-Session. this %s.\n",
saddr2str((struct sockaddr *)&p->session_id.remote));
+ // for now: ignore any stopped sessions as they will go down
+ if (p->is_dying || p->stopped_by_vpn_controller || p->stop_timestamp.tv_sec || p->stop_timestamp.tv_usec) {
+ plog(LLV_DEBUG, LOCATION, local,
+ "still searching. skipping... session to %s is already stopped, active ph1 %d ph2 %d.\n",
+ saddr2str((struct sockaddr *)&p->session_id.remote),
+ p->ikev1_state.active_ph1cnt, p->ikev1_state.active_ph2cnt);
+ continue;
+ }
+
if (memcmp(&p->session_id, &id, sizeof(id)) == 0) {
plog(LLV_DEBUG, LOCATION, local,
"Pre-existing IKE-Session to %s. case 1.\n",
plog(LLV_DEBUG2, LOCATION, NULL, "skipping sweep of asserted session.\n");
continue;
}
-
+
+ // cleanup any stopped sessions as they will go down
+ if (p->stopped_by_vpn_controller || p->stop_timestamp.tv_sec || p->stop_timestamp.tv_usec) {
+ plog(LLV_DEBUG2, LOCATION, NULL, "sweeping stopped session.\n");
+ ike_session_cleanup(p, ike_session_stopped_by_sleepwake);
+ continue;
+ }
+
if (!ike_session_has_established_ph1(p) && !ike_session_has_established_ph2(p)) {
- p->is_dying = 1;
plog(LLV_DEBUG2, LOCATION, NULL, "session died while sleeping.\n");
+ ike_session_cleanup(p, ike_session_stopped_by_sleepwake);
}
if (p->traffic_monitor.sc_mon) {
if (p->traffic_monitor.sc_mon->xtime <= swept_at) {
vfree(raddr);
if (addr->force) {
(void)ike_session_update_ph1_ph2tree(iph1);
- isakmp_ph1delete(iph1);
+ isakmp_ph1expire(iph1);
}
}
}
{
struct ph1handle *iph1;
+ if (iph2->status != PHASE2ST_STATUS2 ||
+ iph2->is_dying) {
+ plog(LLV_DEBUG2, LOCATION, NULL, "CHKPH1THERE: ph2 handle has advanced too far (status %d, STATUS2 %d, dying %d)... ignoring\n", iph2->status, PHASE2ST_STATUS2, iph2->is_dying);
+ return;
+ }
+
iph2->retry_checkph1--;
if (iph2->retry_checkph1 < 0 ||
ike_session_verify_ph2_parent_session(iph2)) {
"failed to allocate notification payload.\n");
return NULL;
}
+ } else {
+ plog(LLV_DEBUG, LOCATION, iph1->remote,
+ "failed to add initial-contact payload: rekey %d, ini-contact %d, contacted %d.\n",
+ iph1->is_rekey? 1:0, iph1->rmconf->ini_contact, getcontacted(iph1->remote)? 1:0);
}
return NULL;
}
if (update_myaddrs() && lcconf->autograbaddr)
if (check_rtsock_sched == NULL) /* only schedule if not already done */
check_rtsock_sched = sched_new(1, check_rtsock, NULL);
+ else {
+ // force reinit if schedule is too far off (3 seconds or more)
+ time_t too_far = current_time() + 3;
+ if (check_rtsock_sched->dead ||
+ check_rtsock_sched->xtime >= too_far) {
+ plog(LLV_DEBUG, LOCATION, NULL,
+ "forced reinit of addrs\n");
+ update_fds = 0;
+ check_rtsock(NULL);
+ }
+ }
// initfds(); //%%% BUG FIX - not needed here
}
if (update_fds) {