Add a echo_timeout configuration option.

Add a idle_echo_timeout configuration option.
This commit is contained in:
Fernando Alves 2012-02-20 20:50:57 +01:00 committed by Benjamin Cama
parent 81ca38323a
commit 76ae461853
6 changed files with 46 additions and 11 deletions

View file

@ -357,6 +357,17 @@ from the master.
Determines the minumum number of up to date slaves required before the Determines the minumum number of up to date slaves required before the
master will drop routes (default: 1). master will drop routes (default: 1).
</LI> </LI>
<LI><B>echo_timeout</B> (int)<BR>
Time between last packet sent and LCP ECHO generation
(default: 10 (seconds)).
</LI>
<LI><B>idle_echo_timeout</B> (int)<BR>
Drop sessions who have not responded within idle_echo_timeout seconds
(default: 240 (seconds))
</LI>
</UL> </UL>
<P>BGP routing configuration is entered by the command: <P>BGP routing configuration is entered by the command:

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
l2tpns (2.2.1-2fdn1.4) unstable; urgency=low
* Add a echo_timeout configuration option.
* Add a idle_echo_timeout configuration option.
-- Fernando Alves <fernando.alves@sameswireless.fr> Mon, 20 Feb 2012 20:47:52 +0100
l2tpns (2.2.1-2fdn1.3) unstable; urgency=low l2tpns (2.2.1-2fdn1.3) unstable; urgency=low
* Fix: Sends small packets in the MPPPP frame (for reorder). * Fix: Sends small packets in the MPPPP frame (for reorder).

View file

@ -112,6 +112,11 @@ set accounting_dir "/var/run/l2tpns/acct"
#set nexthop 10.0.1.1 #set nexthop 10.0.1.1
#set nexthop6 2001:db8::1 #set nexthop6 2001:db8::1
# Time between last packet sent and LCP ECHO generation (default 10 seconds)
#set echo_timeout 10
# Drop sessions who have not responded within idle_echo_timeout seconds (default 240 seconds)
#set idle_echo_timeout 240
# Drop/kill sessions # Drop/kill sessions
#load plugin "sessionctl" #load plugin "sessionctl"

View file

@ -162,6 +162,8 @@ config_descriptt config_values[] = {
CONFIG("hostname", hostname, STRING), CONFIG("hostname", hostname, STRING),
CONFIG("nexthop_address", nexthop_address, IPv4), CONFIG("nexthop_address", nexthop_address, IPv4),
CONFIG("nexthop6_address", nexthop6_address, IPv6), CONFIG("nexthop6_address", nexthop6_address, IPv6),
CONFIG("echo_timeout", echo_timeout, INT),
CONFIG("idle_echo_timeout", idle_echo_timeout, INT),
{ NULL, 0, 0, 0 }, { NULL, 0, 0, 0 },
}; };
@ -3481,8 +3483,8 @@ static void regular_cleanups(double period)
} }
} }
// Drop sessions who have not responded within IDLE_TIMEOUT seconds // Drop sessions who have not responded within IDLE_ECHO_TIMEOUT seconds
if (session[s].last_packet && (time_now - session[s].last_packet >= IDLE_TIMEOUT)) if (session[s].last_packet && (time_now - session[s].last_packet >= config->idle_echo_timeout))
{ {
sessionshutdown(s, "No response to LCP ECHO requests.", CDN_ADMIN_DISC, TERM_LOST_SERVICE); sessionshutdown(s, "No response to LCP ECHO requests.", CDN_ADMIN_DISC, TERM_LOST_SERVICE);
STAT(session_timeout); STAT(session_timeout);
@ -3491,7 +3493,7 @@ static void regular_cleanups(double period)
} }
// No data in ECHO_TIMEOUT seconds, send LCP ECHO // No data in ECHO_TIMEOUT seconds, send LCP ECHO
if (session[s].ppp.phase >= Establish && (time_now - session[s].last_packet >= ECHO_TIMEOUT) && if (session[s].ppp.phase >= Establish && (time_now - session[s].last_packet >= config->echo_timeout) &&
(time_now - sess_local[s].last_echo >= ECHO_TIMEOUT)) (time_now - sess_local[s].last_echo >= ECHO_TIMEOUT))
{ {
uint8_t b[MAXETHER]; uint8_t b[MAXETHER];
@ -4267,6 +4269,9 @@ static void initdata(int optdebug, char *optconfig)
config->ppp_max_failure = 5; config->ppp_max_failure = 5;
config->kill_timedout_sessions = 1; config->kill_timedout_sessions = 1;
strcpy(config->random_device, RANDOMDEVICE); strcpy(config->random_device, RANDOMDEVICE);
// Set default value echo_timeout and idle_echo_timeout
config->echo_timeout = ECHO_TIMEOUT;
config->idle_echo_timeout = IDLE_ECHO_TIMEOUT;
log_stream = stderr; log_stream = stderr;

View file

@ -49,7 +49,7 @@
#define RINGBUFFER_SIZE 10000 // Number of ringbuffer entries to allocate #define RINGBUFFER_SIZE 10000 // Number of ringbuffer entries to allocate
#define MAX_LOG_LENGTH 512 // Maximum size of log message #define MAX_LOG_LENGTH 512 // Maximum size of log message
#define ECHO_TIMEOUT 10 // Time between last packet sent and LCP ECHO generation #define ECHO_TIMEOUT 10 // Time between last packet sent and LCP ECHO generation
#define IDLE_TIMEOUT 240 // Time between last packet seen and session shutdown #define IDLE_ECHO_TIMEOUT 240 // Time between last packet seen and session shutdown
#define BUSY_WAIT_TIME 3000 // 5 minutes in 1/10th seconds to wait for radius to cleanup on shutdown #define BUSY_WAIT_TIME 3000 // 5 minutes in 1/10th seconds to wait for radius to cleanup on shutdown
#define MP_BEGIN 0x80 // This value is used when (b)egin bit is set in MP header #define MP_BEGIN 0x80 // This value is used when (b)egin bit is set in MP header
@ -746,6 +746,10 @@ typedef struct
in_addr_t nexthop_address; in_addr_t nexthop_address;
struct in6_addr nexthop6_address; struct in6_addr nexthop6_address;
#endif #endif
int echo_timeout; // Time between last packet sent and LCP ECHO generation
int idle_echo_timeout; // Time between last packet seen and
// Drop sessions who have not responded within IDLE_ECHO_TIMEOUT seconds
} configt; } configt;
enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 }; enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 };

7
ppp.c
View file

@ -1879,8 +1879,11 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
// calculate the jitter average // calculate the jitter average
uint32_t ljitter = time_now_ms - sess_local[s].prev_time; uint32_t ljitter = time_now_ms - sess_local[s].prev_time;
sess_local[s].jitteravg = (sess_local[s].jitteravg + ljitter)>>1; if (ljitter > 0)
sess_local[s].prev_time = time_now_ms; {
sess_local[s].jitteravg = (sess_local[s].jitteravg + ljitter)>>1;
sess_local[s].prev_time = time_now_ms;
}
uint32_t Mmin; uint32_t Mmin;