X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=676839bf359ad52d6b2d8715fa60cdfa0cb27dc8;hb=df7501b15fe4ed7f6674acde69dd8f51c5e16b82;hp=532fb130fd82b0d5a123d2a0ce749094acfb3de3;hpb=0b3acd3a1122d542e2994d7791cc9127e91778f1;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 532fb13..676839b 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -415,7 +415,8 @@ int establish_ppp (int tty_fd) warn("Couldn't set /dev/ppp (channel) to nonblock: %m"); set_ppp_fd(fd); - ifunit = -1; + if (!looped) + ifunit = -1; if (!looped && !multilink) { /* * Create a new PPP unit. @@ -550,22 +551,16 @@ static int make_ppp_unit() } /* - * make_new_bundle - create a new PPP unit (i.e. a bundle) - * and connect our channel to it. This should only get called - * if `multilink' was set at the time establish_ppp was called. + * cfg_bundle - configure the existing bundle. + * Used in demand mode. */ -void make_new_bundle(int mrru, int mtru, int rssn, int tssn) +void cfg_bundle(int mrru, int mtru, int rssn, int tssn) { int flags; struct ifreq ifr; - if (looped || !new_style_driver) + if (!new_style_driver) return; - dbglog("make_new_bundle(%d,%d,%d,%d)", mrru, mtru, rssn, tssn); - - /* make us a ppp unit */ - if (make_ppp_unit() < 0) - die(1); /* set the mrru, mtu and flags */ if (ioctl(ppp_dev_fd, PPPIOCSMRRU, &mrru) < 0) @@ -591,8 +586,29 @@ void make_new_bundle(int mrru, int mtru, int rssn, int tssn) add_fd(ppp_dev_fd); } +/* + * make_new_bundle - create a new PPP unit (i.e. a bundle) + * and connect our channel to it. This should only get called + * if `multilink' was set at the time establish_ppp was called. + * In demand mode this uses our existing bundle instead of making + * a new one. + */ +void make_new_bundle(int mrru, int mtru, int rssn, int tssn) +{ + if (!new_style_driver) + return; + + /* make us a ppp unit */ + if (make_ppp_unit() < 0) + die(1); + + /* set the mrru, mtu and flags */ + cfg_bundle(mrru, mtru, rssn, tssn); +} + /* * bundle_attach - attach our link to a given PPP unit. + * We assume the unit is controlled by another pppd. */ int bundle_attach(int ifnum) { @@ -609,7 +625,6 @@ int bundle_attach(int ifnum) set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) | SC_MULTILINK); ifunit = ifnum; - dbglog("bundle_attach succeeded"); return 1; } @@ -1846,35 +1861,34 @@ int ppp_available(void) sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch); kernel_version = KVERSION(osmaj, osmin, ospatch); - if (kernel_version >= KVERSION(2,3,13)) { - fd = open("/dev/ppp", O_RDWR); + fd = open("/dev/ppp", O_RDWR); #if 0 - if (fd < 0 && errno == ENOENT) { - /* try making it and see if that helps. */ - if (mknod("/dev/ppp", S_IFCHR | S_IRUSR | S_IWUSR, - makedev(108, 0)) >= 0) { - fd = open("/dev/ppp", O_RDWR); - if (fd >= 0) - info("Created /dev/ppp device node"); - else - unlink("/dev/ppp"); /* didn't work, undo the mknod */ - } else if (errno == EEXIST) { - fd = open("/dev/ppp", O_RDWR); - } + if (fd < 0 && errno == ENOENT) { + /* try making it and see if that helps. */ + if (mknod("/dev/ppp", S_IFCHR | S_IRUSR | S_IWUSR, + makedev(108, 0)) >= 0) { + fd = open("/dev/ppp", O_RDWR); + if (fd >= 0) + info("Created /dev/ppp device node"); + else + unlink("/dev/ppp"); /* didn't work, undo the mknod */ + } else if (errno == EEXIST) { + fd = open("/dev/ppp", O_RDWR); } + } #endif /* 0 */ - if (fd >= 0) { - new_style_driver = 1; - - /* XXX should get from driver */ - driver_version = 2; - driver_modification = 4; - driver_patch = 0; - close(fd); - return 1; - } - return 0; + if (fd >= 0) { + new_style_driver = 1; + + /* XXX should get from driver */ + driver_version = 2; + driver_modification = 4; + driver_patch = 0; + close(fd); + return 1; } + if (kernel_version >= KVERSION(2,3,13)) + return 0; /* * Open a socket for doing the ioctl operations. @@ -2671,8 +2685,8 @@ sys_check_options(void) return 0; } if (multilink && !new_style_driver) { - option_error("multilink is not supported by the kernel driver"); - return 0; + warn("Warning: multilink is not supported by the kernel driver"); + multilink = 0; } return 1; }