diff options
author | brian <brian@FreeBSD.org> | 2001-07-03 22:20:19 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-07-03 22:20:19 +0000 |
commit | 0deba2c342284728c367d996a120510bed8a07a4 (patch) | |
tree | 753c521335e8c5586213ea14afc2e9e2080bf808 /usr.sbin/ppp/bundle.c | |
parent | c6b698395d9dda67bfd2f061db42b9e6038c790b (diff) | |
download | FreeBSD-src-0deba2c342284728c367d996a120510bed8a07a4.zip FreeBSD-src-0deba2c342284728c367d996a120510bed8a07a4.tar.gz |
Reduce the interface MTU by 2 when MPPE has been successfully negotiated.
This is necessary because MPPE will combine the protocol id with the
payload received on the tun interface, encrypt it, then prepend its
own protocol id, effectively increasing the payload by two bytes.
Diffstat (limited to 'usr.sbin/ppp/bundle.c')
-rw-r--r-- | usr.sbin/ppp/bundle.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 7e48499..ba1eca5 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); |