Author: tuexen
Date: Mon Jun 18 18:35:29 2018
New Revision: 335325
URL: https://svnweb.freebsd.org/changeset/base/335325

Log:
  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
  "<unknown>". 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

Modified:
  head/cddl/lib/libdtrace/ip.d
  head/cddl/lib/libdtrace/tcp.d
  head/cddl/lib/libdtrace/udp.d

Modified: head/cddl/lib/libdtrace/ip.d
==============================================================================
--- head/cddl/lib/libdtrace/ip.d        Mon Jun 18 18:10:11 2018        
(r335324)
+++ head/cddl/lib/libdtrace/ip.d        Mon Jun 18 18:35:29 2018        
(r335325)
@@ -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 ? "<unknown>" :
            ((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 ? "<unknown>" :
            ((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 ? "<unknown>" :
            ((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 ? "<unknown>" :
            ((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);

Modified: head/cddl/lib/libdtrace/tcp.d
==============================================================================
--- head/cddl/lib/libdtrace/tcp.d       Mon Jun 18 18:10:11 2018        
(r335324)
+++ head/cddl/lib/libdtrace/tcp.d       Mon Jun 18 18:35:29 2018        
(r335325)
@@ -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 ? "<unknown>" :
            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 ? "<unknown>" :
            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);

Modified: head/cddl/lib/libdtrace/udp.d
==============================================================================
--- head/cddl/lib/libdtrace/udp.d       Mon Jun 18 18:10:11 2018        
(r335324)
+++ head/cddl/lib/libdtrace/udp.d       Mon Jun 18 18:35:29 2018        
(r335325)
@@ -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 ? "<unknown>" :
            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 ? "<unknown>" :
            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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to