diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c index 9bcc1b0daea4..255f94eda3bd 100644 --- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c +++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c @@ -1461,6 +1461,9 @@ static void process_data(struct iwch_ep *ep) { 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]); @@ -1479,8 +1482,8 @@ process_data(struct iwch_ep *ep) in_getsockaddr(ep->com.so, (struct sockaddr **)&local); in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote); CTR3(KTR_IW_CXGB, "%s local %s remote %s", __FUNCTION__, - inet_ntoa(local->sin_addr), - inet_ntoa(remote->sin_addr)); + inet_ntoa_r(local->sin_addr, local_str), + inet_ntoa_r(remote->sin_addr, remote_str)); ep->com.local_addr = *local; ep->com.remote_addr = *remote; free(local, M_SONAME); @@ -1519,6 +1522,9 @@ process_newconn(struct iw_cm_id *parent_cm_id, struct socket *child_so) struct sockaddr_in *local; struct sockaddr_in *remote; 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); if (!child_so) { @@ -1539,7 +1545,7 @@ process_newconn(struct iw_cm_id *parent_cm_id, struct socket *child_so) in_getpeeraddr(child_so, (struct sockaddr **)&remote); CTR3(KTR_IW_CXGB, "%s remote addr %s port %d", __FUNCTION__, - inet_ntoa(remote->sin_addr), ntohs(remote->sin_port)); + inet_ntoa_r(remote->sin_addr, buf), ntohs(remote->sin_port)); 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_port = parent_ep->com.local_addr.sin_port; diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c index 130d42314194..3c6d0b3ffba7 100644 --- a/sys/fs/nfsserver/nfs_nfsdkrpc.c +++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c @@ -174,7 +174,11 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt) if (port >= IPPORT_RESERVED && nd.nd_procnum != NFSPROC_NULL) { #ifdef INET6 - char b6[INET6_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; +#else + char buf[INET_ADDRSTRLEN]; +#endif +#ifdef INET6 #if defined(KLD_MODULE) /* Do not use ip6_sprintf: the nfs module should work without INET6. */ #define ip6_sprintf(buf, a) \ @@ -189,12 +193,12 @@ nfssvc_program(struct svc_req *rqst, SVCXPRT *xprt) printf("NFS request from unprivileged port (%s:%d)\n", #ifdef INET6 sin->sin_family == AF_INET6 ? - ip6_sprintf(b6, &satosin6(sin)->sin6_addr) : + ip6_sprintf(buf, &satosin6(sin)->sin6_addr) : #if defined(KLD_MODULE) #undef ip6_sprintf #endif #endif - inet_ntoa(sin->sin_addr), port); + inet_ntoa_r(sin->sin_addr, buf), port); svcerr_weakauth(rqst); svc_freereq(rqst); m_freem(nd.nd_mrep); diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index a1734e1da0d7..1197a7519eda 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -3999,6 +3999,9 @@ db_show_prison(struct prison *pr) int ii; #endif unsigned jsf; +#ifdef INET + char ip4buf[INET_ADDRSTRLEN]; +#endif #ifdef INET6 char ip6buf[INET6_ADDRSTRLEN]; #endif @@ -4050,7 +4053,7 @@ db_show_prison(struct prison *pr) for (ii = 0; ii < pr->pr_ip4s; ii++) db_printf(" %s %s\n", ii == 0 ? "ip4.addr =" : " ", - inet_ntoa(pr->pr_ip4[ii])); + inet_ntoa_r(pr->pr_ip4[ii], ip4buf)); #endif #ifdef INET6 db_printf(" ip6s = %d\n", pr->pr_ip6s); diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 98ccf6a951a2..25dff3a5bcd2 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -464,9 +464,12 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int flags, struct mbuf *m, if (la == NULL && (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { la = lltable_alloc_entry(LLTABLE(ifp), 0, dst); if (la == NULL) { + char addrbuf[INET_ADDRSTRLEN]; + log(LOG_DEBUG, "arpresolve: can't allocate llinfo for %s on %s\n", - inet_ntoa(SIN(dst)->sin_addr), if_name(ifp)); + inet_ntoa_r(SIN(dst)->sin_addr, addrbuf), + if_name(ifp)); m_freem(m); return (EINVAL); } @@ -803,6 +806,7 @@ in_arpinput(struct mbuf *m) size_t linkhdrsize; int lladdr_off; int error; + char addrbuf[INET_ADDRSTRLEN]; sin.sin_len = sizeof(struct sockaddr_in); sin.sin_family = AF_INET; @@ -927,7 +931,7 @@ match: goto drop; /* it's from me, ignore it. */ if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) { ARP_LOG(LOG_NOTICE, "link address is broadcast for IP address " - "%s!\n", inet_ntoa(isaddr)); + "%s!\n", inet_ntoa_r(isaddr, addrbuf)); goto drop; } @@ -949,7 +953,7 @@ match: myaddr.s_addr != 0) { ARP_LOG(LOG_ERR, "%*D is using my IP address %s on %s!\n", ifp->if_addrlen, (u_char *)ar_sha(ah), ":", - inet_ntoa(isaddr), ifp->if_xname); + inet_ntoa_r(isaddr, addrbuf), ifp->if_xname); itaddr = myaddr; ARPSTAT_INC(dupips); goto reply; @@ -1086,12 +1090,14 @@ reply: if (nh4.nh_ifp != ifp) { ARP_LOG(LOG_INFO, "proxy: ignoring request" " from %s via %s\n", - inet_ntoa(isaddr), ifp->if_xname); + inet_ntoa_r(isaddr, addrbuf), + ifp->if_xname); goto drop; } #ifdef DEBUG_PROXY - printf("arp: proxying for %s\n", inet_ntoa(itaddr)); + printf("arp: proxying for %s\n", + inet_ntoa_r(itaddr, addrbuf)); #endif } } @@ -1101,7 +1107,7 @@ reply: /* RFC 3927 link-local IPv4; always reply by broadcast. */ #ifdef DEBUG_LINKLOCAL printf("arp: sending reply for link-local addr %s\n", - inet_ntoa(itaddr)); + inet_ntoa_r(itaddr, addrbuf)); #endif m->m_flags |= M_BCAST; m->m_flags &= ~M_MCAST; @@ -1162,6 +1168,7 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp uint8_t linkhdr[LLE_MAX_LINKHDR]; size_t linkhdrsize; int lladdr_off; + char addrbuf[INET_ADDRSTRLEN]; LLE_WLOCK_ASSERT(la); @@ -1170,7 +1177,7 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp if (log_arp_wrong_iface) ARP_LOG(LOG_WARNING, "%s is on %s " "but got reply from %*D on %s\n", - inet_ntoa(isaddr), + inet_ntoa_r(isaddr, addrbuf), la->lle_tbl->llt_ifp->if_xname, ifp->if_addrlen, (u_char *)ar_sha(ah), ":", ifp->if_xname); @@ -1187,13 +1194,14 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp "permanent entry for %s on %s\n", ifp->if_addrlen, (u_char *)ar_sha(ah), ":", - inet_ntoa(isaddr), ifp->if_xname); + inet_ntoa_r(isaddr, addrbuf), + ifp->if_xname); return; } if (log_arp_movements) { ARP_LOG(LOG_INFO, "%s moved from %*D " "to %*D on %s\n", - inet_ntoa(isaddr), + inet_ntoa_r(isaddr, addrbuf), ifp->if_addrlen, (u_char *)&la->ll_addr, ":", ifp->if_addrlen, (u_char *)ar_sha(ah), ":", diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 3b7d3275282a..9125389c2c97 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -314,12 +314,12 @@ igmp_scrub_context(struct mbuf *m) #ifdef KTR static __inline char * -inet_ntoa_haddr(in_addr_t haddr) +inet_ntoa_haddr(in_addr_t haddr, char *addrbuf) { struct in_addr ia; ia.s_addr = htonl(haddr); - return (inet_ntoa(ia)); + return (inet_ntoa_r(ia, addrbuf)); } #endif @@ -804,6 +804,9 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip, struct in_multi *inm; int is_general_query; uint16_t timer; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif is_general_query = 0; @@ -873,7 +876,8 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip, inm = inm_lookup(ifp, igmp->igmp_group); if (inm != NULL) { CTR3(KTR_IGMPV3, "process v2 query %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, + ifp->if_xname); igmp_v2_update_group(inm, timer); } } @@ -903,9 +907,12 @@ out_locked: static void 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__, - inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname, timer); + inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname, timer); IN_MULTI_LOCK_ASSERT(); @@ -956,6 +963,9 @@ igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip, uint32_t maxresp, nsrc, qqi; uint16_t timer; uint8_t qrv; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif is_general_query = 0; @@ -1086,7 +1096,8 @@ igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip, } } CTR3(KTR_IGMPV3, "process v3 %s query on ifp %p(%s)", - inet_ntoa(igmpv3->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmpv3->igmp_group, addrbuf), ifp, + ifp->if_xname); /* * If there is a pending General Query response * scheduled sooner than the selected delay, no @@ -1219,6 +1230,9 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip, struct rm_priotracker in_ifa_tracker; struct in_ifaddr *ia; struct in_multi *inm; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif IGMPSTAT_INC(igps_rcv_reports); @@ -1247,7 +1261,7 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip, } CTR3(KTR_IGMPV3, "process v1 report %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname); /* * IGMPv1 report suppression. @@ -1290,14 +1304,16 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip, case IGMP_AWAKENING_MEMBER: CTR3(KTR_IGMPV3, "report suppressed for %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, + ifp->if_xname); case IGMP_SLEEPING_MEMBER: inm->inm_state = IGMP_SLEEPING_MEMBER; break; case IGMP_REPORTING_MEMBER: CTR3(KTR_IGMPV3, "report suppressed for %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, + ifp->if_xname); if (igi->igi_version == IGMP_VERSION_1) inm->inm_state = IGMP_LAZY_MEMBER; else if (igi->igi_version == IGMP_VERSION_2) @@ -1328,6 +1344,9 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip, struct rm_priotracker in_ifa_tracker; struct in_ifaddr *ia; struct in_multi *inm; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif /* * Make sure we don't hear our own membership report. Fast @@ -1371,7 +1390,7 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip, ifa_free(&ia->ia_ifa); CTR3(KTR_IGMPV3, "process v2 report %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname); /* * IGMPv2 report suppression. @@ -1412,7 +1431,8 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip, case IGMP_AWAKENING_MEMBER: CTR3(KTR_IGMPV3, "report suppressed for %s on ifp %p(%s)", - inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname); + inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, + ifp->if_xname); case IGMP_LAZY_MEMBER: inm->inm_state = IGMP_LAZY_MEMBER; break; @@ -1814,6 +1834,9 @@ igmp_v3_process_group_timers(struct igmp_ifsoftc *igi, { int query_response_timer_expired; int state_change_retransmit_timer_expired; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif IN_MULTI_LOCK_ASSERT(); IGMP_LOCK_ASSERT(); @@ -1900,7 +1923,8 @@ igmp_v3_process_group_timers(struct igmp_ifsoftc *igi, inm_commit(inm); CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, - inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname); + inet_ntoa_r(inm->inm_addr, addrbuf), + inm->inm_ifp->if_xname); /* * If we are leaving the group for good, make sure @@ -2346,9 +2370,12 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifsoftc *igi) struct ifnet *ifp; struct mbufq *mq; int error, retval, syncstates; - +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif + CTR4(KTR_IGMPV3, "%s: initial join %s on ifp %p(%s)", - __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp, + __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_ifp->if_xname); error = 0; @@ -2459,7 +2486,8 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifsoftc *igi) if (syncstates) { inm_commit(inm); CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, - inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname); + inet_ntoa_r(inm->inm_addr, addrbuf), + inm->inm_ifp->if_xname); } return (error); @@ -2473,9 +2501,12 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifsoftc *igi) { struct ifnet *ifp; int retval; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif CTR4(KTR_IGMPV3, "%s: state change for %s on ifp %p(%s)", - __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp, + __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_ifp->if_xname); ifp = inm->inm_ifp; @@ -2496,7 +2527,8 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifsoftc *igi) CTR1(KTR_IGMPV3, "%s: nothing to do", __func__); inm_commit(inm); CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, - inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname); + inet_ntoa_r(inm->inm_addr, addrbuf), + inm->inm_ifp->if_xname); return (0); } @@ -2531,11 +2563,14 @@ static void igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi) { int syncstates; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif syncstates = 1; CTR4(KTR_IGMPV3, "%s: final leave %s on ifp %p(%s)", - __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp, + __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_ifp->if_xname); IN_MULTI_LOCK_ASSERT(); @@ -2578,7 +2613,7 @@ igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi) } CTR4(KTR_IGMPV3, "%s: Leaving %s/%s with %d " "pending retransmissions.", __func__, - inet_ntoa(inm->inm_addr), + inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname, inm->inm_scrv); if (inm->inm_scrv == 0) { inm->inm_state = IGMP_NOT_MEMBER; @@ -2612,10 +2647,12 @@ igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi) if (syncstates) { inm_commit(inm); CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__, - inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname); + inet_ntoa_r(inm->inm_addr, addrbuf), + inm->inm_ifp->if_xname); inm->inm_st[1].iss_fmode = MCAST_UNDEFINED; CTR3(KTR_IGMPV3, "%s: T1 now MCAST_UNDEFINED for %s/%s", - __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname); + __func__, inet_ntoa_r(inm->inm_addr, addrbuf), + inm->inm_ifp->if_xname); } } @@ -2663,6 +2700,9 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm, int type; in_addr_t naddr; uint8_t mode; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif IN_MULTI_LOCK_ASSERT(); @@ -2741,7 +2781,7 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm, if (type == IGMP_DO_NOTHING) { CTR3(KTR_IGMPV3, "%s: nothing to do for %s/%s", - __func__, inet_ntoa(inm->inm_addr), + __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname); return (0); } @@ -2756,7 +2796,7 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm, minrec0len += sizeof(in_addr_t); CTR4(KTR_IGMPV3, "%s: queueing %s for %s/%s", __func__, - igmp_rec_type_to_str(type), inet_ntoa(inm->inm_addr), + igmp_rec_type_to_str(type), inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname); /* @@ -2845,7 +2885,7 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm, msrcs = 0; RB_FOREACH_SAFE(ims, ip_msource_tree, &inm->inm_srcs, nims) { CTR2(KTR_IGMPV3, "%s: visit node %s", __func__, - inet_ntoa_haddr(ims->ims_haddr)); + inet_ntoa_haddr(ims->ims_haddr, addrbuf)); now = ims_get_mode(inm, ims, 1); CTR2(KTR_IGMPV3, "%s: node is %d", __func__, now); if ((now != mode) || @@ -2941,7 +2981,7 @@ igmp_v3_enqueue_group_record(struct mbufq *mq, struct in_multi *inm, msrcs = 0; RB_FOREACH_FROM(ims, ip_msource_tree, nims) { CTR2(KTR_IGMPV3, "%s: visit node %s", __func__, - inet_ntoa_haddr(ims->ims_haddr)); + inet_ntoa_haddr(ims->ims_haddr, addrbuf)); now = ims_get_mode(inm, ims, 1); if ((now != mode) || (now == mode && mode == MCAST_UNDEFINED)) { @@ -3024,6 +3064,9 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm) int nallow, nblock; uint8_t mode, now, then; rectype_t crt, drt, nrt; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif IN_MULTI_LOCK_ASSERT(); @@ -3133,7 +3176,8 @@ igmp_v3_enqueue_filter_change(struct mbufq *mq, struct in_multi *inm) nims = RB_MIN(ip_msource_tree, &inm->inm_srcs); RB_FOREACH_FROM(ims, ip_msource_tree, nims) { CTR2(KTR_IGMPV3, "%s: visit node %s", - __func__, inet_ntoa_haddr(ims->ims_haddr)); + __func__, + inet_ntoa_haddr(ims->ims_haddr, addrbuf)); now = ims_get_mode(inm, ims, 1); then = ims_get_mode(inm, ims, 0); CTR3(KTR_IGMPV3, "%s: mode: t0 %d, t1 %d", diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 9588915f29a5..7187469bcc58 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1218,7 +1218,7 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr */ if (!(rt_flags & RTF_HOST) && info.rti_ifp != ifp) { const char *sa, *mask, *addr, *lim; - int len; + const struct sockaddr_in *l3sin; mask = (const char *)&rt_mask; /* @@ -1230,14 +1230,17 @@ in_lltable_rtcheck(struct ifnet *ifp, u_int flags, const struct sockaddr *l3addr sa = (const char *)&rt_key; addr = (const char *)l3addr; - len = ((const struct sockaddr_in *)l3addr)->sin_len; - lim = addr + len; + l3sin = (const struct sockaddr_in *)l3addr; + lim = addr + l3sin->sin_len; for ( ; addr < lim; sa++, mask++, addr++) { if ((*sa ^ *addr) & *mask) { #ifdef DIAGNOSTIC - log(LOG_INFO, "IPv4 address: \"%s\" is not on the network\n", - inet_ntoa(((const struct sockaddr_in *)l3addr)->sin_addr)); + char addrbuf[INET_ADDRSTRLEN]; + + log(LOG_INFO, "IPv4 address: \"%s\" " + "is not on the network\n", + inet_ntoa_r(l3sin->sin_addr, addrbuf)); #endif return (EINVAL); } diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 07b5bbabb691..078f2f24536a 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -495,9 +495,12 @@ in_getmulti(struct ifnet *ifp, const struct in_addr *group, ("%s: ifma not AF_INET", __func__)); KASSERT(inm != NULL, ("%s: no ifma_protospec", __func__)); if (inm->inm_ifma != ifma || inm->inm_ifp != ifp || - !in_hosteq(inm->inm_addr, *group)) + !in_hosteq(inm->inm_addr, *group)) { + char addrbuf[INET_ADDRSTRLEN]; + panic("%s: ifma %p is inconsistent with %p (%s)", - __func__, ifma, inm, inet_ntoa(*group)); + __func__, ifma, inm, inet_ntoa_r(*group, addrbuf)); + } #endif ++inm->inm_refcount; *pinm = inm; @@ -875,7 +878,8 @@ inm_get_source(struct in_multi *inm, const in_addr_t haddr, struct ip_msource find; struct ip_msource *ims, *nims; #ifdef KTR - struct in_addr ia; + struct in_addr ia; + char addrbuf[INET_ADDRSTRLEN]; #endif find.ims_haddr = haddr; @@ -894,7 +898,7 @@ inm_get_source(struct in_multi *inm, const in_addr_t haddr, #ifdef KTR ia.s_addr = htonl(haddr); CTR3(KTR_IGMPV3, "%s: allocated %s as %p", __func__, - inet_ntoa(ia), ims); + inet_ntoa_r(ia, addrbuf), ims); #endif } @@ -912,6 +916,7 @@ ims_merge(struct ip_msource *ims, const struct in_msource *lims, { int n = rollback ? -1 : 1; #ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; struct in_addr ia; ia.s_addr = htonl(ims->ims_haddr); @@ -919,21 +924,21 @@ ims_merge(struct ip_msource *ims, const struct in_msource *lims, if (lims->imsl_st[0] == MCAST_EXCLUDE) { CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on %s", - __func__, n, inet_ntoa(ia)); + __func__, n, inet_ntoa_r(ia, addrbuf)); ims->ims_st[1].ex -= n; } else if (lims->imsl_st[0] == MCAST_INCLUDE) { CTR3(KTR_IGMPV3, "%s: t1 in -= %d on %s", - __func__, n, inet_ntoa(ia)); + __func__, n, inet_ntoa_r(ia, addrbuf)); ims->ims_st[1].in -= n; } if (lims->imsl_st[1] == MCAST_EXCLUDE) { CTR3(KTR_IGMPV3, "%s: t1 ex += %d on %s", - __func__, n, inet_ntoa(ia)); + __func__, n, inet_ntoa_r(ia, addrbuf)); ims->ims_st[1].ex += n; } else if (lims->imsl_st[1] == MCAST_INCLUDE) { CTR3(KTR_IGMPV3, "%s: t1 in += %d on %s", - __func__, n, inet_ntoa(ia)); + __func__, n, inet_ntoa_r(ia, addrbuf)); ims->ims_st[1].in += n; } } @@ -1166,11 +1171,14 @@ in_joingroup_locked(struct ifnet *ifp, const struct in_addr *gina, struct in_mfilter timf; struct in_multi *inm; int error; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif IN_MULTI_LOCK_ASSERT(); CTR4(KTR_IGMPV3, "%s: join %s on %p(%s))", __func__, - inet_ntoa(*gina), ifp, ifp->if_xname); + inet_ntoa_r(*gina, addrbuf), ifp, ifp->if_xname); error = 0; inm = NULL; @@ -1248,13 +1256,16 @@ in_leavegroup_locked(struct in_multi *inm, /*const*/ struct in_mfilter *imf) { struct in_mfilter timf; int error; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif error = 0; IN_MULTI_LOCK_ASSERT(); CTR5(KTR_IGMPV3, "%s: leave inm %p, %s/%s, imf %p", __func__, - inm, inet_ntoa(inm->inm_addr), + inm, inet_ntoa_r(inm->inm_addr, addrbuf), (inm_is_ifp_detached(inm) ? "null" : inm->inm_ifp->if_xname), imf); @@ -1302,9 +1313,13 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp) { struct in_multi *pinm; int error; +#ifdef INVARIANTS + char addrbuf[INET_ADDRSTRLEN]; +#endif KASSERT(IN_LOCAL_GROUP(ntohl(ap->s_addr)), - ("%s: %s not in 224.0.0.0/24", __func__, inet_ntoa(*ap))); + ("%s: %s not in 224.0.0.0/24", __func__, + inet_ntoa_r(*ap, addrbuf))); error = in_joingroup(ifp, ap, NULL, &pinm); if (error != 0) @@ -1349,6 +1364,9 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt) size_t idx; uint16_t fmode; int error, doblock; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif ifp = NULL; error = 0; @@ -1384,7 +1402,7 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt) doblock = 1; CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", - __func__, inet_ntoa(mreqs.imr_interface), ifp); + __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); break; } @@ -1457,7 +1475,8 @@ inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt) ims = imo_match_source(imo, idx, &ssa->sa); if ((ims != NULL && doblock) || (ims == NULL && !doblock)) { CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__, - inet_ntoa(ssa->sin.sin_addr), doblock ? "" : "not "); + inet_ntoa_r(ssa->sin.sin_addr, addrbuf), + doblock ? "" : "not "); error = EADDRNOTAVAIL; goto out_inp_locked; } @@ -1934,6 +1953,9 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt) struct in_msource *lims; size_t idx; int error, is_new; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif ifp = NULL; imf = NULL; @@ -1986,7 +2008,7 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt) ifp = inp_lookup_mcast_ifp(inp, &gsa->sin, mreqs.imr_interface); CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", - __func__, inet_ntoa(mreqs.imr_interface), ifp); + __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); break; } @@ -2233,6 +2255,9 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt) struct in_multi *inm; size_t idx; int error, is_final; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif ifp = NULL; error = 0; @@ -2287,7 +2312,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt) INADDR_TO_IFP(mreqs.imr_interface, ifp); CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", - __func__, inet_ntoa(mreqs.imr_interface), ifp); + __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp); break; @@ -2368,7 +2393,7 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt) ims = imo_match_source(imo, idx, &ssa->sa); if (ims == NULL) { CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__, - inet_ntoa(ssa->sin.sin_addr), "not "); + inet_ntoa_r(ssa->sin.sin_addr, addrbuf), "not "); error = EADDRNOTAVAIL; goto out_inp_locked; } @@ -2450,6 +2475,9 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt) struct ifnet *ifp; struct ip_moptions *imo; int error; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif if (sopt->sopt_valsize == sizeof(struct ip_mreqn)) { /* @@ -2488,7 +2516,7 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt) return (EADDRNOTAVAIL); } CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = %s", __func__, ifp, - inet_ntoa(addr)); + inet_ntoa_r(addr, addrbuf)); } /* Reject interfaces which do not support multicast. */ @@ -2846,6 +2874,9 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS) int retval; u_int namelen; uint32_t fmode, ifindex; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif name = (int *)arg1; namelen = arg2; @@ -2866,7 +2897,7 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS) group.s_addr = name[1]; if (!IN_MULTICAST(ntohl(group.s_addr))) { CTR2(KTR_IGMPV3, "%s: group %s is not multicast", - __func__, inet_ntoa(group)); + __func__, inet_ntoa_r(group, addrbuf)); return (EINVAL); } @@ -2901,7 +2932,7 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS) struct in_addr ina; ina.s_addr = htonl(ims->ims_haddr); CTR2(KTR_IGMPV3, "%s: visit node %s", __func__, - inet_ntoa(ina)); + inet_ntoa_r(ina, addrbuf)); #endif /* * Only copy-out sources which are in-mode. @@ -2965,13 +2996,14 @@ void inm_print(const struct in_multi *inm) { int t; + char addrbuf[INET_ADDRSTRLEN]; if ((ktr_mask & KTR_IGMPV3) == 0) return; printf("%s: --- begin inm %p ---\n", __func__, inm); printf("addr %s ifp %p(%s) ifma %p\n", - inet_ntoa(inm->inm_addr), + inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp, inm->inm_ifp->if_xname, inm->inm_ifma); diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index d1a26a8184b8..37a3b293bc4f 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -380,10 +380,12 @@ icmp_input(struct mbuf **mp, int *offp, int proto) */ #ifdef ICMPPRINTFS if (icmpprintfs) { - char buf[4 * sizeof "123"]; - strcpy(buf, inet_ntoa(ip->ip_src)); + char srcbuf[INET_ADDRSTRLEN]; + char dstbuf[INET_ADDRSTRLEN]; + printf("icmp_input from %s to %s, len %d\n", - buf, inet_ntoa(ip->ip_dst), icmplen); + inet_ntoa_r(ip->ip_src, srcbuf), + inet_ntoa_r(ip->ip_dst, dstbuf), icmplen); } #endif if (icmplen < ICMP_MINLEN) { @@ -649,11 +651,12 @@ reflect: icmpdst.sin_addr = icp->icmp_gwaddr; #ifdef ICMPPRINTFS if (icmpprintfs) { - char buf[4 * sizeof "123"]; - strcpy(buf, inet_ntoa(icp->icmp_ip.ip_dst)); + char dstbuf[INET_ADDRSTRLEN]; + char gwbuf[INET_ADDRSTRLEN]; printf("redirect dst %s to %s\n", - buf, inet_ntoa(icp->icmp_gwaddr)); + inet_ntoa_r(icp->icmp_ip.ip_dst, dstbuf), + inet_ntoa_r(icp->icmp_gwaddr, gwbuf)); } #endif icmpsrc.sin_addr = icp->icmp_ip.ip_dst; @@ -901,10 +904,12 @@ icmp_send(struct mbuf *m, struct mbuf *opts) m->m_pkthdr.rcvif = (struct ifnet *)0; #ifdef ICMPPRINTFS if (icmpprintfs) { - char buf[4 * sizeof "123"]; - strcpy(buf, inet_ntoa(ip->ip_dst)); + char dstbuf[INET_ADDRSTRLEN]; + char srcbuf[INET_ADDRSTRLEN]; + printf("icmp_send dst %s src %s\n", - buf, inet_ntoa(ip->ip_src)); + inet_ntoa_r(ip->ip_dst, dstbuf), + inet_ntoa_r(ip->ip_src, srcbuf)); } #endif (void) ip_output(m, opts, NULL, 0, NULL, NULL); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index c0730caca8f4..58f8cc70a2e9 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -845,6 +845,9 @@ add_vif(struct vifctl *vifcp) struct ifaddr *ifa; struct ifnet *ifp; int error; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif VIF_LOCK(); if (vifcp->vifc_vifi >= MAXVIFS) { @@ -929,7 +932,7 @@ add_vif(struct vifctl *vifcp) VIF_UNLOCK(); CTR4(KTR_IPMF, "%s: add vif %d laddr %s thresh %x", __func__, - (int)vifcp->vifc_vifi, inet_ntoa(vifcp->vifc_lcl_addr), + (int)vifcp->vifc_vifi, inet_ntoa_r(vifcp->vifc_lcl_addr, addrbuf), (int)vifcp->vifc_threshold); return 0; @@ -1052,6 +1055,9 @@ add_mfc(struct mfcctl2 *mfccp) struct rtdetq *rte, *nrte; u_long hash = 0; u_short nstl; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif VIF_LOCK(); MFC_LOCK(); @@ -1061,7 +1067,7 @@ add_mfc(struct mfcctl2 *mfccp) /* If an entry already exists, just update the fields */ if (rt) { CTR4(KTR_IPMF, "%s: update mfc orig %s group %lx parent %x", - __func__, inet_ntoa(mfccp->mfcc_origin), + __func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), mfccp->mfcc_parent); update_mfc_params(rt, mfccp); @@ -1081,7 +1087,7 @@ add_mfc(struct mfcctl2 *mfccp) !TAILQ_EMPTY(&rt->mfc_stall)) { CTR5(KTR_IPMF, "%s: add mfc orig %s group %lx parent %x qh %p", - __func__, inet_ntoa(mfccp->mfcc_origin), + __func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), mfccp->mfcc_parent, TAILQ_FIRST(&rt->mfc_stall)); @@ -1155,12 +1161,15 @@ del_mfc(struct mfcctl2 *mfccp) struct in_addr origin; struct in_addr mcastgrp; struct mfc *rt; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif origin = mfccp->mfcc_origin; mcastgrp = mfccp->mfcc_mcastgrp; CTR3(KTR_IPMF, "%s: delete mfc orig %s group %lx", __func__, - inet_ntoa(origin), (u_long)ntohl(mcastgrp.s_addr)); + inet_ntoa_r(origin, addrbuf), (u_long)ntohl(mcastgrp.s_addr)); MFC_LOCK(); @@ -1223,9 +1232,13 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, struct mfc *rt; int error; vifi_t vifi; +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif CTR3(KTR_IPMF, "ip_mforward: delete mfc orig %s group %lx ifp %p", - inet_ntoa(ip->ip_src), (u_long)ntohl(ip->ip_dst.s_addr), ifp); + inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr), + ifp); if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 || ((u_char *)(ip + 1))[1] != IPOPT_LSRR ) { @@ -1288,7 +1301,7 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m, MRTSTAT_INC(mrts_mfc_misses); MRTSTAT_INC(mrts_no_route); CTR2(KTR_IPMF, "ip_mforward: no mfc for (%s,%lx)", - inet_ntoa(ip->ip_src), (u_long)ntohl(ip->ip_dst.s_addr)); + inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr)); /* * Allocate mbufs early so that we don't do extra work if we are @@ -2570,7 +2583,10 @@ pim_input(struct mbuf **mp, int *offp, int proto) int minlen; int datalen = ntohs(ip->ip_len) - iphlen; int ip_tos; - +#ifdef KTR + char addrbuf[INET_ADDRSTRLEN]; +#endif + *mp = NULL; /* Keep statistics */ @@ -2583,7 +2599,7 @@ pim_input(struct mbuf **mp, int *offp, int proto) if (datalen < PIM_MINLEN) { PIMSTAT_INC(pims_rcv_tooshort); CTR3(KTR_IPMF, "%s: short packet (%d) from %s", - __func__, datalen, inet_ntoa(ip->ip_src)); + __func__, datalen, inet_ntoa_r(ip->ip_src, addrbuf)); m_freem(m); return (IPPROTO_DONE); } @@ -2683,7 +2699,8 @@ pim_input(struct mbuf **mp, int *offp, int proto) encap_ip = (struct ip *)(reghdr + 1); CTR3(KTR_IPMF, "%s: register: encap ip src %s len %d", - __func__, inet_ntoa(encap_ip->ip_src), ntohs(encap_ip->ip_len)); + __func__, inet_ntoa_r(encap_ip->ip_src, addrbuf), + ntohs(encap_ip->ip_len)); /* verify the version number of the inner packet */ if (encap_ip->ip_v != IPVERSION) { @@ -2697,7 +2714,7 @@ pim_input(struct mbuf **mp, int *offp, int proto) if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) { PIMSTAT_INC(pims_rcv_badregisters); CTR2(KTR_IPMF, "%s: bad encap ip dest %s", __func__, - inet_ntoa(encap_ip->ip_dst)); + inet_ntoa_r(encap_ip->ip_dst, addrbuf)); m_freem(m); return (IPPROTO_DONE); } diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c index 3e44ffb7b7c9..399c88bdbb52 100644 --- a/sys/netinet/ip_options.c +++ b/sys/netinet/ip_options.c @@ -196,16 +196,19 @@ ip_dooptions(struct mbuf *m, int pass) #endif if (!V_ip_dosourceroute) { if (V_ipforwarding) { - char buf[16]; /* aaa.bbb.ccc.ddd\0 */ + char srcbuf[INET_ADDRSTRLEN]; + char dstbuf[INET_ADDRSTRLEN]; + /* * Acting as a router, so generate * ICMP */ nosourcerouting: - strcpy(buf, inet_ntoa(ip->ip_dst)); log(LOG_WARNING, - "attempted source route from %s to %s\n", - inet_ntoa(ip->ip_src), buf); + "attempted source route from %s " + "to %s\n", + inet_ntoa_r(ip->ip_src, srcbuf), + inet_ntoa_r(ip->ip_dst, dstbuf)); type = ICMP_UNREACH; code = ICMP_UNREACH_SRCFAIL; goto bad; diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h index 506193c6b557..e9e843c6e95a 100644 --- a/sys/netinet/libalias/alias_local.h +++ b/sys/netinet/libalias/alias_local.h @@ -70,6 +70,12 @@ #define GET_ALIAS_PORT -1 #define GET_ALIAS_ID GET_ALIAS_PORT +#ifdef _KERNEL +#define INET_NTOA_BUF(buf) (buf) +#else +#define INET_NTOA_BUF(buf) (buf), sizeof(buf) +#endif + struct proxy_entry; struct libalias { diff --git a/sys/netinet/libalias/alias_nbt.c b/sys/netinet/libalias/alias_nbt.c index a7598f823d80..b041699f9fb6 100644 --- a/sys/netinet/libalias/alias_nbt.c +++ b/sys/netinet/libalias/alias_nbt.c @@ -344,6 +344,9 @@ AliasHandleUdpNbt( NbtDataHeader *ndh; u_char *p = NULL; char *pmax; +#ifdef LIBALIAS_DEBUG + char addrbuf[INET_ADDRSTRLEN]; +#endif (void)la; (void)lnk; @@ -379,7 +382,8 @@ AliasHandleUdpNbt( if (p == NULL || (char *)p > pmax) p = NULL; #ifdef LIBALIAS_DEBUG - printf("%s:%d-->", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port)); + printf("%s:%d-->", inet_ntoa_r(ndh->source_ip, INET_NTOA_BUF(addrbuf)), + ntohs(ndh->source_port)); #endif /* Doing an IP address and Port number Translation */ if (uh->uh_sum != 0) { @@ -399,7 +403,8 @@ AliasHandleUdpNbt( ndh->source_ip = *alias_address; ndh->source_port = alias_port; #ifdef LIBALIAS_DEBUG - printf("%s:%d\n", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port)); + printf("%s:%d\n", inet_ntoa_r(ndh->source_ip, INET_NTOA_BUF(addrbuf)), + ntohs(ndh->source_port)); fflush(stdout); #endif return ((p == NULL) ? -1 : 0); @@ -480,6 +485,10 @@ AliasHandleResourceNB( { NBTNsRNB *nb; u_short bcount; +#ifdef LIBALIAS_DEBUG + char oldbuf[INET_ADDRSTRLEN]; + char newbuf[INET_ADDRSTRLEN]; +#endif if (q == NULL || (char *)(q + 1) > pmax) return (NULL); @@ -491,8 +500,10 @@ AliasHandleResourceNB( /* Processing all in_addr array */ #ifdef LIBALIAS_DEBUG - printf("NB rec[%s", inet_ntoa(nbtarg->oldaddr)); - printf("->%s, %dbytes] ", inet_ntoa(nbtarg->newaddr), bcount); + printf("NB rec[%s->%s, %dbytes] ", + inet_ntoa_r(nbtarg->oldaddr, INET_NTOA_BUF(oldbuf)), + inet_ntoa_r(nbtarg->newaddr, INET_NTOA_BUF(newbuf)), + bcount); #endif while (nb != NULL && bcount != 0) { if ((char *)(nb + 1) > pmax) { @@ -500,7 +511,7 @@ AliasHandleResourceNB( break; } #ifdef LIBALIAS_DEBUG - printf("<%s>", inet_ntoa(nb->addr)); + printf("<%s>", inet_ntoa_r(nb->addr, INET_NTOA_BUF(newbuf))); #endif if (!bcmp(&nbtarg->oldaddr, &nb->addr, sizeof(struct in_addr))) { if (*nbtarg->uh_sum != 0) { @@ -547,6 +558,10 @@ AliasHandleResourceA( { NBTNsResourceA *a; u_short bcount; +#ifdef LIBALIAS_DEBUG + char oldbuf[INET_ADDRSTRLEN]; + char newbuf[INET_ADDRSTRLEN]; +#endif if (q == NULL || (char *)(q + 1) > pmax) return (NULL); @@ -559,14 +574,15 @@ AliasHandleResourceA( /* Processing all in_addr array */ #ifdef LIBALIAS_DEBUG - printf("Arec [%s", inet_ntoa(nbtarg->oldaddr)); - printf("->%s]", inet_ntoa(nbtarg->newaddr)); + printf("Arec [%s->%s]", + inet_ntoa_r(nbtarg->oldaddr, INET_NTOA_BUF(oldbuf)), + inet_ntoa_r(nbtarg->newaddr, INET_NTOA_BUF(newbuf))); #endif while (bcount != 0) { if (a == NULL || (char *)(a + 1) > pmax) return (NULL); #ifdef LIBALIAS_DEBUG - printf("..%s", inet_ntoa(a->addr)); + printf("..%s", inet_ntoa_r(a->addr, INET_NTOA_BUF(newbuf))); #endif if (!bcmp(&nbtarg->oldaddr, &a->addr, sizeof(struct in_addr))) { if (*nbtarg->uh_sum != 0) { diff --git a/sys/netinet/libalias/alias_proxy.c b/sys/netinet/libalias/alias_proxy.c index 0d49381b392f..132e56295fce 100644 --- a/sys/netinet/libalias/alias_proxy.c +++ b/sys/netinet/libalias/alias_proxy.c @@ -294,6 +294,7 @@ ProxyEncodeTcpStream(struct alias_link *lnk, int slen; char buffer[40]; struct tcphdr *tc; + char addrbuf[INET_ADDRSTRLEN]; /* Compute pointer to tcp header */ tc = (struct tcphdr *)ip_next(pip); @@ -305,7 +306,8 @@ ProxyEncodeTcpStream(struct alias_link *lnk, /* Translate destination address and port to string form */ snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]", - inet_ntoa(GetProxyAddress(lnk)), (u_int) ntohs(GetProxyPort(lnk))); + inet_ntoa_r(GetProxyAddress(lnk), INET_NTOA_BUF(addrbuf)), + (u_int) ntohs(GetProxyPort(lnk))); /* Pad string out to a multiple of two in length */ slen = strlen(buffer); diff --git a/sys/netinet/libalias/alias_sctp.c b/sys/netinet/libalias/alias_sctp.c index 67e475402d5c..fbc8e41e0ed5 100644 --- a/sys/netinet/libalias/alias_sctp.c +++ b/sys/netinet/libalias/alias_sctp.c @@ -904,6 +904,7 @@ TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_asso int ip_size = sizeof(struct ip) + sctp_size; int include_error_cause = 1; char tmp_ip[ip_size]; + char addrbuf[INET_ADDRSTRLEN]; if (ntohs(sm->ip_hdr->ip_len) < ip_size) { /* short packet, cannot send error cause */ include_error_cause = 0; @@ -984,7 +985,8 @@ TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm, struct sctp_nat_asso ((sndrply == SN_SEND_ABORT) ? "Sending" : "Replying"), ((sndrply & SN_TX_ERROR) ? "ErrorM" : "AbortM"), (include_error_cause ? ntohs(error_cause->code) : 0), - inet_ntoa(ip->ip_dst),ntohs(sctp_hdr->dest_port), + inet_ntoa_r(ip->ip_dst, INET_NTOA_BUF(addrbuf)), + ntohs(sctp_hdr->dest_port), ntohl(sctp_hdr->v_tag), ntohl(sctp_hdr->checksum))); } @@ -2574,6 +2576,8 @@ static void logsctpassoc(struct sctp_nat_assoc *assoc, char* s) { struct sctp_GlobalAddress *G_Addr = NULL; char *sp; + char addrbuf[INET_ADDRSTRLEN]; + switch(assoc->state) { case SN_ID: sp = "ID "; @@ -2598,12 +2602,14 @@ static void logsctpassoc(struct sctp_nat_assoc *assoc, char* s) break; } SctpAliasLog("%sAssoc: %s exp=%u la=%s lv=%u lp=%u gv=%u gp=%u tbl=%d\n", - s, sp, assoc->exp, inet_ntoa(assoc->l_addr), ntohl(assoc->l_vtag), - ntohs(assoc->l_port), ntohl(assoc->g_vtag), ntohs(assoc->g_port), + s, sp, assoc->exp, inet_ntoa_r(assoc->l_addr, addrbuf), + ntohl(assoc->l_vtag), ntohs(assoc->l_port), + ntohl(assoc->g_vtag), ntohs(assoc->g_port), assoc->TableRegister); /* list global addresses */ LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) { - SctpAliasLog("\t\tga=%s\n",inet_ntoa(G_Addr->g_addr)); + SctpAliasLog("\t\tga=%s\n", + inet_ntoa_r(G_Addr->g_addr, addrbuf)); } } diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index d27f2b53df28..4f1de87b8918 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -623,6 +623,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) struct sbuf sb; int i, error; struct hc_metrics *hc_entry; + char ip4buf[INET_ADDRSTRLEN]; #ifdef INET6 char ip6buf[INET6_ADDRSTRLEN]; #endif @@ -645,7 +646,8 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) sbuf_printf(&sb, "%-15s %5u %8u %6lums %6lums %8u %8u %8u %4lu " "%4lu %4i\n", - hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) : + hc_entry->ip4.s_addr ? + inet_ntoa_r(hc_entry->ip4, ip4buf) : #ifdef INET6 ip6_sprintf(ip6buf, &hc_entry->ip6), #else diff --git a/sys/netpfil/ipfw/ip_fw_log.c b/sys/netpfil/ipfw/ip_fw_log.c index 5ef8cf1abf0a..a8e53fe50381 100644 --- a/sys/netpfil/ipfw/ip_fw_log.c +++ b/sys/netpfil/ipfw/ip_fw_log.c @@ -211,6 +211,7 @@ ipfw_log(struct ip_fw_chain *chain, struct ip_fw *f, u_int hlen, TARG(cmd->arg1, pipe)); break; case O_FORWARD_IP: { + char buf[INET_ADDRSTRLEN]; ipfw_insn_sa *sa = (ipfw_insn_sa *)cmd; int len; struct in_addr dummyaddr; @@ -220,7 +221,7 @@ ipfw_log(struct ip_fw_chain *chain, struct ip_fw *f, u_int hlen, dummyaddr.s_addr = sa->sa.sin_addr.s_addr; len = snprintf(SNPARGS(action2, 0), "Forward to %s", - inet_ntoa(dummyaddr)); + inet_ntoa_r(dummyaddr, buf)); if (sa->sa.sin_port) snprintf(SNPARGS(action2, len), ":%d",