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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp.c
          +++ new/usr/src/uts/common/inet/tcp/tcp.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2011, Joyent Inc. All rights reserved.
  25   25   * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  26      - * Copyright (c) 2013,2014 by Delphix. All rights reserved.
       26 + * Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  27   27   * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  28   28   */
  29   29  /* Copyright (c) 1990 Mentat Inc. */
  30   30  
  31   31  #include <sys/types.h>
  32   32  #include <sys/stream.h>
  33   33  #include <sys/strsun.h>
  34   34  #include <sys/strsubr.h>
  35   35  #include <sys/stropts.h>
  36   36  #include <sys/strlog.h>
↓ open down ↓ 222 lines elided ↑ open up ↑
 259  259  
 260  260  /* TCP Timer control structure */
 261  261  typedef struct tcpt_s {
 262  262          pfv_t   tcpt_pfv;       /* The routine we are to call */
 263  263          tcp_t   *tcpt_tcp;      /* The parameter we are to pass in */
 264  264  } tcpt_t;
 265  265  
 266  266  /*
 267  267   * Functions called directly via squeue having a prototype of edesc_t.
 268  268   */
 269      -void            tcp_input_listener(void *arg, mblk_t *mp, void *arg2,
 270      -    ip_recv_attr_t *ira);
 271  269  void            tcp_input_data(void *arg, mblk_t *mp, void *arg2,
 272  270      ip_recv_attr_t *ira);
 273  271  static void     tcp_linger_interrupted(void *arg, mblk_t *mp, void *arg2,
 274  272      ip_recv_attr_t *dummy);
 275  273  
 276  274  
 277  275  /* Prototype for TCP functions */
 278  276  static void     tcp_random_init(void);
 279  277  int             tcp_random(void);
 280  278  static int      tcp_connect_ipv4(tcp_t *tcp, ipaddr_t *dstaddrp,
↓ open down ↓ 352 lines elided ↑ open up ↑
 633  631          if (error != 0)
 634  632                  return (error);
 635  633  
 636  634          error = tcp_build_hdrs(tcp);
 637  635          if (error != 0)
 638  636                  return (error);
 639  637  
 640  638          tcp->tcp_localnet = uinfo.iulp_localnet;
 641  639  
 642  640          if (uinfo.iulp_rtt != 0) {
 643      -                clock_t rto;
 644      -
 645      -                tcp->tcp_rtt_sa = uinfo.iulp_rtt;
 646      -                tcp->tcp_rtt_sd = uinfo.iulp_rtt_sd;
 647      -                rto = (tcp->tcp_rtt_sa >> 3) + tcp->tcp_rtt_sd +
 648      -                    tcps->tcps_rexmit_interval_extra +
 649      -                    (tcp->tcp_rtt_sa >> 5);
 650      -
 651      -                TCP_SET_RTO(tcp, rto);
      641 +                tcp->tcp_rtt_sa = MSEC2NSEC(uinfo.iulp_rtt);
      642 +                tcp->tcp_rtt_sd = MSEC2NSEC(uinfo.iulp_rtt_sd);
      643 +                tcp->tcp_rto = tcp_calculate_rto(tcp, tcps, 0);
 652  644          }
 653  645          if (uinfo.iulp_ssthresh != 0)
 654  646                  tcp->tcp_cwnd_ssthresh = uinfo.iulp_ssthresh;
 655  647          else
 656  648                  tcp->tcp_cwnd_ssthresh = TCP_MAX_LARGEWIN;
 657  649          if (uinfo.iulp_spipe > 0) {
 658  650                  connp->conn_sndbuf = MIN(uinfo.iulp_spipe,
 659  651                      tcps->tcps_max_buf);
 660  652                  if (tcps->tcps_snd_lowat_fraction != 0) {
 661  653                          connp->conn_sndlowat = connp->conn_sndbuf /
↓ open down ↓ 1665 lines elided ↑ open up ↑
2327 2319  
2328 2320  /*
2329 2321   * Initialize the various fields in tcp_t.  If parent (the listener) is non
2330 2322   * NULL, certain values will be inheritted from it.
2331 2323   */
2332 2324  void
2333 2325  tcp_init_values(tcp_t *tcp, tcp_t *parent)
2334 2326  {
2335 2327          tcp_stack_t     *tcps = tcp->tcp_tcps;
2336 2328          conn_t          *connp = tcp->tcp_connp;
2337      -        clock_t         rto;
2338 2329  
2339 2330          ASSERT((connp->conn_family == AF_INET &&
2340 2331              connp->conn_ipversion == IPV4_VERSION) ||
2341 2332              (connp->conn_family == AF_INET6 &&
2342 2333              (connp->conn_ipversion == IPV4_VERSION ||
2343 2334              connp->conn_ipversion == IPV6_VERSION)));
2344 2335  
2345 2336          if (parent == NULL) {
2346 2337                  tcp->tcp_naglim = tcps->tcps_naglim_def;
2347 2338  
↓ open down ↓ 48 lines elided ↑ open up ↑
2396 2387                  tcp->tcp_init_cwnd = parent->tcp_init_cwnd;
2397 2388          }
2398 2389  
2399 2390          /*
2400 2391           * Initialize tcp_rtt_sa and tcp_rtt_sd so that the calculated RTO
2401 2392           * will be close to tcp_rexmit_interval_initial.  By doing this, we
2402 2393           * allow the algorithm to adjust slowly to large fluctuations of RTT
2403 2394           * during first few transmissions of a connection as seen in slow
2404 2395           * links.
2405 2396           */
2406      -        tcp->tcp_rtt_sa = tcp->tcp_rto_initial << 2;
2407      -        tcp->tcp_rtt_sd = tcp->tcp_rto_initial >> 1;
2408      -        rto = (tcp->tcp_rtt_sa >> 3) + tcp->tcp_rtt_sd +
2409      -            tcps->tcps_rexmit_interval_extra + (tcp->tcp_rtt_sa >> 5) +
2410      -            tcps->tcps_conn_grace_period;
2411      -        TCP_SET_RTO(tcp, rto);
     2397 +        tcp->tcp_rtt_sa = MSEC2NSEC(tcp->tcp_rto_initial) << 2;
     2398 +        tcp->tcp_rtt_sd = MSEC2NSEC(tcp->tcp_rto_initial) >> 1;
     2399 +        tcp->tcp_rto = tcp_calculate_rto(tcp, tcps,
     2400 +            tcps->tcps_conn_grace_period);
2412 2401  
2413 2402          tcp->tcp_timer_backoff = 0;
2414 2403          tcp->tcp_ms_we_have_waited = 0;
2415 2404          tcp->tcp_last_recv_time = ddi_get_lbolt();
2416 2405          tcp->tcp_cwnd_max = tcps->tcps_cwnd_max_;
2417 2406          tcp->tcp_cwnd_ssthresh = TCP_MAX_LARGEWIN;
2418 2407  
2419 2408          tcp->tcp_maxpsz_multiplier = tcps->tcps_maxpsz_multiplier;
2420 2409  
2421 2410          /* NOTE:  ISS is now set in tcp_set_destination(). */
↓ open down ↓ 2062 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX