Print this page
11546 Track TCP round-trip time in nanoseconds
Portions contributed by: Cody Peter Mello <cody.mello@joyent.com>
Portions contributed by: Brandon Baker <bbaker@delphix.com>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>

@@ -19,10 +19,12 @@
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
+ * Copyright (c) 2016 by Delphix. All rights reserved.
  */
 
 #include <sys/types.h>
 #include <sys/stream.h>
 #define _SUN_TPI_VERSION 2

@@ -867,13 +869,11 @@
                                         tcp_wput_data(tcp, NULL, B_FALSE);
                                 }
                                 tcp->tcp_cork = onoff;
                         }
                         break;
-                case TCP_RTO_INITIAL: {
-                        clock_t rto;
-
+                case TCP_RTO_INITIAL:
                         if (checkonly || val == 0)
                                 break;
 
                         /*
                          * Sanity checks

@@ -899,19 +899,15 @@
                          * really affect anything.
                          */
                         if (tcp->tcp_state >= TCPS_SYN_SENT)
                                 break;
 
-                        tcp->tcp_rtt_sa = tcp->tcp_rto_initial << 2;
-                        tcp->tcp_rtt_sd = tcp->tcp_rto_initial >> 1;
-                        rto = (tcp->tcp_rtt_sa >> 3) + tcp->tcp_rtt_sd +
-                            tcps->tcps_rexmit_interval_extra +
-                            (tcp->tcp_rtt_sa >> 5) +
-                            tcps->tcps_conn_grace_period;
-                        TCP_SET_RTO(tcp, rto);
+                        tcp->tcp_rtt_sa = MSEC2NSEC(tcp->tcp_rto_initial) << 2;
+                        tcp->tcp_rtt_sd = MSEC2NSEC(tcp->tcp_rto_initial) >> 1;
+                        tcp->tcp_rto = tcp_calculate_rto(tcp, tcps,
+                            tcps->tcps_conn_grace_period);
                         break;
-                }
                 case TCP_RTO_MIN:
                         if (checkonly || val == 0)
                                 break;
 
                         if (val < tcps->tcps_rexmit_interval_min_low ||