From nobody Fri Jun 30 23:30:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QtBQM5W5mz4lFx8; Fri, 30 Jun 2023 23:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QtBQM541Fz3JPb; Fri, 30 Jun 2023 23:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688167851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xdyZg/wTP3znCUCvJRYdyny+KffCylaPK51q+iasv2c=; b=d+b8EAlpmKEwT6NXpj90YAQ2Upt9BnJfsTp26er8d/UKUgBoO1Rss9jeBm2IGs2JUtU1Pm LdiZ6L7CD8gsNlNKNW7+ydfn9yErJrXZYmZ4HEV+NRw5HEk8WNp6QqjhhgFSP/jFepcssT yNA7QTeqaBF66kh5L+w8g8Sil+TjeZLgiSyUWTbXnCGsZ/bPHvhWmRTUQbRti+xs2HhM68 S54BvpphauQfkbIdk4Ezpal4j7AwHIO8EYmee6BdGY4vD+bHA20DAxLI3U7B5fTJr3GKn3 OzMXjfrUO5M0BAH04BbFhqXLDb8Ur5HOftYBV1geG/4Yg1765LUPzfW4M4S2Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688167851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xdyZg/wTP3znCUCvJRYdyny+KffCylaPK51q+iasv2c=; b=a5AGX8B+GWNx9QwvrEPartAc1t7SzmF0QL7N/4OKnJdNl3ynDhtXax2QK+n650FOjJ+Xl3 5twDWHGScspvxGC5VUkwqDkZLfuDXljzPaM7oAdwostwAmUtEY/N58L6EQd9WZCLjQNrK0 zXBIoEH7ZuzlM7KIXktGzx2PU5ZHv/vKOkTEpoB5FM0QlPWxvhotqcefwHa9Y48Yp84NoC fCYC3R0GlHXZrL1L+WQxktMewk94Sct5kaj0XvUWvkGIAkPdJW+lSwCZDjAle9JpfzcN41 aS+O8pxdu+L+b0G87EAa6SWmXU415AKJoJKAJGBX+1EArWHxaqT5DjJ230aWUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688167851; a=rsa-sha256; cv=none; b=upFaWdYutp3huOez0MXZlcXxiPTaPn0ERluntkoGe99qUBf0610BruspvgrEdk2IkGETqO AtSuUblr55ep54IdZHQaOrViK2RLvIQb6LEVLv9fZCjL6rFlS8lwRyBkUjeWmXgRC8GyEJ u5z4DnYOaWmijoJPZS/oigUkY/XSR7i5hBdjwOf9ZBxnS3ICVDub7bwlPeSMK/89vxc/qQ WFAnBTG/922oDQijxvD4DVB/0eW/QSmkixxJP9mb7KcN7LNUclPWsURLeyceEb7SyStmEy wTKZriXzPH1gqRBfFSuiWobrLNOLVYsYItiymRksxDHvsrBbDR6Cl3YBx7/gMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QtBQM47CVz1HpP; Fri, 30 Jun 2023 23:30:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 35UNUpU3088345; Fri, 30 Jun 2023 23:30:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 35UNUpNX088344; Fri, 30 Jun 2023 23:30:51 GMT (envelope-from git) Date: Fri, 30 Jun 2023 23:30:51 GMT Message-Id: <202306302330.35UNUpNX088344@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 0631830a7a3c - main - siftr: document siftr probe to man page of the tcp provider List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0631830a7a3c9625f1678b0b6ab8b525ba5e3873 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=0631830a7a3c9625f1678b0b6ab8b525ba5e3873 commit 0631830a7a3c9625f1678b0b6ab8b525ba5e3873 Author: Michael Tuexen AuthorDate: 2023-06-30 22:13:00 +0000 Commit: Michael Tuexen CommitDate: 2023-06-30 22:18:15 +0000 siftr: document siftr probe to man page of the tcp provider This man page documents what is currently implemented in siftr.d. It doesn't work right now in head, but in stable/13. Follow-up commits will fix it for head. Reviewed by: cc, pauamma_gundo.com MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D40809 --- share/man/man4/dtrace_tcp.4 | 138 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 2 deletions(-) diff --git a/share/man/man4/dtrace_tcp.4 b/share/man/man4/dtrace_tcp.4 index 5372b1a858f0..205317819c56 100644 --- a/share/man/man4/dtrace_tcp.4 +++ b/share/man/man4/dtrace_tcp.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 29, 2023 +.Dd July 1, 2023 .Dt DTRACE_TCP 4 .Os .Sh NAME @@ -49,6 +49,7 @@ protocol "tcpinfo_t *" .Fn tcp:::state-change "void *" "csinfo_t *" "void *" "tcpsinfo_t *" "void *" \ "tcplsinfo_t *" +.Fn tcp:::siftr "siftrinfo_t *" .Sh DESCRIPTION The DTrace .Nm tcp @@ -65,6 +66,8 @@ All .Nm tcp probes except for .Fn tcp:::state-change +and +.Fn tcp:::siftr have the same number and type of arguments. The last three arguments are used to describe a TCP segment: the .Vt ipinfo_t @@ -136,6 +139,15 @@ Its first, third and fifth arguments are currently always Its last argument describes the from-state in the transition, and the to-state can be obtained from .Dv args[3]->tcps_state . +.Pp +The +.Fn tcp:::siftr +probe fires when a TCP segment is sent or received by the host. +For a detailed description see +.Xr siftr 4 . +The +.Vt siftrinfo_t +argument provides the information about the TCP connection. .Sh ARGUMENTS The .Vt pktinfo_t @@ -285,10 +297,111 @@ The valid TCP state values are given by the constants prefixed with in .Pa /usr/lib/dtrace/tcp.d . .El +.Pp +The +.Vt siftrinfo_t +type is used by the +.Fn tcp:::siftr +probe to provide the state of the TCP connection. +Its fields are: +.Bl -tag -width "u_int sent_inflight_bytes" -offset indent +.It Vt uint8_t direction +Direction of packet that triggered the log message. +Either +.Qq 0 +for in, or +.Qq 1 +for out. +.It Vt uint8_t ipver +The version of the IP protocol being used. +Either +.Qq 1 +for IPv4, or +.Qq 2 +for IPv6. +.It Vt uint32_t hash +Hash of the packet that triggered the log message. +.It Vt uint16_t tcp_localport +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 uint64_t snd_cwnd +The current congestion window (CWND) for the flow, in bytes. +.It Vt u_long snd_wnd +The current sending window for the flow, in bytes. +The post scaled value is reported, except during the initial handshake (first +few packets), during which time the unscaled value is reported. +.It Vt u_long rcv_wnd +The current receive window for the flow, in bytes. +The post scaled value is always reported. +.It Vt u_long snd_bwnd +The current bandwidth-controlled window for the flow, in bytes. +This field is currently unused and reported as zero. +.It Vt u_long snd_ssthresh +The slow start threshold (SSTHRESH) for the flow, in bytes. +.It Vt int conn_state +A TCP state. +The valid TCP state values are given by the constants prefixed with +.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 int smoothed_rtt +The current smoothed RTT estimate for the flow, in units of TCP_RTT_SCALE * HZ, +where TCP_RTT_SCALE is a define found in +.Pa /usr/include/netinet/tcp_var.h , +and HZ is the kernel's tick timer. +Divide by TCP_RTT_SCALE * HZ to get the RTT in secs. +.It Vt u_char sack_enabled +SACK enabled indicator. 1 if SACK enabled, 0 otherwise. +.It Vt u_char snd_scale +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 +The current value of the t_flags for the flow. +.It Vt int rxt_length +The current retransmission timeout length for the flow, in units of HZ, where HZ +is the kernel's tick timer. +Divide by HZ to get the timeout length in seconds. +.It Vt u_int snd_buf_hiwater +The current size of the socket send buffer in bytes. +.It Vt u_int snd_buf_cc +The current number of bytes in the socket send buffer. +.It Vt u_int rcv_buf_hiwater +The current size of the socket receive buffer in bytes. +.It Vt u_int rcv_buf_cc +The current number of bytes in the socket receive buffer. +.It Vt u_int sent_inflight_bytes +The current number of unacknowledged bytes in-flight. +Bytes acknowledged via SACK are not excluded from this count. +.It Vt int t_segqlen +The current number of segments in the reassembly queue. +.It Vt u_int flowid +Flowid for the connection. +A caveat: Zero '0' either represents a valid flowid or a default value when +the flowid is not being set. +.It Vt u_int flowtype +Flow type for the connection. +Flowtype defines which protocol fields are hashed to produce the flowid. +A complete listing is available in +.Pa /usr/include/sys/mbuf.h +under +.Dv M_HASHTYPE_* . +.El .Sh FILES -.Bl -tag -width "/usr/lib/dtrace/tcp.d" -compact +.Bl -tag -width "/usr/lib/dtrace/siftr.d" -compact .It Pa /usr/lib/dtrace/tcp.d +DTrace type and translator definitions for all the probes of the +.Nm tcp +provider except the +.Nm siftr +probe. +.It Pa /usr/lib/dtrace/siftr.d DTrace type and translator definitions for the +.Nm siftr +probe of the .Nm tcp provider. .El @@ -367,6 +480,26 @@ tcp:::state-change last[args[1]->cs_cid] = timestamp; } .Ed +The following script uses the siftr probe to show the current value of CWND +and SSTHRESH when a packet is sent or received: +.Bd -literal -offset indent +#pragma D option quiet +#pragma D option switchrate=10hz + +dtrace:::BEGIN +{ + printf(" %3s %5s %5s %10s %10s\\n", + "DIR", "LPORT", "RPORT", "CWND", "SSTHRESH"); +} + +tcp:::siftr +{ + printf(" %3s %5d %5d %10d %10d\\n", + siftr_dir_string[args[0]->direction], + args[0]->tcp_localport, args[0]->tcp_foreignport, + args[0]->snd_cwnd, args[0]->snd_ssthresh); +} +.Ed .Sh COMPATIBILITY This provider is compatible with the .Nm tcp @@ -377,6 +510,7 @@ provider in Solaris. .Xr dtrace_sctp 4 , .Xr dtrace_udp 4 , .Xr dtrace_udplite 4 , +.Xr siftr 4 , .Xr tcp 4 , .Xr SDT 9 .Sh HISTORY