From 0bcf5992cb3b49b34376c74e53a6d189018cfb44 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 16 Mar 1999 04:00:53 +0000 Subject: [PATCH] don't call np_down unless np_up has been called --- pppd/ipcp.c | 9 +++++++-- pppd/ipxcp.c | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 6aeb3ab..813bdf3 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: ipcp.c,v 1.39 1999/03/16 03:12:03 paulus Exp $"; +static char rcsid[] = "$Id: ipcp.c,v 1.40 1999/03/16 04:00:53 paulus Exp $"; #endif /* @@ -52,6 +52,7 @@ static int cis_received[NUM_PPP]; /* # Conf-Reqs received */ static int default_route_set[NUM_PPP]; /* Have set up a default route */ static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ static bool usepeerdns; /* Ask peer for DNS addrs */ +static int ipcp_is_up; /* have called np_up() */ /* * Callbacks for fsm code. (CI = Configuration Information) @@ -1497,6 +1498,7 @@ ipcp_up(f) } np_up(f->unit, PPP_IP); + ipcp_is_up = 1; /* * Execute the ip-up script, like this: @@ -1520,7 +1522,10 @@ ipcp_down(f) fsm *f; { IPCPDEBUG(("ipcp: down")); - np_down(f->unit, PPP_IP); + if (ipcp_is_up) { + ipcp_is_up = 0; + np_down(f->unit, PPP_IP); + } sifvjcomp(f->unit, 0, 0, 0); /* diff --git a/pppd/ipxcp.c b/pppd/ipxcp.c index 47d7af7..49e20b4 100644 --- a/pppd/ipxcp.c +++ b/pppd/ipxcp.c @@ -19,7 +19,7 @@ #ifdef IPX_CHANGE #ifndef lint -static char rcsid[] = "$Id: ipxcp.c,v 1.10 1999/03/16 03:15:15 paulus Exp $"; +static char rcsid[] = "$Id: ipxcp.c,v 1.11 1999/03/16 04:00:53 paulus Exp $"; #endif /* @@ -63,6 +63,7 @@ static int ipxcp_rejci __P((fsm *, u_char *, int)); /* Peer rej'd our CI */ static int ipxcp_reqci __P((fsm *, u_char *, int *, int)); /* Rcv CI */ static void ipxcp_up __P((fsm *)); /* We're UP */ static void ipxcp_down __P((fsm *)); /* We're DOWN */ +static void ipxcp_finished __P((fsm *)); /* Don't need lower layer */ static void ipxcp_script __P((fsm *, char *)); /* Run an up/down script */ fsm ipxcp_fsm[NUM_PPP]; /* IPXCP fsm structure */ @@ -78,7 +79,7 @@ static fsm_callbacks ipxcp_callbacks = { /* IPXCP callback routines */ ipxcp_up, /* Called when fsm reaches OPENED state */ ipxcp_down, /* Called when fsm leaves OPENED state */ NULL, /* Called when we want the lower layer up */ - NULL, /* Called when we want the lower layer down */ + ipxcp_finished, /* Called when we want the lower layer down */ NULL, /* Called when Protocol-Reject received */ NULL, /* Retransmission is necessary */ NULL, /* Called to handle protocol-specific codes */ @@ -177,6 +178,8 @@ struct protent ipxcp_protent = { #define CODENAME(x) ((x) == CONFACK ? "ACK" : \ (x) == CONFNAK ? "NAK" : "REJ") +static int ipxcp_is_up; + /* Used in printing the node number */ #define NODE(base) base[0], base[1], base[2], base[3], base[4], base[5] @@ -1272,6 +1275,9 @@ ipxcp_up(f) return; } + ipxcp_is_up = 1; + np_up(f->unit, PPP_IPX); + /* * Execute the ipx-up script, like this: * /etc/ppp/ipx-up interface tty speed local-IPX remote-IPX @@ -1293,12 +1299,27 @@ ipxcp_down(f) { IPXCPDEBUG(("ipxcp: down")); + if (ipxcp_is_up) { + ipxcp_is_up = 0; + np_down(f->unit, PPP_IPX); + } cipxfaddr (f->unit); sifdown(f->unit); ipxcp_script (f, _PATH_IPXDOWN); } +/* + * ipxcp_finished - possibly shut down the lower layers. + */ +static void +ipxcp_finished(f) + fsm *f; +{ + np_finished(f->unit, PPP_IPX); +} + + /* * ipxcp_script - Execute a script with arguments * interface-name tty-name speed local-IPX remote-IPX networks. -- 2.39.2