Change 55690 by peter@daintree on 2008/10/16 15:16:47 Adapt the T_MAXSEG socket option extensions to ybsd7. Affected files ... ... //depot/yahoo/ybsd_7/src/sys/netinet/tcp_input.c#23 edit ... //depot/yahoo/ybsd_7/src/sys/netinet/tcp_output.c#13 edit ... //depot/yahoo/ybsd_7/src/sys/netinet/tcp_syncache.c#17 edit ... //depot/yahoo/ybsd_7/src/sys/netinet/tcp_usrreq.c#14 edit ... //depot/yahoo/ybsd_7/src/sys/netinet/tcp_var.h#13 edit Differences ... --- //depot/yahoo/ybsd_7/src/sys/netinet/tcp_input.c +++ //depot/yahoo/ybsd_7/src/sys/netinet/tcp_input.c @@ -2863,6 +2863,12 @@ if (maxmtu == 0) return; + if (tp->t_usermss) { + if (maxmtu > (tp->t_usermss + min_protoh)) + maxmtu = tp->t_usermss + min_protoh; + if (offer > tp->t_usermss) + offer = tp->t_usermss; + } /* What have we got? */ switch (offer) { case 0: --- //depot/yahoo/ybsd_7/src/sys/netinet/tcp_output.c +++ //depot/yahoo/ybsd_7/src/sys/netinet/tcp_output.c @@ -655,6 +655,8 @@ if (flags & TH_SYN) { tp->snd_nxt = tp->iss; to.to_mss = tcp_mssopt(&tp->t_inpcb->inp_inc); + if (tp->t_usermss && to.to_mss > tp->t_usermss) + to.to_mss = tp->t_usermss; to.to_flags |= TOF_MSS; } /* Window scaling. */ --- //depot/yahoo/ybsd_7/src/sys/netinet/tcp_syncache.c +++ //depot/yahoo/ybsd_7/src/sys/netinet/tcp_syncache.c @@ -115,8 +115,9 @@ TAILQ_ENTRY(syncache) sc_hash; struct in_conninfo sc_inc; /* addresses */ int sc_rxttime; /* retransmit time */ + u_int16_t sc_rxmits; /* retransmit counter */ + u_int16_t sc_usermss; /* User-requested mss cap */ u_long sc_starttime; /* first syn timestamp */ - u_int16_t sc_rxmits; /* retransmit counter */ u_int32_t sc_tsreflect; /* timestamp to reflect */ u_int32_t sc_ts; /* our timestamp to send */ @@ -1069,6 +1070,7 @@ struct mbuf *ipopts = NULL; u_int32_t flowtmp; int win, sb_hiwat, ip_ttl, ip_tos, noopt; + u_int16_t usermss; #if 0 char *s; #endif @@ -1104,6 +1106,7 @@ win = sbspace(&so->so_rcv); sb_hiwat = so->so_rcv.sb_hiwat; noopt = (tp->t_flags & TF_NOOPT); + usermss = tp->t_usermss; /* By the time we drop the lock these should no longer be used. */ so = NULL; @@ -1245,6 +1248,7 @@ sc->sc_flags = 0; sc->sc_flowlabel = 0; sc->sc_timestamp = ticks; + sc->sc_usermss = usermss; /* * Initial receive window: clip sbspace to [0 .. TCP_MAXWIN]. @@ -1309,8 +1313,11 @@ #endif if (to->to_flags & TOF_SACKPERM) sc->sc_flags |= SCF_SACK; - if (to->to_flags & TOF_MSS) + if (to->to_flags & TOF_MSS) { sc->sc_peer_mss = to->to_mss; /* peer mss may be zero */ + if (sc->sc_usermss && sc->sc_peer_mss > sc->sc_usermss) + sc->sc_peer_mss = sc->sc_usermss; + } if (noopt) sc->sc_flags |= SCF_NOOPT; @@ -1379,6 +1386,8 @@ /* Determine MSS we advertize to other end of connection. */ mssopt = tcp_mssopt(&sc->sc_inc); + if (sc->sc_usermss && mssopt > sc->sc_usermss) + mssopt = sc->sc_usermss; if (sc->sc_peer_mss) mssopt = max( min(sc->sc_peer_mss, mssopt), tcp_minmss); @@ -1786,6 +1795,8 @@ sc->sc_rxmits = 0; sc->sc_peer_mss = tcp_sc_msstab[mss]; + if (sc->sc_usermss && sc->sc_peer_mss > sc->sc_usermss) + sc->sc_peer_mss = sc->sc_usermss; tcpstat.tcps_sc_recvcookie++; return (sc); --- //depot/yahoo/ybsd_7/src/sys/netinet/tcp_usrreq.c +++ //depot/yahoo/ybsd_7/src/sys/netinet/tcp_usrreq.c @@ -1360,11 +1360,18 @@ return (error); INP_WLOCK_RECHECK(inp); - if (optval > 0 && optval <= tp->t_maxseg && - optval + 40 >= tcp_minmss) - tp->t_maxseg = optval; - else - error = EINVAL; + if ((so->so_state & SS_ISCONNECTED) == 0) { + if (optval > 0 && optval + 40 >= tcp_minmss) + tp->t_usermss = optval; + else + error = EINVAL; + } else { + if (optval > 0 && optval <= tp->t_maxseg && + optval + 40 >= tcp_minmss) + tp->t_maxseg = optval; + else + error = EINVAL; + } INP_WUNLOCK(inp); break; @@ -1397,7 +1404,10 @@ error = sooptcopyout(sopt, &optval, sizeof optval); break; case TCP_MAXSEG: - optval = tp->t_maxseg; + if ((so->so_state & SS_ISCONNECTED) == 0) + optval = tp->t_usermss; + else + optval = tp->t_maxseg; INP_WUNLOCK(inp); error = sooptcopyout(sopt, &optval, sizeof optval); break; --- //depot/yahoo/ybsd_7/src/sys/netinet/tcp_var.h +++ //depot/yahoo/ybsd_7/src/sys/netinet/tcp_var.h @@ -240,6 +240,8 @@ u_long rcv_rxmtbytes; /* recv bytes retransmitted */ int t_numpersist; /* Number of persist attempts on the connection */ struct tcp_IO_phase_ t_iophase; + + u_int t_usermss; /* User requested t_maxseg */ }; #define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY)