diff --git a/cddl/lib/libdtrace/siftr.d b/cddl/lib/libdtrace/siftr.d --- a/cddl/lib/libdtrace/siftr.d +++ b/cddl/lib/libdtrace/siftr.d @@ -21,6 +21,7 @@ * $FreeBSD$ */ +#pragma D depends_on library ip.d #pragma D depends_on module kernel #pragma D depends_on module siftr #pragma D depends_on provider tcp @@ -44,20 +45,22 @@ struct timeval tval; uint8_t direction; uint8_t ipver; - uint16_t tcp_localport; - uint16_t tcp_foreignport; + uint16_t lport; + uint16_t rport; + string laddr; + string raddr; uint32_t snd_cwnd; uint32_t snd_wnd; uint32_t rcv_wnd; uint32_t t_flags2; uint32_t snd_ssthresh; int conn_state; - u_int max_seg_size; + uint32_t mss; uint32_t srtt; u_char sack_enabled; u_char snd_scale; u_char rcv_scale; - u_int flags; + u_int t_flags; uint32_t rto; u_int snd_buf_hiwater; u_int snd_buf_cc; @@ -73,20 +76,28 @@ translator siftrinfo_t < struct pkt_node *p > { direction = p == NULL ? 0 : p->direction; ipver = p == NULL ? 0 : p->ipver; - tcp_localport = p == NULL ? 0 : ntohs(p->tcp_localport); - tcp_foreignport = p == NULL ? 0 : ntohs(p->tcp_foreignport); + lport = p == NULL ? 0 : ntohs(p->lport); + rport = p == NULL ? 0 : ntohs(p->fport); + laddr = p == NULL ? "" : + p->ipver == INP_IPV4 ? + inet_ntoa(&p->laddr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->laddr.id6_addr); + raddr = p == NULL ? "" : + p->ipver == INP_IPV4 ? + inet_ntoa(&p->faddr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->faddr.id6_addr); snd_cwnd = p == NULL ? 0 : p->snd_cwnd; snd_wnd = p == NULL ? 0 : p->snd_wnd; rcv_wnd = p == NULL ? 0 : p->rcv_wnd; t_flags2 = p == NULL ? 0 : p->t_flags2; snd_ssthresh = p == NULL ? 0 : p->snd_ssthresh; conn_state = p == NULL ? 0 : p->conn_state; - max_seg_size = p == NULL ? 0 : p->max_seg_size; + mss = p == NULL ? 0 : p->mss; srtt = p == NULL ? 0 : p->srtt; sack_enabled = p == NULL ? 0 : p->sack_enabled; snd_scale = p == NULL ? 0 : p->snd_scale; rcv_scale = p == NULL ? 0 : p->rcv_scale; - flags = p == NULL ? 0 : p->flags; + t_flags = p == NULL ? 0 : p->t_flags; rto = p == NULL ? 0 : p->rto; snd_buf_hiwater = p == NULL ? 0 : p->snd_buf_hiwater; snd_buf_cc = p == NULL ? 0 : p->snd_buf_cc; diff --git a/share/man/man4/dtrace_tcp.4 b/share/man/man4/dtrace_tcp.4 --- a/share/man/man4/dtrace_tcp.4 +++ b/share/man/man4/dtrace_tcp.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 1, 2023 +.Dd July 2, 2023 .Dt DTRACE_TCP 4 .Os .Sh NAME @@ -319,10 +319,14 @@ for IPv4, or .Qq 2 for IPv6. -.It Vt uint16_t tcp_localport +.It Vt uint16_t lport The TCP port that the local host is communicating via. -.It Vt uint16_t tcp_foreignport -The TCP port that the foreign host is communicating via. +.It Vt uint16_t rport +The TCP port that the remote host is communicating via. +.It Vt string laddr +The IPv4 or IPv6 address of the local host. +.It Vt string raddr +The IPv4 or IPv6 address of the remote host. .It Vt uint32_t snd_cwnd The current congestion window (CWND) for the flow, in bytes. .It Vt uint32_t snd_wnd @@ -342,8 +346,8 @@ .Ql TCPS_ in .Pa /usr/lib/dtrace/tcp.d . -.It Vt u_int max_seg_size -The maximum segment size for the flow, in bytes. +.It Vt uint32_t mss +The maximum segment size (MSS) for the flow, in bytes. .It Vt uint32_t srtt The current smoothed RTT (SRTT) for the flow in microseconds. .It Vt u_char sack_enabled @@ -352,7 +356,7 @@ The current window scaling factor for the sending window. .It Vt u_char rcv_scale The current window scaling factor for the receiving window. -.It Vt u_int flags +.It Vt u_int t_flags The current value of the t_flags for the flow. .It Vt uint32_t rto The current retransmission timeout (RTO) for the flow in microseconds. @@ -480,15 +484,15 @@ dtrace:::BEGIN { - printf(" %3s %5s %5s %10s %10s\\n", - "DIR", "LPORT", "RPORT", "CWND", "SSTHRESH"); + printf(" %3s %16s:%-5s %16s:%-5s %10s %10s\\n", + "DIR", "LADDR", "LPORT", "RADDR", "RPORT", "CWND", "SSTHRESH"); } tcp:::siftr { - printf(" %3s %5d %5d %10d %10d\\n", + printf(" %3s %16s:%-5d %16s:%-5d %10u %10u\\n", siftr_dir_string[args[0]->direction], - args[0]->tcp_localport, args[0]->tcp_foreignport, + args[0]->laddr, args[0]->lport, args[0]->raddr, args[0]->rport, args[0]->snd_cwnd, args[0]->snd_ssthresh); } .Ed diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -163,9 +163,13 @@ /* IP version pkt_node relates to; either INP_IPV4 or INP_IPV6. */ uint8_t ipver; /* Local TCP port. */ - uint16_t tcp_localport; + uint16_t lport; /* Foreign TCP port. */ - uint16_t tcp_foreignport; + uint16_t fport; + /* Local address. */ + union in_dependaddr laddr; + /* Foreign address. */ + union in_dependaddr faddr; /* Congestion Window (bytes). */ uint32_t snd_cwnd; /* Sending Window (bytes). */ @@ -179,7 +183,7 @@ /* Current state of the TCP FSM. */ int conn_state; /* Max Segment Size (bytes). */ - u_int max_seg_size; + uint32_t mss; /* Smoothed RTT (usecs). */ uint32_t srtt; /* Is SACK enabled? */ @@ -189,7 +193,7 @@ /* Window scaling for recv window. */ u_char rcv_scale; /* TCP control block flags. */ - u_int flags; + u_int t_flags; /* Retransmission timeout (usec). */ uint32_t rto; /* Size of the TCP send buffer in bytes. */ @@ -427,10 +431,10 @@ pkt_node->snd_scale, pkt_node->rcv_scale, pkt_node->conn_state, - pkt_node->max_seg_size, + pkt_node->mss, pkt_node->srtt, pkt_node->sack_enabled, - pkt_node->flags, + pkt_node->t_flags, pkt_node->rto, pkt_node->snd_buf_hiwater, pkt_node->snd_buf_cc, @@ -642,8 +646,10 @@ int ipver, int dir, int inp_locally_locked) { pn->ipver = ipver; - pn->tcp_localport = inp->inp_lport; - pn->tcp_foreignport = inp->inp_fport; + pn->lport = inp->inp_lport; + pn->fport = inp->inp_fport; + pn->laddr = inp->inp_inc.inc_ie.ie_dependladdr; + pn->faddr = inp->inp_inc.inc_ie.ie_dependfaddr; pn->snd_cwnd = tp->snd_cwnd; pn->snd_wnd = tp->snd_wnd; pn->rcv_wnd = tp->rcv_wnd; @@ -652,10 +658,10 @@ pn->snd_scale = tp->snd_scale; pn->rcv_scale = tp->rcv_scale; pn->conn_state = tp->t_state; - pn->max_seg_size = tp->t_maxseg; + pn->mss = tp->t_maxseg; pn->srtt = ((uint64_t)tp->t_srtt * tick) >> TCP_RTT_SHIFT; pn->sack_enabled = (tp->t_flags & TF_SACK_PERMIT) != 0; - pn->flags = tp->t_flags; + pn->t_flags = tp->t_flags; pn->rto = tp->t_rxtcur * tick; pn->snd_buf_hiwater = inp->inp_socket->so_snd.sb_hiwat; pn->snd_buf_cc = sbused(&inp->inp_socket->so_snd);