diff options
-rw-r--r-- | usr.sbin/ppp/ppp/bundle.c | 28 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ccp.c | 34 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/ccp.h | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/datalink.c | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/deflate.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/mp.c | 9 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/mppe.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/pred.c | 3 |
8 files changed, 75 insertions, 15 deletions
diff --git a/usr.sbin/ppp/ppp/bundle.c b/usr.sbin/ppp/ppp/bundle.c index c26d9cf0f0d..9af16bc4052 100644 --- a/usr.sbin/ppp/ppp/bundle.c +++ b/usr.sbin/ppp/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: bundle.c,v 1.57 2001/06/19 10:24:49 brian Exp $ + * $OpenBSD: bundle.c,v 1.58 2001/07/03 22:23:56 brian Exp $ */ #include <sys/param.h> @@ -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/ppp/ccp.c b/usr.sbin/ppp/ppp/ccp.c index db3eceb3b58..08127c5a1d7 100644 --- a/usr.sbin/ppp/ppp/ccp.c +++ b/usr.sbin/ppp/ppp/ccp.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: ccp.c,v 1.20 2001/06/19 10:24:50 brian Exp $ + * $OpenBSD: ccp.c,v 1.21 2001/07/03 22:23:56 brian Exp $ */ #include <sys/param.h> @@ -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/ppp/ccp.h b/usr.sbin/ppp/ppp/ccp.h index 49918eb703d..9de531fa4a6 100644 --- a/usr.sbin/ppp/ppp/ccp.h +++ b/usr.sbin/ppp/ppp/ccp.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: ccp.h,v 1.10 2001/06/19 10:24:50 brian Exp $ + * $OpenBSD: ccp.h,v 1.11 2001/07/03 22:23:56 brian Exp $ */ #define CCP_MAXCODE CODE_RESETACK @@ -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/ppp/datalink.c b/usr.sbin/ppp/ppp/datalink.c index fcc8a07e081..02d749366f3 100644 --- a/usr.sbin/ppp/ppp/datalink.c +++ b/usr.sbin/ppp/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: datalink.c,v 1.35 2001/06/04 16:09:28 brian Exp $ + * $OpenBSD: datalink.c,v 1.36 2001/07/03 22:23:56 brian Exp $ */ #include <sys/param.h> @@ -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/ppp/deflate.c b/usr.sbin/ppp/ppp/deflate.c index 0e9281db0f9..84edd30531c 100644 --- a/usr.sbin/ppp/ppp/deflate.c +++ b/usr.sbin/ppp/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: deflate.c,v 1.12 2001/06/19 10:24:51 brian Exp $ + * $OpenBSD: deflate.c,v 1.13 2001/07/03 22:23:56 brian Exp $ */ #include <sys/types.h> @@ -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/ppp/mp.c b/usr.sbin/ppp/ppp/mp.c index bec0c0b399a..73c69cec417 100644 --- a/usr.sbin/ppp/ppp/mp.c +++ b/usr.sbin/ppp/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: mp.c,v 1.21 2000/11/02 00:54:34 brian Exp $ + * $OpenBSD: mp.c,v 1.22 2001/07/03 22:23:56 brian Exp $ */ #include <sys/param.h> @@ -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/ppp/mppe.c b/usr.sbin/ppp/ppp/mppe.c index b2e4392fbd2..a1b0a246058 100644 --- a/usr.sbin/ppp/ppp/mppe.c +++ b/usr.sbin/ppp/ppp/mppe.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: mppe.c,v 1.6 2001/06/19 10:24:56 brian Exp $ + * $OpenBSD: mppe.c,v 1.7 2001/07/03 22:23:56 brian Exp $ */ #include <sys/types.h> @@ -721,6 +721,7 @@ const struct ccp_algorithm MPPEAlgorithm = { MPPEDictSetup }, { + 2, MPPEInitOptsOutput, MPPESetOptsOutput, MPPEInitOutput, diff --git a/usr.sbin/ppp/ppp/pred.c b/usr.sbin/ppp/ppp/pred.c index c6b6150ce8f..c3e52be8006 100644 --- a/usr.sbin/ppp/ppp/pred.c +++ b/usr.sbin/ppp/ppp/pred.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: pred.c,v 1.11 2001/06/19 10:24:57 brian Exp $ + * $OpenBSD: pred.c,v 1.12 2001/07/03 22:23:56 brian Exp $ */ #include <sys/types.h> @@ -340,6 +340,7 @@ const struct ccp_algorithm Pred1Algorithm = { Pred1DictSetup }, { + 0, Pred1InitOptsOutput, Pred1SetOptsOutput, Pred1InitOutput, |