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.
}
/*
- * 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)
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)
{
set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) | SC_MULTILINK);
ifunit = ifnum;
- dbglog("bundle_attach succeeded");
return 1;
}
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.
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;
}