svn commit: r316208 - in stable/11: cddl/lib/libdtrace sys/netinet sys/netinet/tcp_stacks
George V. Neville-Neil
gnn at FreeBSD.org
Thu Mar 30 02:38:32 UTC 2017
Author: gnn
Date: Thu Mar 30 02:38:30 2017
New Revision: 316208
URL: https://svnweb.freebsd.org/changeset/base/316208
Log:
MFC: 311225, 311243, 313045
Fix DTrace TCP tracepoints to not use mtod() as it is both unnecessary and
dangerous. Those wanting data from an mbuf should use DTrace itself to get
the data.
Add an mbuf to ipinfo_t translator to finish cleanup of mbuf passing to TCP probes.
Modified:
stable/11/cddl/lib/libdtrace/ip.d
stable/11/sys/netinet/in_kdtrace.c
stable/11/sys/netinet/tcp_input.c
stable/11/sys/netinet/tcp_output.c
stable/11/sys/netinet/tcp_stacks/fastpath.c
stable/11/sys/netinet/tcp_subr.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/cddl/lib/libdtrace/ip.d
==============================================================================
--- stable/11/cddl/lib/libdtrace/ip.d Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/cddl/lib/libdtrace/ip.d Thu Mar 30 02:38:30 2017 (r316208)
@@ -238,6 +238,24 @@ translator ipinfo_t < uint8_t *p > {
inet_ntoa6(&((struct ip6_hdr *)p)->ip6_dst);
};
+#pragma D binding "1.13" translator
+translator ipinfo_t < struct mbuf *m > {
+ ip_ver = m == NULL ? 0 : ((struct ip *)m->m_data)->ip_v;
+ ip_plength = m == NULL ? 0 :
+ ((struct ip *)m->m_data)->ip_v == 4 ?
+ ntohs(((struct ip *)m->m_data)->ip_len) -
+ (((struct ip *)m->m_data)->ip_hl << 2):
+ ntohs(((struct ip6_hdr *)m->m_data)->ip6_ctlun.ip6_un1.ip6_un1_plen);
+ ip_saddr = m == NULL ? 0 :
+ ((struct ip *)m->m_data)->ip_v == 4 ?
+ inet_ntoa(&((struct ip *)m->m_data)->ip_src.s_addr) :
+ inet_ntoa6(&((struct ip6_hdr *)m->m_data)->ip6_src);
+ ip_daddr = m == NULL ? 0 :
+ ((struct ip *)m->m_data)->ip_v == 4 ?
+ inet_ntoa(&((struct ip *)m->m_data)->ip_dst.s_addr) :
+ inet_ntoa6(&((struct ip6_hdr *)m->m_data)->ip6_dst);
+};
+
#pragma D binding "1.5" IFF_LOOPBACK
inline int IFF_LOOPBACK = 0x8;
Modified: stable/11/sys/netinet/in_kdtrace.c
==============================================================================
--- stable/11/sys/netinet/in_kdtrace.c Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/sys/netinet/in_kdtrace.c Thu Mar 30 02:38:30 2017 (r316208)
@@ -56,28 +56,28 @@ SDT_PROBE_DEFINE6_XLATE(ip, , , send,
SDT_PROBE_DEFINE5_XLATE(tcp, , , accept__established,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfoh_t *");
SDT_PROBE_DEFINE5_XLATE(tcp, , , accept__refused,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfo_t *");
SDT_PROBE_DEFINE5_XLATE(tcp, , , connect__established,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfoh_t *");
SDT_PROBE_DEFINE5_XLATE(tcp, , , connect__refused,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfoh_t *");
@@ -91,7 +91,7 @@ SDT_PROBE_DEFINE5_XLATE(tcp, , , connect
SDT_PROBE_DEFINE5_XLATE(tcp, , , receive,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfoh_t *");
@@ -113,7 +113,7 @@ SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__
SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__output,
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfo_t *",
- "uint8_t *", "ipinfo_t *");
+ "struct mbuf *", "ipinfo_t *");
SDT_PROBE_DEFINE2_XLATE(tcp, , , debug__user,
"struct tcpcb *", "tcpsinfo_t *" ,
@@ -122,7 +122,7 @@ SDT_PROBE_DEFINE2_XLATE(tcp, , , debug__
SDT_PROBE_DEFINE3_XLATE(tcp, , , debug__drop,
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfo_t *",
- "uint8_t *", "ipinfo_t *");
+ "struct mbuf *", "ipinfo_t *");
SDT_PROBE_DEFINE6_XLATE(tcp, , , state__change,
"void *", "void *",
Modified: stable/11/sys/netinet/tcp_input.c
==============================================================================
--- stable/11/sys/netinet/tcp_input.c Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/sys/netinet/tcp_input.c Thu Mar 30 02:38:30 2017 (r316208)
@@ -1371,7 +1371,7 @@ new_tfo_socket:
tcp_trace(TA_INPUT, ostate, tp,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
tcp_dooptions(&to, optp, optlen, TO_SYN);
#ifdef TCP_RFC7413
if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL))
@@ -1411,7 +1411,7 @@ new_tfo_socket:
goto dropunlock;
}
#endif
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
/*
* Segment belongs to a connection in SYN_SENT, ESTABLISHED or later
@@ -1423,7 +1423,7 @@ new_tfo_socket:
return (IPPROTO_DONE);
dropwithreset:
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
if (ti_locked == TI_RLOCKED) {
INP_INFO_RUNLOCK(&V_tcbinfo);
@@ -1447,7 +1447,7 @@ dropwithreset:
dropunlock:
if (m != NULL)
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
if (ti_locked == TI_RLOCKED) {
INP_INFO_RUNLOCK(&V_tcbinfo);
@@ -1784,8 +1784,7 @@ tcp_do_segment(struct mbuf *m, struct tc
(void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th,
- mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (tp->snd_una == tp->snd_max)
tcp_timer_activate(tp, TT_REXMT, 0);
else if (!tcp_timer_active(tp, TT_PERSIST))
@@ -1831,7 +1830,7 @@ tcp_do_segment(struct mbuf *m, struct tc
tcp_trace(TA_INPUT, ostate, tp,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Automatic sizing of receive socket buffer. Often the send
@@ -1993,7 +1992,7 @@ tcp_do_segment(struct mbuf *m, struct tc
}
if ((thflags & (TH_ACK|TH_RST)) == (TH_ACK|TH_RST)) {
TCP_PROBE5(connect__refused, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
tp = tcp_drop(tp, ECONNREFUSED);
}
if (thflags & TH_RST)
@@ -2046,7 +2045,7 @@ tcp_do_segment(struct mbuf *m, struct tc
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(connect__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
cc_conn_init(tp);
tcp_timer_activate(tp, TT_KEEP,
TP_KEEPIDLE(tp));
@@ -2426,7 +2425,7 @@ tcp_do_segment(struct mbuf *m, struct tc
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(accept__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
#ifdef TCP_RFC7413
if (tp->t_tfo_pending) {
tcp_fastopen_decrement_counter(tp->t_tfo_pending);
@@ -3139,7 +3138,7 @@ dodata: /* XXX */
tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Return any desired output.
@@ -3187,7 +3186,7 @@ dropafterack:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (ti_locked == TI_RLOCKED)
INP_INFO_RUNLOCK(&V_tcbinfo);
ti_locked = TI_UNLOCKED;
@@ -3228,7 +3227,7 @@ drop:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
m_freem(m);
Modified: stable/11/sys/netinet/tcp_output.c
==============================================================================
--- stable/11/sys/netinet/tcp_output.c Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/sys/netinet/tcp_output.c Thu Mar 30 02:38:30 2017 (r316208)
@@ -1351,7 +1351,7 @@ send:
ipov->ih_len = save;
}
#endif /* TCPDEBUG */
- TCP_PROBE3(debug__output, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__output, tp, th, m);
/*
* Fill in IP length and desired time to live and
Modified: stable/11/sys/netinet/tcp_stacks/fastpath.c
==============================================================================
--- stable/11/sys/netinet/tcp_stacks/fastpath.c Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/sys/netinet/tcp_stacks/fastpath.c Thu Mar 30 02:38:30 2017 (r316208)
@@ -297,7 +297,7 @@ tcp_do_fastack(struct mbuf *m, struct tc
(void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
m_freem(m);
if (tp->snd_una == tp->snd_max)
tcp_timer_activate(tp, TT_REXMT, 0);
@@ -389,7 +389,7 @@ tcp_do_fastnewdata(struct mbuf *m, struc
tcp_trace(TA_INPUT, ostate, tp,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Automatic sizing of receive socket buffer. Often the send
* buffer size is not optimally adjusted to the actual network
@@ -561,8 +561,7 @@ tcp_do_slowpath(struct mbuf *m, struct t
goto dropwithreset;
}
if ((thflags & (TH_ACK|TH_RST)) == (TH_ACK|TH_RST)) {
- TCP_PROBE5(connect__refused, NULL, tp,
- mtod(m, const char *), tp, th);
+ TCP_PROBE5(connect__refused, NULL, tp, m, tp, th);
tp = tcp_drop(tp, ECONNREFUSED);
}
if (thflags & TH_RST)
@@ -615,7 +614,7 @@ tcp_do_slowpath(struct mbuf *m, struct t
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(connect__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
cc_conn_init(tp);
tcp_timer_activate(tp, TT_KEEP,
TP_KEEPIDLE(tp));
@@ -986,7 +985,7 @@ tcp_do_slowpath(struct mbuf *m, struct t
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(accept__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
cc_conn_init(tp);
tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp));
}
@@ -1641,7 +1640,7 @@ dodata: /* XXX */
tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Return any desired output.
@@ -1688,7 +1687,7 @@ dropafterack:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__drop, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__drop, tp, th, m);
if (ti_locked == TI_RLOCKED) {
INP_INFO_RUNLOCK(&V_tcbinfo);
}
@@ -1731,7 +1730,7 @@ drop:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__drop, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__drop, tp, th, m);
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
m_freem(m);
@@ -2143,7 +2142,7 @@ tcp_fastack(struct mbuf *m, struct tcphd
(void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
m_freem(m);
if (tp->snd_una == tp->snd_max)
tcp_timer_activate(tp, TT_REXMT, 0);
Modified: stable/11/sys/netinet/tcp_subr.c
==============================================================================
--- stable/11/sys/netinet/tcp_subr.c Thu Mar 30 02:37:37 2017 (r316207)
+++ stable/11/sys/netinet/tcp_subr.c Thu Mar 30 02:38:30 2017 (r316208)
@@ -1129,12 +1129,11 @@ tcp_respond(struct tcpcb *tp, void *ipge
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__output, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__output, tp, th, m);
if (flags & TH_RST)
- TCP_PROBE5(accept__refused, NULL, NULL, mtod(m, const char *),
- tp, nth);
+ TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth);
- TCP_PROBE5(send, NULL, tp, mtod(m, const char *), tp, nth);
+ TCP_PROBE5(send, NULL, tp, m, tp, nth);
#ifdef INET6
if (isipv6)
(void) ip6_output(m, NULL, NULL, 0, NULL, NULL, inp);
More information about the svn-src-stable
mailing list