Skip to content

Commit 88069f6

Browse files
t8mstreambinder
authored andcommitted
fix: make DPD less sensitive
[lkundrak@v3.sk: this patch has been sitting in Fedora package in 2007. I don't understand the details here, but given the origin of the patch I can hazard a guess it was dealing with the Cisco IPSec VPN concentrator that Red Hat was running at the time being too keen to kill idle clients.] https://bugzilla.redhat.com/show_bug.cgi?id=345281
1 parent c4837a1 commit 88069f6

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static const char *config_def_udp_port(void)
349349

350350
static const char *config_def_dpd_idle(void)
351351
{
352-
return "300";
352+
return "600";
353353
}
354354

355355
static const char *config_ca_dir(void)

src/tunip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ static void vpnc_main_loop(struct sa_block *s)
955955
time_t now = time(NULL);
956956
if (s->ike.dpd_seqno != s->ike.dpd_seqno_ack) {
957957
/* Wake up more often for dpd attempts */
958-
select_timeout.tv_sec = 5;
958+
select_timeout.tv_sec = s->ike.dpd_idle/10;
959959
select_timeout.tv_usec = 0;
960960
dpd_ike(s);
961961
next_ike_dpd = now + s->ike.dpd_idle;
@@ -1029,8 +1029,8 @@ static void vpnc_main_loop(struct sa_block *s)
10291029
if (s->ike.dpd_seqno != s->ike.dpd_seqno_ack) {
10301030
dpd_ike(s);
10311031
next_ike_dpd = now + s->ike.dpd_idle;
1032-
if (now + 5 < next_up)
1033-
next_up = now + 5;
1032+
if (now + s->ike.dpd_idle/10 < next_up)
1033+
next_up = now + s->ike.dpd_idle/10;
10341034
}
10351035
else if (now >= next_ike_dpd) {
10361036
dpd_ike(s);

src/vpnc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,20 +801,22 @@ void dpd_ike(struct sa_block *s)
801801
send_dpd(s, 0, s->ike.dpd_seqno);
802802
} else {
803803
/* Our last dpd request has not yet been acked. If it's been
804-
** less than 5 seconds since we sent it do nothing. Otherwise
804+
** less than 1/10th of idle timeout since we sent it do nothing. Otherwise
805805
** decrement dpd_attempts. If dpd_attempts is 0 dpd fails and we
806806
** terminate otherwise we send it again with the same sequence
807807
** number and record current time.
808808
*/
809809
time_t now = time(NULL);
810-
if (now < s->ike.dpd_sent + 5)
810+
if (now < s->ike.dpd_sent + s->ike.dpd_idle/10)
811811
return;
812812
if (--s->ike.dpd_attempts == 0) {
813813
DEBUG(2, printf("dead peer detected, terminating\n"));
814814
do_kill = -2;
815815
return;
816816
}
817817
s->ike.dpd_sent = now;
818+
if (s->ike.dpd_attempts == 3)
819+
++s->ike.dpd_seqno; /* maybe just the dpd reply got lost let's try new seq no */
818820
send_dpd(s, 0, s->ike.dpd_seqno);
819821
}
820822
DEBUG(3, printf("sent DPD packet\n"));

0 commit comments

Comments
 (0)