o Make sure we adjust our min seq and process any outstanding queued

incoming fragments when a link goes down.
o Don't use the minimum sequence numbers of links that aren't open.
o Understand sequence number wrapping when determining the minimum
  sequence number.
o Add & adjust a few comments.
This commit is contained in:
Brian Somers 1998-05-23 17:05:28 +00:00
parent 12d68e37f9
commit 86b1f0d762
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36312
4 changed files with 46 additions and 12 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.c,v 1.1.2.89 1998/05/21 01:13:19 brian Exp $
* $Id: bundle.c,v 1.2 1998/05/21 21:44:08 brian Exp $
*/
#include <sys/types.h>
@ -336,7 +336,8 @@ bundle_LayerDown(void *v, struct fsm *fp)
/*
* The given FSM has been told to come down.
* If it's our last NCP, stop the idle timer.
* If it's an LCP and we're in multilink mode, adjust our tun speed.
* If it's an LCP and we're in multilink mode, adjust our tun
* speed and make sure our minimum sequence number is adjusted.
*/
struct bundle *bundle = (struct bundle *)v;
@ -345,14 +346,25 @@ bundle_LayerDown(void *v, struct fsm *fp)
bundle_StopIdleTimer(bundle);
else if (fp->proto == PROTO_LCP && bundle->ncp.mp.active) {
struct datalink *dl;
struct datalink *lost;
bundle->ifp.Speed = 0;
lost = NULL;
for (dl = bundle->links; dl; dl = dl->next)
if (fp != &dl->physical->link.lcp.fsm && dl->state == DATALINK_OPEN)
if (fp == &dl->physical->link.lcp.fsm)
lost = dl;
else if (dl->state == DATALINK_OPEN)
bundle->ifp.Speed += modem_Speed(dl->physical);
if (bundle->ifp.Speed)
/* Don't configure down to a speed of 0 */
tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru);
if (lost)
mp_LinkLost(&bundle->ncp.mp, lost);
else
log_Printf(LogERROR, "Oops, lost an unrecognised datalink (%s) !\n",
fp->link->name);
}
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: link.h,v 1.1.2.11 1998/04/24 19:15:26 brian Exp $
* $Id: link.h,v 1.2 1998/05/21 21:46:14 brian Exp $
*
*/
@ -39,7 +39,7 @@ struct prompt;
struct link {
int type; /* _LINK type */
const char *name; /* unique id per link type */
const char *name; /* Points to datalink::name */
int len; /* full size of parent struct */
struct pppThroughput throughput; /* Link throughput statistics */
struct mqueue Queue[LINK_QUEUES]; /* Our output queue of mbufs */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp.c,v 1.2 1998/05/21 21:47:05 brian Exp $
* $Id: mp.c,v 1.3 1998/05/23 13:38:09 brian Exp $
*/
#include <sys/types.h>
@ -323,13 +323,23 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
struct mbuf *q, *last;
int32_t seq;
if (mp_ReadHeader(mp, m, &mh) == 0) {
/*
* When `m' and `p' are NULL, it means our oldest link has gone down.
* We want to determine a new min, and process any intermediate stuff
* as normal
*/
if (m && mp_ReadHeader(mp, m, &mh) == 0) {
mbuf_Free(m);
return;
}
seq = p->dl->mp.seq;
p->dl->mp.seq = mh.seq;
if (p) {
seq = p->dl->mp.seq;
p->dl->mp.seq = mh.seq;
} else
seq = mp->seq.min_in;
if (mp->seq.min_in == seq) {
/*
* We've received new data on the link that has our min (oldest) seq.
@ -337,9 +347,11 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
*/
struct datalink *dl;
mp->seq.min_in = p->dl->mp.seq;
mp->seq.min_in = (u_int32_t)-1;
for (dl = mp->bundle->links; dl; dl = dl->next)
if (mp->seq.min_in > dl->mp.seq)
if (dl->state == DATALINK_OPEN &&
(mp->seq.min_in == -1 ||
isbefore(mp->local_is12bit, dl->mp.seq, mp->seq.min_in)))
mp->seq.min_in = dl->mp.seq;
}
@ -544,6 +556,7 @@ mp_FillQueues(struct bundle *bundle)
thislink = nlinks = 0;
for (fdl = NULL, dl = bundle->links; dl; dl = dl->next) {
/* Include non-open links here as mp->out.link will stay more correct */
if (!fdl) {
if (thislink == mp->out.link)
fdl = dl;
@ -991,3 +1004,11 @@ mpserver_Close(struct mpserver *s)
s->fd = -1;
}
}
void
mp_LinkLost(struct mp *mp, struct datalink *dl)
{
if (mp->seq.min_in == dl->mp.seq)
/* We've lost the link that's holding everything up ! */
mp_Input(mp, NULL, NULL);
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp.h,v 1.1.2.12 1998/05/03 22:13:13 brian Exp $
* $Id: mp.h,v 1.2 1998/05/21 21:47:08 brian Exp $
*/
struct mbuf;
@ -132,3 +132,4 @@ extern int mp_SetDatalinkWeight(struct cmdargs const *);
extern int mp_ShowStatus(struct cmdargs const *);
extern const char *mp_Enddisc(u_char, const char *, int);
extern int mp_SetEnddisc(struct cmdargs const *);
extern void mp_LinkLost(struct mp *, struct datalink *);