From: Paul Mackerras Date: Sat, 2 Mar 2013 09:25:28 +0000 (+1100) Subject: pppd: Add master_detach option X-Git-Tag: ppp-2.4.7~24 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=398ed2585640d198c53e736ee5bbd67f7ce8168e pppd: Add master_detach option This adds a new option, master_detach, to allow pppd to detach from the controlling terminal when it is the multilink bundle master but its own link has terminated, even if the nodetach option has been given. Requested-by: Stephen Marron Signed-off-by: Paul Mackerras --- diff --git a/pppd/auth.c b/pppd/auth.c index 7b269b8..2f81283 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -665,9 +665,11 @@ link_terminated(unit) (*the_channel->cleanup)(); if (doing_multilink && multilink_master) { - if (!bundle_terminating) + if (!bundle_terminating) { new_phase(PHASE_MASTER); - else + if (master_detach && !detached) + detach(); + } else mp_bundle_terminated(); } else new_phase(PHASE_DEAD); diff --git a/pppd/options.c b/pppd/options.c index 008b482..45fa742 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -96,6 +96,7 @@ int default_device = 1; /* Using /dev/tty or equivalent */ char devnam[MAXPATHLEN]; /* Device name */ bool nodetach = 0; /* Don't detach from controlling tty */ bool updetach = 0; /* Detach once link is up */ +bool master_detach; /* Detach when we're (only) multilink master */ int maxconnect = 0; /* Maximum connect time */ char user[MAXNAMELEN]; /* Username for PAP */ char passwd[MAXSECRETLEN]; /* Password for PAP */ @@ -210,6 +211,9 @@ option_t general_options[] = { "Detach from controlling tty once link is up", OPT_PRIOSUB | OPT_A2CLR | 1, &nodetach }, + { "master_detach", o_bool, &master_detach, + "Detach when we're multilink master but have no link", 1 }, + { "holdoff", o_int, &holdoff, "Set time in seconds before retrying connection", OPT_PRIO, &holdoff_specified }, diff --git a/pppd/pppd.8 b/pppd/pppd.8 index 77be980..f7954fa 100644 --- a/pppd/pppd.8 +++ b/pppd/pppd.8 @@ -624,6 +624,14 @@ must have an entry in the /etc/ppp/pap\-secrets file as well as the system password database to be allowed access. See also the \fBenable\-session\fR option. .TP +.B master_detach +If multilink is enabled and this pppd process is the multilink bundle +master, and the link controlled by this pppd process terminates, this +pppd process continues to run in order to maintain the bundle. If the +\fBmaster_detach\fR option has been given, pppd will detach from its +controlling terminal in this situation, even if the \fBnodetach\fR +option has been given. +.TP .B maxconnect \fIn Terminate the connection when it has been available for network traffic for \fIn\fR seconds (i.e. \fIn\fR seconds after the first diff --git a/pppd/pppd.h b/pppd/pppd.h index 1f20889..47e4d9a 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -285,6 +285,7 @@ extern u_int32_t netmask; /* IP netmask to set on interface */ extern bool lockflag; /* Create lock file to lock the serial dev */ extern bool nodetach; /* Don't detach from controlling tty */ extern bool updetach; /* Detach from controlling tty when link up */ +extern bool master_detach; /* Detach when multilink master without link */ extern char *initializer; /* Script to initialize physical link */ extern char *connect_script; /* Script to establish physical link */ extern char *disconnect_script; /* Script to disestablish physical link */