Date: Sat, 13 Aug 2011 19:23:10 GMT From: Catalin Nicutar <cnicutar@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 197609 for review Message-ID: <201108131923.p7DJNAXh084839@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@197609?ac=10 Change 197609 by cnicutar@cnicutar_cronos on 2011/08/13 19:22:15 Improve UTO code readability. Affected files ... .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp.h#3 edit .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_input.c#3 edit .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_output.c#3 edit .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_syncache.h#3 edit .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_timer.c#3 edit .. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_var.h#3 edit Differences ... ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp.h#3 (text+ko) ==== @@ -107,9 +107,11 @@ /* * The timeout ranges for TCP UTO have security implications; in particular, * long timeouts might allow for denial-of-service attacks. + * These are only defaults for net.inet.tcp.min_timeout and max_timeout, + * respectively. */ -#define TCP_UTOMIN 100 /* Minimum acceptable timeout. */ -#define TCP_UTOMAX 600 /* Maximum advertised timeout. */ +#define TCP_UTOMIN 100 /* Minimum user timeout in seconds. */ +#define TCP_UTOMAX 600 /* Maximum user timeout in seconds. */ /* ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_input.c#3 (text+ko) ==== @@ -1328,10 +1328,9 @@ if (to.to_flags & TOF_UTO) { /* * Storing the value even if the user might not - * accept it. Also, not clamping it just yet. + * accept it. */ - tp->rcv_uto = (to.to_uto & UTO_MINS) ? - (to.to_uto & ~(UTO_MINS)) * 60 : to.to_uto; + tp->rcv_uto = UTO_VALUE(to); /* * XXX-CN Using option both for send and receive. * Clear it for syncache. @@ -1532,10 +1531,8 @@ * The value is converter to seconds and not clamped (the user * needs to know the real value received). */ - if (to.to_flags & TOF_UTO) { - tp->rcv_uto = (to.to_uto & UTO_MINS) ? - (to.to_uto & ~(UTO_MINS)) * 60 : to.to_uto; - } + if (to.to_flags & TOF_UTO) + tp->rcv_uto = UTO_VALUE(to); /* * If echoed timestamp is later than the current time, ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_output.c#3 (text+ko) ==== @@ -1518,7 +1518,6 @@ /* * If the timeout is larger than UTO_MINS * we'll specify minutes. - * XXX-CN UTO_MINS is arbitrary. */ to->to_uto /= 60; to->to_uto |= UTO_MINS; ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_syncache.h#3 (text+ko) ==== @@ -82,8 +82,8 @@ struct label *sc_label; /* MAC label reference */ struct ucred *sc_cred; /* cred cache for jail checks */ - u_int32_t sc_snd_uto; /* user timeout to send */ - u_int32_t sc_rcv_uto; /* user timeout received */ + u_int32_t sc_snd_uto; /* Sent UTO (seconds) */ + u_int32_t sc_rcv_uto; /* Received UTO (seconds) */ }; /* ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_timer.c#3 (text+ko) ==== @@ -312,7 +312,7 @@ return; } callout_deactivate(&tp->t_timers->tt_keep); - if ((tp->snd_uto) || ((tp->t_flags & TF_RCV_UTO) && tp->rcv_uto)) { + if (USING_UTO(tp)) { /* * This connection is using UTO (either sending or has * received a value). We need to stop sending keepalives @@ -498,7 +498,7 @@ /* UTO starting again since it's the first retransmit. */ tp->t_suto = 0; - if (tp->snd_uto || ((tp->t_flags & TF_RCV_UTO) && tp->rcv_uto)) { + if (USING_UTO(tp)) { /* * Since we're using UTO for this connection we need to * compute how much time we've got left. ==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_var.h#3 (text+ko) ==== @@ -207,9 +207,9 @@ void *t_pspare2[4]; /* 4 TBD */ uint64_t _pad[6]; /* 6 TBD (1-2 CC/RTT?) */ - uint32_t snd_uto; /* sent timeout */ - uint32_t rcv_uto; /* received suggestion from peer */ - int t_suto; /* uto starting time */ + uint32_t snd_uto; /* sent timeout (seconds) */ + uint32_t rcv_uto; /* received suggestion (seconds) */ + int t_suto; /* uto starting time (ticks) */ }; /* @@ -261,6 +261,12 @@ #define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una) +#define USING_UTO(tp) (tp)->snd_uto || \ + (((tp)->t_flags & TF_RCV_UTO) && (tp)->rcv_uto) + +#define UTO_VALUE(to) ((to).to_uto & UTO_MINS) ? \ + ((to).to_uto & ~(UTO_MINS)) * 60 : (to).to_uto + /* * Flags for the t_oobflags field. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108131923.p7DJNAXh084839>