Author: vangyzen
Date: Fri Mar 17 14:54:10 2017
New Revision: 315456
URL: https://svnweb.freebsd.org/changeset/base/315456

Log:
  MFC r313821 r315277 r315286
  
  Use inet_ntoa_r() instead of inet_ntoa() throughout the kernel.
  
  inet_ntoa() cannot be used safely in a multithreaded environment
  because it uses a static local buffer.  Instead, use inet_ntoa_r()
  with a buffer on the caller's stack, except for KTR messages.
  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.
  Therefore, use hex notation in KTR messages.
  
  Sponsored by: Dell EMC

Modified:
  stable/11/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
  stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c
  stable/11/sys/kern/kern_jail.c
  stable/11/sys/netinet/if_ether.c
  stable/11/sys/netinet/igmp.c
  stable/11/sys/netinet/in.c
  stable/11/sys/netinet/in_mcast.c
  stable/11/sys/netinet/ip_icmp.c
  stable/11/sys/netinet/ip_mroute.c
  stable/11/sys/netinet/ip_options.c
  stable/11/sys/netinet/libalias/alias_local.h
  stable/11/sys/netinet/libalias/alias_nbt.c
  stable/11/sys/netinet/libalias/alias_proxy.c
  stable/11/sys/netinet/libalias/alias_sctp.c
  stable/11/sys/netinet/tcp_hostcache.c
  stable/11/sys/netpfil/ipfw/ip_fw_log.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
==============================================================================
--- stable/11/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c     Fri Mar 17 14:18:52 
2017        (r315455)
+++ stable/11/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c     Fri Mar 17 14:54:10 
2017        (r315456)
@@ -1478,9 +1478,9 @@ 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));
+               CTR3(KTR_IW_CXGB, "%s local 0x%08x remote 0x%08x", __FUNCTION__,
+                       ntohl(local->sin_addr.s_addr),
+                       ntohl(remote->sin_addr.s_addr));
                ep->com.local_addr = *local;
                ep->com.remote_addr = *remote;
                free(local, M_SONAME);
@@ -1538,8 +1538,8 @@ process_newconn(struct iw_cm_id *parent_
        in_getsockaddr(child_so, (struct sockaddr **)&local);
        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));
+       CTR3(KTR_IW_CXGB, "%s remote addr 0x%08x port %d", __FUNCTION__, 
+               ntohl(remote->sin_addr.s_addr), 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;

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c
==============================================================================
--- stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c   Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdkrpc.c   Fri Mar 17 14:54:10 2017        
(r315456)
@@ -174,7 +174,11 @@ nfssvc_program(struct svc_req *rqst, SVC
                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, SVC
                        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);

Modified: stable/11/sys/kern/kern_jail.c
==============================================================================
--- stable/11/sys/kern/kern_jail.c      Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/kern/kern_jail.c      Fri Mar 17 14:54:10 2017        
(r315456)
@@ -4729,6 +4729,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
@@ -4780,7 +4783,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);

Modified: stable/11/sys/netinet/if_ether.c
==============================================================================
--- stable/11/sys/netinet/if_ether.c    Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/if_ether.c    Fri Mar 17 14:54:10 2017        
(r315456)
@@ -464,9 +464,12 @@ arpresolve_full(struct ifnet *ifp, int i
        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, 
        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, 
                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, 
                                    "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), ":",

Modified: stable/11/sys/netinet/igmp.c
==============================================================================
--- stable/11/sys/netinet/igmp.c        Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/igmp.c        Fri Mar 17 14:54:10 2017        
(r315456)
@@ -312,17 +312,6 @@ igmp_scrub_context(struct mbuf *m)
        m->m_pkthdr.flowid = 0;
 }
 
-#ifdef KTR
-static __inline char *
-inet_ntoa_haddr(in_addr_t haddr)
-{
-       struct in_addr ia;
-
-       ia.s_addr = htonl(haddr);
-       return (inet_ntoa(ia));
-}
-#endif
-
 /*
  * Restore context from a queued IGMP output chain.
  * Return saved ifindex.
@@ -872,8 +861,9 @@ igmp_input_v2_query(struct ifnet *ifp, c
                 */
                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);
+                       CTR3(KTR_IGMPV3,
+                           "process v2 query 0x%08x on ifp %p(%s)",
+                           ntohl(igmp->igmp_group.s_addr), ifp, ifp->if_xname);
                        igmp_v2_update_group(inm, timer);
                }
        }
@@ -904,8 +894,8 @@ static void
 igmp_v2_update_group(struct in_multi *inm, const int timer)
 {
 
-       CTR4(KTR_IGMPV3, "%s: %s/%s timer=%d", __func__,
-           inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname, timer);
+       CTR4(KTR_IGMPV3, "0x%08x: %s/%s timer=%d", __func__,
+           ntohl(inm->inm_addr.s_addr), inm->inm_ifp->if_xname, timer);
 
        IN_MULTI_LOCK_ASSERT();
 
@@ -1085,8 +1075,8 @@ igmp_input_v3_query(struct ifnet *ifp, c
                                goto out_locked;
                        }
                }
-               CTR3(KTR_IGMPV3, "process v3 %s query on ifp %p(%s)",
-                    inet_ntoa(igmpv3->igmp_group), ifp, ifp->if_xname);
+               CTR3(KTR_IGMPV3, "process v3 0x%08x query on ifp %p(%s)",
+                    ntohl(igmpv3->igmp_group.s_addr), ifp, ifp->if_xname);
                /*
                 * If there is a pending General Query response
                 * scheduled sooner than the selected delay, no
@@ -1246,8 +1236,8 @@ igmp_input_v1_report(struct ifnet *ifp, 
                }
        }
 
-       CTR3(KTR_IGMPV3, "process v1 report %s on ifp %p(%s)",
-            inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
+       CTR3(KTR_IGMPV3, "process v1 report 0x%08x on ifp %p(%s)",
+            ntohl(igmp->igmp_group.s_addr), ifp, ifp->if_xname);
 
        /*
         * IGMPv1 report suppression.
@@ -1289,15 +1279,17 @@ igmp_input_v1_report(struct ifnet *ifp, 
                case IGMP_LAZY_MEMBER:
                case IGMP_AWAKENING_MEMBER:
                        CTR3(KTR_IGMPV3,
-                           "report suppressed for %s on ifp %p(%s)",
-                           inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
+                           "report suppressed for 0x%08x on ifp %p(%s)",
+                           ntohl(igmp->igmp_group.s_addr), 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);
+                           "report suppressed for 0x%08x on ifp %p(%s)",
+                           ntohl(igmp->igmp_group.s_addr), 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)
@@ -1370,8 +1362,8 @@ igmp_input_v2_report(struct ifnet *ifp, 
        if (ia != NULL)
                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);
+       CTR3(KTR_IGMPV3, "process v2 report 0x%08x on ifp %p(%s)",
+            ntohl(igmp->igmp_group.s_addr), ifp, ifp->if_xname);
 
        /*
         * IGMPv2 report suppression.
@@ -1411,8 +1403,8 @@ igmp_input_v2_report(struct ifnet *ifp, 
                case IGMP_IDLE_MEMBER:
                case IGMP_AWAKENING_MEMBER:
                        CTR3(KTR_IGMPV3,
-                           "report suppressed for %s on ifp %p(%s)",
-                           inet_ntoa(igmp->igmp_group), ifp, ifp->if_xname);
+                           "report suppressed for 0x%08x on ifp %p(%s)",
+                           ntohl(igmp->igmp_group.s_addr), ifp, ifp->if_xname);
                case IGMP_LAZY_MEMBER:
                        inm->inm_state = IGMP_LAZY_MEMBER;
                        break;
@@ -1899,8 +1891,9 @@ igmp_v3_process_group_timers(struct igmp
                        (void)igmp_v3_merge_state_changes(inm, scq);
 
                        inm_commit(inm);
-                       CTR3(KTR_IGMPV3, "%s: T1 -> T0 for %s/%s", __func__,
-                           inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname);
+                       CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
+                           ntohl(inm->inm_addr.s_addr),
+                           inm->inm_ifp->if_xname);
 
                        /*
                         * If we are leaving the group for good, make sure
@@ -2346,10 +2339,9 @@ igmp_initial_join(struct in_multi *inm, 
        struct ifnet            *ifp;
        struct mbufq            *mq;
        int                      error, retval, syncstates;
-
-       CTR4(KTR_IGMPV3, "%s: initial join %s on ifp %p(%s)",
-           __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
-           inm->inm_ifp->if_xname);
+ 
+       CTR4(KTR_IGMPV3, "%s: initial join 0x%08x on ifp %p(%s)", __func__,
+           ntohl(inm->inm_addr.s_addr), inm->inm_ifp, inm->inm_ifp->if_xname);
 
        error = 0;
        syncstates = 1;
@@ -2458,8 +2450,8 @@ igmp_initial_join(struct in_multi *inm, 
         */
        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);
+               CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
+                   ntohl(inm->inm_addr.s_addr), inm->inm_ifp->if_xname);
        }
 
        return (error);
@@ -2474,9 +2466,8 @@ igmp_handle_state_change(struct in_multi
        struct ifnet            *ifp;
        int                      retval;
 
-       CTR4(KTR_IGMPV3, "%s: state change for %s on ifp %p(%s)",
-           __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
-           inm->inm_ifp->if_xname);
+       CTR4(KTR_IGMPV3, "%s: state change for 0x%08x on ifp %p(%s)", __func__,
+           ntohl(inm->inm_addr.s_addr), inm->inm_ifp, inm->inm_ifp->if_xname);
 
        ifp = inm->inm_ifp;
 
@@ -2495,8 +2486,8 @@ igmp_handle_state_change(struct in_multi
                }
                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);
+               CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
+                   ntohl(inm->inm_addr.s_addr), inm->inm_ifp->if_xname);
                return (0);
        }
 
@@ -2534,8 +2525,8 @@ igmp_final_leave(struct in_multi *inm, s
 
        syncstates = 1;
 
-       CTR4(KTR_IGMPV3, "%s: final leave %s on ifp %p(%s)",
-           __func__, inet_ntoa(inm->inm_addr), inm->inm_ifp,
+       CTR4(KTR_IGMPV3, "%s: final leave 0x%08x on ifp %p(%s)",
+           __func__, ntohl(inm->inm_addr.s_addr), inm->inm_ifp,
            inm->inm_ifp->if_xname);
 
        IN_MULTI_LOCK_ASSERT();
@@ -2576,9 +2567,9 @@ igmp_final_leave(struct in_multi *inm, s
                        } else {
                                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__,
-                           inet_ntoa(inm->inm_addr),
+                           ntohl(inm->inm_addr.s_addr),
                            inm->inm_ifp->if_xname, inm->inm_scrv);
                        if (inm->inm_scrv == 0) {
                                inm->inm_state = IGMP_NOT_MEMBER;
@@ -2611,11 +2602,12 @@ igmp_final_leave(struct in_multi *inm, s
 
        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);
+               CTR3(KTR_IGMPV3, "%s: T1 -> T0 for 0x%08x/%s", __func__,
+                   ntohl(inm->inm_addr.s_addr), 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);
+               CTR3(KTR_IGMPV3, "%s: T1 now MCAST_UNDEFINED for 0x%08x/%s",
+                   __func__, ntohl(inm->inm_addr.s_addr),
+                   inm->inm_ifp->if_xname);
        }
 }
 
@@ -2740,9 +2732,8 @@ igmp_v3_enqueue_group_record(struct mbuf
                return (igmp_v3_enqueue_filter_change(mq, inm));
 
        if (type == IGMP_DO_NOTHING) {
-               CTR3(KTR_IGMPV3, "%s: nothing to do for %s/%s",
-                   __func__, inet_ntoa(inm->inm_addr),
-                   inm->inm_ifp->if_xname);
+               CTR3(KTR_IGMPV3, "%s: nothing to do for 0x%08x/%s", __func__,
+                   ntohl(inm->inm_addr.s_addr), inm->inm_ifp->if_xname);
                return (0);
        }
 
@@ -2755,8 +2746,8 @@ igmp_v3_enqueue_group_record(struct mbuf
        if (record_has_sources)
                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),
+       CTR4(KTR_IGMPV3, "%s: queueing %s for 0x%08x/%s", __func__,
+           igmp_rec_type_to_str(type), ntohl(inm->inm_addr.s_addr),
            inm->inm_ifp->if_xname);
 
        /*
@@ -2844,8 +2835,8 @@ igmp_v3_enqueue_group_record(struct mbuf
                }
                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));
+                       CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
+                           ims->ims_haddr);
                        now = ims_get_mode(inm, ims, 1);
                        CTR2(KTR_IGMPV3, "%s: node is %d", __func__, now);
                        if ((now != mode) ||
@@ -2940,8 +2931,8 @@ igmp_v3_enqueue_group_record(struct mbuf
 
                msrcs = 0;
                RB_FOREACH_FROM(ims, ip_msource_tree, nims) {
-                       CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
-                           inet_ntoa_haddr(ims->ims_haddr));
+                       CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
+                           ims->ims_haddr);
                        now = ims_get_mode(inm, ims, 1);
                        if ((now != mode) ||
                            (now == mode && mode == MCAST_UNDEFINED)) {
@@ -3132,8 +3123,8 @@ igmp_v3_enqueue_filter_change(struct mbu
                        if (nims == NULL)
                                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));
+                               CTR2(KTR_IGMPV3, "%s: visit node 0x%08x",
+                                   __func__, ims->ims_haddr);
                                now = ims_get_mode(inm, ims, 1);
                                then = ims_get_mode(inm, ims, 0);
                                CTR3(KTR_IGMPV3, "%s: mode: t0 %d, t1 %d",

Modified: stable/11/sys/netinet/in.c
==============================================================================
--- stable/11/sys/netinet/in.c  Fri Mar 17 14:18:52 2017        (r315455)
+++ stable/11/sys/netinet/in.c  Fri Mar 17 14:54:10 2017        (r315456)
@@ -1208,7 +1208,7 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
         */
        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;
                /*
@@ -1220,14 +1220,17 @@ in_lltable_rtcheck(struct ifnet *ifp, u_
 
                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);
                        }

Modified: stable/11/sys/netinet/in_mcast.c
==============================================================================
--- stable/11/sys/netinet/in_mcast.c    Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/in_mcast.c    Fri Mar 17 14:54:10 2017        
(r315456)
@@ -495,9 +495,12 @@ in_getmulti(struct ifnet *ifp, const str
                    ("%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;
@@ -874,9 +877,6 @@ inm_get_source(struct in_multi *inm, con
 {
        struct ip_msource        find;
        struct ip_msource       *ims, *nims;
-#ifdef KTR
-       struct in_addr ia;
-#endif
 
        find.ims_haddr = haddr;
        ims = RB_FIND(ip_msource_tree, &inm->inm_srcs, &find);
@@ -892,9 +892,8 @@ inm_get_source(struct in_multi *inm, con
                ++inm->inm_nsrc;
                ims = nims;
 #ifdef KTR
-               ia.s_addr = htonl(haddr);
-               CTR3(KTR_IGMPV3, "%s: allocated %s as %p", __func__,
-                   inet_ntoa(ia), ims);
+               CTR3(KTR_IGMPV3, "%s: allocated 0x%08x as %p", __func__,
+                   haddr, ims);
 #endif
        }
 
@@ -911,29 +910,24 @@ ims_merge(struct ip_msource *ims, const 
     const int rollback)
 {
        int n = rollback ? -1 : 1;
-#ifdef KTR
-       struct in_addr ia;
-
-       ia.s_addr = htonl(ims->ims_haddr);
-#endif
 
        if (lims->imsl_st[0] == MCAST_EXCLUDE) {
-               CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on %s",
-                   __func__, n, inet_ntoa(ia));
+               CTR3(KTR_IGMPV3, "%s: t1 ex -= %d on 0x%08x",
+                   __func__, n, ims->ims_haddr);
                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));
+               CTR3(KTR_IGMPV3, "%s: t1 in -= %d on 0x%08x",
+                   __func__, n, ims->ims_haddr);
                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));
+               CTR3(KTR_IGMPV3, "%s: t1 ex += %d on 0x%08x",
+                   __func__, n, ims->ims_haddr);
                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));
+               CTR3(KTR_IGMPV3, "%s: t1 in += %d on 0x%08x",
+                   __func__, n, ims->ims_haddr);
                ims->ims_st[1].in += n;
        }
 }
@@ -1169,8 +1163,8 @@ in_joingroup_locked(struct ifnet *ifp, c
 
        IN_MULTI_LOCK_ASSERT();
 
-       CTR4(KTR_IGMPV3, "%s: join %s on %p(%s))", __func__,
-           inet_ntoa(*gina), ifp, ifp->if_xname);
+       CTR4(KTR_IGMPV3, "%s: join 0x%08x on %p(%s))", __func__,
+           ntohl(gina->s_addr), ifp, ifp->if_xname);
 
        error = 0;
        inm = NULL;
@@ -1253,8 +1247,8 @@ in_leavegroup_locked(struct in_multi *in
 
        IN_MULTI_LOCK_ASSERT();
 
-       CTR5(KTR_IGMPV3, "%s: leave inm %p, %s/%s, imf %p", __func__,
-           inm, inet_ntoa(inm->inm_addr),
+       CTR5(KTR_IGMPV3, "%s: leave inm %p, 0x%08x/%s, imf %p", __func__,
+           inm, ntohl(inm->inm_addr.s_addr),
            (inm_is_ifp_detached(inm) ? "null" : inm->inm_ifp->if_xname),
            imf);
 
@@ -1302,9 +1296,13 @@ in_addmulti(struct in_addr *ap, struct i
 {
        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)
@@ -1383,8 +1381,8 @@ inp_block_unblock_source(struct inpcb *i
                if (sopt->sopt_name == IP_BLOCK_SOURCE)
                        doblock = 1;
 
-               CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
-                   __func__, inet_ntoa(mreqs.imr_interface), ifp);
+               CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
+                   __func__, ntohl(mreqs.imr_interface.s_addr), ifp);
                break;
            }
 
@@ -1456,8 +1454,8 @@ inp_block_unblock_source(struct inpcb *i
         */
        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 ");
+               CTR3(KTR_IGMPV3, "%s: source 0x%08x %spresent", __func__,
+                   ntohl(ssa->sin.sin_addr.s_addr), doblock ? "" : "not ");
                error = EADDRNOTAVAIL;
                goto out_inp_locked;
        }
@@ -1985,8 +1983,8 @@ inp_join_group(struct inpcb *inp, struct
 
                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);
+               CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
+                   __func__, ntohl(mreqs.imr_interface.s_addr), ifp);
                break;
        }
 
@@ -2286,8 +2284,8 @@ inp_leave_group(struct inpcb *inp, struc
                if (!in_nullhost(mreqs.imr_interface))
                        INADDR_TO_IFP(mreqs.imr_interface, ifp);
 
-               CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p",
-                   __func__, inet_ntoa(mreqs.imr_interface), ifp);
+               CTR3(KTR_IGMPV3, "%s: imr_interface = 0x%08x, ifp = %p",
+                   __func__, ntohl(mreqs.imr_interface.s_addr), ifp);
 
                break;
 
@@ -2367,8 +2365,8 @@ inp_leave_group(struct inpcb *inp, struc
                }
                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 ");
+                       CTR3(KTR_IGMPV3, "%s: source 0x%08x %spresent",
+                           __func__, ntohl(ssa->sin.sin_addr.s_addr), "not ");
                        error = EADDRNOTAVAIL;
                        goto out_inp_locked;
                }
@@ -2487,8 +2485,8 @@ inp_set_multicast_if(struct inpcb *inp, 
                        if (ifp == NULL)
                                return (EADDRNOTAVAIL);
                }
-               CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = %s", __func__, ifp,
-                   inet_ntoa(addr));
+               CTR3(KTR_IGMPV3, "%s: ifp = %p, addr = 0x%08x", __func__, ifp,
+                   ntohl(addr.s_addr));
        }
 
        /* Reject interfaces which do not support multicast. */
@@ -2865,8 +2863,8 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_A
 
        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));
+               CTR2(KTR_IGMPV3, "%s: group 0x%08x is not multicast",
+                   __func__, ntohl(group.s_addr));
                return (EINVAL);
        }
 
@@ -2897,12 +2895,8 @@ sysctl_ip_mcast_filters(SYSCTL_HANDLER_A
                if (retval != 0)
                        break;
                RB_FOREACH(ims, ip_msource_tree, &inm->inm_srcs) {
-#ifdef KTR
-                       struct in_addr ina;
-                       ina.s_addr = htonl(ims->ims_haddr);
-                       CTR2(KTR_IGMPV3, "%s: visit node %s", __func__,
-                           inet_ntoa(ina));
-#endif
+                       CTR2(KTR_IGMPV3, "%s: visit node 0x%08x", __func__,
+                           ims->ims_haddr);
                        /*
                         * Only copy-out sources which are in-mode.
                         */
@@ -2965,13 +2959,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);

Modified: stable/11/sys/netinet/ip_icmp.c
==============================================================================
--- stable/11/sys/netinet/ip_icmp.c     Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/ip_icmp.c     Fri Mar 17 14:54:10 2017        
(r315456)
@@ -380,10 +380,12 @@ icmp_input(struct mbuf **mp, int *offp, 
         */
 #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 *o
        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);

Modified: stable/11/sys/netinet/ip_mroute.c
==============================================================================
--- stable/11/sys/netinet/ip_mroute.c   Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/ip_mroute.c   Fri Mar 17 14:54:10 2017        
(r315456)
@@ -928,8 +928,8 @@ 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),
+    CTR4(KTR_IPMF, "%s: add vif %d laddr 0x%08x thresh %x", __func__,
+       (int)vifcp->vifc_vifi, ntohl(vifcp->vifc_lcl_addr.s_addr),
        (int)vifcp->vifc_threshold);
 
     return 0;
@@ -1060,8 +1060,8 @@ 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),
+       CTR4(KTR_IPMF, "%s: update mfc orig 0x%08x group %lx parent %x",
+           __func__, ntohl(mfccp->mfcc_origin.s_addr),
            (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
            mfccp->mfcc_parent);
        update_mfc_params(rt, mfccp);
@@ -1080,8 +1080,8 @@ add_mfc(struct mfcctl2 *mfccp)
            in_hosteq(rt->mfc_mcastgrp, mfccp->mfcc_mcastgrp) &&
            !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),
+                   "%s: add mfc orig 0x%08x group %lx parent %x qh %p",
+                   __func__, ntohl(mfccp->mfcc_origin.s_addr),
                    (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr),
                    mfccp->mfcc_parent,
                    TAILQ_FIRST(&rt->mfc_stall));
@@ -1159,8 +1159,8 @@ del_mfc(struct mfcctl2 *mfccp)
     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));
+    CTR3(KTR_IPMF, "%s: delete mfc orig 0x%08x group %lx", __func__,
+       ntohl(origin.s_addr), (u_long)ntohl(mcastgrp.s_addr));
 
     MFC_LOCK();
 
@@ -1224,8 +1224,8 @@ X_ip_mforward(struct ip *ip, struct ifne
     int error;
     vifi_t vifi;
 
-    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);
+    CTR3(KTR_IPMF, "ip_mforward: delete mfc orig 0x%08x group %lx ifp %p",
+       ntohl(ip->ip_src.s_addr), (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 ) {
@@ -1287,8 +1287,8 @@ X_ip_mforward(struct ip *ip, struct ifne
 
        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));
+       CTR2(KTR_IPMF, "ip_mforward: no mfc for (0x%08x,%lx)",
+           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
@@ -2570,7 +2570,7 @@ pim_input(struct mbuf **mp, int *offp, i
     int minlen;
     int datalen = ntohs(ip->ip_len) - iphlen;
     int ip_tos;
-
+ 
     *mp = NULL;
 
     /* Keep statistics */
@@ -2582,8 +2582,8 @@ pim_input(struct mbuf **mp, int *offp, i
      */
     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));
+       CTR3(KTR_IPMF, "%s: short packet (%d) from 0x%08x",
+           __func__, datalen, ntohl(ip->ip_src.s_addr));
        m_freem(m);
        return (IPPROTO_DONE);
     }
@@ -2682,8 +2682,9 @@ pim_input(struct mbuf **mp, int *offp, i
        reghdr = (u_int32_t *)(pim + 1);
        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));
+       CTR3(KTR_IPMF, "%s: register: encap ip src 0x%08x len %d",
+           __func__, ntohl(encap_ip->ip_src.s_addr),
+           ntohs(encap_ip->ip_len));
 
        /* verify the version number of the inner packet */
        if (encap_ip->ip_v != IPVERSION) {
@@ -2696,8 +2697,8 @@ pim_input(struct mbuf **mp, int *offp, i
        /* verify the inner packet is destined to a mcast group */
        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));
+           CTR2(KTR_IPMF, "%s: bad encap ip dest 0x%08x", __func__,
+               ntohl(encap_ip->ip_dst.s_addr));
            m_freem(m);
            return (IPPROTO_DONE);
        }

Modified: stable/11/sys/netinet/ip_options.c
==============================================================================
--- stable/11/sys/netinet/ip_options.c  Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/ip_options.c  Fri Mar 17 14:54:10 2017        
(r315456)
@@ -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;

Modified: stable/11/sys/netinet/libalias/alias_local.h
==============================================================================
--- stable/11/sys/netinet/libalias/alias_local.h        Fri Mar 17 14:18:52 
2017        (r315455)
+++ stable/11/sys/netinet/libalias/alias_local.h        Fri Mar 17 14:54:10 
2017        (r315456)
@@ -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 {

Modified: stable/11/sys/netinet/libalias/alias_nbt.c
==============================================================================
--- stable/11/sys/netinet/libalias/alias_nbt.c  Fri Mar 17 14:18:52 2017        
(r315455)
+++ stable/11/sys/netinet/libalias/alias_nbt.c  Fri Mar 17 14:54:10 2017        
(r315456)
@@ -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) {

Modified: stable/11/sys/netinet/libalias/alias_proxy.c
==============================================================================
--- stable/11/sys/netinet/libalias/alias_proxy.c        Fri Mar 17 14:18:52 
2017        (r315455)
+++ stable/11/sys/netinet/libalias/alias_proxy.c        Fri Mar 17 14:54:10 
2017        (r315456)
@@ -294,6 +294,7 @@ ProxyEncodeTcpStream(struct alias_link *
        int slen;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to