mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 14:26:03 -04:00
dtrace: improve siftr probe
Improve consistency of the field names with tcpsinfo_t: * Use mss instead of max_seg_size. * Use lport and rport instead of tcp_localport and tcp_foreignport. Use t_flags instead of flags to improve consistency with t_flags2. Add laddr and raddr, since the addresses were missing when compared to the output of siftr. Reviewed by: cc Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D40834
This commit is contained in:
parent
ccc806a049
commit
2176c9ab71
3 changed files with 50 additions and 32 deletions
|
|
@ -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 @@ typedef struct siftrinfo {
|
|||
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 @@ typedef struct siftrinfo {
|
|||
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 ? "<unknown>" :
|
||||
p->ipver == INP_IPV4 ?
|
||||
inet_ntoa(&p->laddr.id46_addr.ia46_addr4.s_addr) :
|
||||
inet_ntoa6(&p->laddr.id6_addr);
|
||||
raddr = p == NULL ? "<unknown>" :
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 1, 2023
|
||||
.Dd July 2, 2023
|
||||
.Dt DTRACE_TCP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -319,10 +319,14 @@ Either
|
|||
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 @@ 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 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 @@ SACK enabled indicator. 1 if SACK enabled, 0 otherwise.
|
|||
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 @@ and SSTHRESH when a packet is sent or received:
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -163,9 +163,13 @@ struct pkt_node {
|
|||
/* 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 @@ struct pkt_node {
|
|||
/* 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 @@ struct pkt_node {
|
|||
/* 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. */
|
||||
|
|
@ -223,7 +227,6 @@ struct flow_info
|
|||
#endif
|
||||
uint16_t lport; /* local TCP port */
|
||||
uint16_t fport; /* foreign TCP port */
|
||||
uint8_t ipver; /* IP version */
|
||||
uint32_t key; /* flowid of the connection */
|
||||
};
|
||||
|
||||
|
|
@ -427,10 +430,10 @@ siftr_process_pkt(struct pkt_node * pkt_node)
|
|||
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 +645,10 @@ siftr_siftdata(struct pkt_node *pn, struct inpcb *inp, struct tcpcb *tp,
|
|||
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 +657,10 @@ siftr_siftdata(struct pkt_node *pn, struct inpcb *inp, struct tcpcb *tp,
|
|||
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);
|
||||
|
|
@ -796,7 +801,6 @@ siftr_chkpkt(struct mbuf **m, struct ifnet *ifp, int flags,
|
|||
info.lport = ntohs(inp->inp_lport);
|
||||
info.fport = ntohs(inp->inp_fport);
|
||||
info.key = hash_id;
|
||||
info.ipver = INP_IPV4;
|
||||
|
||||
hash_node = siftr_new_hash_node(info, dir, ss);
|
||||
}
|
||||
|
|
@ -946,7 +950,6 @@ siftr_chkpkt6(struct mbuf **m, struct ifnet *ifp, int flags,
|
|||
info.lport = ntohs(inp->inp_lport);
|
||||
info.fport = ntohs(inp->inp_fport);
|
||||
info.key = hash_id;
|
||||
info.ipver = INP_IPV6;
|
||||
|
||||
hash_node = siftr_new_hash_node(info, dir, ss);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue