ref: eaaeeb6e566c4b6dc65e472c75416d9b9171d416
parent: e2bfa1a57cd5b9b771fb8a33f6b4bc54165d4be8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 18 21:21:11 EDT 2025
ip/ppp: implement termination timeout When receiving termination request, we stayed in Sclosing state indefinitely, sending our own termination requests and waiting for the acks (which might never come). Instead, set a timeout for sending our own termination requests and when expired close the connection.
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -1395,6 +1395,7 @@
newstate(ppp, p, Sreqsent);
break;
case Sopened:
+ p->timeout = Termtimeout;
newstate(ppp, p, Sclosing);
break;
}
@@ -1480,23 +1481,27 @@
p->timeout--;
switch(p->state){
case Sclosing:
+ if(p->timeout <= 0){
+ newstate(ppp, p, Sclosed);
+ break;
+ }
sendtermreq(ppp, p);
break;
case Sreqsent:
case Sacksent:
- if(p->timeout <= 0)
+ if(p->timeout <= 0){
newstate(ppp, p, Sclosed);
- else {
- config(ppp, p, 0);
+ break;
}
+ config(ppp, p, 0);
break;
case Sackrcvd:
- if(p->timeout <= 0)
+ if(p->timeout <= 0){
newstate(ppp, p, Sclosed);
- else {
- config(ppp, p, 0);
- newstate(ppp, p, Sreqsent);
+ break;
}
+ config(ppp, p, 0);
+ newstate(ppp, p, Sreqsent);
break;
}
}
@@ -2620,7 +2625,6 @@
hnputs(m->len, 4);
putframe(ppp, p->proto, b);
freeb(b);
- newstate(ppp, p, Sclosing);
}
static void
--- a/sys/src/cmd/ip/ppp/ppp.h
+++ b/sys/src/cmd/ip/ppp/ppp.h
@@ -173,6 +173,7 @@
Period= 5*1000, /* period of retransmit process (in ms) */
Timeout= 20, /* xmit timeout (in Periods) */
Echotimeout= 5, /* echo timeout (in Periods) */
+ Termtimeout= 3, /* term timeout (in Periods) */
Buflen= 4096,
MAX_STATES= 16, /* van jacobson compression states */
--
⑨