ppp: support adaptive LCP echos
[openwrt/svn-archive/archive.git] / package / network / services / ppp / patches / 121-debian_adaptive_lcp_echo.patch
1 --- a/pppd/lcp.c
2 +++ b/pppd/lcp.c
3 @@ -73,6 +73,7 @@ static void lcp_delayed_up __P((void *))
4 */
5 int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
6 int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
7 +bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */
8 bool lax_recv = 0; /* accept control chars in asyncmap */
9 bool noendpoint = 0; /* don't send/accept endpoint discriminator */
10
11 @@ -151,6 +152,8 @@ static option_t lcp_option_list[] = {
12 OPT_PRIO },
13 { "lcp-echo-interval", o_int, &lcp_echo_interval,
14 "Set time in seconds between LCP echo requests", OPT_PRIO },
15 + { "lcp-echo-adaptive", o_bool, &lcp_echo_adaptive,
16 + "Suppress LCP echo requests if traffic was received", 1 },
17 { "lcp-restart", o_int, &lcp_fsm[0].timeouttime,
18 "Set time in seconds between LCP retransmissions", OPT_PRIO },
19 { "lcp-max-terminate", o_int, &lcp_fsm[0].maxtermtransmits,
20 @@ -2331,6 +2334,22 @@ LcpSendEchoRequest (f)
21 }
22 }
23
24 + /*
25 + * If adaptive echos have been enabled, only send the echo request if
26 + * no traffic was received since the last one.
27 + */
28 + if (lcp_echo_adaptive) {
29 + static unsigned int last_pkts_in = 0;
30 +
31 + update_link_stats(f->unit);
32 + link_stats_valid = 0;
33 +
34 + if (link_stats.pkts_in != last_pkts_in) {
35 + last_pkts_in = link_stats.pkts_in;
36 + return;
37 + }
38 + }
39 +
40 /*
41 * Make and send the echo request frame.
42 */
43 --- a/pppd/pppd.8
44 +++ b/pppd/pppd.8
45 @@ -563,6 +563,11 @@ to 1) if the \fIproxyarp\fR option is us
46 dynamic IP address option (i.e. set /proc/sys/net/ipv4/ip_dynaddr to
47 1) in demand mode if the local address changes.
48 .TP
49 +.B lcp\-echo\-adaptive
50 +If this option is used with the \fIlcp\-echo\-failure\fR option then
51 +pppd will send LCP echo\-request frames only if no traffic was received
52 +from the peer since the last echo\-request was sent.
53 +.TP
54 .B lcp\-echo\-failure \fIn
55 If this option is given, pppd will presume the peer to be dead
56 if \fIn\fR LCP echo\-requests are sent without receiving a valid LCP