Date: Sun, 28 Jun 2009 18:16:44 GMT From: Fang Wang <fangwang@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165351 for review Message-ID: <200906281816.n5SIGiU8060135@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165351 Change 165351 by fangwang@fangwang_utobsd on 2009/06/28 18:15:46 Refine setsockopt and getsockopt for tcp uto, change some details. Affected files ... .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp.h#5 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_input.c#5 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_output.c#7 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_syncache.c#7 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_syncache.h#5 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_timer.c#5 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_usrreq.c#3 edit .. //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_var.h#10 edit Differences ... ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp.h#5 (text+ko) ==== @@ -153,6 +153,15 @@ #define TCP_INFO 0x20 /* retrieve tcp_info structure */ #define TCP_CONGESTION 0x40 /* get/set congestion control algorithm */ #define TCP_UTO 0x80 /* set tcp user timeout */ +/* Used with TCP_UTO through setsockopt and getsockopt */ +struct tcp_uto { + int uto; + int flags; +}; +/* Values for flags in struct tcp_uto */ +#define STORE_UTO 0x01 +#define ENABLE_UTO 0x02 +#define ENABLE_CHANGE 0x04 #define TCP_CA_NAME_MAX 16 /* max congestion control name length */ ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_input.c#5 (text+ko) ==== @@ -1189,7 +1189,7 @@ /* * If TCP user timeout option is received, because it's an * optional option, we do nothing at this moment. And we will - * process when we need retransmission in synchronized states. + * process when we need to use it. */ if (to.to_flags & TOF_UTO) { tp->uto_flags |= TCPUTO_RCVD; @@ -1207,12 +1207,6 @@ if (TSTMP_GT(to.to_tsecr, ticks)) to.to_tsecr = 0; } - if (tp->uto_flags & TCPUTO_SENDING) - if (th->th_ack > tp->uto_carrier) { - tp->uto_flags &= ~TCPUTO_SENDING; - tp->uto_flags |= TCPUTO_SENT; - } - /* * Process options only when we get SYN/ACK back. The SYN case @@ -2252,6 +2246,12 @@ } process_ACK: + if (tp->uto_flags & TCPUTO_SENDING) + if (SEQ_GT(th->th_ack, tp->uto_carrier)) { + tp->uto_flags &= ~TCPUTO_SENDING; + tp->uto_flags |= TCPUTO_SENT; + } + INP_INFO_LOCK_ASSERT(&V_tcbinfo); KASSERT(ti_locked == TI_RLOCKED || ti_locked == TI_WLOCKED, ("tcp_input: process_ACK ti_locked %d", ti_locked)); ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_output.c#7 (text+ko) ==== @@ -1472,6 +1472,7 @@ *optp++ = TCPOPT_UTO; *optp++ = TCPOLEN_UTO; optlen += TCPOLEN_UTO; + to->to_uto = htons(to->to_uto); bcopy((u_char *)&to->to_uto, optp, sizeof(to->to_uto)); optp += sizeof(to->to_uto); to->to_flags &= ~TOF_UTO; ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_syncache.c#7 (text+ko) ==== @@ -1228,7 +1228,7 @@ } if (uto_flags & TCPUTO_NEED) { sc->sc_uto = snd_uto; - sc->sc_flags = SCF_UTO; + sc->sc_flags = SCF_NEED_UTO; } if (V_tcp_syncookies) { @@ -1397,17 +1397,12 @@ if (sc->sc_flags & SCF_SIGNATURE) to.to_flags |= TOF_SIGNATURE; #endif - if (sc->sc_flags & SCF_UTO) { + if (sc->sc_flags & SCF_NEED_UTO) { to.to_uto = sc->sc_uto; to.to_flags |= TOF_UTO; } optlen = tcp_addoptions(&to, (u_char *)(th + 1)); - if ((to.to_flags & TOF_UTO) == 0 && - (sc->sc_flags & SCF_UTO) == 1) { - sc->sc_flags &= ~SCF_UTO; - sc->sc_flags |= SCF_SENT_UTO; - } /* Adjust headers by option size. */ th->th_off = (sizeof(struct tcphdr) + optlen) >> 2; ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_syncache.h#5 (text+ko) ==== @@ -93,9 +93,8 @@ #define SCF_SIGNATURE 0x20 /* send MD5 digests */ #define SCF_SACK 0x80 /* send SACK option */ #define SCF_ECN 0x100 /* send ECN setup packet */ -#define SCF_UTO 0x200 /* send UTO option */ +#define SCF_NEED_UTO 0x200 /* send UTO option */ #define SCF_RCVD_UTO 0x400 /* received UTO option */ -#define SCF_SENT_UTO 0x800 /* send UTO option successfully */ #define SYNCOOKIE_SECRET_SIZE 8 /* dwords */ #define SYNCOOKIE_LIFETIME 16 /* seconds */ ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_timer.c#5 (text+ko) ==== @@ -447,6 +447,7 @@ INP_INFO_WUNLOCK(&V_tcbinfo); CURVNET_RESTORE(); } + static int tcp_timer_uto_interval(struct tcpcb *tp) { @@ -466,6 +467,7 @@ return (interval); } + void tcp_timer_rexmt(void * xtp) { @@ -540,17 +542,13 @@ tp->t_flags &= ~TF_WASFRECOVERY; tp->t_badrxtwin = ticks + (tp->t_srtt >> (TCP_RTT_SHIFT + 1)); - if (tp->uto_flags & TCPUTO_ENABLE && (tp->uto_flags & TCPUTO_SET || - (tp->uto_flags & TCPUTO_PEER_SET) == TCPUTO_PEER_SET)) { + if (tp->uto_flags & TCPUTO_ENABLE && + (tp->uto_flags & TCPUTO_PEER_SET) == TCPUTO_PEER_SET) { u_int utoval; - if (tp->uto_flags & TCPUTO_SET) { - TCP_UTOVAL(utoval, tp->snd_uto); - tp->t_uto_impl = min(tcp_uto_min, max(utoval, tcp_uto_max)); - } else { - TCP_UTOVAL(utoval, tp->rcv_uto); - tp->t_uto_impl = min(tcp_uto_max, - max(tp->t_uto_adv, max(utoval, tcp_uto_min))); - } + TCP_UTOVAL(utoval, tp->rcv_uto); + tp->t_uto_impl = min(tcp_uto_max, + max(tp->t_uto_adv, max(utoval, tcp_uto_min))); + tp->uto_flags &= ~TCPUTO_PEER_SET; tp->uto_flags |= TCPUTO_IMPL; } tp->t_uto_left = tp->t_uto_impl; ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_usrreq.c#3 (text+ko) ==== @@ -1256,6 +1256,7 @@ struct inpcb *inp; struct tcpcb *tp; struct tcp_info ti; + struct tcp_uto tu; error = 0; inp = sotoinpcb(so); @@ -1367,26 +1368,35 @@ case TCP_UTO: INP_WUNLOCK(inp); - error = sooptcopyin(sopt, &optval, sizeof optval, - sizeof optval); + error = sooptcopyin(sopt, &tu, sizeof tu, + sizeof tu); if (error) return (error); INP_WLOCK_RECHECK(inp); - if (optval > 0 && optval <= 0x8FFF * 60) { + if (tu.uto > 0 && tu.uto <= 0x8FFF * 60) { if (optval > 0x8FFF) { - tp->snd_uto = optval / 60; + tp->snd_uto = tu.uto / 60; tp->snd_uto <<= 1; tp->snd_uto |= 1; } else { - tp->snd_uto = optval; + tp->snd_uto = tu.uto; tp->snd_uto <<= 1; } - tp->t_uto_adv = optval; - tp->uto_flags |= TCPUTO_NEED; - tp->uto_flags |= TCPUTO_ENABLE; - tp->uto_flags &= ~TCPUTO_CHANGEABLE; - } + if (tu.flags & ENABLE_UTO) + tp->uto_flags |= TCPUTO_ENABLE; + if (tu.flags & STORE_UTO) + tp->uto_flags |= TCPUTO_NEED; + if (tp->uto_flags & TCPUTO_ENABLE && + tp->uto_flags & TCPUTO_NEED) { + tp->t_uto_impl = min(tcp_uto_max, + max(tu.uto, tcp_uto_min)); + tp->t_uto_adv = tp->t_uto_impl; + tp->uto_flags &= ~TCPUTO_CHANGEABLE; + tp->uto_flags |= TCPUTO_IMPL; + } + if (tu.flags & ENABLE_CHANGE) + tp->uto_flags |= TCPUTO_CHANGEABLE; else error = EINVAL; INP_WUNLOCK(inp); @@ -1435,6 +1445,28 @@ INP_WUNLOCK(inp); error = sooptcopyout(sopt, &ti, sizeof ti); break; + case TCP_UTO: + tu.flags = 0; + if (tp->uto_flags & TCPUTO_ENABLE) + tu.flags |= ENABLE_UTO; + if (tp->uto_flags & TCPUTO_CHANGEABLE) + tu.flags |= ENABLE_CHANGE; + if (tp->uto_flags & TCPUTO_ENABLE && + (tp->uto_flags & TCPUTO_PEER_SET) == TCPUTO_PEER_SET) { + u_int utoval; + TCP_UTOVAL(tu.uto, tp->rcv_uto); + tp->t_uto_impl = min(tcp_uto_max, + max(tp->t_uto_adv, max(tu.uto, tcp_uto_min))); + tp->uto_flags &= ~TCPUTO_PEER_SET; + tp->uto_flags |= TCPUTO_IMPL; + } + if (tp->uto_flags & TCPUTO_IMPL) { + tu.flags |= STORE_UTO; + tu.uto = tp->t_uto_impl; + } + INP_WUNLOCK(inp); + error = sooptcopyout(sopt, &tu, sizeof tu); + break; default: INP_WUNLOCK(inp); error = ENOPROTOOPT; ==== //depot/projects/soc2009/tcputo/src/sys/netinet/tcp_var.h#10 (text+ko) ==== @@ -251,7 +251,6 @@ #define TCPUTO_NEED 0x10 /* user timeout need to be sent */ #define TCPUTO_SENDING 0x20 /* user timeout is in the process of sending */ #define TCPUTO_SENT 0x40 /* user timeout is sent successfully */ -#define TCPUTO_SET (TCPUTO_NEED | TCPUTO_SENDING | TCPUTO_SENT) #define TCPUTO_PEER_SET (TCPUTO_CHANGEABLE | TCPUTO_RCVD) #define TCP_UTOVAL(utoval, uto) do { \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906281816.n5SIGiU8060135>