From ef4896e73139a0b31cd932f36e898c00779e7585 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 13 Jul 2001 02:03:38 +0000 Subject: Perform MSS fixups on incoming packets as well as outgoing. --- usr.sbin/ppp/ppp/tcpmss.c | 75 +++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 32 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/ppp/tcpmss.c b/usr.sbin/ppp/ppp/tcpmss.c index f8debc8805e..50606ebee69 100644 --- a/usr.sbin/ppp/ppp/tcpmss.c +++ b/usr.sbin/ppp/ppp/tcpmss.c @@ -70,37 +70,6 @@ #define MAXMSS(mtu) (mtu - sizeof(struct ip) - sizeof(struct tcphdr)) -static void MSSFixup(struct tcphdr *, ssize_t, u_int16_t); - - -static struct mbuf * -tcpmss_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, - int pri, u_short *proto) -{ - struct ip *pip; - int hlen, plen; - - if (!Enabled(bundle, OPT_TCPMSSFIXUP)) - return bp; - - bp = m_pullup(bp); - plen = m_length(bp); - pip = (struct ip *)MBUF_CTOP(bp); - hlen = pip->ip_hl << 2; - - /* - * Check for MSS option only for TCP packets with zero fragment offsets - * and correct total and header lengths. - */ - if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 && - ntohs(pip->ip_len) == plen && hlen <= plen && - plen - hlen >= sizeof(struct tcphdr)) - MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen, - MAXMSS(bundle->iface->mtu)); - - return bp; -} - /*- * The following macro is used to update an * internet checksum. "acc" is a 32-bit @@ -168,4 +137,46 @@ MSSFixup(struct tcphdr *tc, ssize_t pktlen, u_int16_t maxmss) } } -struct layer tcpmsslayer = { LAYER_PROTO, "tcpmss", tcpmss_LayerPush, NULL }; +static struct mbuf * +tcpmss_Check(struct bundle *bundle, struct mbuf *bp) +{ + struct ip *pip; + int hlen, plen; + + if (!Enabled(bundle, OPT_TCPMSSFIXUP)) + return bp; + + bp = m_pullup(bp); + plen = m_length(bp); + pip = (struct ip *)MBUF_CTOP(bp); + hlen = pip->ip_hl << 2; + + /* + * Check for MSS option only for TCP packets with zero fragment offsets + * and correct total and header lengths. + */ + if (pip->ip_p == IPPROTO_TCP && (ntohs(pip->ip_off) & IP_OFFMASK) == 0 && + ntohs(pip->ip_len) == plen && hlen <= plen && + plen - hlen >= sizeof(struct tcphdr)) + MSSFixup((struct tcphdr *)(MBUF_CTOP(bp) + hlen), plen - hlen, + MAXMSS(bundle->iface->mtu)); + + return bp; +} + +static struct mbuf * +tcpmss_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, + int pri, u_short *proto) +{ + return tcpmss_Check(bundle, bp); +} + +static struct mbuf * +tcpmss_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp, + u_short *proto) +{ + return tcpmss_Check(bundle, bp); +} + +struct layer tcpmsslayer = + { LAYER_PROTO, "tcpmss", tcpmss_LayerPush, tcpmss_LayerPull }; -- cgit v1.2.3