Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
170042c
commit 37c63e9
Showing
23 changed files
with
668 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
package/network/services/ppp/patches/121-debian_adaptive_lcp_echo.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- a/pppd/lcp.c | ||
+++ b/pppd/lcp.c | ||
@@ -72,6 +72,7 @@ static void lcp_delayed_up __P((void *)) | ||
*/ | ||
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 */ | ||
|
||
@@ -150,6 +151,8 @@ static option_t lcp_option_list[] = { | ||
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, | ||
@@ -2330,6 +2333,22 @@ LcpSendEchoRequest (f) | ||
} | ||
} | ||
|
||
+ /* | ||
+ * 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. | ||
*/ | ||
--- a/pppd/pppd.8 | ||
+++ b/pppd/pppd.8 | ||
@@ -575,6 +575,11 @@ to 1) if the \fIproxyarp\fR option is us | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
package/network/services/ppp/patches/206-compensate_time_change.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
pppd: Watch out for time warps | ||
|
||
On many embedded systems there is no battery backed RTC and a proper system | ||
time only becomes available through NTP after establishing a connection. | ||
|
||
When the clock suddenly jumps forward, the internal accounting (connect time) | ||
is confused resulting in unreliable data. | ||
|
||
This patch implements periodic clock checking to look for time warps, if one | ||
is detected, the internal counters are adjusted accordingly. | ||
|
||
Signed-off-by: Jo-Philipp Wich <jo@mein.io> | ||
|
||
--- a/pppd/main.c | ||
+++ b/pppd/main.c | ||
@@ -89,6 +89,7 @@ | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
+#include <sys/sysinfo.h> | ||
|
||
#include "pppd.h" | ||
#include "magic.h" | ||
@@ -226,6 +227,7 @@ static struct subprocess *children; | ||
|
||
/* Prototypes for procedures local to this file. */ | ||
|
||
+static void check_time(void); | ||
static void setup_signals __P((void)); | ||
static void create_pidfile __P((int pid)); | ||
static void create_linkpidfile __P((int pid)); | ||
@@ -525,6 +527,7 @@ main(argc, argv) | ||
info("Starting link"); | ||
} | ||
|
||
+ check_time(); | ||
gettimeofday(&start_time, NULL); | ||
script_unsetenv("CONNECT_TIME"); | ||
script_unsetenv("BYTES_SENT"); | ||
@@ -1274,6 +1277,36 @@ struct callout { | ||
|
||
static struct callout *callout = NULL; /* Callout list */ | ||
static struct timeval timenow; /* Current time */ | ||
+static long uptime_diff = 0; | ||
+static int uptime_diff_set = 0; | ||
+ | ||
+static void check_time(void) | ||
+{ | ||
+ long new_diff; | ||
+ struct timeval t; | ||
+ struct sysinfo i; | ||
+ struct callout *p; | ||
+ | ||
+ gettimeofday(&t, NULL); | ||
+ sysinfo(&i); | ||
+ new_diff = t.tv_sec - i.uptime; | ||
+ | ||
+ if (!uptime_diff_set) { | ||
+ uptime_diff = new_diff; | ||
+ uptime_diff_set = 1; | ||
+ return; | ||
+ } | ||
+ | ||
+ if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) { | ||
+ /* system time has changed, update counters and timeouts */ | ||
+ info("System time change detected."); | ||
+ start_time.tv_sec += new_diff - uptime_diff; | ||
+ | ||
+ for (p = callout; p != NULL; p = p->c_next) | ||
+ p->c_time.tv_sec += new_diff - uptime_diff; | ||
+ } | ||
+ uptime_diff = new_diff; | ||
+} | ||
|
||
/* | ||
* timeout - Schedule a timeout. | ||
@@ -1344,6 +1377,8 @@ calltimeout() | ||
{ | ||
struct callout *p; | ||
|
||
+ check_time(); | ||
+ | ||
while (callout != NULL) { | ||
p = callout; | ||
|
||
@@ -1371,6 +1406,8 @@ timeleft(tvp) | ||
{ | ||
if (callout == NULL) | ||
return NULL; | ||
+ | ||
+ check_time(); | ||
|
||
gettimeofday(&timenow, NULL); | ||
tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.