diff -ruN ppp-2.4.2/pppd/options.c ppp-2.4.2-minunit/pppd/options.c --- ppp-2.4.2/pppd/options.c 2004-02-23 15:10:48.000000000 +0200 +++ ppp-2.4.2-minunit/pppd/options.c 2004-04-02 20:56:20.000000000 +0300 @@ -103,6 +103,7 @@ bool tune_kernel; /* may alter kernel settings */ int connect_delay = 1000; /* wait this many ms after connect script */ int req_unit = -1; /* requested interface unit */ +int req_minunit = -1; /* requested minimal interface unit */ bool multilink = 0; /* Enable multilink operation */ char *bundle_name = NULL; /* bundle name for multilink */ bool dump_options; /* print out option values */ @@ -260,6 +261,9 @@ { "unit", o_int, &req_unit, "PPP interface unit number to use if possible", OPT_PRIO | OPT_LLIMIT, 0, 0 }, + { "minunit", o_int, &req_minunit, + "PPP interface minimal unit number", + OPT_PRIO | OPT_LLIMIT, 0, 0 }, { "dump", o_bool, &dump_options, "Print out option values after parsing all options", 1 }, diff -ruN ppp-2.4.2/pppd/pppd.8 ppp-2.4.2-minunit/pppd/pppd.8 --- ppp-2.4.2/pppd/pppd.8 2004-02-23 15:10:48.000000000 +0200 +++ ppp-2.4.2-minunit/pppd/pppd.8 2004-04-02 20:54:41.000000000 +0300 @@ -1010,6 +1010,9 @@ Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound connections. .TP +.B minunit \fInum +Such as unit, but always select bigger interface +.TP .B updetach With this option, pppd will detach from its controlling terminal once it has successfully established the ppp connection (to the point where diff -ruN ppp-2.4.2/pppd/pppd.h ppp-2.4.2-minunit/pppd/pppd.h --- ppp-2.4.2/pppd/pppd.h 2003-04-15 12:53:44.000000000 +0300 +++ ppp-2.4.2-minunit/pppd/pppd.h 2004-04-02 20:55:41.000000000 +0300 @@ -80,6 +80,7 @@ #define MAXARGS 1 /* max # args to a command */ #define MAXNAMELEN 256 /* max length of hostname or name for auth */ #define MAXSECRETLEN 256 /* max length of password or secret */ +#define MAXUNIT 255 /* max ppp interface */ /* * Option descriptor structure. @@ -304,6 +305,7 @@ extern int connect_delay; /* Time to delay after connect script */ extern int max_data_rate; /* max bytes/sec through charshunt */ extern int req_unit; /* interface unit number to use */ +extern int req_minunit; /* interface minimal unit number to use */ extern bool multilink; /* enable multilink operation */ extern bool noendpoint; /* don't send or accept endpt. discrim. */ extern char *bundle_name; /* bundle name for multilink */ diff -ruN ppp-2.4.2/pppd/sys-linux.c ppp-2.4.2-minunit/pppd/sys-linux.c --- ppp-2.4.2/pppd/sys-linux.c 2004-02-23 15:10:49.000000000 +0200 +++ ppp-2.4.2-minunit/pppd/sys-linux.c 2004-04-02 21:07:01.000000000 +0300 @@ -638,13 +638,26 @@ || fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1) warn("Couldn't set /dev/ppp to nonblock: %m"); - ifunit = req_unit; - x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); - if (x < 0 && req_unit >= 0 && errno == EEXIST) { + if (req_minunit > -1) { + for(ifunit = req_minunit;req_minunit < MAXUNIT; ifunit = ++req_minunit) { + x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + if (x < 0 && errno == EEXIST) { + warn("Couldn't allocate PPP unit %d as it is already in use try to attempt next", req_minunit); + } + if (x >= 0) + break; + } + } + if ((x < 0) || (req_minunit == -1)) { + ifunit = req_unit; + x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + if (x < 0 && req_unit >= 0 && errno == EEXIST) { warn("Couldn't allocate PPP unit %d as it is already in use", req_unit); ifunit = -1; x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + } } + if (x < 0) error("Couldn't create new ppp unit: %m"); return x; --- ppp-2.4.2/pppd/pppd.8.orig 2006-07-22 23:34:00 +0600 +++ ppp-2.4.2/pppd/pppd.8 2006-07-22 23:42:34 +0600 @@ -1010,6 +1010,9 @@ Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound connections. .TP +.B minunit \fInum +PPP interface minimal unit number. Such as unit, but always select bigger interface +.TP .B updetach With this option, pppd will detach from its controlling terminal once it has successfully established the ppp connection (to the point where