Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 1998 02:07:22 +0900 (JST)
From:      Iwasa Kazmi <kzmi@ca2.so-net.ne.jp>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/6835: ppp -background tries dialing forever
Message-ID:  <199806021707.CAA17241@kzmi.ca2.so-net.ne.jp>

next in thread | raw e-mail | index | archive | help

>Number:         6835
>Category:       bin
>Synopsis:       ppp -background tries connect to non-active modem forever
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun  2 10:20:00 PDT 1998
>Last-Modified:
>Originator:     Iwasa Kazmi
>Organization:
>Release:        FreeBSD 2.2.6-STABLE i386
>Environment:
use /usr/sbin/ppp
modem = cuaa0

>Description:
When modem's turned off and ppp's invoked with -background option, ppp falls in the loop OpenModem->DialModem->OpenModem->DialModem...

If ppp tries OpenModem, it success to open.
(ppp loged "Connected!" and "Dial attempt 1 of 1")
If ppp tries DialModem, it will abort by timeout.
Then ppp tries next phone number. However, primary phone number is still available. So, ppp tries to dial primariy phone number continuously.

>How-To-Repeat:


>Fix:

solution example:
If modem was turned off, chat for dial script would fail by timeout.
So, in only case that dial script failed by timeout, ppp gives up to try next phone number. (assume as caught SIGINT)
	
In ppp/chat.c,

 #define MATCH   1
 #define NOMATCH 0
 #define ABORT   -1
 #define TIMEOUT -2   <-- new return value

In function WaitforString,

    } else if (i == 0) {        /* Timeout reached! */
      *inp = 0;
      if (inp != inbuff)
        LogPrintf(LogCHAT, "Got: %s\n", inbuff);
      LogPrintf(LogCHAT, "Can't get (%d).\n", timeout.tv_sec);
 #ifdef SIGALRM
      sigsetmask(omask);
 #endif
      return (TIMEOUT);    <-- return TIMEOUT instead of NOMATCH
    }

In function DoChat,

    state = ExpectString(*argv++);
    switch (state) {
    case MATCH:
      if (*argv)
        SendString(*argv++);
      break;
    case TIMEOUT:              <--
      signal(SIGINT, oint);    <--
      return (TIMEOUT);        <-- new return value
    case ABORT:
    case NOMATCH:
      signal(SIGINT, oint);
      return (NOMATCH);
    }

In ppp/modem.c, function DialModem,

  if ((excode = DoChat(ScriptBuffer)) > 0) {
    .....
    if ((excode = DoChat(ScriptBuffer)) > 0) {
      .....
    } else if (excode == -1)
      excode = EX_SIG;
    else {

!!!    if login script was failed by TIMEOUT, here (not need changes)

      LogPrintf(LogWARN, "DialModem: login failed.\n");
      excode = EX_NOLOGIN;
    }
    .....
  } else if (excode == -1)
    excode = EX_SIG;
  else if (excode == -2)        <-- if TIMEOUT was returned ...
    excode = EX_SIG;            <-- ( another value is better ? )
  else {
    LogPrintf(LogWARN, "DialModem: dial failed.\n");
    excode = EX_NODIAL;
  }


In ppp/main.c, function DoLoop,

    /*
     * If Ip packet for output is enqueued and require dial up, Just do it!
     */
    if (dial_up && RedialTimer.state != TIMER_RUNNING) {
      .....
      if (OpenModem() < 0) {
        .....
      } else {
        .....
        if ((res = DialModem()) == EX_DONE) {
          .....
        } else {
          if (mode & MODE_BACKGROUND) {
            if (VarNextPhone == NULL || res == EX_SIG)

!!!             DialModem()  --> DoChat()
!!!             when DoChat() returns TIMEOUT, DialModem() returns EX_SIG

              Cleanup(EX_DIAL); /* Tried all numbers - no luck */
            else
              /* Try all numbers in background mode */
              StartRedialTimer(VarRedialNextTimeout);
          } else if (!(mode & MODE_DDIAL) &&
            .....
          } else if (VarNextPhone == NULL)
            .....
          else
            .....
        }
      }
    }

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806021707.CAA17241>