o Don't limit our tun device number to 256. As long as there's

another /dev/ entry, keep trying to open them.
o Don't allow ``open ccp'' if lcp isn't open.
This commit is contained in:
Brian Somers 1998-04-27 01:40:38 +00:00
parent e43ebac1c2
commit 107d62e7ac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35471
2 changed files with 13 additions and 18 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.c,v 1.1.2.61 1998/04/24 19:15:57 brian Exp $
* $Id: bundle.c,v 1.1.2.62 1998/04/25 10:48:45 brian Exp $
*/
#include <sys/types.h>
@ -419,13 +419,6 @@ bundle_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
}
#define MAX_TUN 256
/*
* MAX_TUN is set at 256 because that is the largest minor number
* we can use (certainly with mknod(1) anyway). The search for a
* device aborts when it reaches the first `Device not configured'
* (ENXIO) or the third `No such file or directory' (ENOENT) error.
*/
struct bundle *
bundle_Create(const char *prefix, struct prompt *prompt, int type)
{
@ -440,24 +433,24 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
err = ENOENT;
enoentcount = 0;
for (bundle.unit = 0; bundle.unit <= MAX_TUN; bundle.unit++) {
for (bundle.unit = 0; ; bundle.unit++) {
snprintf(bundle.dev, sizeof bundle.dev, "%s%d", prefix, bundle.unit);
bundle.tun_fd = ID0open(bundle.dev, O_RDWR);
if (bundle.tun_fd >= 0)
break;
if (errno == ENXIO) {
bundle.unit = MAX_TUN;
else if (errno == ENXIO) {
err = errno;
break;
} else if (errno == ENOENT) {
if (++enoentcount > 2)
bundle.unit = MAX_TUN;
break;
} else
err = errno;
}
if (bundle.unit > MAX_TUN) {
prompt_Printf(prompt, "No tunnel device is available (%s).\n",
strerror(err));
if (bundle.tun_fd < 0) {
LogPrintf(LogWARN, "No available tunnel devices found (%s).\n",
strerror(err));
return NULL;
}

View File

@ -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.131.2.71 1998/04/24 19:15:59 brian Exp $
* $Id: command.c,v 1.131.2.72 1998/04/25 10:48:53 brian Exp $
*
*/
#include <sys/types.h>
@ -509,7 +509,7 @@ static int
ShowVersion(struct cmdargs const *arg)
{
static char VarVersion[] = "PPP Version 2.0-beta";
static char VarLocalVersion[] = "$Date: 1998/04/24 19:15:59 $";
static char VarLocalVersion[] = "$Date: 1998/04/25 10:48:53 $";
prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
return 0;
@ -805,7 +805,9 @@ OpenCommand(struct cmdargs const *arg)
!strcasecmp(arg->argv[arg->argn], "ccp")) {
struct fsm *fp = &ChooseLink(arg)->ccp.fsm;
if (fp->state != ST_OPENED) {
if (fp->link->lcp.fsm.state != ST_OPENED)
LogPrintf(LogWARN, "open: LCP must be open before opening CCP\n");
else if (fp->state != ST_OPENED) {
FsmUp(fp);
FsmOpen(fp);
}