[tor-bugs] #12890 [Tor]: Design and implement optimizations for socket write limits

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Dec 18 04:48:08 UTC 2014


#12890: Design and implement optimizations for socket write limits
-----------------------------+--------------------------------
     Reporter:  robgjansen   |      Owner:  robgjansen
         Type:  enhancement  |     Status:  new
     Priority:  normal       |  Milestone:  Tor: 0.2.6.x-final
    Component:  Tor          |    Version:
   Resolution:               |   Keywords:  tor-relay
Actual Points:               |  Parent ID:  #12541
       Points:               |
-----------------------------+--------------------------------

Comment (by yawning):

 More regarding portability, since nickm was asking about it in IRC, and I
 went and actually looked at the code due to comments by other people that
 use TCP_INFO scaring me.

 References:
  * The [https://github.com/esnet/iperf/blob/master/src/tcp_info.c iperf
 code].
  * FXR [http://fxr.watson.org/fxr/source/netinet/tcp.h]

 The good:
  * Linux < 2.6.x does not support this, since this is when the call was
 added.
  * Windows depends on version (with a preference towards the Windows-ism
 added in Vista since it's a single call that appears to return all the
 necessary information).  The iperf people claim that TCP_INFO is
 supported, but I can't find documentation to back this up.

 The bad:
  * NetBSD/OpenBSD/Darwin do not support TCP_INFO.

 The ugly:
  * FreeBSD support was added in the FreeBSD 6.0 timeframe, *but* a bunch
 of values are missing (
 http://fxr.watson.org/fxr/source/netinet/tcp_usrreq.c#L1259) including a
 way to get "SND.UNA", making it effectively worthless ("SND.WND",
 "SND.NXT" and "cwnd" are insufficient to calculate the amount of inflight
 data).  However making it work is a trivial 1 line change to
 `tcp_usrreq.c:tcp_fill_info()`.

   {{{
     /* The full patch will want to rename tcp_info.__tcpi_unacked... */
     ti->__tcpi_unacked = tp->snd_una;
   }}}

   The FreeBSD version of the tcp_space calculation assuming the patch
 would be something like:
   {{{
     /*
      * Everything is in bytes, so none of that MSS sillyness.
      *
      * It's probably worth calculating the available space based off:
      *  wnd_size = min(ti.tcpi_snd_cwnd, ti.tcpi_snd_wnd)
      * instead of just tcpi_snd_cwnd since the information is already
      * in the tcp_info structure.
      */
     tcp_space = ti.tcpi_snd_cwnd - (ti.tcpi_snd_next - ti.__tcpi_unacked);
   }}}

 I assume that just using the `ioctl()` calls to get the send buffer
 capacity/current size on non-Linux/Windows platforms will still be an
 improvement, but it bums me out a bit.  If people want I can write the
 kernel patches for all of the BSDs (except Darwin, for obvious reasons).

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/12890#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list