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
This commit is contained in:
Michael Tuexen 2018-06-18 18:35:29 +00:00
parent c4db0baa34
commit 7575d3df5b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335325
3 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);