Re-challenge timeouts are made up of a single scalar factor which is
multiplied with the unit `lcp.timeout' if you will, so that changing
from ticks to seconds here only requires reducing this second factor.

I added comments to hopefully make clear enough that the `timeout'
member alone carries this implementation dependent information, and that
the rest of the struct members are indeed just "counters" as this note
says.

In sppp_increasing_timeout(), `timo' is left untouched as this raises
the minimum timeout to one second, not just one tick (it is the scalar
factor, not the final value).

        void
        sppp_lcp_init(struct sppp *sp)
        {
                ...

                /*
                 * Initialize counters and timeout values.  Note that we don't
                 * use the 3 seconds suggested in RFC 1661 since we are likely
                 * running on a fast link.  XXX We should probably implement
                 * the exponential backoff option.  Note that these values are
                 * relevant for all control protocols, not just LCP only.
                 */
                sp->lcp.timeout = 1;    /* seconds */
                sp->lcp.max_terminate = 2;
                sp->lcp.max_configure = 10;
                sp->lcp.max_failure = 10;
        }

OK?

Index: net/if_sppp.h
===================================================================
RCS file: /cvs/src/sys/net/if_sppp.h,v
retrieving revision 1.26
diff -u -p -r1.26 if_sppp.h
--- net/if_sppp.h       24 Jan 2017 10:08:30 -0000      1.26
+++ net/if_sppp.h       24 Jun 2019 18:03:22 -0000
@@ -110,7 +110,7 @@ struct slcp {
        u_long  protos;         /* bitmask of protos that are started */
        u_char  echoid;         /* id of last keepalive echo request */
        /* restart max values, see RFC 1661 */
-       int     timeout;
+       int     timeout;        /* seconds */
        int     max_terminate;
        int     max_configure;
        int     max_failure;
Index: net/if_spppsubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_spppsubr.c,v
retrieving revision 1.178
diff -u -p -r1.178 if_spppsubr.c
--- net/if_spppsubr.c   22 Jun 2019 20:15:09 -0000      1.178
+++ net/if_spppsubr.c   24 Jun 2019 18:03:23 -0000
@@ -1491,7 +1491,7 @@ sppp_increasing_timeout (const struct cp
        timo = sp->lcp.max_configure - sp->rst_counter[cp->protoidx];
        if (timo < 1)
                timo = 1;
-       timeout_add(&sp->ch[cp->protoidx], timo * sp->lcp.timeout);
+       timeout_add_sec(&sp->ch[cp->protoidx], timo * sp->lcp.timeout);
 }
 
 void
@@ -1608,7 +1608,7 @@ sppp_lcp_init(struct sppp *sp)
         * the exponential backoff option.  Note that these values are
         * relevant for all control protocols, not just LCP only.
         */
-       sp->lcp.timeout = 1 * hz;
+       sp->lcp.timeout = 1;    /* seconds */
        sp->lcp.max_terminate = 2;
        sp->lcp.max_configure = 10;
        sp->lcp.max_failure = 10;
@@ -3828,7 +3828,7 @@ sppp_pap_open(struct sppp *sp)
        if (sp->myauth.proto == PPP_PAP) {
                /* we are peer, send a request, and start a timer */
                pap.scr(sp);
-               timeout_add(&sp->pap_my_to_ch, sp->lcp.timeout);
+               timeout_add_sec(&sp->pap_my_to_ch, sp->lcp.timeout);
        }
 }
 

Reply via email to