Skip to content

Commit

Permalink
tcp_info: Add and export more FreeBSD-specific fields
Browse files Browse the repository at this point in the history
This change adds struct tcp_info fields corresponding to the following
struct tcpcb ones:
- snd_una
- snd_max
- rcv_numsacks
- rcv_adv
- dupacks

Note that while both tcp_fill_info() and fill_tcp_info_from_tcb() are
extended accordingly, no counterpart of rcv_numsacks is available in
the cxgbe(4) TOE PCB, though.

Sponsored by:	NetApp, Inc. (originally)
  • Loading branch information
sparcplug committed Aug 22, 2023
1 parent 8c6104c commit dc485b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions sys/dev/cxgbe/tom/t4_tom.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,13 @@ fill_tcp_info_from_tcb(struct adapter *sc, uint64_t *tcb, struct tcp_info *ti)
ti->tcpi_snd_ssthresh = GET_TCB_FIELD(tcb, SND_SSTHRESH);
ti->tcpi_snd_cwnd = GET_TCB_FIELD(tcb, SND_CWND);
ti->tcpi_rcv_nxt = GET_TCB_FIELD(tcb, RCV_NXT);
ti->tcpi_rcv_adv = GET_TCB_FIELD(tcb, RCV_ADV);
ti->tcpi_dupacks = GET_TCB_FIELD(tcb, T_DUPACKS);

v = GET_TCB_FIELD(tcb, TX_MAX);
ti->tcpi_snd_nxt = v - GET_TCB_FIELD(tcb, SND_NXT_RAW);
ti->tcpi_snd_una = v - GET_TCB_FIELD(tcb, SND_UNA_RAW);
ti->tcpi_snd_max = v - GET_TCB_FIELD(tcb, SND_MAX_RAW);

/* Receive window being advertised by us. */
ti->tcpi_rcv_wscale = GET_TCB_FIELD(tcb, SND_SCALE); /* Yes, SND. */
Expand Down
8 changes: 7 additions & 1 deletion sys/netinet/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,14 @@ struct tcp_info {
u_int32_t tcpi_total_tlp; /* tail loss probes sent */
u_int64_t tcpi_total_tlp_bytes; /* tail loss probe bytes sent */

u_int32_t tcpi_snd_una; /* Unacked seqno sent */
u_int32_t tcpi_snd_max; /* Highest seqno sent */
u_int32_t tcpi_rcv_numsacks; /* Distinct SACK blks present */
u_int32_t tcpi_rcv_adv; /* Peer advertised window */
u_int32_t tcpi_dupacks; /* Consecutive dup ACKs recvd */

/* Padding to grow without breaking ABI. */
u_int32_t __tcpi_pad[19]; /* Padding. */
u_int32_t __tcpi_pad[14]; /* Padding. */
};

/*
Expand Down
5 changes: 5 additions & 0 deletions sys/netinet/tcp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,11 @@ tcp_fill_info(const struct tcpcb *tp, struct tcp_info *ti)
ti->tcpi_snd_rexmitpack = tp->t_sndrexmitpack;
ti->tcpi_rcv_ooopack = tp->t_rcvoopack;
ti->tcpi_snd_zerowin = tp->t_sndzerowin;
ti->tcpi_snd_una = tp->snd_una;
ti->tcpi_snd_max = tp->snd_max;
ti->tcpi_rcv_numsacks = tp->rcv_numsacks;
ti->tcpi_rcv_adv = tp->rcv_adv;
ti->tcpi_dupacks = tp->t_dupacks;
#ifdef TCP_OFFLOAD
if (tp->t_flags & TF_TOE) {
ti->tcpi_options |= TCPI_OPT_TOE;
Expand Down

0 comments on commit dc485b9

Please sign in to comment.