diff options
author | brian <brian@FreeBSD.org> | 2001-07-13 02:04:19 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-07-13 02:04:19 +0000 |
commit | c29f79581ed1694ff6ad0b6e42468e574bfa81df (patch) | |
tree | 6a42064de54cd6726d3135ce4d7b086bbd2a120c /usr.sbin | |
parent | 025e912e14514c7cfe14df4e17284702d8fa8cdf (diff) | |
download | FreeBSD-src-c29f79581ed1694ff6ad0b6e42468e574bfa81df.zip FreeBSD-src-c29f79581ed1694ff6ad0b6e42468e574bfa81df.tar.gz |
Perform MSS fixups on incoming packets as well as outgoing.
MFC after: 1 week
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/tcpmss.c | 75 |
1 files changed, 43 insertions, 32 deletions
diff --git a/usr.sbin/ppp/tcpmss.c b/usr.sbin/ppp/tcpmss.c index f8debc8..50606eb 100644 --- a/usr.sbin/ppp/tcpmss.c +++ b/usr.sbin/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 }; |