summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/mp.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-08-05 10:32:16 +0000
committerbrian <brian@FreeBSD.org>1999-08-05 10:32:16 +0000
commit75000c38838f6ae4afe9de4dd06bd3fde6120e1b (patch)
tree26404e4742c87264dac32602be9ec171a2100df1 /usr.sbin/ppp/mp.c
parentc32597f76112e043f5178c1c2237ad6d753da072 (diff)
downloadFreeBSD-src-75000c38838f6ae4afe9de4dd06bd3fde6120e1b.zip
FreeBSD-src-75000c38838f6ae4afe9de4dd06bd3fde6120e1b.tar.gz
o Obsolete the undocumented ``set weight'' command.
o If we're using RADIUS and the RADIUS mtu is less than our peers mru/mrru, reduce our mtu to this value for NetBSD too. o Make struct throughput's sample period dynamic and tweak the ppp version number to reflect the extra stuff being passed through the local domain socket as a result (MP mode). o Measure the current throughput based on the number of samples actually taken rather than on the full sample period. o Keep the throughput statisics persistent while being passed to another ppp invocation through the local domain socket. o When showing throughput statistics after the timer has stopped, use the stopped time for overall calculations, not the current time. Also show the stopped time and how long the current throughput has been sampled for. o Use time() consistently in throughput.c o Tighten up the ``show bundle'' output. o Introduce the ``set bandwidth'' command. o Rewrite the ``set autoload'' command. It now takes three arguments and works based on a rolling bundle throughput average compared against the theoretical bundle bandwidth over a given period (read: it's now functional).
Diffstat (limited to 'usr.sbin/ppp/mp.c')
-rw-r--r--usr.sbin/ppp/mp.c92
1 files changed, 75 insertions, 17 deletions
diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c
index d7a8485..e8920ce 100644
--- a/usr.sbin/ppp/mp.c
+++ b/usr.sbin/ppp/mp.c
@@ -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.24 1999/06/03 13:29:32 brian Exp $
+ * $Id: mp.c,v 1.25 1999/06/09 16:54:03 brian Exp $
*/
#include <sys/param.h>
@@ -183,6 +183,52 @@ mp_LayerFinish(void *v, struct fsm *fp)
fsm_Open(fp); /* CCP goes to ST_STOPPED */
}
+static void
+mp_UpDown(void *v)
+{
+ struct mp *mp = (struct mp *)v;
+ int percent;
+
+ percent = mp->link.throughput.OctetsPerSecond * 800 / mp->bundle->bandwidth;
+ if (percent >= mp->cfg.autoload.max) {
+ log_Printf(LogDEBUG, "%d%% saturation - bring a link up ?\n", percent);
+ bundle_AutoAdjust(mp->bundle, percent, AUTO_UP);
+ } else if (percent <= mp->cfg.autoload.min) {
+ log_Printf(LogDEBUG, "%d%% saturation - bring a link down ?\n", percent);
+ bundle_AutoAdjust(mp->bundle, percent, AUTO_DOWN);
+ }
+}
+
+void
+mp_StopAutoloadTimer(struct mp *mp)
+{
+ throughput_stop(&mp->link.throughput);
+}
+
+void
+mp_CheckAutoloadTimer(struct mp *mp)
+{
+ if (mp->link.throughput.SamplePeriod != mp->cfg.autoload.period) {
+ throughput_destroy(&mp->link.throughput);
+ throughput_init(&mp->link.throughput, mp->cfg.autoload.period);
+ throughput_callback(&mp->link.throughput, mp_UpDown, mp);
+ }
+
+ if (bundle_WantAutoloadTimer(mp->bundle))
+ throughput_start(&mp->link.throughput, "MP throughput", 1);
+ else
+ mp_StopAutoloadTimer(mp);
+}
+
+void
+mp_RestartAutoloadTimer(struct mp *mp)
+{
+ if (mp->link.throughput.SamplePeriod != mp->cfg.autoload.period)
+ mp_CheckAutoloadTimer(mp);
+ else
+ throughput_clear(&mp->link.throughput, THROUGHPUT_OVERALL, NULL);
+}
+
void
mp_Init(struct mp *mp, struct bundle *bundle)
{
@@ -202,7 +248,10 @@ mp_Init(struct mp *mp, struct bundle *bundle)
mp->link.name = "mp";
mp->link.len = sizeof *mp;
- throughput_init(&mp->link.throughput);
+ mp->cfg.autoload.period = SAMPLE_PERIOD;
+ mp->cfg.autoload.min = mp->cfg.autoload.max = 0;
+ throughput_init(&mp->link.throughput, mp->cfg.autoload.period);
+ throughput_callback(&mp->link.throughput, mp_UpDown, mp);
memset(mp->link.Queue, '\0', sizeof mp->link.Queue);
memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in);
memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out);
@@ -263,7 +312,9 @@ mp_Up(struct mp *mp, struct datalink *dl)
mp->peer_is12bit = lcp->his_shortseq;
mp->peer = dl->peer;
- throughput_init(&mp->link.throughput);
+ throughput_destroy(&mp->link.throughput);
+ throughput_init(&mp->link.throughput, mp->cfg.autoload.period);
+ throughput_callback(&mp->link.throughput, mp_UpDown, mp);
memset(mp->link.Queue, '\0', sizeof mp->link.Queue);
memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in);
memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out);
@@ -312,6 +363,9 @@ mp_Down(struct mp *mp)
if (mp->active) {
struct mbuf *next;
+ /* Stop that ! */
+ mp_StopAutoloadTimer(mp);
+
/* Don't want any more of these */
mpserver_Close(&mp->server);
@@ -334,7 +388,7 @@ void
mp_linkInit(struct mp_link *mplink)
{
mplink->seq = 0;
- mplink->weight = 1500;
+ mplink->bandwidth = 0;
}
static void
@@ -636,17 +690,14 @@ mp_FillQueues(struct bundle *bundle)
while (!end) {
if (dl->state == DATALINK_OPEN) {
- if (len <= dl->mp.weight + LINK_MINWEIGHT) {
- /*
- * XXX: Should we remember how much of our `weight' wasn't sent
- * so that we can compensate next time ?
- */
+ /* Write at most his_mru bytes to the physical link */
+ if (len <= dl->physical->link.lcp.his_mru) {
mo = m;
end = 1;
mbuf_SetType(mo, MB_MPOUT);
} else {
- mo = mbuf_Alloc(dl->mp.weight, MB_MPOUT);
- mo->cnt = dl->mp.weight;
+ /* It's > his_mru, chop the packet (`m') into bits */
+ mo = mbuf_Alloc(dl->physical->link.lcp.his_mru, MB_MPOUT);
len -= mo->cnt;
m = mbuf_Read(m, MBUF_CTOP(mo), mo->cnt);
}
@@ -671,7 +722,7 @@ mp_FillQueues(struct bundle *bundle)
}
int
-mp_SetDatalinkWeight(struct cmdargs const *arg)
+mp_SetDatalinkBandwidth(struct cmdargs const *arg)
{
int val;
@@ -679,12 +730,15 @@ mp_SetDatalinkWeight(struct cmdargs const *arg)
return -1;
val = atoi(arg->argv[arg->argn]);
- if (val < LINK_MINWEIGHT) {
- log_Printf(LogWARN, "Link weights must not be less than %d\n",
- LINK_MINWEIGHT);
+ if (val <= 0) {
+ log_Printf(LogWARN, "The link bandwidth must be greater than zero\n");
return 1;
}
- arg->cx->mp.weight = val;
+ arg->cx->mp.bandwidth = val;
+
+ if (arg->cx->state == DATALINK_OPEN)
+ bundle_CalculateBandwidth(arg->bundle);
+
return 0;
}
@@ -723,6 +777,7 @@ mp_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "\nMy Side:\n");
if (mp->active) {
+ prompt_Printf(arg->prompt, " Output SEQ: %u\n", mp->out.seq);
prompt_Printf(arg->prompt, " MRRU: %u\n", mp->local_mrru);
prompt_Printf(arg->prompt, " Short Seq: %s\n",
mp->local_is12bit ? "on" : "off");
@@ -734,7 +789,7 @@ mp_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "\nHis Side:\n");
if (mp->active) {
prompt_Printf(arg->prompt, " Auth Name: %s\n", mp->peer.authname);
- prompt_Printf(arg->prompt, " Next SEQ: %u\n", mp->out.seq);
+ prompt_Printf(arg->prompt, " Input SEQ: %u\n", mp->seq.next_in);
prompt_Printf(arg->prompt, " MRRU: %u\n", mp->peer_mrru);
prompt_Printf(arg->prompt, " Short Seq: %s\n",
mp->peer_is12bit ? "on" : "off");
@@ -754,6 +809,9 @@ mp_ShowStatus(struct cmdargs const *arg)
command_ShowNegval(mp->cfg.shortseq));
prompt_Printf(arg->prompt, " Discriminator: %s\n",
command_ShowNegval(mp->cfg.negenddisc));
+ prompt_Printf(arg->prompt, " AutoLoad: min %d%%, max %d%%,"
+ " period %d secs\n", mp->cfg.autoload.min,
+ mp->cfg.autoload.max, mp->cfg.autoload.period);
return 0;
}
OpenPOWER on IntegriCloud