34_all_lcp-echo-adaptive.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. diff -Nru ppp-2.4.5.orig/pppd/lcp.c ppp-2.4.5/pppd/lcp.c
  2. --- ppp-2.4.5.orig/pppd/lcp.c 2009-11-16 23:26:07.000000000 +0100
  3. +++ ppp-2.4.5/pppd/lcp.c 2010-11-27 10:46:26.000000000 +0100
  4. @@ -73,6 +73,7 @@
  5. */
  6. int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
  7. int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
  8. +bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */
  9. bool lax_recv = 0; /* accept control chars in asyncmap */
  10. bool noendpoint = 0; /* don't send/accept endpoint discriminator */
  11. @@ -151,6 +152,8 @@
  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. @@ -2322,6 +2325,22 @@
  21. }
  22. /*
  23. + * If adaptive echos have been enabled, only send the echo request if
  24. + * no traffic was received since the last one.
  25. + */
  26. + if (lcp_echo_adaptive) {
  27. + static unsigned int last_pkts_in = 0;
  28. +
  29. + update_link_stats(f->unit);
  30. + link_stats_valid = 0;
  31. +
  32. + if (link_stats.pkts_in != last_pkts_in) {
  33. + last_pkts_in = link_stats.pkts_in;
  34. + return;
  35. + }
  36. + }
  37. +
  38. + /*
  39. * Make and send the echo request frame.
  40. */
  41. if (f->state == OPENED) {
  42. diff -Nru ppp-2.4.5.orig/pppd/pppd.8 ppp-2.4.5/pppd/pppd.8
  43. --- ppp-2.4.5.orig/pppd/pppd.8 2009-11-16 23:26:07.000000000 +0100
  44. +++ ppp-2.4.5/pppd/pppd.8 2010-11-27 10:44:58.000000000 +0100
  45. @@ -549,6 +549,11 @@
  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