From 5d06879adb95ac922703072a28fc11048d809a4b Mon Sep 17 00:00:00 2001 From: "George V. Neville-Neil" Date: Sun, 13 Sep 2015 15:50:55 +0000 Subject: [PATCH] dd DTrace probe points, translators and a corresponding script to provide the TCPDEBUG functionality with pure DTrace. Reviewed by: rwatson MFC after: 2 weeks Sponsored by: Limelight Networks Differential Revision: D3530 --- cddl/lib/libdtrace/tcp.d | 133 ++++++++++++++++++++++++++++++- share/dtrace/tcpdebug | 165 +++++++++++++++++++++++++++++++++++++++ sys/netinet/in_kdtrace.c | 19 +++++ sys/netinet/in_kdtrace.h | 10 +++ sys/netinet/tcp_input.c | 8 ++ sys/netinet/tcp_output.c | 1 + sys/netinet/tcp_subr.c | 1 + sys/netinet/tcp_timer.c | 7 ++ sys/netinet/tcp_usrreq.c | 17 ++++ 9 files changed, 360 insertions(+), 1 deletion(-) create mode 100755 share/dtrace/tcpdebug diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index 8398cd3ec6ad..da55c1daf787 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -103,11 +103,15 @@ typedef struct tcpsinfo { int32_t tcps_state; /* TCP state */ uint32_t tcps_iss; /* Initial sequence # sent */ uint32_t tcps_suna; /* sequence # sent but unacked */ + uint32_t tcps_smax; /* highest sequence number sent */ uint32_t tcps_snxt; /* next sequence # to send */ uint32_t tcps_rack; /* sequence # we have acked */ uint32_t tcps_rnxt; /* next sequence # expected */ uint32_t tcps_swnd; /* send window size */ int32_t tcps_snd_ws; /* send window scaling */ + uint32_t tcps_swl1; /* window update seg seq number */ + uint32_t tcps_swl2; /* window update seg ack number */ + uint32_t tcps_rup; /* receive urgent pointer */ uint32_t tcps_rwnd; /* receive window size */ int32_t tcps_rcv_ws; /* receive window scaling */ uint32_t tcps_cwnd; /* congestion window */ @@ -117,7 +121,8 @@ typedef struct tcpsinfo { uint32_t tcps_rto; /* round-trip timeout, msec */ uint32_t tcps_mss; /* max segment size */ int tcps_retransmit; /* retransmit send event, boolean */ - int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ + int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ + int tcps_debug; /* socket has SO_DEBUG set */ } tcpsinfo_t; /* @@ -188,12 +193,16 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_state = p == NULL ? -1 : p->t_state; tcps_iss = p == NULL ? 0 : p->iss; tcps_suna = p == NULL ? 0 : p->snd_una; + tcps_smax = p == NULL ? 0 : p->snd_max; tcps_snxt = p == NULL ? 0 : p->snd_nxt; tcps_rack = p == NULL ? 0 : p->last_ack_sent; tcps_rnxt = p == NULL ? 0 : p->rcv_nxt; tcps_swnd = p == NULL ? -1 : p->snd_wnd; tcps_snd_ws = p == NULL ? -1 : p->snd_scale; + tcps_swl1 = p == NULL ? -1 : p->snd_wl1; + tcps_swl2 = p == NULL ? -1 : p->snd_wl2; tcps_rwnd = p == NULL ? -1 : p->rcv_wnd; + tcps_rup = p == NULL ? -1 : p->rcv_up; tcps_rcv_ws = p == NULL ? -1 : p->rcv_scale; tcps_cwnd = p == NULL ? -1 : p->snd_cwnd; tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh; @@ -203,6 +212,8 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_mss = p == NULL ? -1 : p->t_maxseg; tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ + tcps_debug = p == NULL ? 0 : + p->t_inpcb->inp_socket->so_options & 1; }; #pragma D binding "1.6.3" translator @@ -242,3 +253,123 @@ translator tcpinfoh_t < struct tcphdr *p > { translator tcplsinfo_t < int s > { tcps_state = s; }; + + +/* Support for TCP debug */ + +#pragma D binding "1.12.1" TA_INPUT +inline int TA_INPUT = 0; +#pragma D binding "1.12.1" TA_OUTPUT +inline int TA_OUTPUT = 1; +#pragma D binding "1.12.1" TA_USER +inline int TA_USER = 2; +#pragma D binding "1.12.1" TA_RESPOND +inline int TA_RESPOND = 3; +#pragma D binding "1.12.1" TA_DROP +inline int TA_DROP = 4; + +/* direction strings. */ + +#pragma D binding "1.12.1" tcpdebug_dir_string +inline string tcpdebug_dir_string[uint8_t direction] = + direction == TA_INPUT ? "input" : + direction == TA_OUTPUT ? "output" : + direction == TA_USER ? "user" : + direction == TA_RESPOND ? "respond" : + direction == TA_OUTPUT ? "drop" : + "unknown" ; + +#pragma D binding "1.12.1" tcpflag_string +inline string tcpflag_string[uint8_t flags] = + flags & TH_FIN ? "FIN" : + flags & TH_SYN ? "SYN" : + flags & TH_RST ? "RST" : + flags & TH_PUSH ? "PUSH" : + flags & TH_ACK ? "ACK" : + flags & TH_URG ? "URG" : + flags & TH_ECE ? "ECE" : + flags & TH_CWR ? "CWR" : + "unknown" ; + +#pragma D binding "1.12.1" PRU_ATTACH +inline int PRU_ATTACH = 0; +#pragma D binding "1.12.1" PRU_DETACH +inline int PRU_DETACH = 1; +#pragma D binding "1.12.1" PRU_BIND +inline int PRU_BIND = 2; +#pragma D binding "1.12.1" PRU_LISTEN +inline int PRU_LISTEN = 3; +#pragma D binding "1.12.1" PRU_CONNECT +inline int PRU_CONNECT = 4; +#pragma D binding "1.12.1" PRU_ACCEPT +inline int PRU_ACCEPT = 5 ; +#pragma D binding "1.12.1" PRU_DISCONNECT +inline int PRU_DISCONNECT= 6; +#pragma D binding "1.12.1" PRU_SHUTDOWN +inline int PRU_SHUTDOWN = 7; +#pragma D binding "1.12.1" PRU_RCVD +inline int PRU_RCVD = 8; +#pragma D binding "1.12.1" PRU_SEND +inline int PRU_SEND = 9; +#pragma D binding "1.12.1" PRU_ABORT +inline int PRU_ABORT = 10; +#pragma D binding "1.12.1" PRU_CONTROL +inline int PRU_CONTROL = 11; +#pragma D binding "1.12.1" PRU_SENSE +inline int PRU_SENSE = 12; +#pragma D binding "1.12.1" PRU_RCVOOB +inline int PRU_RCVOOB = 13; +#pragma D binding "1.12.1" PRU_SENDOOB +inline int PRU_SENDOOB = 14; +#pragma D binding "1.12.1" PRU_SOCKADDR +inline int PRU_SOCKADDR = 15; +#pragma D binding "1.12.1" PRU_PEERADDR +inline int PRU_PEERADDR = 16; +#pragma D binding "1.12.1" PRU_CONNECT2 +inline int PRU_CONNECT2 = 17; +#pragma D binding "1.12.1" PRU_FASTTIMO +inline int PRU_FASTTIMO = 18; +#pragma D binding "1.12.1" PRU_SLOWTIMO +inline int PRU_SLOWTIMO = 19; +#pragma D binding "1.12.1" PRU_PROTORCV +inline int PRU_PROTORCV = 20; +#pragma D binding "1.12.1" PRU_PROTOSEND +inline int PRU_PROTOSEND = 21; +#pragma D binding "1.12.1" PRU_SEND_EOF +inline int PRU_SEND_EOF = 22; +#pragma D binding "1.12.1" PRU_SOSETLABEL +inline int PRU_SOSETLABEL = 23; +#pragma D binding "1.12.1" PRU_CLOSE +inline int PRU_CLOSE = 24; +#pragma D binding "1.12.1" PRU_FLUSH +inline int PRU_FLUSH = 25; + +#pragma D binding "1.12.1" prureq_string +inline string prureq_string[uint8_t req] = + req == PRU_ATTACH ? "ATTACH" : + req == PRU_DETACH ? "DETACH" : + req == PRU_BIND ? "BIND" : + req == PRU_LISTEN ? "LISTEN" : + req == PRU_CONNECT ? "CONNECT" : + req == PRU_ACCEPT ? "ACCEPT" : + req == PRU_DISCONNECT ? "DISCONNECT" : + req == PRU_SHUTDOWN ? "SHUTDOWN" : + req == PRU_RCVD ? "RCVD" : + req == PRU_SEND ? "SEND" : + req == PRU_ABORT ? "ABORT" : + req == PRU_CONTROL ? "CONTROL" : + req == PRU_SENSE ? "SENSE" : + req == PRU_RCVOOB ? "RCVOOB" : + req == PRU_SENDOOB ? "SENDOOB" : + req == PRU_SOCKADDR ? "SOCKADDR" : + req == PRU_PEERADDR ? "PEERADDR" : + req == PRU_CONNECT2 ? "CONNECT2" : + req == PRU_FASTTIMO ? "FASTTIMO" : + req == PRU_SLOWTIMO ? "SLOWTIMO" : + req == PRU_PROTORCV ? "PROTORCV" : + req == PRU_PROTOSEND ? "PROTOSEND" : + req == PRU_SEND ? "SEND_EOF" : + req == PRU_SOSETLABEL ? "SOSETLABEL" : + req == PRU_CLOSE ? "CLOSE" : + req == PRU_FLUSH ? "FLUSE" : + "unknown" ; diff --git a/share/dtrace/tcpdebug b/share/dtrace/tcpdebug new file mode 100755 index 000000000000..411aaf386ef3 --- /dev/null +++ b/share/dtrace/tcpdebug @@ -0,0 +1,165 @@ +#!/usr/sbin/dtrace -s +/* + * Copyright (c) 2015 George V. Neville-Neil + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + * The tcpdebug D script uses the tcp:kernel::debug tracepoints + * to replicate the action of turning on TCPDEBUG in a kernel configuration. + * + * A TCP debug statement shows a connection's + * + * direction: input, output, user, drop + * state: CLOSED, LISTEN, SYN_SENT, SYN_RCVD, ESTABLISHED, + * CLOSE_WAIT, FIN_WAIT_1, CLOSING, LAST_ACK, FIN_WAIT_2,TIME_WAIT + * sequence: sequence space + * + * congestion: rcv_nxt, rcv_wnd, rcv_up, snd_una, snd_nxt, snx_max, + * snd_wl1, snd_wl2, snd_wnd + * + * NOTE: Only sockets with SO_DEBUG set will be shown. + * + * Usage: tcpdebug + */ + +#pragma D option quiet +tcp:kernel::debug-input +/args[0]->tcps_debug/ +{ + seq = args[1]->tcp_seq; + ack = args[1]->tcp_ack; + len = args[2]->ip_plength - sizeof(struct tcphdr); + flags = args[1]->tcp_flags; + + printf("%p %s: input [%xu..%xu]", arg0, + tcp_state_string[args[0]->tcps_state], seq, seq + len); + + printf("@%x, urp=%x", ack, args[1]->tcp_urgent); + + printf("%s", flags != 0 ? "<" : ""); + printf("%s", flags & TH_SYN ? "SYN," :""); + printf("%s", flags & TH_ACK ? "ACK," :""); + printf("%s", flags & TH_FIN ? "FIN," :""); + printf("%s", flags & TH_RST ? "RST," :""); + printf("%s", flags & TH_PUSH ? "PUSH," :""); + printf("%s", flags & TH_URG ? "URG," :""); + printf("%s", flags & TH_ECE ? "ECE," :""); + printf("%s", flags & TH_CWR ? "CWR" :""); + printf("%s", flags != 0 ? ">" : ""); + + printf("\n"); + printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n", + args[0]->tcps_rnxt, args[0]->tcps_rwnd, args[0]->tcps_rup, + args[0]->tcps_suna, args[0]->tcps_snxt, args[0]->tcps_smax); + printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n", + args[0]->tcps_swl1, args[0]->tcps_swl2, args[0]->tcps_swnd); + +} + +tcp:kernel::debug-output +/args[0]->tcps_debug/ +{ + seq = args[1]->tcp_seq; + ack = args[1]->tcp_ack; + len = args[2]->ip_plength - 20; + + printf("%p %s: output [%x..%x]", arg0, + tcp_state_string[args[0]->tcps_state], seq, seq + len); + + printf("@%x, urp=%x", ack, args[1]->tcp_urgent); + + printf("%s", flags != 0 ? "<" : ""); + printf("%s", flags & TH_SYN ? "SYN," :""); + printf("%s", flags & TH_ACK ? "ACK," :""); + printf("%s", flags & TH_FIN ? "FIN," :""); + printf("%s", flags & TH_RST ? "RST," :""); + printf("%s", flags & TH_PUSH ? "PUSH," :""); + printf("%s", flags & TH_URG ? "URG," :""); + printf("%s", flags & TH_ECE ? "ECE," :""); + printf("%s", flags & TH_CWR ? "CWR" :""); + printf("%s", flags != 0 ? ">" : ""); + + printf("\n"); + printf("\trcv_(nxt,wnd,up) (%u,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n", + args[0]->tcps_rnxt, args[0]->tcps_rwnd, args[0]->tcps_rup, + args[0]->tcps_suna, args[0]->tcps_snxt, args[0]->tcps_smax); + printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n", + args[0]->tcps_swl1, args[0]->tcps_swl2, args[0]->tcps_swnd); + +} + +tcp:kernel::debug-drop +/args[0]->tcps_debug/ +{ + printf("%p %s: output [x..x] @%x, urp=%x\n", arg0, + tcp_state_string[args[0]->tcps_state], + args[1]->tcp_ack, + args[1]->tcp_urgent); + + seq = args[1]->tcp_seq; + ack = args[1]->tcp_ack; + len = args[2]->ip_plength; + + printf("%p %s: drop [%x..%x]", arg0, + tcp_state_string[args[0]->tcps_state], seq, seq + len); + + printf("@%x, urp=%x", ack, args[1]->tcp_urgent); + + printf("%s", flags != 0 ? "<" : ""); + printf("%s", flags & TH_SYN ? "SYN," :""); + printf("%s", flags & TH_ACK ? "ACK," :""); + printf("%s", flags & TH_FIN ? "FIN," :""); + printf("%s", flags & TH_RST ? "RST," :""); + printf("%s", flags & TH_PUSH ? "PUSH," :""); + printf("%s", flags & TH_URG ? "URG," :""); + printf("%s", flags & TH_ECE ? "ECE," :""); + printf("%s", flags & TH_CWR ? "CWR" :""); + printf("%s", flags != 0 ? ">" : ""); + + printf("\n"); + printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n", + args[0]->tcps_rnxt, args[0]->tcps_rwnd, args[0]->tcps_rup, + args[0]->tcps_suna, args[0]->tcps_snxt, args[0]->tcps_smax); + printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n", + args[0]->tcps_swl1, args[0]->tcps_swl2, args[0]->tcps_swnd); + +} + +tcp:kernel::debug-user +/args[0]->tcps_debug/ +{ + printf("%p %s: user ", arg0, + tcp_state_string[args[0]->tcps_state]); + + printf("%s", prureq_string[arg1]); + printf("\n"); + printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n", + args[0]->tcps_rnxt, args[0]->tcps_rwnd, args[0]->tcps_rup, + args[0]->tcps_suna, args[0]->tcps_snxt, args[0]->tcps_smax); + printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n", + args[0]->tcps_swl1, args[0]->tcps_swl2, args[0]->tcps_swnd); + +} + diff --git a/sys/netinet/in_kdtrace.c b/sys/netinet/in_kdtrace.c index edcc85383a45..f39f0e88b185 100644 --- a/sys/netinet/in_kdtrace.c +++ b/sys/netinet/in_kdtrace.c @@ -105,6 +105,25 @@ SDT_PROBE_DEFINE5_XLATE(tcp, , , send, SDT_PROBE_DEFINE1_XLATE(tcp, , , siftr, "struct pkt_node *", "siftrinfo_t *"); +SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__input, + "struct tcpcb *", "tcpsinfo_t *" , + "struct tcphdr *", "tcpinfo_t *", + "uint8_t *", "ipinfo_t *"); + +SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__output, + "struct tcpcb *", "tcpsinfo_t *" , + "struct tcphdr *", "tcpinfo_t *", + "uint8_t *", "ipinfo_t *"); + +SDT_PROBE_DEFINE2_XLATE(tcp, , , debug__user, + "struct tcpcb *", "tcpsinfo_t *" , + "int", "int"); + +SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__drop, + "struct tcpcb *", "tcpsinfo_t *" , + "struct tcphdr *", "tcpinfo_t *", + "uint8_t *", "ipinfo_t *") + SDT_PROBE_DEFINE6_XLATE(tcp, , , state__change, "void *", "void *", "struct tcpcb *", "csinfo_t *", diff --git a/sys/netinet/in_kdtrace.h b/sys/netinet/in_kdtrace.h index c0511d084b77..ba8355a17c84 100644 --- a/sys/netinet/in_kdtrace.h +++ b/sys/netinet/in_kdtrace.h @@ -34,6 +34,12 @@ SDT_PROBE5(udp, , , probe, arg0, arg1, arg2, arg3, arg4) #define TCP_PROBE1(probe, arg0) \ SDT_PROBE1(tcp, , , probe, arg0) +#define TCP_PROBE2(probe, arg0, arg1) \ + SDT_PROBE2(tcp, , , probe, arg0, arg1) +#define TCP_PROBE3(probe, arg0, arg1, arg2) \ + SDT_PROBE3(tcp, , , probe, arg0, arg1, arg2) +#define TCP_PROBE4(probe, arg0, arg1, arg2, arg3) \ + SDT_PROBE4(tcp, , , probe, arg0, arg1, arg2, arg3) #define TCP_PROBE5(probe, arg0, arg1, arg2, arg3, arg4) \ SDT_PROBE5(tcp, , , probe, arg0, arg1, arg2, arg3, arg4) #define TCP_PROBE6(probe, arg0, arg1, arg2, arg3, arg4, arg5) \ @@ -55,6 +61,10 @@ SDT_PROBE_DECLARE(tcp, , , receive); SDT_PROBE_DECLARE(tcp, , , send); SDT_PROBE_DECLARE(tcp, , , siftr); SDT_PROBE_DECLARE(tcp, , , state__change); +SDT_PROBE_DECLARE(tcp, , , debug__input); +SDT_PROBE_DECLARE(tcp, , , debug__output); +SDT_PROBE_DECLARE(tcp, , , debug__user); +SDT_PROBE_DECLARE(tcp, , , debug__drop); SDT_PROBE_DECLARE(udp, , , receive); SDT_PROBE_DECLARE(udp, , , send); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index e7ef6dbb80d8..83a7d3154717 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1377,6 +1377,7 @@ tcp_input(struct mbuf **mp, int *offp, int proto) tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); tcp_dooptions(&to, optp, optlen, TO_SYN); syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL); /* @@ -1779,6 +1780,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, + mtod(m, const char *)); if (tp->snd_una == tp->snd_max) tcp_timer_activate(tp, TT_REXMT, 0); else if (!tcp_timer_active(tp, TT_PERSIST)) @@ -1825,6 +1828,8 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); + /* * Automatic sizing of receive socket buffer. Often the send * buffer size is not optimally adjusted to the actual network @@ -3022,6 +3027,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); /* * Return any desired output. @@ -3069,6 +3075,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); if (ti_locked == TI_RLOCKED) INP_INFO_RUNLOCK(&V_tcbinfo); ti_locked = TI_UNLOCKED; @@ -3109,6 +3116,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen, &tcp_savetcp, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); if (tp != NULL) INP_WUNLOCK(tp->t_inpcb); m_freem(m); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 342990e22b70..9495135d4e86 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1253,6 +1253,7 @@ tcp_output(struct tcpcb *tp) ipov->ih_len = save; } #endif /* TCPDEBUG */ + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); /* * Fill in IP length and desired time to live and diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 207ad0312c34..b6f616cfd037 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -720,6 +720,7 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG)) tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0); #endif + TCP_PROBE3(debug__input, tp, th, mtod(m, const char *)); if (flags & TH_RST) TCP_PROBE5(accept__refused, NULL, NULL, mtod(m, const char *), tp, nth); diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 799064685ada..60b882f869f7 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -369,6 +370,8 @@ tcp_timer_2msl(void *xtp) tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0, PRU_SLOWTIMO); #endif + TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); + if (tp != NULL) INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); @@ -454,6 +457,7 @@ tcp_timer_keep(void *xtp) tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0, PRU_SLOWTIMO); #endif + TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); CURVNET_RESTORE(); @@ -468,6 +472,7 @@ tcp_timer_keep(void *xtp) tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0, PRU_SLOWTIMO); #endif + TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); if (tp != NULL) INP_WUNLOCK(tp->t_inpcb); INP_INFO_RUNLOCK(&V_tcbinfo); @@ -546,6 +551,7 @@ tcp_timer_persist(void *xtp) if (tp != NULL && tp->t_inpcb->inp_socket->so_options & SO_DEBUG) tcp_trace(TA_USER, ostate, tp, NULL, NULL, PRU_SLOWTIMO); #endif + TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); if (tp != NULL) INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); @@ -792,6 +798,7 @@ tcp_timer_rexmt(void * xtp) tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0, PRU_SLOWTIMO); #endif + TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); if (tp != NULL) INP_WUNLOCK(inp); if (headlocked) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index fe390e0e4513..cc50c9c0dbbf 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -146,6 +147,7 @@ tcp_usr_attach(struct socket *so, int proto, struct thread *td) tp = intotcpcb(inp); out: TCPDEBUG2(PRU_ATTACH); + TCP_PROBE2(debug__user, tp, PRU_ATTACH); return error; } @@ -295,6 +297,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) INP_HASH_WUNLOCK(&V_tcbinfo); out: TCPDEBUG2(PRU_BIND); + TCP_PROBE2(debug__user, tp, PRU_BIND); INP_WUNLOCK(inp); return (error); @@ -355,6 +358,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) INP_HASH_WUNLOCK(&V_tcbinfo); out: TCPDEBUG2(PRU_BIND); + TCP_PROBE2(debug__user, tp, PRU_BIND); INP_WUNLOCK(inp); return (error); } @@ -399,6 +403,7 @@ tcp_usr_listen(struct socket *so, int backlog, struct thread *td) out: TCPDEBUG2(PRU_LISTEN); + TCP_PROBE2(debug__user, tp, PRU_LISTEN); INP_WUNLOCK(inp); return (error); } @@ -444,6 +449,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct thread *td) out: TCPDEBUG2(PRU_LISTEN); + TCP_PROBE2(debug__user, tp, PRU_LISTEN); INP_WUNLOCK(inp); return (error); } @@ -592,6 +598,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) out: TCPDEBUG2(PRU_CONNECT); + TCP_PROBE2(debug__user, tp, PRU_CONNECT); INP_WUNLOCK(inp); return (error); } @@ -631,6 +638,7 @@ tcp_usr_disconnect(struct socket *so) tcp_disconnect(tp); out: TCPDEBUG2(PRU_DISCONNECT); + TCP_PROBE2(debug__user, tp, PRU_DISCONNECT); INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); return (error); @@ -674,6 +682,7 @@ tcp_usr_accept(struct socket *so, struct sockaddr **nam) out: TCPDEBUG2(PRU_ACCEPT); + TCP_PROBE2(debug__user, tp, PRU_ACCEPT); INP_WUNLOCK(inp); if (error == 0) *nam = in_sockaddr(port, &addr); @@ -724,6 +733,7 @@ tcp6_usr_accept(struct socket *so, struct sockaddr **nam) out: TCPDEBUG2(PRU_ACCEPT); + TCP_PROBE2(debug__user, tp, PRU_ACCEPT); INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); if (error == 0) { @@ -764,6 +774,7 @@ tcp_usr_shutdown(struct socket *so) out: TCPDEBUG2(PRU_SHUTDOWN); + TCP_PROBE2(debug__user, tp, PRU_SHUTDOWN); INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); @@ -799,6 +810,7 @@ tcp_usr_rcvd(struct socket *so, int flags) out: TCPDEBUG2(PRU_RCVD); + TCP_PROBE2(debug__user, tp, PRU_RCVD); INP_WUNLOCK(inp); return (error); } @@ -953,6 +965,8 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, out: TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB : ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); + TCP_PROBE2(debug__user, tp, (flags & PRUS_OOB) ? PRU_SENDOOB : + ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); INP_WUNLOCK(inp); if (flags & PRUS_EOF) INP_INFO_RUNLOCK(&V_tcbinfo); @@ -1013,6 +1027,7 @@ tcp_usr_abort(struct socket *so) TCPDEBUG1(); tcp_drop(tp, ECONNABORTED); TCPDEBUG2(PRU_ABORT); + TCP_PROBE2(debug__user, tp, PRU_ABORT); } if (!(inp->inp_flags & INP_DROPPED)) { SOCK_LOCK(so); @@ -1052,6 +1067,7 @@ tcp_usr_close(struct socket *so) TCPDEBUG1(); tcp_disconnect(tp); TCPDEBUG2(PRU_CLOSE); + TCP_PROBE2(debug__user, tp, PRU_CLOSE); } if (!(inp->inp_flags & INP_DROPPED)) { SOCK_LOCK(so); @@ -1101,6 +1117,7 @@ tcp_usr_rcvoob(struct socket *so, struct mbuf *m, int flags) out: TCPDEBUG2(PRU_RCVOOB); + TCP_PROBE2(debug__user, tp, PRU_RCVOOB); INP_WUNLOCK(inp); return (error); }