summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_ppp.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1999-11-01 19:44:28 +0000
committerarchie <archie@FreeBSD.org>1999-11-01 19:44:28 +0000
commit4ede940c7518cfffdceb290b1d430a57d83fdc5f (patch)
tree5c8f132ea946cfc5cf1905615c6dc08392a3309b /sys/netgraph/ng_ppp.c
parent6fc7a68ebf1afb65275fbeca97f2d652d882667d (diff)
downloadFreeBSD-src-4ede940c7518cfffdceb290b1d430a57d83fdc5f.zip
FreeBSD-src-4ede940c7518cfffdceb290b1d430a57d83fdc5f.tar.gz
Fix some bugs in MP allocation routine when links are non-equivalent.
Diffstat (limited to 'sys/netgraph/ng_ppp.c')
-rw-r--r--sys/netgraph/ng_ppp.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index d24c496..46ce2aa 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -728,12 +728,16 @@ ng_ppp_output(node_p node, int linkNum, struct mbuf *m, meta_p meta)
return (ENETDOWN);
}
- /* Update stats XXX even if error? */
- priv->linkStats[linkNum].xmitFrames++;
- priv->linkStats[linkNum].xmitOctets += m->m_pkthdr.len;
-
/* Deliver frame */
NG_SEND_DATA(error, priv->links[linkNum], m, meta);
+
+ /* Update stats and 'bytes in queue' counter */
+ if (error == 0) {
+ priv->linkStats[linkNum].xmitFrames++;
+ priv->linkStats[linkNum].xmitOctets += m->m_pkthdr.len;
+ priv->qstat[linkNum].bytesInQueue += m->m_pkthdr.len;
+ microtime(&priv->qstat[linkNum].lastWrite);
+ }
return error;
}
@@ -1155,7 +1159,7 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib)
}
/* Get current time */
- getmicrotime(&now);
+ microtime(&now);
/* Compute latencies for each link at this point in time */
for (activeLinkNum = 0;
@@ -1236,10 +1240,11 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib)
total += distrib[sortByLatency[i]];
}
- /* Deal with any rounding error by adjusting fastest link */
- if (total != len) {
+ /* Deal with any rounding error */
+ if (total < len) {
int fast = 0;
+ /* Find the fastest link */
for (i = 1; i < numFragments; i++) {
if (priv->conf.links[
priv->activeLinks[sortByLatency[i]]].bandwidth >
@@ -1248,12 +1253,24 @@ ng_ppp_mp_strategy(node_p node, int len, int *distrib)
fast = i;
}
distrib[sortByLatency[fast]] += len - total;
- }
+ } else while (total > len) {
+ int delta, slow = 0;
- /* Update bytes in queue counters */
- for (i = 0; i < priv->numActiveLinks; i++) {
- priv->qstat[i].bytesInQueue += distrib[i];
- priv->qstat[i].lastWrite = now;
+ /* Find the slowest link that still has bytes to remove */
+ for (i = 1; i < numFragments; i++) {
+ if (distrib[sortByLatency[slow]] == 0
+ || (distrib[sortByLatency[i]] > 0
+ && priv->conf.links[priv->activeLinks[
+ sortByLatency[i]]].bandwidth <
+ priv->conf.links[priv->activeLinks[
+ sortByLatency[slow]]].bandwidth))
+ slow = i;
+ }
+ delta = total - len;
+ if (delta > distrib[sortByLatency[slow]])
+ delta = distrib[sortByLatency[slow]];
+ distrib[sortByLatency[slow]] -= delta;
+ total -= delta;
}
}
OpenPOWER on IntegriCloud