Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107380087
D40304.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D40304.diff
View Options
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -4647,28 +4647,33 @@
{
uint32_t srtt;
- if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_USEC)
- srtt = tp->t_srtt;
- else if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS) {
- /* TICKS are stored shifted; unshift for the real TICKS */
- srtt = tp->t_srtt >> TCP_RTT_SHIFT;
- }
- if (tp->t_tmr_granularity == granularity)
- return (srtt);
- /* If we reach here they are oppsite what the caller wants */
- if (granularity == TCP_TMR_GRANULARITY_USEC) {
- /*
- * The user wants useconds and internally
- * its kept in ticks, convert to useconds.
- * Put unshift at last improves precision.
- */
- srtt = TICKS_2_USEC(tp->t_srtt) >> TCP_RTT_SHIFT;
- } else if (granularity == TCP_TMR_GRANULARITY_TICKS) {
- /*
- * The user wants ticks and internally its
- * kept in useconds, convert to ticks.
- */
- srtt = USEC_2_TICKS(srtt);
+ KASSERT(granularity == TCP_TMR_GRANULARITY_USEC ||
+ granularity == TCP_TMR_GRANULARITY_TICKS,
+ ("%s: called with unexpected granularity %d", __func__,
+ granularity));
+
+ srtt = tp->t_srtt;
+
+ /*
+ * We only support two granularities. If the stored granularity
+ * does not match the granularity requested by the caller,
+ * convert the stored value to the requested unit of granularity.
+ */
+ if (tp->t_tmr_granularity != granularity) {
+ if (granularity == TCP_TMR_GRANULARITY_USEC)
+ srtt = TICKS_2_USEC(srtt);
+ else
+ srtt = USEC_2_TICKS(srtt);
}
+
+ /*
+ * If the srtt is stored with ticks granularity, we need to
+ * unshift to get the actual value. We do this after the
+ * conversion above (if one was necessary) in order to maximize
+ * precision.
+ */
+ if (tp->t_tmr_granularity == TCP_TMR_GRANULARITY_TICKS)
+ srtt = srtt >> TCP_RTT_SHIFT;
+
return (srtt);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 14, 7:48 AM (19 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15792424
Default Alt Text
D40304.diff (1 KB)
Attached To
Mode
D40304: Refactor tcp_get_srtt()
Attached
Detach File
Event Timeline
Log In to Comment