KTR: log IPv4 addresses in hex rather than dotted-quad

When I made the changes in r313821, I fell victim to one of the
classic blunders, the most famous of which is: never get involved
in a land war in Asia.  But only slightly less well known is this:
Keep your brain turned on and engaged when making a tedious, sweeping,
mechanical change.  KTR can correctly log the immediate integral values
passed to it, as well as constant strings, but not non-constant strings,
since they might change by the time ktrdump retrieves them.

Reported by:	glebius
MFC after:	3 days
Sponsored by:	Dell EMC
This commit is contained in:
vangyzen 2017-03-14 18:27:48 +00:00
parent fbc7088a82
commit fad1018fc7
4 changed files with 99 additions and 209 deletions

View File

@ -1461,9 +1461,6 @@ static void
process_data(struct iwch_ep *ep) process_data(struct iwch_ep *ep)
{ {
struct sockaddr_in *local, *remote; struct sockaddr_in *local, *remote;
#ifdef KTR
char local_str[INET_ADDRSTRLEN], remote_str[INET_ADDRSTRLEN];
#endif
CTR4(KTR_IW_CXGB, "%s ep %p so %p state %s", __FUNCTION__, ep, ep->com.so, states[ep->com.state]); CTR4(KTR_IW_CXGB, "%s ep %p so %p state %s", __FUNCTION__, ep, ep->com.so, states[ep->com.state]);
@ -1481,9 +1478,8 @@ process_data(struct iwch_ep *ep)
*/ */
in_getsockaddr(ep->com.so, (struct sockaddr **)&local); in_getsockaddr(ep->com.so, (struct sockaddr **)&local);
in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote); in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote);
CTR3(KTR_IW_CXGB, "%s local %s remote %s", __FUNCTION__, CTR3(KTR_IW_CXGB, "%s local 0x%08x remote 0x%08x", __FUNCTION__,
inet_ntoa_r(local->sin_addr, local_str), local->sin_addr.s_addr, remote->sin_addr.s_addr);
inet_ntoa_r(remote->sin_addr, remote_str));
ep->com.local_addr = *local; ep->com.local_addr = *local;
ep->com.remote_addr = *remote; ep->com.remote_addr = *remote;
free(local, M_SONAME); free(local, M_SONAME);
@ -1522,9 +1518,6 @@ process_newconn(struct iw_cm_id *parent_cm_id, struct socket *child_so)
struct sockaddr_in *local; struct sockaddr_in *local;
struct sockaddr_in *remote; struct sockaddr_in *remote;
struct iwch_ep *parent_ep = parent_cm_id->provider_data; struct iwch_ep *parent_ep = parent_cm_id->provider_data;
#ifdef KTR
char buf[INET_ADDRSTRLEN];
#endif
CTR3(KTR_IW_CXGB, "%s parent ep %p so %p", __FUNCTION__, parent_ep, parent_ep->com.so); CTR3(KTR_IW_CXGB, "%s parent ep %p so %p", __FUNCTION__, parent_ep, parent_ep->com.so);
if (!child_so) { if (!child_so) {
@ -1544,8 +1537,8 @@ process_newconn(struct iw_cm_id *parent_cm_id, struct socket *child_so)
in_getsockaddr(child_so, (struct sockaddr **)&local); in_getsockaddr(child_so, (struct sockaddr **)&local);
in_getpeeraddr(child_so, (struct sockaddr **)&remote); in_getpeeraddr(child_so, (struct sockaddr **)&remote);
CTR3(KTR_IW_CXGB, "%s remote addr %s port %d", __FUNCTION__, CTR3(KTR_IW_CXGB, "%s remote addr 0x%08x port %d", __FUNCTION__,
inet_ntoa_r(remote->sin_addr, buf), ntohs(remote->sin_port)); remote->sin_addr.s_addr, ntohs(remote->sin_port));
child_ep->com.tdev = parent_ep->com.tdev; child_ep->com.tdev = parent_ep->com.tdev;
child_ep->com.local_addr.sin_family = parent_ep->com.local_addr.sin_family; child_ep->com.local_addr.sin_family = parent_ep->com.local_addr.sin_family;
child_ep->com.local_addr.sin_port = parent_ep->com.local_addr.sin_port; child_ep->com.local_addr.sin_port = parent_ep->com.local_addr.sin_port;

View File

@ -312,17 +312,6 @@ igmp_scrub_context(struct mbuf *m)
m->m_pkthdr.flowid = 0; m->m_pkthdr.flowid = 0;
} }
#ifdef KTR
static __inline char *
inet_ntoa_haddr(in_addr_t haddr, char *addrbuf)
{
struct in_addr ia;
ia.s_addr = htonl(haddr);
return (inet_ntoa_r(ia, addrbuf));
}
#endif
/* /*
* Restore context from a queued IGMP output chain. * Restore context from a queued IGMP output chain.
* Return saved ifindex. * Return saved ifindex.
@ -804,9 +793,6 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
struct in_multi *inm; struct in_multi *inm;
int is_general_query; int is_general_query;
uint16_t timer; uint16_t timer;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
is_general_query = 0; is_general_query = 0;
@ -875,9 +861,9 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
*/ */
inm = inm_lookup(ifp, igmp->igmp_group); inm = inm_lookup(ifp, igmp->igmp_group);
if (inm != NULL) { if (inm != NULL) {
CTR3(KTR_IGMPV3, "process v2 query %s on ifp %p(%s)", CTR3(KTR_IGMPV3,
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, "process v2 query 0x%08x on ifp %p(%s)",
ifp->if_xname); igmp->igmp_group.s_addr, ifp, ifp->if_xname);
igmp_v2_update_group(inm, timer); igmp_v2_update_group(inm, timer);
} }
} }
@ -907,12 +893,9 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
static void static void
igmp_v2_update_group(struct in_multi *inm, const int timer) igmp_v2_update_group(struct in_multi *inm, const int timer)
{ {
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
CTR4(KTR_IGMPV3, "%s: %s/%s timer=%d", __func__, CTR4(KTR_IGMPV3, "0x%08x: %s/%s timer=%d", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname, timer); inm->inm_addr.s_addr, inm->inm_ifp->if_xname, timer);
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
@ -963,9 +946,6 @@ igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip,
uint32_t maxresp, nsrc, qqi; uint32_t maxresp, nsrc, qqi;
uint16_t timer; uint16_t timer;
uint8_t qrv; uint8_t qrv;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
is_general_query = 0; is_general_query = 0;
@ -1095,9 +1075,8 @@ igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip,
goto out_locked; goto out_locked;
} }
} }
CTR3(KTR_IGMPV3, "process v3 %s query on ifp %p(%s)", CTR3(KTR_IGMPV3, "process v3 0x%08x query on ifp %p(%s)",
inet_ntoa_r(igmpv3->igmp_group, addrbuf), ifp, igmpv3->igmp_group.s_addr, ifp, ifp->if_xname);
ifp->if_xname);
/* /*
* If there is a pending General Query response * If there is a pending General Query response
* scheduled sooner than the selected delay, no * scheduled sooner than the selected delay, no
@ -1230,9 +1209,6 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip,
struct rm_priotracker in_ifa_tracker; struct rm_priotracker in_ifa_tracker;
struct in_ifaddr *ia; struct in_ifaddr *ia;
struct in_multi *inm; struct in_multi *inm;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
IGMPSTAT_INC(igps_rcv_reports); IGMPSTAT_INC(igps_rcv_reports);
@ -1260,8 +1236,8 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip,
} }
} }
CTR3(KTR_IGMPV3, "process v1 report %s on ifp %p(%s)", CTR3(KTR_IGMPV3, "process v1 report 0x%08x on ifp %p(%s)",
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname); igmp->igmp_group.s_addr, ifp, ifp->if_xname);
/* /*
* IGMPv1 report suppression. * IGMPv1 report suppression.
@ -1303,16 +1279,16 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip,
case IGMP_LAZY_MEMBER: case IGMP_LAZY_MEMBER:
case IGMP_AWAKENING_MEMBER: case IGMP_AWAKENING_MEMBER:
CTR3(KTR_IGMPV3, CTR3(KTR_IGMPV3,
"report suppressed for %s on ifp %p(%s)", "report suppressed for 0x%08x on ifp %p(%s)",
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, igmp->igmp_group.s_addr, ifp,
ifp->if_xname); ifp->if_xname);
case IGMP_SLEEPING_MEMBER: case IGMP_SLEEPING_MEMBER:
inm->inm_state = IGMP_SLEEPING_MEMBER; inm->inm_state = IGMP_SLEEPING_MEMBER;
break; break;
case IGMP_REPORTING_MEMBER: case IGMP_REPORTING_MEMBER:
CTR3(KTR_IGMPV3, CTR3(KTR_IGMPV3,
"report suppressed for %s on ifp %p(%s)", "report suppressed for 0x%08x on ifp %p(%s)",
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, igmp->igmp_group.s_addr, ifp,
ifp->if_xname); ifp->if_xname);
if (igi->igi_version == IGMP_VERSION_1) if (igi->igi_version == IGMP_VERSION_1)
inm->inm_state = IGMP_LAZY_MEMBER; inm->inm_state = IGMP_LAZY_MEMBER;
@ -1344,9 +1320,6 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip,
struct rm_priotracker in_ifa_tracker; struct rm_priotracker in_ifa_tracker;
struct in_ifaddr *ia; struct in_ifaddr *ia;
struct in_multi *inm; struct in_multi *inm;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
/* /*
* Make sure we don't hear our own membership report. Fast * Make sure we don't hear our own membership report. Fast
@ -1389,8 +1362,8 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip,
if (ia != NULL) if (ia != NULL)
ifa_free(&ia->ia_ifa); ifa_free(&ia->ia_ifa);
CTR3(KTR_IGMPV3, "process v2 report %s on ifp %p(%s)", CTR3(KTR_IGMPV3, "process v2 report 0x%08x on ifp %p(%s)",
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname); igmp->igmp_group.s_addr, ifp, ifp->if_xname);
/* /*
* IGMPv2 report suppression. * IGMPv2 report suppression.
@ -1430,9 +1403,8 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip,
case IGMP_IDLE_MEMBER: case IGMP_IDLE_MEMBER:
case IGMP_AWAKENING_MEMBER: case IGMP_AWAKENING_MEMBER:
CTR3(KTR_IGMPV3, CTR3(KTR_IGMPV3,
"report suppressed for %s on ifp %p(%s)", "report suppressed for 0x%08x on ifp %p(%s)",
inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, igmp->igmp_group.s_addr, ifp, ifp->if_xname);
ifp->if_xname);
case IGMP_LAZY_MEMBER: case IGMP_LAZY_MEMBER:
inm->inm_state = IGMP_LAZY_MEMBER; inm->inm_state = IGMP_LAZY_MEMBER;
break; break;
@ -1834,9 +1806,6 @@ igmp_v3_process_group_timers(struct igmp_ifsoftc *igi,
{ {
int query_response_timer_expired; int query_response_timer_expired;
int state_change_retransmit_timer_expired; int state_change_retransmit_timer_expired;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
IGMP_LOCK_ASSERT(); IGMP_LOCK_ASSERT();
@ -1922,9 +1891,8 @@ igmp_v3_process_group_timers(struct igmp_ifsoftc *igi,
(void)igmp_v3_merge_state_changes(inm, scq); (void)igmp_v3_merge_state_changes(inm, scq);
inm_commit(inm); inm_commit(inm);
CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
/* /*
* If we are leaving the group for good, make sure * If we are leaving the group for good, make sure
@ -2370,13 +2338,9 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifsoftc *igi)
struct ifnet *ifp; struct ifnet *ifp;
struct mbufq *mq; struct mbufq *mq;
int error, retval, syncstates; int error, retval, syncstates;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
CTR4(KTR_IGMPV3, "%s: initial join %s on ifp %p(%s)", CTR4(KTR_IGMPV3, "%s: initial join 0x%08x on ifp %p(%s)", __func__,
__func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_addr.s_addr, inm->inm_ifp, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
error = 0; error = 0;
syncstates = 1; syncstates = 1;
@ -2485,9 +2449,8 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifsoftc *igi)
*/ */
if (syncstates) { if (syncstates) {
inm_commit(inm); inm_commit(inm);
CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
} }
return (error); return (error);
@ -2501,13 +2464,9 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifsoftc *igi)
{ {
struct ifnet *ifp; struct ifnet *ifp;
int retval; int retval;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
CTR4(KTR_IGMPV3, "%s: state change for %s on ifp %p(%s)", CTR4(KTR_IGMPV3, "%s: state change for 0x%08x on ifp %p(%s)", __func__,
__func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_addr.s_addr, inm->inm_ifp, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
ifp = inm->inm_ifp; ifp = inm->inm_ifp;
@ -2526,9 +2485,8 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifsoftc *igi)
} }
CTR1(KTR_IGMPV3, "%s: nothing to do", __func__); CTR1(KTR_IGMPV3, "%s: nothing to do", __func__);
inm_commit(inm); inm_commit(inm);
CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
return (0); return (0);
} }
@ -2563,14 +2521,11 @@ static void
igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi) igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi)
{ {
int syncstates; int syncstates;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
syncstates = 1; syncstates = 1;
CTR4(KTR_IGMPV3, "%s: final leave %s on ifp %p(%s)", CTR4(KTR_IGMPV3, "%s: final leave 0x%08x on ifp %p(%s)",
__func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, __func__, inm->inm_addr.s_addr, inm->inm_ifp,
inm->inm_ifp->if_xname); inm->inm_ifp->if_xname);
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
@ -2611,9 +2566,9 @@ igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi)
} else { } else {
inm->inm_scrv = igi->igi_rv; inm->inm_scrv = igi->igi_rv;
} }
CTR4(KTR_IGMPV3, "%s: Leaving %s/%s with %d " CTR4(KTR_IGMPV3, "%s: Leaving 0x%08x/%s with %d "
"pending retransmissions.", __func__, "pending retransmissions.", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr,
inm->inm_ifp->if_xname, inm->inm_scrv); inm->inm_ifp->if_xname, inm->inm_scrv);
if (inm->inm_scrv == 0) { if (inm->inm_scrv == 0) {
inm->inm_state = IGMP_NOT_MEMBER; inm->inm_state = IGMP_NOT_MEMBER;
@ -2646,13 +2601,11 @@ igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi)
if (syncstates) { if (syncstates) {
inm_commit(inm); inm_commit(inm);
CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
inm->inm_st[1].iss_fmode = MCAST_UNDEFINED; inm->inm_st[1].iss_fmode = MCAST_UNDEFINED;
CTR3(KTR_IGMPV3, "%s: T1 now MCAST_UNDEFINED for %s/%s", CTR3(KTR_IGMPV3, "%s: T1 now MCAST_UNDEFINED for 0x%08x/%s",
__func__, inet_ntoa_r(inm->inm_addr, addrbuf), __func__, inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
} }
} }
@ -2700,9 +2653,6 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm,
int type; int type;
in_addr_t naddr; in_addr_t naddr;
uint8_t mode; uint8_t mode;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
@ -2780,9 +2730,8 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm,
return (igmp_v3_enqueue_filter_change(mq, inm)); return (igmp_v3_enqueue_filter_change(mq, inm));
if (type == IGMP_DO_NOTHING) { if (type == IGMP_DO_NOTHING) {
CTR3(KTR_IGMPV3, "%s: nothing to do for %s/%s", CTR3(KTR_IGMPV3, "%s: nothing to do for 0x%08x/%s", __func__,
__func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_addr.s_addr, inm->inm_ifp->if_xname);
inm->inm_ifp->if_xname);
return (0); return (0);
} }
@ -2795,8 +2744,8 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm,
if (record_has_sources) if (record_has_sources)
minrec0len += sizeof(in_addr_t); minrec0len += sizeof(in_addr_t);
CTR4(KTR_IGMPV3, "%s: queueing %s for %s/%s", __func__, CTR4(KTR_IGMPV3, "%s: queueing %s for 0x%08x/%s", __func__,
igmp_rec_type_to_str(type), inet_ntoa_r(inm->inm_addr, addrbuf), igmp_rec_type_to_str(type), inm->inm_addr.s_addr,
inm->inm_ifp->if_xname); inm->inm_ifp->if_xname);
/* /*
@ -2884,8 +2833,8 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm,
} }
msrcs = 0; msrcs = 0;
RB_FOREACH_SAFE(ims, ip_msource_tree, &inm->inm_srcs, nims) { RB_FOREACH_SAFE(ims, ip_msource_tree, &inm->inm_srcs, nims) {
CTR2(KTR_IGMPV3, "%s: visit node %s", __func__, CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
inet_ntoa_haddr(ims->ims_haddr, addrbuf)); htonl(ims->ims_haddr));
now = ims_get_mode(inm, ims, 1); now = ims_get_mode(inm, ims, 1);
CTR2(KTR_IGMPV3, "%s: node is %d", __func__, now); CTR2(KTR_IGMPV3, "%s: node is %d", __func__, now);
if ((now != mode) || if ((now != mode) ||
@ -2980,8 +2929,8 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm,
msrcs = 0; msrcs = 0;
RB_FOREACH_FROM(ims, ip_msource_tree, nims) { RB_FOREACH_FROM(ims, ip_msource_tree, nims) {
CTR2(KTR_IGMPV3, "%s: visit node %s", __func__, CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
inet_ntoa_haddr(ims->ims_haddr, addrbuf)); htonl(ims->ims_haddr));
now = ims_get_mode(inm, ims, 1); now = ims_get_mode(inm, ims, 1);
if ((now != mode) || if ((now != mode) ||
(now == mode && mode == MCAST_UNDEFINED)) { (now == mode && mode == MCAST_UNDEFINED)) {
@ -3064,9 +3013,6 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm)
int nallow, nblock; int nallow, nblock;
uint8_t mode, now, then; uint8_t mode, now, then;
rectype_t crt, drt, nrt; rectype_t crt, drt, nrt;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
@ -3175,9 +3121,8 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm)
if (nims == NULL) if (nims == NULL)
nims = RB_MIN(ip_msource_tree, &inm->inm_srcs); nims = RB_MIN(ip_msource_tree, &inm->inm_srcs);
RB_FOREACH_FROM(ims, ip_msource_tree, nims) { RB_FOREACH_FROM(ims, ip_msource_tree, nims) {
CTR2(KTR_IGMPV3, "%s: visit node %s", CTR2(KTR_IGMPV3, "%s: visit node 0x%08x",
__func__, __func__, htonl(ims->ims_haddr));
inet_ntoa_haddr(ims->ims_haddr, addrbuf));
now = ims_get_mode(inm, ims, 1); now = ims_get_mode(inm, ims, 1);
then = ims_get_mode(inm, ims, 0); then = ims_get_mode(inm, ims, 0);
CTR3(KTR_IGMPV3, "%s: mode: t0 %d, t1 %d", CTR3(KTR_IGMPV3, "%s: mode: t0 %d, t1 %d",

View File

@ -877,10 +877,6 @@ inm_get_source(struct in_multi *inm, const in_addr_t haddr,
{ {
struct ip_msource find; struct ip_msource find;
struct ip_msource *ims, *nims; struct ip_msource *ims, *nims;
#ifdef KTR
struct in_addr ia;
char addrbuf[INET_ADDRSTRLEN];
#endif
find.ims_haddr = haddr; find.ims_haddr = haddr;
ims = RB_FIND(ip_msource_tree, &inm->inm_srcs, &find); ims = RB_FIND(ip_msource_tree, &inm->inm_srcs, &find);
@ -896,9 +892,8 @@ inm_get_source(struct in_multi *inm, const in_addr_t haddr,
++inm->inm_nsrc; ++inm->inm_nsrc;
ims = nims; ims = nims;
#ifdef KTR #ifdef KTR
ia.s_addr = htonl(haddr); CTR3(KTR_IGMPV3, "%s: allocated 0x%08x as %p", __func__,
CTR3(KTR_IGMPV3, "%s: allocated %s as %p", __func__, htonl(haddr), ims);
inet_ntoa_r(ia, addrbuf), ims);
#endif #endif
} }
@ -916,29 +911,28 @@ ims_merge(struct ip_msource *ims, const struct in_msource *lims,
{ {
int n = rollback ? -1 : 1; int n = rollback ? -1 : 1;
#ifdef KTR #ifdef KTR
char addrbuf[INET_ADDRSTRLEN]; uint32_t addr;
struct in_addr ia;
ia.s_addr = htonl(ims->ims_haddr); addr = htonl(ims->ims_haddr);
#endif #endif
if (lims->imsl_st[0] == MCAST_EXCLUDE) { if (lims->imsl_st[0] == MCAST_EXCLUDE) {
CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on %s", CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on 0x%08x",
__func__, n, inet_ntoa_r(ia, addrbuf)); __func__, n, addr);
ims->ims_st[1].ex -= n; ims->ims_st[1].ex -= n;
} else if (lims->imsl_st[0] == MCAST_INCLUDE) { } else if (lims->imsl_st[0] == MCAST_INCLUDE) {
CTR3(KTR_IGMPV3, "%s: t1 in -= %d on %s", CTR3(KTR_IGMPV3, "%s: t1 in -= %d on 0x%08x",
__func__, n, inet_ntoa_r(ia, addrbuf)); __func__, n, addr);
ims->ims_st[1].in -= n; ims->ims_st[1].in -= n;
} }
if (lims->imsl_st[1] == MCAST_EXCLUDE) { if (lims->imsl_st[1] == MCAST_EXCLUDE) {
CTR3(KTR_IGMPV3, "%s: t1 ex += %d on %s", CTR3(KTR_IGMPV3, "%s: t1 ex += %d on 0x%08x",
__func__, n, inet_ntoa_r(ia, addrbuf)); __func__, n, addr);
ims->ims_st[1].ex += n; ims->ims_st[1].ex += n;
} else if (lims->imsl_st[1] == MCAST_INCLUDE) { } else if (lims->imsl_st[1] == MCAST_INCLUDE) {
CTR3(KTR_IGMPV3, "%s: t1 in += %d on %s", CTR3(KTR_IGMPV3, "%s: t1 in += %d on 0x%08x",
__func__, n, inet_ntoa_r(ia, addrbuf)); __func__, n, addr);
ims->ims_st[1].in += n; ims->ims_st[1].in += n;
} }
} }
@ -1171,14 +1165,11 @@ in_joingroup_locked(struct ifnet *ifp, const struct in_addr *gina,
struct in_mfilter timf; struct in_mfilter timf;
struct in_multi *inm; struct in_multi *inm;
int error; int error;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
CTR4(KTR_IGMPV3, "%s: join %s on %p(%s))", __func__, CTR4(KTR_IGMPV3, "%s: join 0x%08x on %p(%s))", __func__,
inet_ntoa_r(*gina, addrbuf), ifp, ifp->if_xname); gina->s_addr, ifp, ifp->if_xname);
error = 0; error = 0;
inm = NULL; inm = NULL;
@ -1256,16 +1247,13 @@ in_leavegroup_locked(struct in_multi *inm, /*const*/ struct in_mfilter *imf)
{ {
struct in_mfilter timf; struct in_mfilter timf;
int error; int error;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
error = 0; error = 0;
IN_MULTI_LOCK_ASSERT(); IN_MULTI_LOCK_ASSERT();
CTR5(KTR_IGMPV3, "%s: leave inm %p, %s/%s, imf %p", __func__, CTR5(KTR_IGMPV3, "%s: leave inm %p, 0x%08x/%s, imf %p", __func__,
inm, inet_ntoa_r(inm->inm_addr, addrbuf), inm, inm->inm_addr.s_addr,
(inm_is_ifp_detached(inm) ? "null" : inm->inm_ifp->if_xname), (inm_is_ifp_detached(inm) ? "null" : inm->inm_ifp->if_xname),
imf); imf);
@ -1364,9 +1352,6 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt)
size_t idx; size_t idx;
uint16_t fmode; uint16_t fmode;
int error, doblock; int error, doblock;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
ifp = NULL; ifp = NULL;
error = 0; error = 0;
@ -1401,8 +1386,8 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt)
if (sopt->sopt_name == IP_BLOCK_SOURCE) if (sopt->sopt_name == IP_BLOCK_SOURCE)
doblock = 1; doblock = 1;
CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
__func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); __func__, mreqs.imr_interface.s_addr, ifp);
break; break;
} }
@ -1474,9 +1459,8 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt)
*/ */
ims = imo_match_source(imo, idx, &ssa->sa); ims = imo_match_source(imo, idx, &ssa->sa);
if ((ims != NULL && doblock) || (ims == NULL && !doblock)) { if ((ims != NULL && doblock) || (ims == NULL && !doblock)) {
CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__, CTR3(KTR_IGMPV3, "%s: source 0x%08x %spresent", __func__,
inet_ntoa_r(ssa->sin.sin_addr, addrbuf), ssa->sin.sin_addr.s_addr, doblock ? "" : "not ");
doblock ? "" : "not ");
error = EADDRNOTAVAIL; error = EADDRNOTAVAIL;
goto out_inp_locked; goto out_inp_locked;
} }
@ -1953,9 +1937,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
struct in_msource *lims; struct in_msource *lims;
size_t idx; size_t idx;
int error, is_new; int error, is_new;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
ifp = NULL; ifp = NULL;
imf = NULL; imf = NULL;
@ -2007,8 +1988,8 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
ifp = inp_lookup_mcast_ifp(inp, &gsa->sin, ifp = inp_lookup_mcast_ifp(inp, &gsa->sin,
mreqs.imr_interface); mreqs.imr_interface);
CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
__func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); __func__, mreqs.imr_interface.s_addr, ifp);
break; break;
} }
@ -2255,9 +2236,6 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
struct in_multi *inm; struct in_multi *inm;
size_t idx; size_t idx;
int error, is_final; int error, is_final;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
ifp = NULL; ifp = NULL;
error = 0; error = 0;
@ -2311,8 +2289,8 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
if (!in_nullhost(mreqs.imr_interface)) if (!in_nullhost(mreqs.imr_interface))
INADDR_TO_IFP(mreqs.imr_interface, ifp); INADDR_TO_IFP(mreqs.imr_interface, ifp);
CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
__func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); __func__, mreqs.imr_interface.s_addr, ifp);
break; break;
@ -2392,8 +2370,8 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
} }
ims = imo_match_source(imo, idx, &ssa->sa); ims = imo_match_source(imo, idx, &ssa->sa);
if (ims == NULL) { if (ims == NULL) {
CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__, CTR3(KTR_IGMPV3, "%s: source 0x%08x %spresent",
inet_ntoa_r(ssa->sin.sin_addr, addrbuf), "not "); __func__, ssa->sin.sin_addr.s_addr, "not ");
error = EADDRNOTAVAIL; error = EADDRNOTAVAIL;
goto out_inp_locked; goto out_inp_locked;
} }
@ -2475,9 +2453,6 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
struct ifnet *ifp; struct ifnet *ifp;
struct ip_moptions *imo; struct ip_moptions *imo;
int error; int error;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
if (sopt->sopt_valsize == sizeof(struct ip_mreqn)) { if (sopt->sopt_valsize == sizeof(struct ip_mreqn)) {
/* /*
@ -2515,8 +2490,8 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
if (ifp == NULL) if (ifp == NULL)
return (EADDRNOTAVAIL); return (EADDRNOTAVAIL);
} }
CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = %s", __func__, ifp, CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = 0x%08x", __func__, ifp,
inet_ntoa_r(addr, addrbuf)); addr.s_addr);
} }
/* Reject interfaces which do not support multicast. */ /* Reject interfaces which do not support multicast. */
@ -2874,9 +2849,6 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS)
int retval; int retval;
u_int namelen; u_int namelen;
uint32_t fmode, ifindex; uint32_t fmode, ifindex;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
name = (int *)arg1; name = (int *)arg1;
namelen = arg2; namelen = arg2;
@ -2896,8 +2868,8 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS)
group.s_addr = name[1]; group.s_addr = name[1];
if (!IN_MULTICAST(ntohl(group.s_addr))) { if (!IN_MULTICAST(ntohl(group.s_addr))) {
CTR2(KTR_IGMPV3, "%s: group %s is not multicast", CTR2(KTR_IGMPV3, "%s: group 0x%08x is not multicast",
__func__, inet_ntoa_r(group, addrbuf)); __func__, group.s_addr);
return (EINVAL); return (EINVAL);
} }
@ -2928,12 +2900,8 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS)
if (retval != 0) if (retval != 0)
break; break;
RB_FOREACH(ims, ip_msource_tree, &inm->inm_srcs) { RB_FOREACH(ims, ip_msource_tree, &inm->inm_srcs) {
#ifdef KTR CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
struct in_addr ina; htonl(ims->ims_haddr));
ina.s_addr = htonl(ims->ims_haddr);
CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
inet_ntoa_r(ina, addrbuf));
#endif
/* /*
* Only copy-out sources which are in-mode. * Only copy-out sources which are in-mode.
*/ */

View File

@ -845,9 +845,6 @@ add_vif(struct vifctl *vifcp)
struct ifaddr *ifa; struct ifaddr *ifa;
struct ifnet *ifp; struct ifnet *ifp;
int error; int error;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
VIF_LOCK(); VIF_LOCK();
if (vifcp->vifc_vifi >= MAXVIFS) { if (vifcp->vifc_vifi >= MAXVIFS) {
@ -931,8 +928,8 @@ add_vif(struct vifctl *vifcp)
VIF_UNLOCK(); VIF_UNLOCK();
CTR4(KTR_IPMF, "%s: add vif %d laddr %s thresh %x", __func__, CTR4(KTR_IPMF, "%s: add vif %d laddr 0x%08x thresh %x", __func__,
(int)vifcp->vifc_vifi, inet_ntoa_r(vifcp->vifc_lcl_addr, addrbuf), (int)vifcp->vifc_vifi, vifcp->vifc_lcl_addr.s_addr,
(int)vifcp->vifc_threshold); (int)vifcp->vifc_threshold);
return 0; return 0;
@ -1055,9 +1052,6 @@ add_mfc(struct mfcctl2 *mfccp)
struct rtdetq *rte, *nrte; struct rtdetq *rte, *nrte;
u_long hash = 0; u_long hash = 0;
u_short nstl; u_short nstl;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
VIF_LOCK(); VIF_LOCK();
MFC_LOCK(); MFC_LOCK();
@ -1066,8 +1060,8 @@ add_mfc(struct mfcctl2 *mfccp)
/* If an entry already exists, just update the fields */ /* If an entry already exists, just update the fields */
if (rt) { if (rt) {
CTR4(KTR_IPMF, "%s: update mfc orig %s group %lx parent %x", CTR4(KTR_IPMF, "%s: update mfc orig 0x%08x group %lx parent %x",
__func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf), __func__, mfccp->mfcc_origin.s_addr,
(u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent); mfccp->mfcc_parent);
update_mfc_params(rt, mfccp); update_mfc_params(rt, mfccp);
@ -1086,8 +1080,8 @@ add_mfc(struct mfcctl2 *mfccp)
in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp) && in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp) &&
!TAILQ_EMPTY(&rt->mfc_stall)) { !TAILQ_EMPTY(&rt->mfc_stall)) {
CTR5(KTR_IPMF, CTR5(KTR_IPMF,
"%s: add mfc orig %s group %lx parent %x qh %p", "%s: add mfc orig 0x%08x group %lx parent %x qh %p",
__func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf), __func__, mfccp->mfcc_origin.s_addr,
(u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
mfccp->mfcc_parent, mfccp->mfcc_parent,
TAILQ_FIRST(&rt->mfc_stall)); TAILQ_FIRST(&rt->mfc_stall));
@ -1161,15 +1155,12 @@ del_mfc(struct mfcctl2 *mfccp)
struct in_addr origin; struct in_addr origin;
struct in_addr mcastgrp; struct in_addr mcastgrp;
struct mfc *rt; struct mfc *rt;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
origin = mfccp->mfcc_origin; origin = mfccp->mfcc_origin;
mcastgrp = mfccp->mfcc_mcastgrp; mcastgrp = mfccp->mfcc_mcastgrp;
CTR3(KTR_IPMF, "%s: delete mfc orig %s group %lx", __func__, CTR3(KTR_IPMF, "%s: delete mfc orig 0x%08x group %lx", __func__,
inet_ntoa_r(origin, addrbuf), (u_long)ntohl(mcastgrp.s_addr)); origin.s_addr, (u_long)ntohl(mcastgrp.s_addr));
MFC_LOCK(); MFC_LOCK();
@ -1232,13 +1223,9 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
struct mfc *rt; struct mfc *rt;
int error; int error;
vifi_t vifi; vifi_t vifi;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
CTR3(KTR_IPMF, "ip_mforward: delete mfc orig %s group %lx ifp %p", CTR3(KTR_IPMF, "ip_mforward: delete mfc orig 0x%08x group %lx ifp %p",
inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr), ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr), ifp);
ifp);
if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 || if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 ||
((u_char *)(ip + 1))[1] != IPOPT_LSRR ) { ((u_char *)(ip + 1))[1] != IPOPT_LSRR ) {
@ -1300,8 +1287,8 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
MRTSTAT_INC(mrts_mfc_misses); MRTSTAT_INC(mrts_mfc_misses);
MRTSTAT_INC(mrts_no_route); MRTSTAT_INC(mrts_no_route);
CTR2(KTR_IPMF, "ip_mforward: no mfc for (%s,%lx)", CTR2(KTR_IPMF, "ip_mforward: no mfc for (0x%08x,%lx)",
inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr)); ntohl(ip->ip_src.s_addr), (u_long)ntohl(ip->ip_dst.s_addr));
/* /*
* Allocate mbufs early so that we don't do extra work if we are * Allocate mbufs early so that we don't do extra work if we are
@ -2583,9 +2570,6 @@ pim_input(struct mbuf **mp, int *offp, int proto)
int minlen; int minlen;
int datalen = ntohs(ip->ip_len) - iphlen; int datalen = ntohs(ip->ip_len) - iphlen;
int ip_tos; int ip_tos;
#ifdef KTR
char addrbuf[INET_ADDRSTRLEN];
#endif
*mp = NULL; *mp = NULL;
@ -2598,8 +2582,8 @@ pim_input(struct mbuf **mp, int *offp, int proto)
*/ */
if (datalen < PIM_MINLEN) { if (datalen < PIM_MINLEN) {
PIMSTAT_INC(pims_rcv_tooshort); PIMSTAT_INC(pims_rcv_tooshort);
CTR3(KTR_IPMF, "%s: short packet (%d) from %s", CTR3(KTR_IPMF, "%s: short packet (%d) from 0x%08x",
__func__, datalen, inet_ntoa_r(ip->ip_src, addrbuf)); __func__, datalen, ntohl(ip->ip_src.s_addr));
m_freem(m); m_freem(m);
return (IPPROTO_DONE); return (IPPROTO_DONE);
} }
@ -2698,8 +2682,8 @@ pim_input(struct mbuf **mp, int *offp, int proto)
reghdr = (u_int32_t *)(pim + 1); reghdr = (u_int32_t *)(pim + 1);
encap_ip = (struct ip *)(reghdr + 1); encap_ip = (struct ip *)(reghdr + 1);
CTR3(KTR_IPMF, "%s: register: encap ip src %s len %d", CTR3(KTR_IPMF, "%s: register: encap ip src 0x%08x len %d",
__func__, inet_ntoa_r(encap_ip->ip_src, addrbuf), __func__, ntohl(encap_ip->ip_src.s_addr),
ntohs(encap_ip->ip_len)); ntohs(encap_ip->ip_len));
/* verify the version number of the inner packet */ /* verify the version number of the inner packet */
@ -2713,8 +2697,8 @@ pim_input(struct mbuf **mp, int *offp, int proto)
/* verify the inner packet is destined to a mcast group */ /* verify the inner packet is destined to a mcast group */
if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) { if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) {
PIMSTAT_INC(pims_rcv_badregisters); PIMSTAT_INC(pims_rcv_badregisters);
CTR2(KTR_IPMF, "%s: bad encap ip dest %s", __func__, CTR2(KTR_IPMF, "%s: bad encap ip dest 0x%08x", __func__,
inet_ntoa_r(encap_ip->ip_dst, addrbuf)); ntohl(encap_ip->ip_dst.s_addr));
m_freem(m); m_freem(m);
return (IPPROTO_DONE); return (IPPROTO_DONE);
} }