[Swan-dev] pluto: Do not retransmit forever

Antony Antony antony at phenome.org
Thu Apr 23 19:52:24 EEST 2015


Hi Herbert,
thanks for the patch. Independently, I was working on different one which should do the same for ikev2 and now I extend it to ikev1 picking up bits from your patch.

test the master? The commits are fe03bd4d6d4c2e78fa621a76be4f1b360c588e16, a2d0e225ed67d202 + cd1a26feb1e68995428ad72f3c238047d7a36e40 

It will also take care of the case where you want stop after retransmit-timeout , e.g 

retransmit-timeout=2s
retransmit-interval=100
will stop around 2 seconds.

-antony


On Tue, Apr 21, 2015 at 05:08:22PM +0800, Herbert Xu wrote:
> The commit 09de73638a62207c268482982fce7ee96a9d6ba1 ("pluto:
> first attempt to replace pluto select loop with libevent") causes
> pluto to retransmit forever.
> 
> This patch fixes this by stopping retransmissions after the count
> reaches MAXIMUM_RETRANSMITS_PER_EXCHANGE.
> 
> diff --git a/programs/pluto/timer.c b/programs/pluto/timer.c
> index 700b018..f4299a9 100644
> --- a/programs/pluto/timer.c
> +++ b/programs/pluto/timer.c
> @@ -62,6 +62,9 @@ static unsigned long retrans_delay(struct state *st, unsigned long delay_ms)
>  	unsigned long delay_cap = deltamillisecs(c->r_timeout); /* ms */
>  	u_int8_t x = st->st_retransmit++;	/* ??? odd type */
>  
> +	if (x > MAXIMUM_RETRANSMITS_PER_EXCHANGE)
> +		return 0;
> +
>  	/*
>  	 * Very carefully calculate capped exponential backoff.
>  	 * The test is expressed as a right shift to avoid overflow.
> @@ -70,8 +73,7 @@ static unsigned long retrans_delay(struct state *st, unsigned long delay_ms)
>  	 * Surely a bound of 12 (factor of 2048) is safe and more than enough.
>  	 */
>  
> -	delay_ms = (x > MAXIMUM_RETRANSMITS_PER_EXCHANGE ||
> -			delay_cap >> x < delay_ms) ?
> +	delay_ms = delay_cap >> x < delay_ms ?
>  		delay_cap : delay_ms << x;
>  
>  	whack_log(RC_RETRANSMISSION,
> @@ -128,8 +130,10 @@ static void retransmit_v1_msg(struct state *st)
>  		delay_ms = c->r_interval;
>  	}
>  
> +	if (delay_ms != 0)
> +		delay_ms = retrans_delay(st, delay_ms);
> +
>  	if (delay_ms != 0) {
> -		delay_ms =  retrans_delay(st, delay_ms);
>  		resend_ike_v1_msg(st, "EVENT_v1_RETRANSMIT");
>  		event_schedule_ms(EVENT_v1_RETRANSMIT, delay_ms, st);
>  	} else {
> @@ -241,8 +245,10 @@ static void retransmit_v2_msg(struct state *st)
>  		delay_ms = c->r_interval;
>  	}
>  
> +	if (delay_ms != 0)
> +		delay_ms = retrans_delay(st, delay_ms);
> +
>  	if (delay_ms != 0) {
> -		delay_ms =  retrans_delay(st, delay_ms);
>  		send_ike_msg(st, "EVENT_v2_RETRANSMIT");
>  		event_schedule_ms(EVENT_v2_RETRANSMIT, delay_ms, st);
>  		return;
> -- 
> Email: Herbert Xu <herbert at gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> _______________________________________________
> Swan-dev mailing list
> Swan-dev at lists.libreswan.org
> https://lists.libreswan.org/mailman/listinfo/swan-dev
> 


More information about the Swan-dev mailing list