Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2017 20:17:48 -0800
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Eric van Gyzen <vangyzen@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r313821 - in head/sys: dev/cxgb/ulp/iw_cxgb fs/nfsserver kern netinet netinet/libalias netpfil/ipfw
Message-ID:  <20170217041748.GI58829@FreeBSD.org>
In-Reply-To: <201702162047.v1GKlf9j014479@repo.freebsd.org>
References:  <201702162047.v1GKlf9j014479@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
  Eric,

  heh, things are worse. Multiple places you changes are CTR()
macros. Neither inet_ntoa() nor inet_ntoa_r() will work with
them. :(

Basicly non-constant strings can not be logged with KTR. All
the lines you touched should log actual binary value of the
IPv4 address.

I am not asking you to do this work! :) But I couldn't leave
that without a comment.

On Thu, Feb 16, 2017 at 08:47:41PM +0000, Eric van Gyzen wrote:
E> Author: vangyzen
E> Date: Thu Feb 16 20:47:41 2017
E> New Revision: 313821
E> URL: https://svnweb.freebsd.org/changeset/base/313821
E> 
E> Log:
E>   Use inet_ntoa_r() instead of inet_ntoa() throughout the kernel
E>   
E>   inet_ntoa() cannot be used safely in a multithreaded environment
E>   because it uses a static local buffer. Instead, use inet_ntoa_r()
E>   with a buffer on the caller's stack.
E>   
E>   Suggested by:	glebius, emaste
E>   Reviewed by:	gnn
E>   MFC after:	2 weeks
E>   Sponsored by:	Dell EMC
E>   Differential Revision:	https://reviews.freebsd.org/D9625
E> 
E> Modified:
E>   head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
E>   head/sys/fs/nfsserver/nfs_nfsdkrpc.c
E>   head/sys/kern/kern_jail.c
E>   head/sys/netinet/if_ether.c
E>   head/sys/netinet/igmp.c
E>   head/sys/netinet/in.c
E>   head/sys/netinet/in_mcast.c
E>   head/sys/netinet/ip_icmp.c
E>   head/sys/netinet/ip_mroute.c
E>   head/sys/netinet/ip_options.c
E>   head/sys/netinet/libalias/alias_local.h
E>   head/sys/netinet/libalias/alias_nbt.c
E>   head/sys/netinet/libalias/alias_proxy.c
E>   head/sys/netinet/libalias/alias_sctp.c
E>   head/sys/netinet/tcp_hostcache.c
E>   head/sys/netpfil/ipfw/ip_fw_log.c
E> 
E> Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
E> ==============================================================================
E> --- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -1461,6 +1461,9 @@ static void
E>  process_data(struct iwch_ep *ep)
E>  {
E>  	struct sockaddr_in *local, *remote;
E> +#ifdef KTR
E> +	char local_str[INET_ADDRSTRLEN], remote_str[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	CTR4(KTR_IW_CXGB, "%s ep %p so %p state %s", __FUNCTION__, ep, ep->com.so, states[ep->com.state]);
E>  
E> @@ -1479,8 +1482,8 @@ process_data(struct iwch_ep *ep)
E>  		in_getsockaddr(ep->com.so, (struct sockaddr **)&local);
E>  		in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote);
E>  		CTR3(KTR_IW_CXGB, "%s local %s remote %s", __FUNCTION__, 
E> -			inet_ntoa(local->sin_addr),
E> -			inet_ntoa(remote->sin_addr));
E> +			inet_ntoa_r(local->sin_addr, local_str),
E> +			inet_ntoa_r(remote->sin_addr, remote_str));
E>  		ep->com.local_addr = *local;
E>  		ep->com.remote_addr = *remote;
E>  		free(local, M_SONAME);
E> @@ -1519,6 +1522,9 @@ process_newconn(struct iw_cm_id *parent_
E>  	struct sockaddr_in *local;
E>  	struct sockaddr_in *remote;
E>  	struct iwch_ep *parent_ep = parent_cm_id->provider_data;
E> +#ifdef KTR
E> +	char buf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	CTR3(KTR_IW_CXGB, "%s parent ep %p so %p", __FUNCTION__, parent_ep, parent_ep->com.so);
E>  	if (!child_so) {
E> @@ -1539,7 +1545,7 @@ process_newconn(struct iw_cm_id *parent_
E>  	in_getpeeraddr(child_so, (struct sockaddr **)&remote);
E>  
E>  	CTR3(KTR_IW_CXGB, "%s remote addr %s port %d", __FUNCTION__, 
E> -		inet_ntoa(remote->sin_addr), ntohs(remote->sin_port));
E> +		inet_ntoa_r(remote->sin_addr, buf), ntohs(remote->sin_port));
E>  	child_ep->com.tdev = parent_ep->com.tdev;
E>  	child_ep->com.local_addr.sin_family = parent_ep->com.local_addr.sin_family;
E>  	child_ep->com.local_addr.sin_port = parent_ep->com.local_addr.sin_port;
E> 
E> Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
E> ==============================================================================
E> --- head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/fs/nfsserver/nfs_nfsdkrpc.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -174,7 +174,11 @@ nfssvc_program(struct svc_req *rqst, SVC
E>  		if (port >= IPPORT_RESERVED &&
E>  		    nd.nd_procnum != NFSPROC_NULL) {
E>  #ifdef INET6
E> -			char b6[INET6_ADDRSTRLEN];
E> +			char buf[INET6_ADDRSTRLEN];
E> +#else
E> +			char buf[INET_ADDRSTRLEN];
E> +#endif
E> +#ifdef INET6
E>  #if defined(KLD_MODULE)
E>  			/* Do not use ip6_sprintf: the nfs module should work without INET6. */
E>  #define	ip6_sprintf(buf, a)						\
E> @@ -189,12 +193,12 @@ nfssvc_program(struct svc_req *rqst, SVC
E>  			printf("NFS request from unprivileged port (%s:%d)\n",
E>  #ifdef INET6
E>  			    sin->sin_family == AF_INET6 ?
E> -			    ip6_sprintf(b6, &satosin6(sin)->sin6_addr) :
E> +			    ip6_sprintf(buf, &satosin6(sin)->sin6_addr) :
E>  #if defined(KLD_MODULE)
E>  #undef ip6_sprintf
E>  #endif
E>  #endif
E> -			    inet_ntoa(sin->sin_addr), port);
E> +			    inet_ntoa_r(sin->sin_addr, buf), port);
E>  			svcerr_weakauth(rqst);
E>  			svc_freereq(rqst);
E>  			m_freem(nd.nd_mrep);
E> 
E> Modified: head/sys/kern/kern_jail.c
E> ==============================================================================
E> --- head/sys/kern/kern_jail.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/kern/kern_jail.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -3999,6 +3999,9 @@ db_show_prison(struct prison *pr)
E>  	int ii;
E>  #endif
E>  	unsigned jsf;
E> +#ifdef INET
E> +	char ip4buf[INET_ADDRSTRLEN];
E> +#endif
E>  #ifdef INET6
E>  	char ip6buf[INET6_ADDRSTRLEN];
E>  #endif
E> @@ -4050,7 +4053,7 @@ db_show_prison(struct prison *pr)
E>  	for (ii = 0; ii < pr->pr_ip4s; ii++)
E>  		db_printf(" %s %s\n",
E>  		    ii == 0 ? "ip4.addr        =" : "                 ",
E> -		    inet_ntoa(pr->pr_ip4[ii]));
E> +		    inet_ntoa_r(pr->pr_ip4[ii], ip4buf));
E>  #endif
E>  #ifdef INET6
E>  	db_printf(" ip6s            = %d\n", pr->pr_ip6s);
E> 
E> Modified: head/sys/netinet/if_ether.c
E> ==============================================================================
E> --- head/sys/netinet/if_ether.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/if_ether.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -464,9 +464,12 @@ arpresolve_full(struct ifnet *ifp, int i
E>  	if (la == NULL && (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) {
E>  		la = lltable_alloc_entry(LLTABLE(ifp), 0, dst);
E>  		if (la == NULL) {
E> +			char addrbuf[INET_ADDRSTRLEN];
E> +
E>  			log(LOG_DEBUG,
E>  			    "arpresolve: can't allocate llinfo for %s on %s\n",
E> -			    inet_ntoa(SIN(dst)->sin_addr), if_name(ifp));
E> +			    inet_ntoa_r(SIN(dst)->sin_addr, addrbuf),
E> +			    if_name(ifp));
E>  			m_freem(m);
E>  			return (EINVAL);
E>  		}
E> @@ -803,6 +806,7 @@ in_arpinput(struct mbuf *m)
E>  	size_t linkhdrsize;
E>  	int lladdr_off;
E>  	int error;
E> +	char addrbuf[INET_ADDRSTRLEN];
E>  
E>  	sin.sin_len = sizeof(struct sockaddr_in);
E>  	sin.sin_family = AF_INET;
E> @@ -927,7 +931,7 @@ match:
E>  		goto drop;	/* it's from me, ignore it. */
E>  	if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) {
E>  		ARP_LOG(LOG_NOTICE, "link address is broadcast for IP address "
E> -		    "%s!\n", inet_ntoa(isaddr));
E> +		    "%s!\n", inet_ntoa_r(isaddr, addrbuf));
E>  		goto drop;
E>  	}
E>  
E> @@ -949,7 +953,7 @@ match:
E>  	    myaddr.s_addr != 0) {
E>  		ARP_LOG(LOG_ERR, "%*D is using my IP address %s on %s!\n",
E>  		   ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
E> -		   inet_ntoa(isaddr), ifp->if_xname);
E> +		   inet_ntoa_r(isaddr, addrbuf), ifp->if_xname);
E>  		itaddr = myaddr;
E>  		ARPSTAT_INC(dupips);
E>  		goto reply;
E> @@ -1086,12 +1090,14 @@ reply:
E>  			if (nh4.nh_ifp != ifp) {
E>  				ARP_LOG(LOG_INFO, "proxy: ignoring request"
E>  				    " from %s via %s\n",
E> -				    inet_ntoa(isaddr), ifp->if_xname);
E> +				    inet_ntoa_r(isaddr, addrbuf),
E> +				    ifp->if_xname);
E>  				goto drop;
E>  			}
E>  
E>  #ifdef DEBUG_PROXY
E> -			printf("arp: proxying for %s\n", inet_ntoa(itaddr));
E> +			printf("arp: proxying for %s\n",
E> +			    inet_ntoa_r(itaddr, addrbuf));
E>  #endif
E>  		}
E>  	}
E> @@ -1101,7 +1107,7 @@ reply:
E>  		/* RFC 3927 link-local IPv4; always reply by broadcast. */
E>  #ifdef DEBUG_LINKLOCAL
E>  		printf("arp: sending reply for link-local addr %s\n",
E> -		    inet_ntoa(itaddr));
E> +		    inet_ntoa_r(itaddr, addrbuf));
E>  #endif
E>  		m->m_flags |= M_BCAST;
E>  		m->m_flags &= ~M_MCAST;
E> @@ -1162,6 +1168,7 @@ arp_check_update_lle(struct arphdr *ah, 
E>  	uint8_t linkhdr[LLE_MAX_LINKHDR];
E>  	size_t linkhdrsize;
E>  	int lladdr_off;
E> +	char addrbuf[INET_ADDRSTRLEN];
E>  
E>  	LLE_WLOCK_ASSERT(la);
E>  
E> @@ -1170,7 +1177,7 @@ arp_check_update_lle(struct arphdr *ah, 
E>  		if (log_arp_wrong_iface)
E>  			ARP_LOG(LOG_WARNING, "%s is on %s "
E>  			    "but got reply from %*D on %s\n",
E> -			    inet_ntoa(isaddr),
E> +			    inet_ntoa_r(isaddr, addrbuf),
E>  			    la->lle_tbl->llt_ifp->if_xname,
E>  			    ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
E>  			    ifp->if_xname);
E> @@ -1187,13 +1194,14 @@ arp_check_update_lle(struct arphdr *ah, 
E>  				    "permanent entry for %s on %s\n",
E>  				    ifp->if_addrlen,
E>  				    (u_char *)ar_sha(ah), ":",
E> -				    inet_ntoa(isaddr), ifp->if_xname);
E> +				    inet_ntoa_r(isaddr, addrbuf),
E> +				    ifp->if_xname);
E>  			return;
E>  		}
E>  		if (log_arp_movements) {
E>  			ARP_LOG(LOG_INFO, "%s moved from %*D "
E>  			    "to %*D on %s\n",
E> -			    inet_ntoa(isaddr),
E> +			    inet_ntoa_r(isaddr, addrbuf),
E>  			    ifp->if_addrlen,
E>  			    (u_char *)&la->ll_addr, ":",
E>  			    ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
E> 
E> Modified: head/sys/netinet/igmp.c
E> ==============================================================================
E> --- head/sys/netinet/igmp.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/igmp.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -314,12 +314,12 @@ igmp_scrub_context(struct mbuf *m)
E>  
E>  #ifdef KTR
E>  static __inline char *
E> -inet_ntoa_haddr(in_addr_t haddr)
E> +inet_ntoa_haddr(in_addr_t haddr, char *addrbuf)
E>  {
E>  	struct in_addr ia;
E>  
E>  	ia.s_addr = htonl(haddr);
E> -	return (inet_ntoa(ia));
E> +	return (inet_ntoa_r(ia, addrbuf));
E>  }
E>  #endif
E>  
E> @@ -804,6 +804,9 @@ igmp_input_v2_query(struct ifnet *ifp, c
E>  	struct in_multi		*inm;
E>  	int			 is_general_query;
E>  	uint16_t		 timer;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	is_general_query = 0;
E>  
E> @@ -873,7 +876,8 @@ igmp_input_v2_query(struct ifnet *ifp, c
E>  		inm = inm_lookup(ifp, igmp->igmp_group);
E>  		if (inm != NULL) {
E>  			CTR3(KTR_IGMPV3, "process v2 query %s on ifp %p(%s)",
E> -			    inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +			    inet_ntoa_r(igmp->igmp_group, addrbuf), ifp,
E> +			    ifp->if_xname);
E>  			igmp_v2_update_group(inm, timer);
E>  		}
E>  	}
E> @@ -903,9 +907,12 @@ out_locked:
E>  static void
E>  igmp_v2_update_group(struct in_multi *inm, const int timer)
E>  {
E> +#ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	CTR4(KTR_IGMPV3, "%s: %s/%s timer=%d", __func__,
E> -	    inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname, timer);
E> +	    inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp->if_xname, timer);
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  
E> @@ -956,6 +963,9 @@ igmp_input_v3_query(struct ifnet *ifp, c
E>  	uint32_t		 maxresp, nsrc, qqi;
E>  	uint16_t		 timer;
E>  	uint8_t			 qrv;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	is_general_query = 0;
E>  
E> @@ -1086,7 +1096,8 @@ igmp_input_v3_query(struct ifnet *ifp, c
E>  			}
E>  		}
E>  		CTR3(KTR_IGMPV3, "process v3 %s query on ifp %p(%s)",
E> -		     inet_ntoa(igmpv3->igmp_group), ifp, ifp->if_xname);
E> +		     inet_ntoa_r(igmpv3->igmp_group, addrbuf), ifp,
E> +		     ifp->if_xname);
E>  		/*
E>  		 * If there is a pending General Query response
E>  		 * scheduled sooner than the selected delay, no
E> @@ -1219,6 +1230,9 @@ igmp_input_v1_report(struct ifnet *ifp, 
E>  	struct rm_priotracker in_ifa_tracker;
E>  	struct in_ifaddr *ia;
E>  	struct in_multi *inm;
E> +#ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	IGMPSTAT_INC(igps_rcv_reports);
E>  
E> @@ -1247,7 +1261,7 @@ igmp_input_v1_report(struct ifnet *ifp, 
E>  	}
E>  
E>  	CTR3(KTR_IGMPV3, "process v1 report %s on ifp %p(%s)",
E> -	     inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +	     inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname);
E>  
E>  	/*
E>  	 * IGMPv1 report suppression.
E> @@ -1290,14 +1304,16 @@ igmp_input_v1_report(struct ifnet *ifp, 
E>  		case IGMP_AWAKENING_MEMBER:
E>  			CTR3(KTR_IGMPV3,
E>  			    "report suppressed for %s on ifp %p(%s)",
E> -			    inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +			    inet_ntoa_r(igmp->igmp_group, addrbuf), ifp,
E> +			    ifp->if_xname);
E>  		case IGMP_SLEEPING_MEMBER:
E>  			inm->inm_state = IGMP_SLEEPING_MEMBER;
E>  			break;
E>  		case IGMP_REPORTING_MEMBER:
E>  			CTR3(KTR_IGMPV3,
E>  			    "report suppressed for %s on ifp %p(%s)",
E> -			    inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +			    inet_ntoa_r(igmp->igmp_group, addrbuf), ifp,
E> +			    ifp->if_xname);
E>  			if (igi->igi_version == IGMP_VERSION_1)
E>  				inm->inm_state = IGMP_LAZY_MEMBER;
E>  			else if (igi->igi_version == IGMP_VERSION_2)
E> @@ -1328,6 +1344,9 @@ igmp_input_v2_report(struct ifnet *ifp, 
E>  	struct rm_priotracker in_ifa_tracker;
E>  	struct in_ifaddr *ia;
E>  	struct in_multi *inm;
E> +#ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	/*
E>  	 * Make sure we don't hear our own membership report.  Fast
E> @@ -1371,7 +1390,7 @@ igmp_input_v2_report(struct ifnet *ifp, 
E>  		ifa_free(&ia->ia_ifa);
E>  
E>  	CTR3(KTR_IGMPV3, "process v2 report %s on ifp %p(%s)",
E> -	     inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +	     inet_ntoa_r(igmp->igmp_group, addrbuf), ifp, ifp->if_xname);
E>  
E>  	/*
E>  	 * IGMPv2 report suppression.
E> @@ -1412,7 +1431,8 @@ igmp_input_v2_report(struct ifnet *ifp, 
E>  		case IGMP_AWAKENING_MEMBER:
E>  			CTR3(KTR_IGMPV3,
E>  			    "report suppressed for %s on ifp %p(%s)",
E> -			    inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
E> +			    inet_ntoa_r(igmp->igmp_group, addrbuf), ifp,
E> +			    ifp->if_xname);
E>  		case IGMP_LAZY_MEMBER:
E>  			inm->inm_state = IGMP_LAZY_MEMBER;
E>  			break;
E> @@ -1814,6 +1834,9 @@ igmp_v3_process_group_timers(struct igmp
E>  {
E>  	int query_response_timer_expired;
E>  	int state_change_retransmit_timer_expired;
E> +#ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  	IGMP_LOCK_ASSERT();
E> @@ -1900,7 +1923,8 @@ igmp_v3_process_group_timers(struct igmp
E>  
E>  			inm_commit(inm);
E>  			CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__,
E> -			    inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
E> +			    inet_ntoa_r(inm->inm_addr, addrbuf),
E> +			    inm->inm_ifp->if_xname);
E>  
E>  			/*
E>  			 * If we are leaving the group for good, make sure
E> @@ -2346,9 +2370,12 @@ igmp_initial_join(struct in_multi *inm, 
E>  	struct ifnet		*ifp;
E>  	struct mbufq		*mq;
E>  	int			 error, retval, syncstates;
E> -
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E> + 
E>  	CTR4(KTR_IGMPV3, "%s: initial join %s on ifp %p(%s)",
E> -	    __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
E> +	    __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp,
E>  	    inm->inm_ifp->if_xname);
E>  
E>  	error = 0;
E> @@ -2459,7 +2486,8 @@ igmp_initial_join(struct in_multi *inm, 
E>  	if (syncstates) {
E>  		inm_commit(inm);
E>  		CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__,
E> -		    inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
E> +		    inet_ntoa_r(inm->inm_addr, addrbuf),
E> +		    inm->inm_ifp->if_xname);
E>  	}
E>  
E>  	return (error);
E> @@ -2473,9 +2501,12 @@ igmp_handle_state_change(struct in_multi
E>  {
E>  	struct ifnet		*ifp;
E>  	int			 retval;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	CTR4(KTR_IGMPV3, "%s: state change for %s on ifp %p(%s)",
E> -	    __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
E> +	    __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp,
E>  	    inm->inm_ifp->if_xname);
E>  
E>  	ifp = inm->inm_ifp;
E> @@ -2496,7 +2527,8 @@ igmp_handle_state_change(struct in_multi
E>  		CTR1(KTR_IGMPV3, "%s: nothing to do", __func__);
E>  		inm_commit(inm);
E>  		CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__,
E> -		    inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
E> +		    inet_ntoa_r(inm->inm_addr, addrbuf),
E> +		    inm->inm_ifp->if_xname);
E>  		return (0);
E>  	}
E>  
E> @@ -2531,11 +2563,14 @@ static void
E>  igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi)
E>  {
E>  	int syncstates;
E> +#ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	syncstates = 1;
E>  
E>  	CTR4(KTR_IGMPV3, "%s: final leave %s on ifp %p(%s)",
E> -	    __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
E> +	    __func__, inet_ntoa_r(inm->inm_addr, addrbuf), inm->inm_ifp,
E>  	    inm->inm_ifp->if_xname);
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E> @@ -2578,7 +2613,7 @@ igmp_final_leave(struct in_multi *inm, s
E>  			}
E>  			CTR4(KTR_IGMPV3, "%s: Leaving %s/%s with %d "
E>  			    "pending retransmissions.", __func__,
E> -			    inet_ntoa(inm->inm_addr),
E> +			    inet_ntoa_r(inm->inm_addr, addrbuf),
E>  			    inm->inm_ifp->if_xname, inm->inm_scrv);
E>  			if (inm->inm_scrv == 0) {
E>  				inm->inm_state = IGMP_NOT_MEMBER;
E> @@ -2612,10 +2647,12 @@ igmp_final_leave(struct in_multi *inm, s
E>  	if (syncstates) {
E>  		inm_commit(inm);
E>  		CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__,
E> -		    inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
E> +		    inet_ntoa_r(inm->inm_addr, addrbuf),
E> +		    inm->inm_ifp->if_xname);
E>  		inm->inm_st[1].iss_fmode = MCAST_UNDEFINED;
E>  		CTR3(KTR_IGMPV3, "%s: T1 now MCAST_UNDEFINED for %s/%s",
E> -		    __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
E> +		    __func__, inet_ntoa_r(inm->inm_addr, addrbuf),
E> +		    inm->inm_ifp->if_xname);
E>  	}
E>  }
E>  
E> @@ -2663,6 +2700,9 @@ igmp_v3_enqueue_group_record(struct mbuf
E>  	int			 type;
E>  	in_addr_t		 naddr;
E>  	uint8_t			 mode;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  
E> @@ -2741,7 +2781,7 @@ igmp_v3_enqueue_group_record(struct mbuf
E>  
E>  	if (type == IGMP_DO_NOTHING) {
E>  		CTR3(KTR_IGMPV3, "%s: nothing to do for %s/%s",
E> -		    __func__, inet_ntoa(inm->inm_addr),
E> +		    __func__, inet_ntoa_r(inm->inm_addr, addrbuf),
E>  		    inm->inm_ifp->if_xname);
E>  		return (0);
E>  	}
E> @@ -2756,7 +2796,7 @@ igmp_v3_enqueue_group_record(struct mbuf
E>  		minrec0len += sizeof(in_addr_t);
E>  
E>  	CTR4(KTR_IGMPV3, "%s: queueing %s for %s/%s", __func__,
E> -	    igmp_rec_type_to_str(type), inet_ntoa(inm->inm_addr),
E> +	    igmp_rec_type_to_str(type), inet_ntoa_r(inm->inm_addr, addrbuf),
E>  	    inm->inm_ifp->if_xname);
E>  
E>  	/*
E> @@ -2845,7 +2885,7 @@ igmp_v3_enqueue_group_record(struct mbuf
E>  		msrcs = 0;
E>  		RB_FOREACH_SAFE(ims, ip_msource_tree, &inm->inm_srcs, nims) {
E>  			CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
E> -			    inet_ntoa_haddr(ims->ims_haddr));
E> +			    inet_ntoa_haddr(ims->ims_haddr, addrbuf));
E>  			now = ims_get_mode(inm, ims, 1);
E>  			CTR2(KTR_IGMPV3, "%s: node is %d", __func__, now);
E>  			if ((now != mode) ||
E> @@ -2941,7 +2981,7 @@ igmp_v3_enqueue_group_record(struct mbuf
E>  		msrcs = 0;
E>  		RB_FOREACH_FROM(ims, ip_msource_tree, nims) {
E>  			CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
E> -			    inet_ntoa_haddr(ims->ims_haddr));
E> +			    inet_ntoa_haddr(ims->ims_haddr, addrbuf));
E>  			now = ims_get_mode(inm, ims, 1);
E>  			if ((now != mode) ||
E>  			    (now == mode && mode == MCAST_UNDEFINED)) {
E> @@ -3024,6 +3064,9 @@ igmp_v3_enqueue_filter_change(struct mbu
E>  	int			 nallow, nblock;
E>  	uint8_t			 mode, now, then;
E>  	rectype_t		 crt, drt, nrt;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  
E> @@ -3133,7 +3176,8 @@ igmp_v3_enqueue_filter_change(struct mbu
E>  				nims = RB_MIN(ip_msource_tree, &inm->inm_srcs);
E>  			RB_FOREACH_FROM(ims, ip_msource_tree, nims) {
E>  				CTR2(KTR_IGMPV3, "%s: visit node %s",
E> -				    __func__, inet_ntoa_haddr(ims->ims_haddr));
E> +				    __func__,
E> +				    inet_ntoa_haddr(ims->ims_haddr, addrbuf));
E>  				now = ims_get_mode(inm, ims, 1);
E>  				then = ims_get_mode(inm, ims, 0);
E>  				CTR3(KTR_IGMPV3, "%s: mode: t0 %d, t1 %d",
E> 
E> Modified: head/sys/netinet/in.c
E> ==============================================================================
E> --- head/sys/netinet/in.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/in.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -1218,7 +1218,7 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
E>  	 */
E>  	if (!(rt_flags & RTF_HOST) && info.rti_ifp != ifp) {
E>  		const char *sa, *mask, *addr, *lim;
E> -		int len;
E> +		const struct sockaddr_in *l3sin;
E>  
E>  		mask = (const char *)&rt_mask;
E>  		/*
E> @@ -1230,14 +1230,17 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
E>  
E>  		sa = (const char *)&rt_key;
E>  		addr = (const char *)l3addr;
E> -		len = ((const struct sockaddr_in *)l3addr)->sin_len;
E> -		lim = addr + len;
E> +		l3sin = (const struct sockaddr_in *)l3addr;
E> +		lim = addr + l3sin->sin_len;
E>  
E>  		for ( ; addr < lim; sa++, mask++, addr++) {
E>  			if ((*sa ^ *addr) & *mask) {
E>  #ifdef DIAGNOSTIC
E> -				log(LOG_INFO, "IPv4 address: \"%s\" is not on the network\n",
E> -				    inet_ntoa(((const struct sockaddr_in *)l3addr)->sin_addr));
E> +				char addrbuf[INET_ADDRSTRLEN];
E> +
E> +				log(LOG_INFO, "IPv4 address: \"%s\" "
E> +				    "is not on the network\n",
E> +				    inet_ntoa_r(l3sin->sin_addr, addrbuf));
E>  #endif
E>  				return (EINVAL);
E>  			}
E> 
E> Modified: head/sys/netinet/in_mcast.c
E> ==============================================================================
E> --- head/sys/netinet/in_mcast.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/in_mcast.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -495,9 +495,12 @@ in_getmulti(struct ifnet *ifp, const str
E>  		    ("%s: ifma not AF_INET", __func__));
E>  		KASSERT(inm != NULL, ("%s: no ifma_protospec", __func__));
E>  		if (inm->inm_ifma != ifma || inm->inm_ifp != ifp ||
E> -		    !in_hosteq(inm->inm_addr, *group))
E> +		    !in_hosteq(inm->inm_addr, *group)) {
E> +			char addrbuf[INET_ADDRSTRLEN];
E> +
E>  			panic("%s: ifma %p is inconsistent with %p (%s)",
E> -			    __func__, ifma, inm, inet_ntoa(*group));
E> +			    __func__, ifma, inm, inet_ntoa_r(*group, addrbuf));
E> +		}
E>  #endif
E>  		++inm->inm_refcount;
E>  		*pinm = inm;
E> @@ -875,7 +878,8 @@ inm_get_source(struct in_multi *inm, con
E>  	struct ip_msource	 find;
E>  	struct ip_msource	*ims, *nims;
E>  #ifdef KTR
E> -	struct in_addr ia;
E> +	struct in_addr		 ia;
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E>  #endif
E>  
E>  	find.ims_haddr = haddr;
E> @@ -894,7 +898,7 @@ inm_get_source(struct in_multi *inm, con
E>  #ifdef KTR
E>  		ia.s_addr = htonl(haddr);
E>  		CTR3(KTR_IGMPV3, "%s: allocated %s as %p", __func__,
E> -		    inet_ntoa(ia), ims);
E> +		    inet_ntoa_r(ia, addrbuf), ims);
E>  #endif
E>  	}
E>  
E> @@ -912,6 +916,7 @@ ims_merge(struct ip_msource *ims, const 
E>  {
E>  	int n = rollback ? -1 : 1;
E>  #ifdef KTR
E> +	char addrbuf[INET_ADDRSTRLEN];
E>  	struct in_addr ia;
E>  
E>  	ia.s_addr = htonl(ims->ims_haddr);
E> @@ -919,21 +924,21 @@ ims_merge(struct ip_msource *ims, const 
E>  
E>  	if (lims->imsl_st[0] == MCAST_EXCLUDE) {
E>  		CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on %s",
E> -		    __func__, n, inet_ntoa(ia));
E> +		    __func__, n, inet_ntoa_r(ia, addrbuf));
E>  		ims->ims_st[1].ex -= n;
E>  	} else if (lims->imsl_st[0] == MCAST_INCLUDE) {
E>  		CTR3(KTR_IGMPV3, "%s: t1 in -= %d on %s",
E> -		    __func__, n, inet_ntoa(ia));
E> +		    __func__, n, inet_ntoa_r(ia, addrbuf));
E>  		ims->ims_st[1].in -= n;
E>  	}
E>  
E>  	if (lims->imsl_st[1] == MCAST_EXCLUDE) {
E>  		CTR3(KTR_IGMPV3, "%s: t1 ex += %d on %s",
E> -		    __func__, n, inet_ntoa(ia));
E> +		    __func__, n, inet_ntoa_r(ia, addrbuf));
E>  		ims->ims_st[1].ex += n;
E>  	} else if (lims->imsl_st[1] == MCAST_INCLUDE) {
E>  		CTR3(KTR_IGMPV3, "%s: t1 in += %d on %s",
E> -		    __func__, n, inet_ntoa(ia));
E> +		    __func__, n, inet_ntoa_r(ia, addrbuf));
E>  		ims->ims_st[1].in += n;
E>  	}
E>  }
E> @@ -1166,11 +1171,14 @@ in_joingroup_locked(struct ifnet *ifp, c
E>  	struct in_mfilter	 timf;
E>  	struct in_multi		*inm;
E>  	int			 error;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  
E>  	CTR4(KTR_IGMPV3, "%s: join %s on %p(%s))", __func__,
E> -	    inet_ntoa(*gina), ifp, ifp->if_xname);
E> +	    inet_ntoa_r(*gina, addrbuf), ifp, ifp->if_xname);
E>  
E>  	error = 0;
E>  	inm = NULL;
E> @@ -1248,13 +1256,16 @@ in_leavegroup_locked(struct in_multi *in
E>  {
E>  	struct in_mfilter	 timf;
E>  	int			 error;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	error = 0;
E>  
E>  	IN_MULTI_LOCK_ASSERT();
E>  
E>  	CTR5(KTR_IGMPV3, "%s: leave inm %p, %s/%s, imf %p", __func__,
E> -	    inm, inet_ntoa(inm->inm_addr),
E> +	    inm, inet_ntoa_r(inm->inm_addr, addrbuf),
E>  	    (inm_is_ifp_detached(inm) ? "null" : inm->inm_ifp->if_xname),
E>  	    imf);
E>  
E> @@ -1302,9 +1313,13 @@ in_addmulti(struct in_addr *ap, struct i
E>  {
E>  	struct in_multi *pinm;
E>  	int error;
E> +#ifdef INVARIANTS
E> +	char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	KASSERT(IN_LOCAL_GROUP(ntohl(ap->s_addr)),
E> -	    ("%s: %s not in 224.0.0.0/24", __func__, inet_ntoa(*ap)));
E> +	    ("%s: %s not in 224.0.0.0/24", __func__,
E> +	    inet_ntoa_r(*ap, addrbuf)));
E>  
E>  	error = in_joingroup(ifp, ap, NULL, &pinm);
E>  	if (error != 0)
E> @@ -1349,6 +1364,9 @@ inp_block_unblock_source(struct inpcb *i
E>  	size_t				 idx;
E>  	uint16_t			 fmode;
E>  	int				 error, doblock;
E> +#ifdef KTR
E> +	char				 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	ifp = NULL;
E>  	error = 0;
E> @@ -1384,7 +1402,7 @@ inp_block_unblock_source(struct inpcb *i
E>  			doblock = 1;
E>  
E>  		CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
E> -		    __func__, inet_ntoa(mreqs.imr_interface), ifp);
E> +		    __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp);
E>  		break;
E>  	    }
E>  
E> @@ -1457,7 +1475,8 @@ inp_block_unblock_source(struct inpcb *i
E>  	ims = imo_match_source(imo, idx, &ssa->sa);
E>  	if ((ims != NULL && doblock) || (ims == NULL && !doblock)) {
E>  		CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__,
E> -		    inet_ntoa(ssa->sin.sin_addr), doblock ? "" : "not ");
E> +		    inet_ntoa_r(ssa->sin.sin_addr, addrbuf),
E> +		    doblock ? "" : "not ");
E>  		error = EADDRNOTAVAIL;
E>  		goto out_inp_locked;
E>  	}
E> @@ -1934,6 +1953,9 @@ inp_join_group(struct inpcb *inp, struct
E>  	struct in_msource		*lims;
E>  	size_t				 idx;
E>  	int				 error, is_new;
E> +#ifdef KTR
E> +	char				 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	ifp = NULL;
E>  	imf = NULL;
E> @@ -1986,7 +2008,7 @@ inp_join_group(struct inpcb *inp, struct
E>  		ifp = inp_lookup_mcast_ifp(inp, &gsa->sin,
E>  		    mreqs.imr_interface);
E>  		CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
E> -		    __func__, inet_ntoa(mreqs.imr_interface), ifp);
E> +		    __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp);
E>  		break;
E>  	}
E>  
E> @@ -2233,6 +2255,9 @@ inp_leave_group(struct inpcb *inp, struc
E>  	struct in_multi			*inm;
E>  	size_t				 idx;
E>  	int				 error, is_final;
E> +#ifdef KTR
E> +	char				 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	ifp = NULL;
E>  	error = 0;
E> @@ -2287,7 +2312,7 @@ inp_leave_group(struct inpcb *inp, struc
E>  			INADDR_TO_IFP(mreqs.imr_interface, ifp);
E>  
E>  		CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
E> -		    __func__, inet_ntoa(mreqs.imr_interface), ifp);
E> +		    __func__, inet_ntoa_r(mreqs.imr_interface, addrbuf), ifp);
E>  
E>  		break;
E>  
E> @@ -2368,7 +2393,7 @@ inp_leave_group(struct inpcb *inp, struc
E>  		ims = imo_match_source(imo, idx, &ssa->sa);
E>  		if (ims == NULL) {
E>  			CTR3(KTR_IGMPV3, "%s: source %s %spresent", __func__,
E> -			    inet_ntoa(ssa->sin.sin_addr), "not ");
E> +			    inet_ntoa_r(ssa->sin.sin_addr, addrbuf), "not ");
E>  			error = EADDRNOTAVAIL;
E>  			goto out_inp_locked;
E>  		}
E> @@ -2450,6 +2475,9 @@ inp_set_multicast_if(struct inpcb *inp, 
E>  	struct ifnet		*ifp;
E>  	struct ip_moptions	*imo;
E>  	int			 error;
E> +#ifdef KTR
E> +	char			 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	if (sopt->sopt_valsize == sizeof(struct ip_mreqn)) {
E>  		/*
E> @@ -2488,7 +2516,7 @@ inp_set_multicast_if(struct inpcb *inp, 
E>  				return (EADDRNOTAVAIL);
E>  		}
E>  		CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = %s", __func__, ifp,
E> -		    inet_ntoa(addr));
E> +		    inet_ntoa_r(addr, addrbuf));
E>  	}
E>  
E>  	/* Reject interfaces which do not support multicast. */
E> @@ -2846,6 +2874,9 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_A
E>  	int				 retval;
E>  	u_int				 namelen;
E>  	uint32_t			 fmode, ifindex;
E> +#ifdef KTR
E> +	char				 addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>  	name = (int *)arg1;
E>  	namelen = arg2;
E> @@ -2866,7 +2897,7 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_A
E>  	group.s_addr = name[1];
E>  	if (!IN_MULTICAST(ntohl(group.s_addr))) {
E>  		CTR2(KTR_IGMPV3, "%s: group %s is not multicast",
E> -		    __func__, inet_ntoa(group));
E> +		    __func__, inet_ntoa_r(group, addrbuf));
E>  		return (EINVAL);
E>  	}
E>  
E> @@ -2901,7 +2932,7 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_A
E>  			struct in_addr ina;
E>  			ina.s_addr = htonl(ims->ims_haddr);
E>  			CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
E> -			    inet_ntoa(ina));
E> +			    inet_ntoa_r(ina, addrbuf));
E>  #endif
E>  			/*
E>  			 * Only copy-out sources which are in-mode.
E> @@ -2965,13 +2996,14 @@ void
E>  inm_print(const struct in_multi *inm)
E>  {
E>  	int t;
E> +	char addrbuf[INET_ADDRSTRLEN];
E>  
E>  	if ((ktr_mask & KTR_IGMPV3) == 0)
E>  		return;
E>  
E>  	printf("%s: --- begin inm %p ---\n", __func__, inm);
E>  	printf("addr %s ifp %p(%s) ifma %p\n",
E> -	    inet_ntoa(inm->inm_addr),
E> +	    inet_ntoa_r(inm->inm_addr, addrbuf),
E>  	    inm->inm_ifp,
E>  	    inm->inm_ifp->if_xname,
E>  	    inm->inm_ifma);
E> 
E> Modified: head/sys/netinet/ip_icmp.c
E> ==============================================================================
E> --- head/sys/netinet/ip_icmp.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/ip_icmp.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -380,10 +380,12 @@ icmp_input(struct mbuf **mp, int *offp, 
E>  	 */
E>  #ifdef ICMPPRINTFS
E>  	if (icmpprintfs) {
E> -		char buf[4 * sizeof "123"];
E> -		strcpy(buf, inet_ntoa(ip->ip_src));
E> +		char srcbuf[INET_ADDRSTRLEN];
E> +		char dstbuf[INET_ADDRSTRLEN];
E> +
E>  		printf("icmp_input from %s to %s, len %d\n",
E> -		       buf, inet_ntoa(ip->ip_dst), icmplen);
E> +		    inet_ntoa_r(ip->ip_src, srcbuf),
E> +		    inet_ntoa_r(ip->ip_dst, dstbuf), icmplen);
E>  	}
E>  #endif
E>  	if (icmplen < ICMP_MINLEN) {
E> @@ -649,11 +651,12 @@ reflect:
E>  		icmpdst.sin_addr = icp->icmp_gwaddr;
E>  #ifdef	ICMPPRINTFS
E>  		if (icmpprintfs) {
E> -			char buf[4 * sizeof "123"];
E> -			strcpy(buf, inet_ntoa(icp->icmp_ip.ip_dst));
E> +			char dstbuf[INET_ADDRSTRLEN];
E> +			char gwbuf[INET_ADDRSTRLEN];
E>  
E>  			printf("redirect dst %s to %s\n",
E> -			       buf, inet_ntoa(icp->icmp_gwaddr));
E> +			       inet_ntoa_r(icp->icmp_ip.ip_dst, dstbuf),
E> +			       inet_ntoa_r(icp->icmp_gwaddr, gwbuf));
E>  		}
E>  #endif
E>  		icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
E> @@ -901,10 +904,12 @@ icmp_send(struct mbuf *m, struct mbuf *o
E>  	m->m_pkthdr.rcvif = (struct ifnet *)0;
E>  #ifdef ICMPPRINTFS
E>  	if (icmpprintfs) {
E> -		char buf[4 * sizeof "123"];
E> -		strcpy(buf, inet_ntoa(ip->ip_dst));
E> +		char dstbuf[INET_ADDRSTRLEN];
E> +		char srcbuf[INET_ADDRSTRLEN];
E> +
E>  		printf("icmp_send dst %s src %s\n",
E> -		       buf, inet_ntoa(ip->ip_src));
E> +		    inet_ntoa_r(ip->ip_dst, dstbuf),
E> +		    inet_ntoa_r(ip->ip_src, srcbuf));
E>  	}
E>  #endif
E>  	(void) ip_output(m, opts, NULL, 0, NULL, NULL);
E> 
E> Modified: head/sys/netinet/ip_mroute.c
E> ==============================================================================
E> --- head/sys/netinet/ip_mroute.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/ip_mroute.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -845,6 +845,9 @@ add_vif(struct vifctl *vifcp)
E>      struct ifaddr *ifa;
E>      struct ifnet *ifp;
E>      int error;
E> +#ifdef KTR
E> +    char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>      VIF_LOCK();
E>      if (vifcp->vifc_vifi >= MAXVIFS) {
E> @@ -929,7 +932,7 @@ add_vif(struct vifctl *vifcp)
E>      VIF_UNLOCK();
E>  
E>      CTR4(KTR_IPMF, "%s: add vif %d laddr %s thresh %x", __func__,
E> -	(int)vifcp->vifc_vifi, inet_ntoa(vifcp->vifc_lcl_addr),
E> +	(int)vifcp->vifc_vifi, inet_ntoa_r(vifcp->vifc_lcl_addr, addrbuf),
E>  	(int)vifcp->vifc_threshold);
E>  
E>      return 0;
E> @@ -1052,6 +1055,9 @@ add_mfc(struct mfcctl2 *mfccp)
E>      struct rtdetq *rte, *nrte;
E>      u_long hash = 0;
E>      u_short nstl;
E> +#ifdef KTR
E> +    char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>      VIF_LOCK();
E>      MFC_LOCK();
E> @@ -1061,7 +1067,7 @@ add_mfc(struct mfcctl2 *mfccp)
E>      /* If an entry already exists, just update the fields */
E>      if (rt) {
E>  	CTR4(KTR_IPMF, "%s: update mfc orig %s group %lx parent %x",
E> -	    __func__, inet_ntoa(mfccp->mfcc_origin),
E> +	    __func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf),
E>  	    (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
E>  	    mfccp->mfcc_parent);
E>  	update_mfc_params(rt, mfccp);
E> @@ -1081,7 +1087,7 @@ add_mfc(struct mfcctl2 *mfccp)
E>  	    !TAILQ_EMPTY(&rt->mfc_stall)) {
E>  		CTR5(KTR_IPMF,
E>  		    "%s: add mfc orig %s group %lx parent %x qh %p",
E> -		    __func__, inet_ntoa(mfccp->mfcc_origin),
E> +		    __func__, inet_ntoa_r(mfccp->mfcc_origin, addrbuf),
E>  		    (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
E>  		    mfccp->mfcc_parent,
E>  		    TAILQ_FIRST(&rt->mfc_stall));
E> @@ -1155,12 +1161,15 @@ del_mfc(struct mfcctl2 *mfccp)
E>      struct in_addr	origin;
E>      struct in_addr	mcastgrp;
E>      struct mfc		*rt;
E> +#ifdef KTR
E> +    char		addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>      origin = mfccp->mfcc_origin;
E>      mcastgrp = mfccp->mfcc_mcastgrp;
E>  
E>      CTR3(KTR_IPMF, "%s: delete mfc orig %s group %lx", __func__,
E> -	inet_ntoa(origin), (u_long)ntohl(mcastgrp.s_addr));
E> +	inet_ntoa_r(origin, addrbuf), (u_long)ntohl(mcastgrp.s_addr));
E>  
E>      MFC_LOCK();
E>  
E> @@ -1223,9 +1232,13 @@ X_ip_mforward(struct ip *ip, struct ifne
E>      struct mfc *rt;
E>      int error;
E>      vifi_t vifi;
E> +#ifdef KTR
E> +    char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E>  
E>      CTR3(KTR_IPMF, "ip_mforward: delete mfc orig %s group %lx ifp %p",
E> -	inet_ntoa(ip->ip_src), (u_long)ntohl(ip->ip_dst.s_addr), ifp);
E> +	inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr),
E> +	ifp);
E>  
E>      if (ip->ip_hl < (sizeof(struct ip) + TUNNEL_LEN) >> 2 ||
E>  		((u_char *)(ip + 1))[1] != IPOPT_LSRR ) {
E> @@ -1288,7 +1301,7 @@ X_ip_mforward(struct ip *ip, struct ifne
E>  	MRTSTAT_INC(mrts_mfc_misses);
E>  	MRTSTAT_INC(mrts_no_route);
E>  	CTR2(KTR_IPMF, "ip_mforward: no mfc for (%s,%lx)",
E> -	    inet_ntoa(ip->ip_src), (u_long)ntohl(ip->ip_dst.s_addr));
E> +	    inet_ntoa_r(ip->ip_src, addrbuf), (u_long)ntohl(ip->ip_dst.s_addr));
E>  
E>  	/*
E>  	 * Allocate mbufs early so that we don't do extra work if we are
E> @@ -2570,7 +2583,10 @@ pim_input(struct mbuf **mp, int *offp, i
E>      int minlen;
E>      int datalen = ntohs(ip->ip_len) - iphlen;
E>      int ip_tos;
E> -
E> +#ifdef KTR
E> +    char addrbuf[INET_ADDRSTRLEN];
E> +#endif
E> + 
E>      *mp = NULL;
E>  
E>      /* Keep statistics */
E> @@ -2583,7 +2599,7 @@ pim_input(struct mbuf **mp, int *offp, i
E>      if (datalen < PIM_MINLEN) {
E>  	PIMSTAT_INC(pims_rcv_tooshort);
E>  	CTR3(KTR_IPMF, "%s: short packet (%d) from %s",
E> -	    __func__, datalen, inet_ntoa(ip->ip_src));
E> +	    __func__, datalen, inet_ntoa_r(ip->ip_src, addrbuf));
E>  	m_freem(m);
E>  	return (IPPROTO_DONE);
E>      }
E> @@ -2683,7 +2699,8 @@ pim_input(struct mbuf **mp, int *offp, i
E>  	encap_ip = (struct ip *)(reghdr + 1);
E>  
E>  	CTR3(KTR_IPMF, "%s: register: encap ip src %s len %d",
E> -	    __func__, inet_ntoa(encap_ip->ip_src), ntohs(encap_ip->ip_len));
E> +	    __func__, inet_ntoa_r(encap_ip->ip_src, addrbuf),
E> +	    ntohs(encap_ip->ip_len));
E>  
E>  	/* verify the version number of the inner packet */
E>  	if (encap_ip->ip_v != IPVERSION) {
E> @@ -2697,7 +2714,7 @@ pim_input(struct mbuf **mp, int *offp, i
E>  	if (!IN_MULTICAST(ntohl(encap_ip->ip_dst.s_addr))) {
E>  	    PIMSTAT_INC(pims_rcv_badregisters);
E>  	    CTR2(KTR_IPMF, "%s: bad encap ip dest %s", __func__,
E> -		inet_ntoa(encap_ip->ip_dst));
E> +		inet_ntoa_r(encap_ip->ip_dst, addrbuf));
E>  	    m_freem(m);
E>  	    return (IPPROTO_DONE);
E>  	}
E> 
E> Modified: head/sys/netinet/ip_options.c
E> ==============================================================================
E> --- head/sys/netinet/ip_options.c	Thu Feb 16 20:44:44 2017	(r313820)
E> +++ head/sys/netinet/ip_options.c	Thu Feb 16 20:47:41 2017	(r313821)
E> @@ -196,16 +196,19 @@ ip_dooptions(struct mbuf *m, int pass)
E>  #endif
E>  			if (!V_ip_dosourceroute) {
E>  				if (V_ipforwarding) {
E> -					char buf[16]; /* aaa.bbb.ccc.ddd\0 */
E> +					char srcbuf[INET_ADDRSTRLEN];
E> +					char dstbuf[INET_ADDRSTRLEN];
E> +
E>  					/*
E>  					 * Acting as a router, so generate
E>  					 * ICMP
E>  					 */
E>  nosourcerouting:
E> -					strcpy(buf, inet_ntoa(ip->ip_dst));
E>  					log(LOG_WARNING, 
E> -					    "attempted source route from %s to %s\n",
E> -					    inet_ntoa(ip->ip_src), buf);
E> +					    "attempted source route from %s "
E> +					    "to %s\n",
E> 
E> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
E> _______________________________________________
E> svn-src-all@freebsd.org mailing list
E> https://lists.freebsd.org/mailman/listinfo/svn-src-all
E> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"

-- 
Totus tuus, Glebius.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170217041748.GI58829>