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