diff options
author | brian <brian@cvs.openbsd.org> | 1999-02-26 21:28:25 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-02-26 21:28:25 +0000 |
commit | d9bb8348dcd75cceeef873afce1e276ba72bb0de (patch) | |
tree | 20e64151e4d59f6c7afc3cbcaacba5d1a1079d67 | |
parent | 004b18a91803abee9d3721d108861a549d6bd7ab (diff) |
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
-rw-r--r-- | usr.sbin/ppp/ppp/auth.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/auth.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/cbcp.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ccp.c | 42 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ccp.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/command.c | 118 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/datalink.c | 16 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/defs.h | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/fsm.c | 78 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/fsm.h | 22 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ipcp.c | 38 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ipcp.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/lcp.c | 50 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/lcp.h | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/modem.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ppp.8 | 38 |
16 files changed, 301 insertions, 147 deletions
diff --git a/usr.sbin/ppp/ppp/auth.c b/usr.sbin/ppp/ppp/auth.c index e47c84ab9f1..9898fb433d0 100644 --- a/usr.sbin/ppp/ppp/auth.c +++ b/usr.sbin/ppp/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.8 1999/02/20 01:15:12 brian Exp $ + * $Id: auth.c,v 1.9 1999/02/26 21:28:18 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -290,7 +290,9 @@ auth_Init(struct authinfo *authp, struct physical *p, auth_func req, auth_func success, auth_func failure) { memset(authp, '\0', sizeof(struct authinfo)); - authp->cfg.fsmretry = DEF_FSMRETRY; + authp->cfg.fsm.timeout = DEF_FSMRETRY; + authp->cfg.fsm.maxreq = DEF_FSMAUTHTRIES; + authp->cfg.fsm.maxtrm = 0; /* not used */ authp->fn.req = req; authp->fn.success = success; authp->fn.failure = failure; @@ -303,9 +305,9 @@ auth_StartReq(struct authinfo *authp) timer_Stop(&authp->authtimer); authp->authtimer.func = AuthTimeout; authp->authtimer.name = "auth"; - authp->authtimer.load = authp->cfg.fsmretry * SECTICKS; + authp->authtimer.load = authp->cfg.fsm.timeout * SECTICKS; authp->authtimer.arg = (void *)authp; - authp->retry = 3; + authp->retry = authp->cfg.fsm.maxreq; authp->id = 1; (*authp->fn.req)(authp); timer_Start(&authp->authtimer); diff --git a/usr.sbin/ppp/ppp/auth.h b/usr.sbin/ppp/ppp/auth.h index bc5f53aba6c..63174af8922 100644 --- a/usr.sbin/ppp/ppp/auth.h +++ b/usr.sbin/ppp/ppp/auth.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.h,v 1.5 1999/02/18 00:50:44 brian Exp $ + * $Id: auth.h,v 1.6 1999/02/26 21:28:19 brian Exp $ * * TODO: */ @@ -40,7 +40,7 @@ struct authinfo { int id; struct physical *physical; struct { - u_int fsmretry; + struct fsm_retry fsm; /* How often/frequently to resend requests */ } cfg; }; diff --git a/usr.sbin/ppp/ppp/cbcp.c b/usr.sbin/ppp/ppp/cbcp.c index 2b0ea11b732..6913d34a075 100644 --- a/usr.sbin/ppp/ppp/cbcp.c +++ b/usr.sbin/ppp/ppp/cbcp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cbcp.c,v 1.5 1999/02/06 03:22:31 brian Exp $ + * $Id: cbcp.c,v 1.6 1999/02/26 21:28:19 brian Exp $ */ #include <sys/param.h> @@ -327,7 +327,7 @@ cbcp_Up(struct cbcp *cbcp) } else cbcp->fsm.type = CBCP_CLIENTNUM; cbcp_NewPhase(cbcp, CBCP_STOPPED); /* Wait for a REQ */ - cbcp_StartTimer(cbcp, cbcp->fsm.delay * DEF_REQs); + cbcp_StartTimer(cbcp, cbcp->fsm.delay * DEF_FSMTRIES); } else { if (*cbcp->fsm.phone == '\0') cbcp->fsm.type = CBCP_NONUM; @@ -338,7 +338,7 @@ cbcp_Up(struct cbcp *cbcp) cbcp->fsm.type = CBCP_LISTNUM; else cbcp->fsm.type = CBCP_SERVERNUM; - cbcp->fsm.restart = DEF_REQs; + cbcp->fsm.restart = DEF_FSMTRIES; cbcp_SendReq(cbcp); } } @@ -635,7 +635,7 @@ cbcp_Input(struct physical *p, struct mbuf *bp) if (cbcp->fsm.state == CBCP_STOPPED || cbcp->fsm.state == CBCP_RESPSENT) { timer_Stop(&cbcp->fsm.timer); if (cbcp_AdjustResponse(cbcp, data)) { - cbcp->fsm.restart = DEF_REQs; + cbcp->fsm.restart = DEF_FSMTRIES; cbcp->fsm.id = head->id; cbcp_SendResponse(cbcp); } else @@ -661,7 +661,7 @@ cbcp_Input(struct physical *p, struct mbuf *bp) break; case CBCP_ACTION_ACK: - cbcp->fsm.restart = DEF_REQs; + cbcp->fsm.restart = DEF_FSMTRIES; cbcp_SendAck(cbcp); if (cbcp->fsm.type == CBCP_NONUM) { /* diff --git a/usr.sbin/ppp/ppp/ccp.c b/usr.sbin/ppp/ppp/ccp.c index 8edba14406b..6b298121b95 100644 --- a/usr.sbin/ppp/ppp/ccp.c +++ b/usr.sbin/ppp/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.2 1999/02/06 03:22:32 brian Exp $ + * $Id: ccp.c,v 1.3 1999/02/26 21:28:20 brian Exp $ * * TODO: * o Support other compression protocols @@ -70,7 +70,7 @@ static void CcpLayerStart(struct fsm *); static void CcpLayerFinish(struct fsm *); static int CcpLayerUp(struct fsm *); static void CcpLayerDown(struct fsm *); -static void CcpInitRestartCounter(struct fsm *); +static void CcpInitRestartCounter(struct fsm *, int); static void CcpRecvResetReq(struct fsm *); static void CcpRecvResetAck(struct fsm *, u_char); @@ -150,7 +150,10 @@ ccp_ReportStatus(struct cmdargs const *arg) ccp->compin, ccp->uncompin); prompt_Printf(arg->prompt, "\n Defaults: "); - prompt_Printf(arg->prompt, "FSM retry = %us\n", ccp->cfg.fsmretry); + prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config" + " REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout, + ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s", + ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s"); prompt_Printf(arg->prompt, " deflate windows: "); prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize); prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize); @@ -178,12 +181,14 @@ ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l, { /* Initialise ourselves */ - fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, 10, LogCCP, + fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, LogCCP, bundle, l, parent, &ccp_Callbacks, ccp_TimerNames); ccp->cfg.deflate.in.winsize = 0; ccp->cfg.deflate.out.winsize = 15; - ccp->cfg.fsmretry = DEF_FSMRETRY; + ccp->cfg.fsm.timeout = DEF_FSMRETRY; + ccp->cfg.fsm.maxreq = DEF_FSMTRIES; + ccp->cfg.fsm.maxtrm = DEF_FSMTRIES; ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED; ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED; ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0; @@ -196,7 +201,6 @@ ccp_Setup(struct ccp *ccp) { /* Set ourselves up for a startup */ ccp->fsm.open_mode = 0; - ccp->fsm.maxconfig = 10; ccp->his_proto = ccp->my_proto = -1; ccp->reset_sent = ccp->last_reset = -1; ccp->in.algorithm = ccp->out.algorithm = -1; @@ -209,13 +213,23 @@ ccp_Setup(struct ccp *ccp) } static void -CcpInitRestartCounter(struct fsm *fp) +CcpInitRestartCounter(struct fsm *fp, int what) { /* Set fsm timer load */ struct ccp *ccp = fsm2ccp(fp); - fp->FsmTimer.load = ccp->cfg.fsmretry * SECTICKS; - fp->restart = DEF_REQs; + fp->FsmTimer.load = ccp->cfg.fsm.timeout * SECTICKS; + switch (what) { + case FSM_REQ_TIMER: + fp->restart = ccp->cfg.fsm.maxreq; + break; + case FSM_TRM_TIMER: + fp->restart = ccp->cfg.fsm.maxtrm; + break; + default: + fp->restart = 1; + break; + } } static void @@ -304,7 +318,10 @@ static void CcpLayerStart(struct fsm *fp) { /* We're about to start up ! */ + struct ccp *ccp = fsm2ccp(fp); + log_Printf(LogCCP, "%s: LayerStart.\n", fp->link->name); + fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3; } static void @@ -350,7 +367,9 @@ CcpLayerUp(struct fsm *fp) { /* We're now up */ struct ccp *ccp = fsm2ccp(fp); + log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name); + if (ccp->in.state == NULL && ccp->in.algorithm >= 0 && ccp->in.algorithm < NALGORITHMS) { ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt); @@ -359,6 +378,7 @@ CcpLayerUp(struct fsm *fp) fp->link->name, protoname(ccp->his_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); + return 0; } } @@ -371,12 +391,16 @@ CcpLayerUp(struct fsm *fp) fp->link->name, protoname(ccp->my_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); + return 0; } } + fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3; + log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n", fp->link->name, protoname(ccp->my_proto), ccp->my_proto, protoname(ccp->his_proto), ccp->his_proto); + return 1; } diff --git a/usr.sbin/ppp/ppp/ccp.h b/usr.sbin/ppp/ppp/ccp.h index 425611fe811..45af80acc47 100644 --- a/usr.sbin/ppp/ppp/ccp.h +++ b/usr.sbin/ppp/ppp/ccp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.h,v 1.2 1999/02/06 03:22:32 brian Exp $ + * $Id: ccp.h,v 1.3 1999/02/26 21:28:20 brian Exp $ * * TODO: */ @@ -49,7 +49,7 @@ struct ccp_config { int winsize; } in, out; } deflate; - u_int fsmretry; /* FSM retry frequency */ + struct fsm_retry fsm; /* How often/frequently to resend requests */ unsigned neg[CCP_NEG_TOTAL]; }; diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c index e5be2339348..301d6fe86a8 100644 --- a/usr.sbin/ppp/ppp/command.c +++ b/usr.sbin/ppp/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.11 1999/02/25 20:07:34 brian Exp $ + * $Id: command.c,v 1.12 1999/02/26 21:28:20 brian Exp $ * */ #include <sys/param.h> @@ -141,7 +141,7 @@ #define NEG_DNS 52 const char Version[] = "2.11"; -const char VersionDate[] = "$Date: 1999/02/25 20:07:34 $"; +const char VersionDate[] = "$Date: 1999/02/26 21:28:20 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -1319,6 +1319,47 @@ SetInterfaceAddr(struct cmdargs const *arg) } static int +SetRetry(int argc, char const *const *argv, u_int *timeout, u_int *maxreq, + u_int *maxtrm, int def) +{ + if (argc == 0) { + *timeout = DEF_FSMRETRY; + *maxreq = def; + if (maxtrm != NULL) + *maxtrm = def; + } else { + long l = atol(argv[0]); + + if (l < MIN_FSMRETRY) { + log_Printf(LogWARN, "%ld: Invalid FSM retry period - min %d\n", + l, MIN_FSMRETRY); + return 1; + } else + *timeout = l; + + if (argc > 1) { + l = atol(argv[1]); + if (l < 1) { + log_Printf(LogWARN, "%ld: Invalid FSM REQ tries - changed to 1\n", l); + l = 1; + } + *maxreq = l; + + if (argc > 2 && maxtrm != NULL) { + l = atol(argv[2]); + if (l < 1) { + log_Printf(LogWARN, "%ld: Invalid FSM TRM tries - changed to 1\n", l); + l = 1; + } + *maxtrm = l; + } + } + } + + return 0; +} + +static int SetVariable(struct cmdargs const *arg) { long long_val, param = (long)arg->cmd->args; @@ -1548,53 +1589,35 @@ SetVariable(struct cmdargs const *arg) break; case VAR_LCPRETRY: - long_val = atol(argp); - if (long_val < MIN_FSMRETRY) { - log_Printf(LogWARN, "%ld: Invalid LCP FSM retry period - min %d\n", - long_val, MIN_FSMRETRY); - return 1; - } else - cx->physical->link.lcp.cfg.fsmretry = long_val; + return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, + &cx->physical->link.lcp.cfg.fsm.timeout, + &cx->physical->link.lcp.cfg.fsm.maxreq, + &cx->physical->link.lcp.cfg.fsm.maxtrm, DEF_FSMTRIES); break; case VAR_CHAPRETRY: - long_val = atol(argp); - if (long_val < MIN_FSMRETRY) { - log_Printf(LogWARN, "%ld: Invalid CHAP FSM retry period - min %d\n", - long_val, MIN_FSMRETRY); - return 1; - } else - cx->chap.auth.cfg.fsmretry = long_val; + return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, + &cx->chap.auth.cfg.fsm.timeout, + &cx->chap.auth.cfg.fsm.maxreq, NULL, DEF_FSMAUTHTRIES); break; case VAR_PAPRETRY: - long_val = atol(argp); - if (long_val < MIN_FSMRETRY) { - log_Printf(LogWARN, "%ld: Invalid PAP FSM retry period - min %d\n", - long_val, MIN_FSMRETRY); - return 1; - } else - cx->pap.cfg.fsmretry = long_val; + return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, + &cx->pap.cfg.fsm.timeout, &cx->pap.cfg.fsm.maxreq, + NULL, DEF_FSMAUTHTRIES); break; case VAR_CCPRETRY: - long_val = atol(argp); - if (long_val < MIN_FSMRETRY) { - log_Printf(LogWARN, "%ld: Invalid CCP FSM retry period - min %d\n", - long_val, MIN_FSMRETRY); - return 1; - } else - l->ccp.cfg.fsmretry = long_val; + return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, + &l->ccp.cfg.fsm.timeout, &l->ccp.cfg.fsm.maxreq, + &l->ccp.cfg.fsm.maxtrm, DEF_FSMTRIES); break; case VAR_IPCPRETRY: - long_val = atol(argp); - if (long_val < MIN_FSMRETRY) { - log_Printf(LogWARN, "%ld: Invalid IPCP FSM retry period - min %d\n", - long_val, MIN_FSMRETRY); - return 1; - } else - arg->bundle->ncp.ipcp.cfg.fsmretry = long_val; + return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, + &arg->bundle->ncp.ipcp.cfg.fsm.timeout, + &arg->bundle->ncp.ipcp.cfg.fsm.maxreq, + &arg->bundle->ncp.ipcp.cfg.fsm.maxtrm, DEF_FSMTRIES); break; case VAR_NBNS: @@ -1747,12 +1770,13 @@ static struct cmdtab const SetCommands[] = { {"cbcp", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "CBCP control", "set cbcp [*|phone[,phone...] [delay [timeout]]]", (const void *)VAR_CBCP}, - {"ccpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, - "FSM retry period", "set ccpretry value", (const void *)VAR_CCPRETRY}, + {"ccpretry", "ccpretries", SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, + "CCP retries", "set ccpretry value [attempts]", (const void *)VAR_CCPRETRY}, {"cd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Carrier delay requirement", "set cd value[!]", (const void *)VAR_CD}, - {"chapretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, - "CHAP retry period", "set chapretry value", (const void *)VAR_CHAPRETRY}, + {"chapretry", "chapretries", SetVariable, LOCAL_AUTH | LOCAL_CX, + "CHAP retries", "set chapretry value [attempts]", + (const void *)VAR_CHAPRETRY}, {"choked", NULL, SetVariable, LOCAL_AUTH, "choked timeout", "set choked [secs]", (const void *)VAR_CHOKED}, {"ctsrts", "crtscts", SetCtsRts, LOCAL_AUTH | LOCAL_CX, @@ -1779,10 +1803,10 @@ static struct cmdtab const SetCommands[] = { "hangup script", "set hangup chat-script", (const void *) VAR_HANGUP}, {"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "destination address", "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"}, - {"ipcpretry", NULL, SetVariable, LOCAL_AUTH, - "FSM retry period", "set ipcpretry value", (const void *)VAR_IPCPRETRY}, - {"lcpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, - "FSM retry period", "set lcpretry value", (const void *)VAR_LCPRETRY}, + {"ipcpretry", "ipcpretries", SetVariable, LOCAL_AUTH, "IPCP retries", + "set ipcpretry value [attempts]", (const void *)VAR_IPCPRETRY}, + {"lcpretry", "lcpretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "LCP retries", + "set lcpretry value [attempts]", (const void *)VAR_LCPRETRY}, {"log", NULL, log_SetLevel, LOCAL_AUTH, "log level", "set log [local] [+|-]async|cbcp|ccp|chat|command|connect|debug|hdlc|id0|" "ipcp|lcp|lqm|phase|tcp/ip|timer|tun..."}, @@ -1802,8 +1826,8 @@ static struct cmdtab const SetCommands[] = { "set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS}, {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode", "set openmode active|passive [secs]", (const void *)VAR_OPENMODE}, - {"papretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, - "PAP retry period", "set papretry value", (const void *)VAR_PAPRETRY}, + {"papretry", "papretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "PAP retries", + "set papretry value [attempts]", (const void *)VAR_PAPRETRY}, {"parity", NULL, SetModemParity, LOCAL_AUTH | LOCAL_CX, "modem parity", "set parity [odd|even|none]"}, {"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "telephone number(s)", diff --git a/usr.sbin/ppp/ppp/datalink.c b/usr.sbin/ppp/ppp/datalink.c index d3a69720974..cbf0beae99a 100644 --- a/usr.sbin/ppp/ppp/datalink.c +++ b/usr.sbin/ppp/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.14 1999/02/25 12:07:23 brian Exp $ + * $Id: datalink.c,v 1.15 1999/02/26 21:28:21 brian Exp $ */ #include <sys/param.h> @@ -808,10 +808,10 @@ datalink_Clone(struct datalink *odl, const char *name) return NULL; } pap_Init(&dl->pap, dl->physical); - dl->pap.cfg.fsmretry = odl->pap.cfg.fsmretry; + dl->pap.cfg = odl->pap.cfg; chap_Init(&dl->chap, dl->physical); - dl->chap.auth.cfg.fsmretry = odl->chap.auth.cfg.fsmretry; + dl->chap.auth.cfg = odl->chap.auth.cfg; memcpy(&dl->physical->cfg, &odl->physical->cfg, sizeof dl->physical->cfg); memcpy(&dl->physical->link.lcp.cfg, &odl->physical->link.lcp.cfg, @@ -1149,7 +1149,7 @@ iov2datalink(struct bundle *bundle, struct iovec *iov, int *niov, int maxiov, int fd) { struct datalink *dl, *cdl; - u_int retry; + struct fsm_retry copy; char *oname; dl = (struct datalink *)iov[(*niov)++].iov_base; @@ -1214,13 +1214,13 @@ iov2datalink(struct bundle *bundle, struct iovec *iov, int *niov, int maxiov, free(dl); dl = NULL; } else { - retry = dl->pap.cfg.fsmretry; + copy = dl->pap.cfg.fsm; pap_Init(&dl->pap, dl->physical); - dl->pap.cfg.fsmretry = retry; + dl->pap.cfg.fsm = copy; - retry = dl->chap.auth.cfg.fsmretry; + copy = dl->chap.auth.cfg.fsm; chap_Init(&dl->chap, dl->physical); - dl->chap.auth.cfg.fsmretry = retry; + dl->chap.auth.cfg.fsm = copy; cbcp_Init(&dl->cbcp, dl->physical); chat_Init(&dl->chat, dl->physical, NULL, 1, NULL); diff --git a/usr.sbin/ppp/ppp/defs.h b/usr.sbin/ppp/ppp/defs.h index cac6434e406..cba0206e052 100644 --- a/usr.sbin/ppp/ppp/defs.h +++ b/usr.sbin/ppp/ppp/defs.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: defs.h,v 1.5 1999/02/25 20:07:36 brian Exp $ + * $Id: defs.h,v 1.6 1999/02/26 21:28:21 brian Exp $ * * TODO: */ @@ -56,7 +56,8 @@ #define DEF_LQRPERIOD 30 /* Default LQR frequency */ #define MIN_FSMRETRY 3 /* Minimum FSM retry frequency */ #define DEF_FSMRETRY 3 /* FSM retry frequency */ -#define DEF_REQs 5 /* This number of REQs in IRC */ +#define DEF_FSMTRIES 5 /* Default max retries */ +#define DEF_FSMAUTHTRIES 3 /* Default max auth retries */ #define DEF_CDDELAY 1 /* Delay before checking for carrier */ #define CONFFILE "ppp.conf" diff --git a/usr.sbin/ppp/ppp/fsm.c b/usr.sbin/ppp/ppp/fsm.c index 8a076dd8d30..35f16f36807 100644 --- a/usr.sbin/ppp/ppp/fsm.c +++ b/usr.sbin/ppp/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.3 1999/02/06 03:22:36 brian Exp $ + * $Id: fsm.c,v 1.4 1999/02/26 21:28:22 brian Exp $ * * TODO: */ @@ -59,7 +59,7 @@ static void FsmSendConfigReq(struct fsm *); static void FsmSendTerminateReq(struct fsm *); -static void FsmInitRestartCounter(struct fsm *); +static void FsmInitRestartCounter(struct fsm *, int); typedef void (recvfn)(struct fsm *, struct fsmheader *, struct mbuf *); static recvfn FsmRecvConfigReq, FsmRecvConfigAck, FsmRecvConfigNak, @@ -129,7 +129,7 @@ StoppedTimeout(void *v) void fsm_Init(struct fsm *fp, const char *name, u_short proto, int mincode, - int maxcode, int maxcfg, int LogLevel, struct bundle *bundle, + int maxcode, int LogLevel, struct bundle *bundle, struct link *l, const struct fsm_parent *parent, struct fsm_callbacks *fn, const char *timer_names[3]) { @@ -140,7 +140,7 @@ fsm_Init(struct fsm *fp, const char *name, u_short proto, int mincode, fp->state = fp->min_code > CODE_TERMACK ? ST_OPENED : ST_INITIAL; fp->reqid = 1; fp->restart = 1; - fp->maxconfig = maxcfg; + fp->more.reqs = fp->more.naks = fp->more.rejs = 1; memset(&fp->FsmTimer, '\0', sizeof fp->FsmTimer); memset(&fp->OpenTimer, '\0', sizeof fp->OpenTimer); memset(&fp->StoppedTimer, '\0', sizeof fp->StoppedTimer); @@ -229,7 +229,7 @@ FsmOpenNow(void *v) (*fp->fn->LayerStart)(fp); (*fp->parent->LayerStart)(fp->parent->object, fp); } - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); FsmSendConfigReq(fp); NewState(fp, ST_REQSENT); } @@ -283,7 +283,7 @@ fsm_Up(struct fsm * fp) NewState(fp, ST_CLOSED); break; case ST_STARTING: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); FsmSendConfigReq(fp); NewState(fp, ST_REQSENT); break; @@ -342,7 +342,7 @@ fsm_Close(struct fsm *fp) break; case ST_OPENED: (*fp->fn->LayerDown)(fp); - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_TRM_TIMER); FsmSendTerminateReq(fp); NewState(fp, ST_CLOSING); (*fp->parent->LayerDown)(fp->parent->object, fp); @@ -350,7 +350,7 @@ fsm_Close(struct fsm *fp) case ST_REQSENT: case ST_ACKRCVD: case ST_ACKSENT: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_TRM_TIMER); FsmSendTerminateReq(fp); NewState(fp, ST_CLOSING); break; @@ -363,11 +363,13 @@ fsm_Close(struct fsm *fp) static void FsmSendConfigReq(struct fsm * fp) { - if (--fp->maxconfig > 0) { + if (fp->more.reqs-- > 0 && fp->restart-- > 0) { (*fp->fn->SendConfigReq)(fp); - timer_Start(&fp->FsmTimer); /* Start restart timer */ - fp->restart--; /* Decrement restart counter */ + timer_Start(&fp->FsmTimer); /* Start restart timer */ } else { + if (fp->more.reqs < 0) + log_Printf(LogPHASE, "%s: Too many %s REQs sent - abandoning " + "negotiation\n", fp->link->name, fp->name); fsm_Close(fp); } } @@ -429,12 +431,12 @@ FsmTimeout(void *v) } static void -FsmInitRestartCounter(struct fsm * fp) +FsmInitRestartCounter(struct fsm *fp, int what) { timer_Stop(&fp->FsmTimer); fp->FsmTimer.func = FsmTimeout; - fp->FsmTimer.arg = (void *) fp; - (*fp->fn->InitRestartCounter)(fp); + fp->FsmTimer.arg = (void *)fp; + (*fp->fn->InitRestartCounter)(fp, what); } /* @@ -510,7 +512,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) switch (fp->state) { case ST_STOPPED: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); /* Fall through */ case ST_OPENED: @@ -526,8 +528,17 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack); switch (fp->state) { - case ST_OPENED: case ST_STOPPED: + /* + * According to the RFC (1661) state transition table, a TLS isn't + * required for a RCR when state == ST_STOPPED, but the RFC + * must be wrong as TLS hasn't yet been called (since the last TLF) + */ + (*fp->fn->LayerStart)(fp); + (*fp->parent->LayerStart)(fp->parent->object, fp); + /* Fall through */ + + case ST_OPENED: if (ackaction) NewState(fp, ST_ACKSENT); else @@ -544,7 +555,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) (*fp->parent->LayerUp)(fp->parent->object, fp); else { (*fp->fn->LayerDown)(fp); - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_TRM_TIMER); FsmSendTerminateReq(fp); NewState(fp, ST_CLOSING); } @@ -556,6 +567,19 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) break; } mbuf_Free(bp); + + if (dec.rejend != dec.rej && --fp->more.rejs <= 0) { + log_Printf(LogPHASE, "%s: Too many %s REJs sent - abandoning negotiation\n", + fp->link->name, fp->name); + fsm_Close(fp); + } + + if (dec.nakend != dec.nak && --fp->more.naks <= 0) { + fsm_Close(fp); + log_Printf(LogPHASE, "%s: Too many %s NAKs sent - abandoning negotiation\n", + fp->link->name, fp->name); + fsm_Close(fp); + } } static void @@ -571,7 +595,7 @@ FsmRecvConfigAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) case ST_STOPPING: break; case ST_REQSENT: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); NewState(fp, ST_ACKRCVD); break; case ST_ACKRCVD: @@ -579,13 +603,13 @@ FsmRecvConfigAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) NewState(fp, ST_REQSENT); break; case ST_ACKSENT: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); NewState(fp, ST_OPENED); if ((*fp->fn->LayerUp)(fp)) (*fp->parent->LayerUp)(fp->parent->object, fp); else { (*fp->fn->LayerDown)(fp); - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_TRM_TIMER); FsmSendTerminateReq(fp); NewState(fp, ST_CLOSING); } @@ -645,7 +669,7 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) switch (fp->state) { case ST_REQSENT: case ST_ACKSENT: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); FsmSendConfigReq(fp); break; case ST_OPENED: @@ -688,11 +712,12 @@ FsmRecvTermReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) case ST_OPENED: (*fp->fn->LayerDown)(fp); (*fp->fn->SendTerminateAck)(fp, lhp->id); - FsmInitRestartCounter(fp); - timer_Start(&fp->FsmTimer); /* Start restart timer */ + FsmInitRestartCounter(fp, FSM_TRM_TIMER); + timer_Start(&fp->FsmTimer); /* Start restart timer */ fp->restart = 0; NewState(fp, ST_STOPPING); (*fp->parent->LayerDown)(fp->parent->object, fp); + /* A delayed ST_STOPPED is now scheduled */ break; } mbuf_Free(bp); @@ -771,7 +796,7 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) switch (fp->state) { case ST_REQSENT: case ST_ACKSENT: - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); FsmSendConfigReq(fp); break; case ST_OPENED: @@ -999,7 +1024,7 @@ fsm_Reopen(struct fsm *fp) { if (fp->state == ST_OPENED) { (*fp->fn->LayerDown)(fp); - FsmInitRestartCounter(fp); + FsmInitRestartCounter(fp, FSM_REQ_TIMER); FsmSendConfigReq(fp); NewState(fp, ST_REQSENT); (*fp->parent->LayerDown)(fp->parent->object, fp); @@ -1009,6 +1034,9 @@ fsm_Reopen(struct fsm *fp) void fsm2initial(struct fsm *fp) { + timer_Stop(&fp->FsmTimer); + timer_Stop(&fp->OpenTimer); + timer_Stop(&fp->StoppedTimer); if (fp->state == ST_STOPPED) fsm_Close(fp); if (fp->state > ST_INITIAL) diff --git a/usr.sbin/ppp/ppp/fsm.h b/usr.sbin/ppp/ppp/fsm.h index b515656c30c..51b2e3aed13 100644 --- a/usr.sbin/ppp/ppp/fsm.h +++ b/usr.sbin/ppp/ppp/fsm.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.h,v 1.2 1999/02/06 03:22:36 brian Exp $ + * $Id: fsm.h,v 1.3 1999/02/26 21:28:22 brian Exp $ * * TODO: */ @@ -45,8 +45,17 @@ #define OPEN_PASSIVE -1 +#define FSM_REQ_TIMER 1 +#define FSM_TRM_TIMER 2 + struct fsm; +struct fsm_retry { + u_int timeout; /* FSM retry frequency */ + u_int maxreq; /* Max Config REQ retries */ + u_int maxtrm; /* Max Term REQ retries */ +}; + struct fsm_decode { u_char ack[100], *ackend; u_char nak[100], *nakend; @@ -58,7 +67,7 @@ struct fsm_callbacks { void (*LayerDown) (struct fsm *); /* About to come down (tld) */ void (*LayerStart) (struct fsm *); /* Layer about to start up (tls) */ void (*LayerFinish) (struct fsm *); /* Layer now down (tlf) */ - void (*InitRestartCounter) (struct fsm *); /* Set fsm timer load */ + void (*InitRestartCounter) (struct fsm *, int); /* Set fsm timer load */ void (*SendConfigReq) (struct fsm *); /* Send REQ please */ void (*SentTerminateReq) (struct fsm *); /* Term REQ just sent */ void (*SendTerminateAck) (struct fsm *, u_char); /* Send Term ACK please */ @@ -88,7 +97,12 @@ struct fsm { int state; /* State of the machine */ u_char reqid; /* Next request id */ int restart; /* Restart counter value */ - int maxconfig; /* Max config REQ before a close() */ + + struct { + int reqs; /* Max config REQs before a close() */ + int naks; /* Max config NAKs before a close() */ + int rejs; /* Max config REJs before a close() */ + } more; struct pppTimer FsmTimer; /* Restart Timer */ struct pppTimer OpenTimer; /* Delay before opening */ @@ -143,7 +157,7 @@ struct fsmconfig { u_char length; }; -extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, int, +extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, struct bundle *, struct link *, const struct fsm_parent *, struct fsm_callbacks *, const char *[3]); extern void fsm_Output(struct fsm *, u_int, u_int, u_char *, int); diff --git a/usr.sbin/ppp/ppp/ipcp.c b/usr.sbin/ppp/ppp/ipcp.c index ab4923e396d..5d57dbb7a5a 100644 --- a/usr.sbin/ppp/ppp/ipcp.c +++ b/usr.sbin/ppp/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.7 1999/02/06 03:22:39 brian Exp $ + * $Id: ipcp.c,v 1.8 1999/02/26 21:28:22 brian Exp $ * * TODO: * o More RFC1772 backward compatibility @@ -96,7 +96,7 @@ static int IpcpLayerUp(struct fsm *); static void IpcpLayerDown(struct fsm *); static void IpcpLayerStart(struct fsm *); static void IpcpLayerFinish(struct fsm *); -static void IpcpInitRestartCounter(struct fsm *); +static void IpcpInitRestartCounter(struct fsm *, int); static void IpcpSendConfigReq(struct fsm *); static void IpcpSentTerminateReq(struct fsm *); static void IpcpSendTerminateAck(struct fsm *, u_char); @@ -282,6 +282,10 @@ ipcp_Show(struct cmdargs const *arg) } prompt_Printf(arg->prompt, "\nDefaults:\n"); + prompt_Printf(arg->prompt, " FSM retry = %us, max %u Config" + " REQ%s, %u Term REQ%s\n", ipcp->cfg.fsm.timeout, + ipcp->cfg.fsm.maxreq, ipcp->cfg.fsm.maxreq == 1 ? "" : "s", + ipcp->cfg.fsm.maxtrm, ipcp->cfg.fsm.maxtrm == 1 ? "" : "s"); prompt_Printf(arg->prompt, " My Address: %s/%d", inet_ntoa(ipcp->cfg.my_range.ipaddr), ipcp->cfg.my_range.width); @@ -348,7 +352,7 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l, static const char *timer_names[] = {"IPCP restart", "IPCP openmode", "IPCP stopped"}; - fsm_Init(&ipcp->fsm, "IPCP", PROTO_IPCP, 1, IPCP_MAXCODE, 10, LogIPCP, + fsm_Init(&ipcp->fsm, "IPCP", PROTO_IPCP, 1, IPCP_MAXCODE, LogIPCP, bundle, l, parent, &ipcp_Callbacks, timer_names); ipcp->route = NULL; @@ -371,7 +375,9 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l, ipcp->cfg.ns.nbns[0].s_addr = INADDR_ANY; ipcp->cfg.ns.nbns[1].s_addr = INADDR_ANY; - ipcp->cfg.fsmretry = DEF_FSMRETRY; + ipcp->cfg.fsm.timeout = DEF_FSMRETRY; + ipcp->cfg.fsm.maxreq = DEF_FSMTRIES; + ipcp->cfg.fsm.maxtrm = DEF_FSMTRIES; ipcp->cfg.vj.neg = NEG_ENABLED|NEG_ACCEPTED; memset(&ipcp->vj, '\0', sizeof ipcp->vj); @@ -394,7 +400,6 @@ ipcp_Setup(struct ipcp *ipcp, u_int32_t mask) int pos, n; ipcp->fsm.open_mode = 0; - ipcp->fsm.maxconfig = 10; ipcp->ifmask.s_addr = mask == INADDR_NONE ? ipcp->cfg.netmask.s_addr : mask; if (iplist_isvalid(&ipcp->cfg.peer_list)) { @@ -571,13 +576,23 @@ ChooseHisAddr(struct bundle *bundle, struct in_addr gw) } static void -IpcpInitRestartCounter(struct fsm * fp) +IpcpInitRestartCounter(struct fsm *fp, int what) { /* Set fsm timer load */ struct ipcp *ipcp = fsm2ipcp(fp); - fp->FsmTimer.load = ipcp->cfg.fsmretry * SECTICKS; - fp->restart = DEF_REQs; + fp->FsmTimer.load = ipcp->cfg.fsm.timeout * SECTICKS; + switch (what) { + case FSM_REQ_TIMER: + fp->restart = ipcp->cfg.fsm.maxreq; + break; + case FSM_TRM_TIMER: + fp->restart = ipcp->cfg.fsm.maxtrm; + break; + default: + fp->restart = 1; + break; + } } static void @@ -628,7 +643,7 @@ IpcpSendConfigReq(struct fsm *fp) } static void -IpcpSentTerminateReq(struct fsm * fp) +IpcpSentTerminateReq(struct fsm *fp) { /* Term REQ just sent by FSM */ } @@ -649,8 +664,7 @@ IpcpLayerStart(struct fsm *fp) log_Printf(LogIPCP, "%s: LayerStart.\n", fp->link->name); throughput_start(&ipcp->throughput, "IPCP throughput", Enabled(fp->bundle, OPT_THROUGHPUT)); - - /* This is where we should be setting up the interface in AUTO mode */ + fp->more.reqs = fp->more.naks = fp->more.rejs = ipcp->cfg.fsm.maxreq * 3; } static void @@ -765,7 +779,9 @@ IpcpLayerUp(struct fsm *fp) system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL, NULL); } + fp->more.reqs = fp->more.naks = fp->more.rejs = ipcp->cfg.fsm.maxreq * 3; log_DisplayPrompts(); + return 1; } diff --git a/usr.sbin/ppp/ppp/ipcp.h b/usr.sbin/ppp/ppp/ipcp.h index aec762e11b7..b32b3cdc026 100644 --- a/usr.sbin/ppp/ppp/ipcp.h +++ b/usr.sbin/ppp/ppp/ipcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.h,v 1.3 1999/02/06 03:22:39 brian Exp $ + * $Id: ipcp.h,v 1.4 1999/02/26 21:28:23 brian Exp $ * * TODO: */ @@ -77,7 +77,7 @@ struct ipcp { struct in_addr nbns[2]; /* NetBIOS NS addresses offered */ } ns; - u_int fsmretry; /* FSM retry frequency */ + struct fsm_retry fsm; /* How often/frequently to resend requests */ } cfg; struct { diff --git a/usr.sbin/ppp/ppp/lcp.c b/usr.sbin/ppp/ppp/lcp.c index 2209539aff9..4e52feeaa33 100644 --- a/usr.sbin/ppp/ppp/lcp.c +++ b/usr.sbin/ppp/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.7 1999/02/18 00:50:45 brian Exp $ + * $Id: lcp.c,v 1.8 1999/02/26 21:28:23 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -81,7 +81,7 @@ static int LcpLayerUp(struct fsm *); static void LcpLayerDown(struct fsm *); static void LcpLayerStart(struct fsm *); static void LcpLayerFinish(struct fsm *); -static void LcpInitRestartCounter(struct fsm *); +static void LcpInitRestartCounter(struct fsm *, int); static void LcpSendConfigReq(struct fsm *); static void LcpSentTerminateReq(struct fsm *); static void LcpSendTerminateAck(struct fsm *, u_char); @@ -171,8 +171,10 @@ lcp_ReportStatus(struct cmdargs const *arg) lcp->cfg.openmode == OPEN_PASSIVE ? "passive" : "active"); if (lcp->cfg.openmode > 0) prompt_Printf(arg->prompt, " (delay %ds)", lcp->cfg.openmode); - prompt_Printf(arg->prompt, "\n FSM retry = %us\n", - lcp->cfg.fsmretry); + prompt_Printf(arg->prompt, "\n FSM retry = %us, max %u Config" + " REQ%s, %u Term REQ%s\n", lcp->cfg.fsm.timeout, + lcp->cfg.fsm.maxreq, lcp->cfg.fsm.maxreq == 1 ? "" : "s", + lcp->cfg.fsm.maxtrm, lcp->cfg.fsm.maxtrm == 1 ? "" : "s"); prompt_Printf(arg->prompt, "\n Negotiation:\n"); prompt_Printf(arg->prompt, " ACFCOMP = %s\n", command_ShowNegval(lcp->cfg.acfcomp)); @@ -218,14 +220,16 @@ lcp_Init(struct lcp *lcp, struct bundle *bundle, struct link *l, /* Initialise ourselves */ int mincode = parent ? 1 : LCP_MINMPCODE; - fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, mincode, LCP_MAXCODE, 10, LogLCP, + fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, mincode, LCP_MAXCODE, LogLCP, bundle, l, parent, &lcp_Callbacks, lcp_TimerNames); lcp->cfg.mru = DEF_MRU; lcp->cfg.accmap = 0; lcp->cfg.openmode = 1; lcp->cfg.lqrperiod = DEF_LQRPERIOD; - lcp->cfg.fsmretry = DEF_FSMRETRY; + lcp->cfg.fsm.timeout = DEF_FSMRETRY; + lcp->cfg.fsm.maxreq = DEF_FSMTRIES; + lcp->cfg.fsm.maxtrm = DEF_FSMTRIES; lcp->cfg.acfcomp = NEG_ENABLED|NEG_ACCEPTED; lcp->cfg.chap05 = NEG_ACCEPTED; @@ -244,7 +248,6 @@ void lcp_Setup(struct lcp *lcp, int openmode) { lcp->fsm.open_mode = openmode; - lcp->fsm.maxconfig = 10; lcp->his_mru = lcp->fsm.bundle->cfg.mtu; if (!lcp->his_mru || lcp->his_mru > DEF_MRU) @@ -311,13 +314,23 @@ lcp_Setup(struct lcp *lcp, int openmode) } static void -LcpInitRestartCounter(struct fsm * fp) +LcpInitRestartCounter(struct fsm *fp, int what) { /* Set fsm timer load */ struct lcp *lcp = fsm2lcp(fp); - fp->FsmTimer.load = lcp->cfg.fsmretry * SECTICKS; - fp->restart = DEF_REQs; + fp->FsmTimer.load = lcp->cfg.fsm.timeout * SECTICKS; + switch (what) { + case FSM_REQ_TIMER: + fp->restart = lcp->cfg.fsm.maxreq; + break; + case FSM_TRM_TIMER: + fp->restart = lcp->cfg.fsm.maxtrm; + break; + default: + fp->restart = 1; + break; + } } static void @@ -429,7 +442,7 @@ lcp_SendProtoRej(struct lcp *lcp, u_char *option, int count) } static void -LcpSentTerminateReq(struct fsm * fp) +LcpSentTerminateReq(struct fsm *fp) { /* Term REQ just sent by FSM */ } @@ -454,6 +467,7 @@ LcpLayerStart(struct fsm *fp) log_Printf(LogLCP, "%s: LayerStart\n", fp->link->name); lcp->LcpFailedMagic = 0; + fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3; } static void @@ -474,6 +488,8 @@ LcpLayerUp(struct fsm *fp) async_SetLinkParams(&p->async, lcp); lqr_Start(lcp); hdlc_StartTimer(&p->hdlc); + fp->more.reqs = fp->more.naks = fp->more.rejs = lcp->cfg.fsm.maxreq * 3; + return 1; } @@ -764,8 +780,12 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, " without DES)\n"); else #endif - log_Printf(LogLCP, "Peer will only send %s (not supported)\n", - Auth2Nam(PROTO_CHAP, cp[4])); + log_Printf(LogLCP, "Peer will only send %s (not %s)\n", + Auth2Nam(PROTO_CHAP, cp[4]), +#ifdef HAVE_DES + cp[4] == 0x80 ? "configured" : +#endif + "supported"); lcp->his_reject |= (1 << type); } break; @@ -1062,7 +1082,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, } break; - case MODE_NAK: /* Treat this as a REJ, we don't vary or disc */ + case MODE_NAK: /* Treat this as a REJ, we don't vary our disc */ case MODE_REJ: lcp->his_reject |= (1 << type); break; @@ -1130,7 +1150,7 @@ reqreject: } void -lcp_Input(struct lcp *lcp, struct mbuf * bp) +lcp_Input(struct lcp *lcp, struct mbuf *bp) { /* Got PROTO_LCP from link */ fsm_Input(&lcp->fsm, bp); diff --git a/usr.sbin/ppp/ppp/lcp.h b/usr.sbin/ppp/ppp/lcp.h index 9669293d2cc..25fd2be8167 100644 --- a/usr.sbin/ppp/ppp/lcp.h +++ b/usr.sbin/ppp/ppp/lcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.h,v 1.3 1999/02/18 00:50:45 brian Exp $ + * $Id: lcp.h,v 1.4 1999/02/26 21:28:24 brian Exp $ * * TODO: */ @@ -77,8 +77,7 @@ struct lcp { u_int32_t accmap; /* Initial ACCMAP value */ int openmode; /* when to start CFG REQs */ u_int32_t lqrperiod; /* LQR frequency (seconds) */ - u_int fsmretry; /* FSM retry frequency */ - + struct fsm_retry fsm; /* How often/frequently to resend requests */ unsigned acfcomp : 2; /* Address & Control Field Compression neg */ unsigned chap05 : 2; /* Challenge Handshake Authentication proto */ #ifdef HAVE_DES diff --git a/usr.sbin/ppp/ppp/modem.c b/usr.sbin/ppp/ppp/modem.c index ed1c6762abb..c48e510aad6 100644 --- a/usr.sbin/ppp/ppp/modem.c +++ b/usr.sbin/ppp/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.5 1999/02/25 20:07:36 brian Exp $ + * $Id: modem.c,v 1.6 1999/02/26 21:28:24 brian Exp $ * * TODO: */ @@ -810,6 +810,8 @@ modem_Close(struct physical *modem) if (!modem->isatty) { modem_PhysicalClose(modem); + if (*modem->name.full == '/') + modem_Unlock(modem); *modem->name.full = '\0'; modem->name.base = modem->name.full; return; diff --git a/usr.sbin/ppp/ppp/ppp.8 b/usr.sbin/ppp/ppp/ppp.8 index 09e28d445db..a7e8bcc6ff9 100644 --- a/usr.sbin/ppp/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.22 1999/02/25 12:07:23 brian Exp $ +.\" $Id: ppp.8,v 1.23 1999/02/26 21:28:24 brian Exp $ .Dd 20 September 1995 .nr XX \w'\fC00' .Os FreeBSD @@ -3588,17 +3588,41 @@ In all cases, if the interface is already configured, .Nm will try to maintain the interface IP numbers so that any existing bound sockets will remain valid. -.It set ccpretry Ar period -.It set chapretry Ar period -.It set ipcpretry Ar period -.It set lcpretry Ar period -.It set papretry Ar period +.It "set ccpretry|ccpretries" Ar "[timeout [reqtries [trmtries]]]" +.It "set chapretry|chapretries" Ar "[timeout [reqtries]]" +.It "set ipcpretry|ipcpretries" Ar "[timeout [reqtries [trmtries]]]" +.It "set lcpretry|lcpretries" Ar "[timeout [reqtries [trmtries]]]" +.It "set papretry|papretries" Ar "[timeout [reqtries]]" These commands set the number of seconds that .Nm will wait before resending Finite State Machine (FSM) Request packets. The default -.Ar period +.Ar timeout for all FSMs is 3 seconds (which should suffice in most cases). +.Pp +If +.Ar reqtries +is specified, it tells +.Nm +how many configuration request attempts it should make while receiving +no reply from the peer before giving up. The default is 5 attempts for +CCP, LCP and IPCP and 3 attempts for PAP and CHAP. +.Pp +If +.Ar trmtries +is specified, it tells +.Nm +how many terminate requests should be sent before giving up waiting for the +peers response. The default is 3 attempts. Authentication protocols are +not terminated and it is therefore invalid to specify +.Ar trmtries +for PAP or CHAP. +.Pp +In order to avoid netogiations with the peer that will never converge, +.Nm +will only send at most 3 times the configured number of +.Ar reqtries +in any given negotiation session before giving up and closing that layer. .It set log [local] [+|-] Ns Ar value... This command allows the adjustment of the current log level. Refer to the Logging Facility section for further details. |