summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authorgnn <gnn@FreeBSD.org>2017-03-30 02:38:30 +0000
committergnn <gnn@FreeBSD.org>2017-03-30 02:38:30 +0000
commit5d1e46a0803ec1a7882e80016c9ebfc55350f7d2 (patch)
tree0eb7d54364e3262ea47989e3345bfae6f974c789 /cddl
parent3b73956452f3e6b0a89b5a700a7268ad7d7f25e7 (diff)
downloadFreeBSD-src-5d1e46a0803ec1a7882e80016c9ebfc55350f7d2.zip
FreeBSD-src-5d1e46a0803ec1a7882e80016c9ebfc55350f7d2.tar.gz
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.
Diffstat (limited to 'cddl')
-rw-r--r--cddl/lib/libdtrace/ip.d18
1 files changed, 18 insertions, 0 deletions
diff --git a/cddl/lib/libdtrace/ip.d b/cddl/lib/libdtrace/ip.d
index e3fc23d..bf487e6 100644
--- a/cddl/lib/libdtrace/ip.d
+++ b/cddl/lib/libdtrace/ip.d
@@ -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;
OpenPOWER on IntegriCloud