summaryrefslogtreecommitdiffstats
path: root/sys/netinet/if_ether.c
diff options
context:
space:
mode:
authorvangyzen <vangyzen@FreeBSD.org>2017-03-17 14:54:10 +0000
committervangyzen <vangyzen@FreeBSD.org>2017-03-17 14:54:10 +0000
commit5ebfb876ead3dd5491730d0a543aba065d39d55d (patch)
tree60e75e61e458ac8a4a1f540317c9b35ba1b0c445 /sys/netinet/if_ether.c
parentd4eaf4dc21922349befba86e51d55edae9355763 (diff)
downloadFreeBSD-src-5ebfb876ead3dd5491730d0a543aba065d39d55d.zip
FreeBSD-src-5ebfb876ead3dd5491730d0a543aba065d39d55d.tar.gz
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
Diffstat (limited to 'sys/netinet/if_ether.c')
-rw-r--r--sys/netinet/if_ether.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 98ccf6a..25dff3a 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -464,9 +464,12 @@ arpresolve_full(struct ifnet *ifp, int is_gw, int flags, struct mbuf *m,
if (la == NULL && (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) {
la = lltable_alloc_entry(LLTABLE(ifp), 0, dst);
if (la == NULL) {
+ char addrbuf[INET_ADDRSTRLEN];
+
log(LOG_DEBUG,
"arpresolve: can't allocate llinfo for %s on %s\n",
- inet_ntoa(SIN(dst)->sin_addr), if_name(ifp));
+ inet_ntoa_r(SIN(dst)->sin_addr, addrbuf),
+ if_name(ifp));
m_freem(m);
return (EINVAL);
}
@@ -803,6 +806,7 @@ in_arpinput(struct mbuf *m)
size_t linkhdrsize;
int lladdr_off;
int error;
+ char addrbuf[INET_ADDRSTRLEN];
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
@@ -927,7 +931,7 @@ match:
goto drop; /* it's from me, ignore it. */
if (!bcmp(ar_sha(ah), ifp->if_broadcastaddr, ifp->if_addrlen)) {
ARP_LOG(LOG_NOTICE, "link address is broadcast for IP address "
- "%s!\n", inet_ntoa(isaddr));
+ "%s!\n", inet_ntoa_r(isaddr, addrbuf));
goto drop;
}
@@ -949,7 +953,7 @@ match:
myaddr.s_addr != 0) {
ARP_LOG(LOG_ERR, "%*D is using my IP address %s on %s!\n",
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
- inet_ntoa(isaddr), ifp->if_xname);
+ inet_ntoa_r(isaddr, addrbuf), ifp->if_xname);
itaddr = myaddr;
ARPSTAT_INC(dupips);
goto reply;
@@ -1086,12 +1090,14 @@ reply:
if (nh4.nh_ifp != ifp) {
ARP_LOG(LOG_INFO, "proxy: ignoring request"
" from %s via %s\n",
- inet_ntoa(isaddr), ifp->if_xname);
+ inet_ntoa_r(isaddr, addrbuf),
+ ifp->if_xname);
goto drop;
}
#ifdef DEBUG_PROXY
- printf("arp: proxying for %s\n", inet_ntoa(itaddr));
+ printf("arp: proxying for %s\n",
+ inet_ntoa_r(itaddr, addrbuf));
#endif
}
}
@@ -1101,7 +1107,7 @@ reply:
/* RFC 3927 link-local IPv4; always reply by broadcast. */
#ifdef DEBUG_LINKLOCAL
printf("arp: sending reply for link-local addr %s\n",
- inet_ntoa(itaddr));
+ inet_ntoa_r(itaddr, addrbuf));
#endif
m->m_flags |= M_BCAST;
m->m_flags &= ~M_MCAST;
@@ -1162,6 +1168,7 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp
uint8_t linkhdr[LLE_MAX_LINKHDR];
size_t linkhdrsize;
int lladdr_off;
+ char addrbuf[INET_ADDRSTRLEN];
LLE_WLOCK_ASSERT(la);
@@ -1170,7 +1177,7 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp
if (log_arp_wrong_iface)
ARP_LOG(LOG_WARNING, "%s is on %s "
"but got reply from %*D on %s\n",
- inet_ntoa(isaddr),
+ inet_ntoa_r(isaddr, addrbuf),
la->lle_tbl->llt_ifp->if_xname,
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
ifp->if_xname);
@@ -1187,13 +1194,14 @@ arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp
"permanent entry for %s on %s\n",
ifp->if_addrlen,
(u_char *)ar_sha(ah), ":",
- inet_ntoa(isaddr), ifp->if_xname);
+ inet_ntoa_r(isaddr, addrbuf),
+ ifp->if_xname);
return;
}
if (log_arp_movements) {
ARP_LOG(LOG_INFO, "%s moved from %*D "
"to %*D on %s\n",
- inet_ntoa(isaddr),
+ inet_ntoa_r(isaddr, addrbuf),
ifp->if_addrlen,
(u_char *)&la->ll_addr, ":",
ifp->if_addrlen, (u_char *)ar_sha(ah), ":",
OpenPOWER on IntegriCloud