Remove (struct tcpcb) from the API?

Jonathan Looney jonlooney at
Fri Oct 7 11:34:29 UTC 2016

On Thu, Oct 6, 2016 at 4:21 PM, Adrian Chadd <adrian.chadd at> wrote:

> Wait, I thought we had xtcpcb or something to face userland?

Yes, but the xtcpcb structure includes the entire (struct tcpcb):

    struct  xtcpcb {
            size_t  xt_len;
            struct  inpcb   xt_inp;
            struct  tcpcb   xt_tp;
            struct  xsocket xt_socket;
            struct  xtcp_timer xt_timer;
            u_quad_t        xt_alignment_hack;

And, in tcp_pcblist():

    struct xtcpcb xt;
    inp_ppcb = inp->inp_ppcb;
    bcopy(inp_ppcb, &xt.xt_tp, sizeof xt.xt_tp);

So, my proposal is to replace xt_tp with a minimal structure that includes
the (20 or so?) fields that userland actually cares about. Importantly, we
can then leave that structure as the stable API, while we are free to
modify the actual (struct tcpcb). Relatedly, this could cut down
substantially on the number of bytes we copy out for each TCP session
(which can really add up on a loaded box, and only adds to the overhead of
the locking).


More information about the freebsd-transport mailing list