diff options
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/bundle.c | 26 | ||||
-rw-r--r-- | usr.sbin/ppp/ccp.c | 32 | ||||
-rw-r--r-- | usr.sbin/ppp/ccp.h | 2 | ||||
-rw-r--r-- | usr.sbin/ppp/datalink.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/deflate.c | 2 | ||||
-rw-r--r-- | usr.sbin/ppp/mp.c | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/mppe.c | 1 | ||||
-rw-r--r-- | usr.sbin/ppp/pred.c | 1 |
8 files changed, 67 insertions, 7 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 7e484991816b..ba1eca594b13 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -276,7 +276,8 @@ bundle_LayerUp(void *v, struct fsm *fp) bundle_StartIdleTimer(bundle, 0); bundle_Notify(bundle, EX_NORMAL); mp_CheckAutoloadTimer(&fp->bundle->ncp.mp); - } + } else if (fp->proto == PROTO_CCP) + bundle_CalculateBandwidth(fp->bundle); /* Against ccp_MTUOverhead */ } static void @@ -1816,11 +1817,16 @@ void bundle_CalculateBandwidth(struct bundle *bundle) { struct datalink *dl; - int sp; + int sp, overhead, maxoverhead; bundle->bandwidth = 0; bundle->iface->mtu = 0; - for (dl = bundle->links; dl; dl = dl->next) + maxoverhead = 0; + + for (dl = bundle->links; dl; dl = dl->next) { + overhead = ccp_MTUOverhead(&dl->physical->link.ccp); + if (maxoverhead < overhead) + maxoverhead = overhead; if (dl->state == DATALINK_OPEN) { if ((sp = dl->mp.bandwidth) == 0 && (sp = physical_GetSpeed(dl->physical)) == 0) @@ -1833,13 +1839,17 @@ bundle_CalculateBandwidth(struct bundle *bundle) break; } } + } if(bundle->bandwidth == 0) bundle->bandwidth = 115200; /* Shrug */ - if (bundle->ncp.mp.active) + if (bundle->ncp.mp.active) { bundle->iface->mtu = bundle->ncp.mp.peer_mrru; - else if (!bundle->iface->mtu) + overhead = ccp_MTUOverhead(&bundle->ncp.mp.link.ccp); + if (maxoverhead < overhead) + maxoverhead = overhead; + } else if (!bundle->iface->mtu) bundle->iface->mtu = DEF_MRU; #ifndef NORADIUS @@ -1851,6 +1861,12 @@ bundle_CalculateBandwidth(struct bundle *bundle) } #endif + if (maxoverhead) { + log_Printf(LogLCP, "Reducing MTU from %d to %d (CCP requirement)\n", + bundle->iface->mtu, bundle->iface->mtu - maxoverhead); + bundle->iface->mtu -= maxoverhead; + } + tun_configure(bundle); route_UpdateMTU(bundle); diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index e8f0a411cbe8..b3a80f89c213 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -299,6 +299,19 @@ ccp_Required(struct ccp *ccp) return 0; } +/* + * Report whether it's possible to increase a packet's size after + * compression (and by how much). + */ +int +ccp_MTUOverhead(struct ccp *ccp) +{ + if (ccp->fsm.state == ST_OPENED) + return algorithm[ccp->out.algorithm]->o.MTUOverhead; + + return 0; +} + static void CcpInitRestartCounter(struct fsm *fp, int what) { @@ -474,7 +487,24 @@ CcpLayerUp(struct fsm *fp) /* We're now up */ struct ccp *ccp = fsm2ccp(fp); struct ccp_opt **o; - int f; + int f, fail; + + for (f = fail = 0; f < NALGORITHMS; f++) + if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) && + (*algorithm[f]->Required)(&ccp->fsm) && + (ccp->in.algorithm != f || ccp->out.algorithm != f)) { + /* Blow it all away - we haven't negotiated a required algorithm */ + log_Printf(LogWARN, "%s: Failed to negotiate (required) %s\n", + fp->link->name, protoname(algorithm[f]->id)); + fail = 1; + } + + if (fail) { + ccp->his_proto = ccp->my_proto = -1; + fsm_Close(fp); + fsm_Close(&fp->link->lcp.fsm); + return 0; + } log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name); diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index e604e22ccd3b..bb4f08bac588 100644 --- a/usr.sbin/ppp/ccp.h +++ b/usr.sbin/ppp/ccp.h @@ -135,6 +135,7 @@ struct ccp_algorithm { void (*DictSetup)(void *, struct ccp *, u_short, struct mbuf *); } i; struct { + int MTUOverhead; void (*OptInit)(struct lcp_opt *, const struct ccp_config *); int (*Set)(struct lcp_opt *, const struct ccp_config *); void *(*Init)(struct lcp_opt *); @@ -149,6 +150,7 @@ extern void ccp_Init(struct ccp *, struct bundle *, struct link *, const struct fsm_parent *); extern void ccp_Setup(struct ccp *); extern int ccp_Required(struct ccp *); +extern int ccp_MTUOverhead(struct ccp *); extern void ccp_SendResetReq(struct fsm *); extern struct mbuf *ccp_Input(struct bundle *, struct link *, struct mbuf *); diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index 5f8544f387be..71616cc1aa4b 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -570,7 +570,8 @@ datalink_LayerUp(void *v, struct fsm *fp) auth_StartReq(&dl->chap.auth); } else datalink_AuthOk(dl); - } + } else if (fp->proto == PROTO_CCP) + (*dl->parent->LayerUp)(dl->parent->object, &dl->physical->link.ccp.fsm); } static void diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index 340d048641dc..ef04c270bcdd 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -567,6 +567,7 @@ const struct ccp_algorithm PppdDeflateAlgorithm = { DeflateDictSetup }, { + 0, DeflateInitOptsOutput, DeflateSetOptsOutput, DeflateInitOutput, @@ -591,6 +592,7 @@ const struct ccp_algorithm DeflateAlgorithm = { DeflateDictSetup }, { + 0, DeflateInitOptsOutput, DeflateSetOptsOutput, DeflateInitOutput, diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index 2652d465baf5..448b9e29eeef 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -167,6 +167,8 @@ static void mp_LayerUp(void *v, struct fsm *fp) { /* The given fsm (ccp) is now up */ + + bundle_CalculateBandwidth(fp->bundle); /* Against ccp_MTUOverhead */ } static void @@ -646,6 +648,11 @@ mp_Output(struct mp *mp, struct bundle *bundle, struct link *l, mp->out.seq, m_length(m), l->name); mp->out.seq = inc_seq(mp->peer_is12bit, mp->out.seq); + if (l->ccp.fsm.state != ST_OPENED && ccp_Required(&l->ccp)) { + log_Printf(LogPHASE, "%s: Not transmitting... waiting for CCP\n", l->name); + return; + } + link_PushPacket(l, m, bundle, LINK_QUEUES(l) - 1, PROTO_MP); } diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c index 5b32d1b0f42b..891492b49e31 100644 --- a/usr.sbin/ppp/mppe.c +++ b/usr.sbin/ppp/mppe.c @@ -721,6 +721,7 @@ const struct ccp_algorithm MPPEAlgorithm = { MPPEDictSetup }, { + 2, MPPEInitOptsOutput, MPPESetOptsOutput, MPPEInitOutput, diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c index 47d9a8cec880..d1a5b53f1276 100644 --- a/usr.sbin/ppp/pred.c +++ b/usr.sbin/ppp/pred.c @@ -340,6 +340,7 @@ const struct ccp_algorithm Pred1Algorithm = { Pred1DictSetup }, { + 0, Pred1InitOptsOutput, Pred1SetOptsOutput, Pred1InitOutput, |