From 7575d3df5b3dd239d39381efebc9e6e80bac62db Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Mon, 18 Jun 2018 18:35:29 +0000 Subject: [PATCH] The IP, TCP, and UDP provider report IP addresses as strings. In some cases, the required information is not available and the UDP provider reported an empty string in this case and the IP and TCP provider reported a NULL pointer. This patch changes the value provided in this case to the string "". This make the behaviour consistent and in-line with the behaviour of Solaris. Reviewed by: markj@, dteske@, gnn@ Differential Revision: https://reviews.freebsd.org/D15855 --- cddl/lib/libdtrace/ip.d | 8 ++++---- cddl/lib/libdtrace/tcp.d | 4 ++-- cddl/lib/libdtrace/udp.d | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cddl/lib/libdtrace/ip.d b/cddl/lib/libdtrace/ip.d index 2c7bde161aa..d413a300284 100644 --- a/cddl/lib/libdtrace/ip.d +++ b/cddl/lib/libdtrace/ip.d @@ -228,11 +228,11 @@ translator ipinfo_t < uint8_t *p > { ((struct ip *)p)->ip_v == 4 ? ntohs(((struct ip *)p)->ip_len) - (((struct ip *)p)->ip_hl << 2): ntohs(((struct ip6_hdr *)p)->ip6_ctlun.ip6_un1.ip6_un1_plen); - ip_saddr = p == NULL ? 0 : + ip_saddr = p == NULL ? "" : ((struct ip *)p)->ip_v == 4 ? inet_ntoa(&((struct ip *)p)->ip_src.s_addr) : inet_ntoa6(&((struct ip6_hdr *)p)->ip6_src); - ip_daddr = p == NULL ? 0 : + ip_daddr = p == NULL ? "" : ((struct ip *)p)->ip_v == 4 ? inet_ntoa(&((struct ip *)p)->ip_dst.s_addr) : inet_ntoa6(&((struct ip6_hdr *)p)->ip6_dst); @@ -246,11 +246,11 @@ translator ipinfo_t < struct mbuf *m > { 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 : + ip_saddr = m == NULL ? "" : ((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 : + ip_daddr = m == NULL ? "" : ((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); diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index 383d284821b..bf7788c88f0 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -190,11 +190,11 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_active = -1; /* XXX */ tcps_lport = p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_lport); tcps_rport = p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_fport); - tcps_laddr = p == NULL ? 0 : + tcps_laddr = p == NULL ? "" : p->t_inpcb->inp_vflag == INP_IPV4 ? inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.id6_addr); - tcps_raddr = p == NULL ? 0 : + tcps_raddr = p == NULL ? "" : p->t_inpcb->inp_vflag == INP_IPV4 ? inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.id6_addr); diff --git a/cddl/lib/libdtrace/udp.d b/cddl/lib/libdtrace/udp.d index 917baa663c7..603bbbd2961 100644 --- a/cddl/lib/libdtrace/udp.d +++ b/cddl/lib/libdtrace/udp.d @@ -56,11 +56,11 @@ translator udpsinfo_t < struct inpcb *p > { udps_addr = (uintptr_t)p; udps_lport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_lport); udps_rport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_fport); - udps_laddr = p == NULL ? "" : + udps_laddr = p == NULL ? "" : p->inp_vflag == INP_IPV4 ? inet_ntoa(&p->inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : inet_ntoa6(&p->inp_inc.inc_ie.ie_dependladdr.id6_addr); - udps_raddr = p == NULL ? "" : + udps_raddr = p == NULL ? "" : p->inp_vflag == INP_IPV4 ? inet_ntoa(&p->inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : inet_ntoa6(&p->inp_inc.inc_ie.ie_dependfaddr.id6_addr);