libkern: Make inet_ntoa MPSAFE by passing string buffer to it.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 13 Feb 2017 13:51:20 +0000 (21:51 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 13 Feb 2017 13:52:16 +0000 (21:52 +0800)
15 files changed:
sys/kern/kern_jail.c
sys/libkern/inet_ntoa.c
sys/net/gre/if_gre.c
sys/net/ipfw/ip_fw2.c
sys/net/libalias/alias_nbt.c
sys/net/libalias/alias_proxy.c
sys/net/pf/pf_osfp.c
sys/netinet/if_ether.c
sys/netinet/in.h
sys/netinet/ip_input.c
sys/netinet/tcp_input.c
sys/netinet/udp_usrreq.c
sys/netproto/ipsec/ipsec.c
sys/vfs/nfs/nfs_syscalls.c
sys/vfs/nfs/nfs_vfsops.c

index d1ba011..8afa4ba 100644 (file)
@@ -604,11 +604,13 @@ retry:
 
                /* Copy the IPS */
                SLIST_FOREACH(jip, &pr->pr_ips, entries) {
+                       char buf[INET_ADDRSTRLEN];
+
                        jsin = (struct sockaddr_in *)&jip->ip;
 
                        switch(jsin->sin_family) {
                        case AF_INET:
-                               oip = inet_ntoa(jsin->sin_addr);
+                               oip = kinet_ntoa(jsin->sin_addr, buf);
                                break;
 #ifdef INET6
                        case AF_INET6:
index 8fa18fb..abd0805 100644 (file)
@@ -37,9 +37,8 @@
 #include <netinet/in.h>
 
 char *
-inet_ntoa(struct in_addr ina)
+kinet_ntoa(struct in_addr ina, char *buf)
 {
-       static char buf[sizeof "aaa.bbb.ccc.ddd"];
        unsigned char *ucp = (unsigned char *)&ina;
 
        ksprintf(buf, "%d.%d.%d.%d",
@@ -47,6 +46,5 @@ inet_ntoa(struct in_addr ina)
                 ucp[1] & 0xff,
                 ucp[2] & 0xff,
                 ucp[3] & 0xff);
-       return buf;
+       return (buf);
 }
-
index c47da15..648be3c 100644 (file)
@@ -652,6 +652,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
 static int
 gre_compute_route(struct gre_softc *sc)
 {
+#ifdef DIAGNOSTIC
+       char abuf[INET_ADDRSTRLEN];
+#endif
        struct route *ro;
        u_int32_t a, b, c;
 
@@ -680,7 +683,7 @@ gre_compute_route(struct gre_softc *sc)
 
 #ifdef DIAGNOSTIC
        kprintf("%s: searching a route to %s", if_name(&sc->sc_if),
-           inet_ntoa(((struct sockaddr_in *)&ro->ro_dst)->sin_addr));
+           kinet_ntoa(((struct sockaddr_in *)&ro->ro_dst)->sin_addr, abuf));
 #endif
 
        rtalloc(ro);
@@ -708,7 +711,8 @@ gre_compute_route(struct gre_softc *sc)
 
 #ifdef DIAGNOSTIC
        kprintf(", choosing %s with gateway %s", if_name(ro->ro_rt->rt_ifp),
-           inet_ntoa(((struct sockaddr_in *)(ro->ro_rt->rt_gateway))->sin_addr));
+           kinet_ntoa(
+               ((struct sockaddr_in *)(ro->ro_rt->rt_gateway))->sin_addr, abuf));
        kprintf("\n");
 #endif
 
index 8e80465..f548b72 100644 (file)
@@ -659,7 +659,7 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh,
 {
        char *action;
        int limit_reached = 0;
-       char action2[40], proto[48], fragment[28];
+       char action2[40], proto[48], fragment[28], abuf[INET_ADDRSTRLEN];
 
        fragment[0] = '\0';
        proto[0] = '\0';
@@ -738,8 +738,8 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh,
                                int len;
 
                                len = ksnprintf(SNPARGS(action2, 0),
-                                               "Forward to %s",
-                                               inet_ntoa(sa->sa.sin_addr));
+                                   "Forward to %s",
+                                   kinet_ntoa(sa->sa.sin_addr, abuf));
                                if (sa->sa.sin_port) {
                                        ksnprintf(SNPARGS(action2, len), ":%d",
                                                  sa->sa.sin_port);
@@ -776,29 +776,29 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh,
                switch (ip->ip_p) {
                case IPPROTO_TCP:
                        len = ksnprintf(SNPARGS(proto, 0), "TCP %s",
-                                       inet_ntoa(ip->ip_src));
+                                       kinet_ntoa(ip->ip_src, abuf));
                        if (offset == 0) {
                                ksnprintf(SNPARGS(proto, len), ":%d %s:%d",
                                          ntohs(tcp->th_sport),
-                                         inet_ntoa(ip->ip_dst),
+                                         kinet_ntoa(ip->ip_dst, abuf),
                                          ntohs(tcp->th_dport));
                        } else {
                                ksnprintf(SNPARGS(proto, len), " %s",
-                                         inet_ntoa(ip->ip_dst));
+                                         kinet_ntoa(ip->ip_dst, abuf));
                        }
                        break;
 
                case IPPROTO_UDP:
                        len = ksnprintf(SNPARGS(proto, 0), "UDP %s",
-                                       inet_ntoa(ip->ip_src));
+                                       kinet_ntoa(ip->ip_src, abuf));
                        if (offset == 0) {
                                ksnprintf(SNPARGS(proto, len), ":%d %s:%d",
                                          ntohs(udp->uh_sport),
-                                         inet_ntoa(ip->ip_dst),
+                                         kinet_ntoa(ip->ip_dst, abuf),
                                          ntohs(udp->uh_dport));
                        } else {
                                ksnprintf(SNPARGS(proto, len), " %s",
-                                         inet_ntoa(ip->ip_dst));
+                                         kinet_ntoa(ip->ip_dst, abuf));
                        }
                        break;
 
@@ -812,16 +812,16 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh,
                                len = ksnprintf(SNPARGS(proto, 0), "ICMP ");
                        }
                        len += ksnprintf(SNPARGS(proto, len), "%s",
-                                        inet_ntoa(ip->ip_src));
+                                        kinet_ntoa(ip->ip_src, abuf));
                        ksnprintf(SNPARGS(proto, len), " %s",
-                                 inet_ntoa(ip->ip_dst));
+                                 kinet_ntoa(ip->ip_dst, abuf));
                        break;
 
                default:
                        len = ksnprintf(SNPARGS(proto, 0), "P:%d %s", ip->ip_p,
-                                       inet_ntoa(ip->ip_src));
+                                       kinet_ntoa(ip->ip_src, abuf));
                        ksnprintf(SNPARGS(proto, len), " %s",
-                                 inet_ntoa(ip->ip_dst));
+                                 kinet_ntoa(ip->ip_dst, abuf));
                        break;
                }
 
index 322431c..be49e05 100644 (file)
@@ -341,6 +341,9 @@ AliasHandleUdpNbt(
     u_short alias_port
 )
 {
+#ifdef LIBALIAS_DEBUG
+       char abuf[INET_ADDRSTRLEN];
+#endif
        struct udphdr *uh;
        NbtDataHeader *ndh;
        u_char *p = NULL;
@@ -380,7 +383,8 @@ AliasHandleUdpNbt(
        if (p == NULL || (char *)p > pmax)
                p = NULL;
 #ifdef LIBALIAS_DEBUG
-       kprintf("%s:%d-->", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port));
+       kprintf("%s:%d-->", kinet_ntoa(ndh->source_ip, abuf),
+           ntohs(ndh->source_port));
 #endif
        /* Doing an IP address and Port number Translation */
        if (uh->uh_sum != 0) {
@@ -400,7 +404,8 @@ AliasHandleUdpNbt(
        ndh->source_ip = *alias_address;
        ndh->source_port = alias_port;
 #ifdef LIBALIAS_DEBUG
-       kprintf("%s:%d\n", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port));
+       kprintf("%s:%d\n", kinet_ntoa(ndh->source_ip, abuf),
+           ntohs(ndh->source_port));
        fflush(stdout);
 #endif
        return ((p == NULL) ? -1 : 0);
@@ -481,6 +486,9 @@ AliasHandleResourceNB(
 {
        NBTNsRNB *nb;
        u_short bcount;
+#ifdef LIBALIAS_DEBUG
+       char abuf[INET_ADDRSTRLEN];
+#endif
 
        if (q == NULL || (char *)(q + 1) > pmax)
                return (NULL);
@@ -492,8 +500,8 @@ AliasHandleResourceNB(
 
        /* Processing all in_addr array */
 #ifdef LIBALIAS_DEBUG
-       kprintf("NB rec[%s", inet_ntoa(nbtarg->oldaddr));
-       kprintf("->%s, %dbytes] ", inet_ntoa(nbtarg->newaddr), bcount);
+       kprintf("NB rec[%s", kinet_ntoa(nbtarg->oldaddr, abuf));
+       kprintf("->%s, %dbytes] ", kinet_ntoa(nbtarg->newaddr, abuf), bcount);
 #endif
        while (nb != NULL && bcount != 0) {
                if ((char *)(nb + 1) > pmax) {
@@ -501,7 +509,7 @@ AliasHandleResourceNB(
                        break;
                }
 #ifdef LIBALIAS_DEBUG
-               kprintf("<%s>", inet_ntoa(nb->addr));
+               kprintf("<%s>", kinet_ntoa(nb->addr, abuf));
 #endif
                if (!bcmp(&nbtarg->oldaddr, &nb->addr, sizeof(struct in_addr))) {
                        if (*nbtarg->uh_sum != 0) {
@@ -548,6 +556,9 @@ AliasHandleResourceA(
 {
        NBTNsResourceA *a;
        u_short bcount;
+#ifdef LIBALIAS_DEBUG
+       char abuf[INET_ADDRSTRLEN];
+#endif
 
        if (q == NULL || (char *)(q + 1) > pmax)
                return (NULL);
@@ -560,14 +571,14 @@ AliasHandleResourceA(
 
        /* Processing all in_addr array */
 #ifdef LIBALIAS_DEBUG
-       kprintf("Arec [%s", inet_ntoa(nbtarg->oldaddr));
-       kprintf("->%s]", inet_ntoa(nbtarg->newaddr));
+       kprintf("Arec [%s", kinet_ntoa(nbtarg->oldaddr, abuf));
+       kprintf("->%s]", kinet_ntoa(nbtarg->newaddr, abuf));
 #endif
        while (bcount != 0) {
                if (a == NULL || (char *)(a + 1) > pmax)
                        return (NULL);
 #ifdef LIBALIAS_DEBUG
-               kprintf("..%s", inet_ntoa(a->addr));
+               kprintf("..%s", kinet_ntoa(a->addr, abuf));
 #endif
                if (!bcmp(&nbtarg->oldaddr, &a->addr, sizeof(struct in_addr))) {
                        if (*nbtarg->uh_sum != 0) {
index 4fa8321..049b38b 100644 (file)
@@ -389,7 +389,7 @@ ProxyEncodeTcpStream(struct alias_link *lnk,
     int maxpacketsize)
 {
        int slen;
-       char buffer[40];
+       char buffer[40], addr[INET_ADDRSTRLEN];
        struct tcphdr *tc;
 
 /* Compute pointer to tcp header */
@@ -402,7 +402,8 @@ ProxyEncodeTcpStream(struct alias_link *lnk,
 
 /* Translate destination address and port to string form */
        ksnprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
-           inet_ntoa(GetProxyAddress(lnk)), (u_int) ntohs(GetProxyPort(lnk)));
+           kinet_ntoa(GetProxyAddress(lnk), addr),
+           (u_int) ntohs(GetProxyPort(lnk)));
 
 /* Pad string out to a multiple of two in length */
        slen = strlen(buffer);
index 02b5c1b..56ba887 100644 (file)
@@ -136,7 +136,7 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st
                if (ip->ip_off & IP_DF)
                        fp.fp_flags |= PF_OSFP_DF;
 #ifdef _KERNEL
-               strlcpy(srcname, inet_ntoa(ip->ip_src), sizeof(srcname));
+               kinet_ntoa(ip->ip_src, srcname);
 #else
                memset(&sin, 0, sizeof(sin));
                sin.sin_family = AF_INET;
index 1c03ef4..37551d7 100644 (file)
@@ -530,8 +530,10 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
                        rt = la->la_rt;
        }
        if (la == NULL || rt == NULL) {
+               char addr[INET_ADDRSTRLEN];
+
                log(LOG_DEBUG, "arpresolve: can't allocate llinfo for %s%s%s\n",
-                   inet_ntoa(SIN(dst)->sin_addr), la ? "la" : " ",
+                   kinet_ntoa(SIN(dst)->sin_addr, addr), la ? "la" : " ",
                    rt ? "rt" : "");
                m_freem(m);
                return (0);
@@ -692,6 +694,7 @@ arp_update_oncpu(struct mbuf *m, in_addr_t saddr, boolean_t create,
        struct sockaddr_dl *sdl;
        struct rtentry *rt;
        char hexstr[2][64];
+       char sbuf[INET_ADDRSTRLEN];
        int changed = create;
 
        KASSERT(curthread->td_type == TD_TYPE_NETISR,
@@ -737,7 +740,7 @@ arp_update_oncpu(struct mbuf *m, in_addr_t saddr, boolean_t create,
                                log(LOG_ERR,
                                    "arp: %s is on %s "
                                    "but got reply from %s on %s\n",
-                                   inet_ntoa(isaddr),
+                                   kinet_ntoa(isaddr, sbuf),
                                    rt->rt_ifp->if_xname, hexstr[0],
                                    ifp->if_xname);
                        }
@@ -769,7 +772,7 @@ arp_update_oncpu(struct mbuf *m, in_addr_t saddr, boolean_t create,
                                            hexstr[1], HEX_NCPYLEN(ifp->if_addrlen), ":");
                                        log(LOG_INFO,
                                            "arp: %s moved from %s to %s on %s\n",
-                                           inet_ntoa(isaddr), hexstr[0], hexstr[1],
+                                           kinet_ntoa(isaddr, sbuf), hexstr[0], hexstr[1],
                                            ifp->if_xname);
                                }
                        } else {
@@ -779,7 +782,7 @@ arp_update_oncpu(struct mbuf *m, in_addr_t saddr, boolean_t create,
                                        log(LOG_ERR,
                                        "arp: %s attempts to modify "
                                        "permanent entry for %s on %s\n",
-                                       hexstr[0], inet_ntoa(isaddr), ifp->if_xname);
+                                       hexstr[0], kinet_ntoa(isaddr, sbuf), ifp->if_xname);
                                }
                                return changed;
                        }
@@ -859,7 +862,7 @@ in_arpinput(struct mbuf *m)
        uint8_t *enaddr = NULL;
        int req_len;
        int changed;
-       char hexstr[64];
+       char hexstr[64], sbuf[INET_ADDRSTRLEN];
 
        req_len = arphdr_len2(ifp->if_addrlen, sizeof(struct in_addr));
        if (m->m_len < req_len && (m = m_pullup(m, req_len)) == NULL) {
@@ -1014,7 +1017,7 @@ match:
        if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) {
                log(LOG_ERR,
                    "arp: link address is broadcast for IP address %s!\n",
-                   inet_ntoa(isaddr));
+                   kinet_ntoa(isaddr, sbuf));
                m_freem(m);
                return;
        }
@@ -1023,7 +1026,7 @@ match:
                    hexstr, HEX_NCPYLEN(ifp->if_addrlen), ":");
                log(LOG_ERR,
                   "arp: %s is using my IP address %s!\n",
-                   hexstr, inet_ntoa(isaddr));
+                   hexstr, kinet_ntoa(isaddr, sbuf));
                itaddr = myaddr;
                goto reply;
        }
@@ -1149,6 +1152,9 @@ in_arpreply(struct mbuf *m, in_addr_t taddr, in_addr_t myaddr)
                la = arplookup(taddr, FALSE, RTL_DONTREPORT, SIN_PROXY);
                if (la == NULL) {
                        struct sockaddr_in sin;
+#ifdef DEBUG_PROXY
+                       char tbuf[INET_ADDRSTRLEN];
+#endif
 
                        if (!arp_proxyall) {
                                m_freem(m);
@@ -1178,7 +1184,8 @@ in_arpreply(struct mbuf *m, in_addr_t taddr, in_addr_t myaddr)
                        memcpy(ar_tha(ah), ar_sha(ah), ah->ar_hln);
                        memcpy(ar_sha(ah), enaddr, ah->ar_hln);
 #ifdef DEBUG_PROXY
-                       kprintf("arp: proxying for %s\n", inet_ntoa(itaddr));
+                       kprintf("arp: proxying for %s\n",
+                           kinet_ntoa(itaddr, tbuf));
 #endif
                } else {
                        struct sockaddr_dl *sdl;
@@ -1273,8 +1280,10 @@ arplookup(in_addr_t addr, boolean_t create, boolean_t generate_report,
 
        if (why) {
                if (create && log_arp_creation_failure) {
+                       char abuf[INET_ADDRSTRLEN];
+
                        log(LOG_DEBUG, "arplookup %s failed: %s\n",
-                           inet_ntoa(sin.sin_addr), why);
+                           kinet_ntoa(sin.sin_addr, abuf), why);
                }
                if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_WASCLONED)) {
                        /* No references to this route.  Purge it. */
index 611b3c6..46de27a 100644 (file)
@@ -525,7 +525,7 @@ struct thread;
 int     in_broadcast(struct in_addr, struct ifnet *);
 int     in_canforward(struct in_addr);
 int     in_localaddr(struct in_addr);
-char   *inet_ntoa(struct in_addr); /* in libkern */
+char   *kinet_ntoa(struct in_addr, char *); /* in libkern */
 char   *inet_ntop(int, const void * __restrict, char * __restrict,
            socklen_t); /* in libkern */
 
index d7532ca..fa41b5c 100644 (file)
@@ -1581,16 +1581,17 @@ ip_dooptions(struct mbuf *m, int pass, struct sockaddr_in *next_hop)
                                goto dropit;
                        if (!ip_dosourceroute) {
                                if (ipforwarding) {
-                                       char buf[sizeof "aaa.bbb.ccc.ddd"];
+                                       char sbuf[INET_ADDRSTRLEN];
+                                       char dbuf[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);
+                                           kinet_ntoa(ip->ip_src, sbuf),
+                                           kinet_ntoa(ip->ip_dst, dbuf));
                                        type = ICMP_UNREACH;
                                        code = ICMP_UNREACH_SRCFAIL;
                                        goto bad;
index 070fb09..582294f 100644 (file)
@@ -889,8 +889,7 @@ findpcb:
 #ifdef INET6
                        char dbuf[INET6_ADDRSTRLEN+2], sbuf[INET6_ADDRSTRLEN+2];
 #else
-                       char dbuf[sizeof "aaa.bbb.ccc.ddd"];
-                       char sbuf[sizeof "aaa.bbb.ccc.ddd"];
+                       char dbuf[INET_ADDRSTRLEN], sbuf[INET_ADDRSTRLEN];
 #endif
                        if (isipv6) {
                                strcpy(dbuf, "[");
@@ -900,8 +899,8 @@ findpcb:
                                strcat(sbuf, ip6_sprintf(&ip6->ip6_src));
                                strcat(sbuf, "]");
                        } else {
-                               strcpy(dbuf, inet_ntoa(ip->ip_dst));
-                               strcpy(sbuf, inet_ntoa(ip->ip_src));
+                               kinet_ntoa(ip->ip_dst, dbuf);
+                               kinet_ntoa(ip->ip_src, sbuf);
                        }
                        switch (log_in_vain) {
                        case 1:
index 20877f5..a99c3f4 100644 (file)
@@ -623,13 +623,12 @@ done:
            udp_reuseport_ext ? m : NULL);
        if (inp == NULL) {
                if (log_in_vain) {
-                       char buf[sizeof "aaa.bbb.ccc.ddd"];
+                       char src[INET_ADDRSTRLEN], dst[INET_ADDRSTRLEN];
 
-                       strcpy(buf, inet_ntoa(ip->ip_dst));
                        log(LOG_INFO,
                            "Connection attempt to UDP %s:%d from %s:%d\n",
-                           buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
-                           ntohs(uh->uh_sport));
+                           kinet_ntoa(ip->ip_dst, dst), ntohs(uh->uh_dport),
+                           kinet_ntoa(ip->ip_src, src), ntohs(uh->uh_sport));
                }
                udp_stat.udps_noport++;
                if (m->m_flags & (M_BCAST | M_MCAST)) {
index 6d937c5..be21753 100644 (file)
@@ -1755,10 +1755,13 @@ vshiftl(unsigned char *bitmap, int nbit, int wsize)
 char *
 ipsec_address(union sockaddr_union* sa)
 {
+       /* XXX not MPSAFE */
+       static char sbuf[INET_ADDRSTRLEN];
+
        switch (sa->sa.sa_family) {
 #if INET
        case AF_INET:
-               return inet_ntoa(sa->sin.sin_addr);
+               return kinet_ntoa(sa->sin.sin_addr, sbuf);
 #endif /* INET */
 
 #if INET6
index ac4936a..3ffd97c 100644 (file)
@@ -642,11 +642,13 @@ nfssvc_nfsd(struct nfsd_srvargs *nsd, caddr_t argp, struct thread *td)
                        port = ntohs(sin->sin_port);
                        if (port >= IPPORT_RESERVED && 
                            nd->nd_procnum != NFSPROC_NULL) {
+                           char addr[INET_ADDRSTRLEN];
+
                            nd->nd_procnum = NFSPROC_NOOP;
                            nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
                            cacherep = RC_DOIT;
                            kprintf("NFS request from unprivileged port (%s:%d)\n",
-                                  inet_ntoa(sin->sin_addr), port);
+                                   kinet_ntoa(sin->sin_addr, addr), port);
                        }
                    }
                }
index 8c5fd01..2af2e01 100644 (file)
@@ -563,7 +563,7 @@ nfs_mountroot(struct mount *mp)
        struct thread *td = curthread;          /* XXX */
        int error, i;
        u_long l;
-       char buf[128];
+       char buf[128], addr[INET_ADDRSTRLEN];
 
 #if defined(BOOTP_NFSROOT) && defined(BOOTP)
        bootpc_init();          /* use bootp to get nfs_diskless filled in */
@@ -592,11 +592,11 @@ nfs_mountroot(struct mount *mp)
 #define SINP(sockaddr) ((struct sockaddr_in *)(sockaddr))
        kprintf("nfs_mountroot: interface %s ip %s",
                nd->myif.ifra_name,
-               inet_ntoa(SINP(&nd->myif.ifra_addr)->sin_addr));
+               kinet_ntoa(SINP(&nd->myif.ifra_addr)->sin_addr, addr));
        kprintf(" bcast %s",
-               inet_ntoa(SINP(&nd->myif.ifra_broadaddr)->sin_addr));
+               kinet_ntoa(SINP(&nd->myif.ifra_broadaddr)->sin_addr, addr));
        kprintf(" mask %s\n",
-               inet_ntoa(SINP(&nd->myif.ifra_mask)->sin_addr));
+               kinet_ntoa(SINP(&nd->myif.ifra_mask)->sin_addr, addr));
 #undef SINP
 
        /*
@@ -635,7 +635,7 @@ nfs_mountroot(struct mount *mp)
                sin.sin_family = AF_INET;
                sin.sin_len = sizeof(sin);
                kprintf("nfs_mountroot: gateway %s\n",
-                       inet_ntoa(nd->mygateway.sin_addr));
+                       kinet_ntoa(nd->mygateway.sin_addr, addr));
                error = rtrequest_global(RTM_ADD, (struct sockaddr *)&sin,
                                        (struct sockaddr *)&nd->mygateway,
                                        (struct sockaddr *)&mask,