* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: bundle.c,v 1.34 2000/04/02 01:36:24 brian Exp $
+ * $OpenBSD: bundle.c,v 1.35 2000/04/06 10:09:57 brian Exp $
*/
#include <sys/param.h>
* If it's our last NCP, stop the autoload timer
* If it's an LCP, adjust our phys_type.open value and any timers.
* If it's an LCP and we're in multilink mode, adjust our tun
+ * If it's the last LCP, down all NCPs
* speed and make sure our minimum sequence number is adjusted.
*/
bundle->upat = 0;
mp_StopAutoloadTimer(&bundle->ncp.mp);
} else if (fp->proto == PROTO_LCP) {
+ struct datalink *dl;
+ struct datalink *lost;
+ int others_active;
+
bundle_LinksRemoved(bundle); /* adjust timers & phys_type values */
- if (bundle->ncp.mp.active) {
- struct datalink *dl;
- struct datalink *lost;
- lost = NULL;
- for (dl = bundle->links; dl; dl = dl->next)
- if (fp == &dl->physical->link.lcp.fsm)
- lost = dl;
+ lost = NULL;
+ others_active = 0;
+ for (dl = bundle->links; dl; dl = dl->next) {
+ if (fp == &dl->physical->link.lcp.fsm)
+ lost = dl;
+ else if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP)
+ others_active++;
+ }
+ if (bundle->ncp.mp.active) {
bundle_CalculateBandwidth(bundle);
if (lost)
log_Printf(LogALERT, "Oops, lost an unrecognised datalink (%s) !\n",
fp->link->name);
}
+
+ if (!others_active)
+ /* Down the NCPs. We don't expect to get fsm_Close()d ourself ! */
+ fsm2initial(&bundle->ncp.ipcp.fsm);
}
}
if (bundle_Phase(bundle) != PHASE_DEAD)
bundle_NewPhase(bundle, PHASE_TERMINATE);
for (dl = bundle->links; dl; dl = dl->next)
- datalink_Close(dl, CLOSE_STAYDOWN);
+ if (dl->state == DATALINK_OPEN)
+ datalink_Close(dl, CLOSE_STAYDOWN);
fsm2initial(fp);
}
- /*
- * If it's an LCP, don't try to murder any NCPs, let bundle_LinkClosed()
- * do that side of things (at a time when a call to fsm2initial() on the
- * NCP isn't going to take charge of bringing down this link).
- */
}
int