From a43e859d63045b899215c742e3a6538c521d0f11 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Tue, 14 May 2002 00:59:28 +0000 Subject: [PATCH] Calculate the number of open links properly when deciding on whether to just send PROTO_IP packets when we've got only one link up in multi-link mode. Problem noted by: Adrian Close MFC after: 1 week --- usr.sbin/ppp/mp.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index bb26877029a..3e2ca1b5d53 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -668,12 +668,12 @@ mp_FillPhysicalQueues(struct bundle *bundle) struct mp *mp = &bundle->ncp.mp; struct datalink *dl, *fdl; size_t total, add, len; - int thislink, nlinks; + int thislink, nlinks, nopenlinks, sendasip; u_int32_t begin, end; struct mbuf *m, *mo; struct link *bestlink; - thislink = nlinks = 0; + thislink = nlinks = nopenlinks = 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) { @@ -683,6 +683,8 @@ mp_FillPhysicalQueues(struct bundle *bundle) thislink++; } nlinks++; + if (dl->state == DATALINK_OPEN) + nopenlinks++; } if (!fdl) { @@ -714,7 +716,6 @@ mp_FillPhysicalQueues(struct bundle *bundle) } if (!mp_QueueLen(mp)) { - struct datalink *other; int mrutoosmall; /* @@ -724,12 +725,10 @@ mp_FillPhysicalQueues(struct bundle *bundle) * in the outbound traffic going out as PROTO_IP or PROTO_IPV6 rather * than PROTO_MP. */ - for (other = dl->next; other; other = other->next) - if (other->state == DATALINK_OPEN) - break; mrutoosmall = 0; - if (!other) { + sendasip = nopenlinks < 2; + if (sendasip) { if (dl->physical->link.lcp.his_mru < mp->peer_mrru) { /* * Actually, forget it. This test is done against the MRRU rather @@ -738,20 +737,20 @@ mp_FillPhysicalQueues(struct bundle *bundle) * too likely to upset some ppp implementations. */ mrutoosmall = 1; - other = dl; + sendasip = 0; } } - bestlink = other ? &mp->link : &dl->physical->link; + bestlink = sendasip ? &dl->physical->link : &mp->link; if (!ncp_PushPacket(&bundle->ncp, &mp->out.af, bestlink)) break; /* Nothing else to send */ if (mrutoosmall) log_Printf(LogDEBUG, "Don't send data as PROTO_IP, MRU < MRRU\n"); - else if (!other) + else if (sendasip) log_Printf(LogDEBUG, "Sending data as PROTO_IP, not PROTO_MP\n"); - if (!other) { + if (sendasip) { add = link_QueueLen(&dl->physical->link); if (add) { /* this link has got stuff already queued. Let it continue */