summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_icmp.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2003-11-13 00:32:13 +0000
committerandre <andre@FreeBSD.org>2003-11-13 00:32:13 +0000
commitc864ff579247acf8bdc23a4bc7ac60e2a9513423 (patch)
tree59640452fadca985252d3148f2c0bad3b8c04d45 /sys/netinet/ip_icmp.c
parenta3489f51701b77256f3b144c6c47a4b2568e5836 (diff)
downloadFreeBSD-src-c864ff579247acf8bdc23a4bc7ac60e2a9513423.zip
FreeBSD-src-c864ff579247acf8bdc23a4bc7ac60e2a9513423.tar.gz
Move global variables for icmp_input() to its stack. With SMP or
preemption two CPUs can be in the same function at the same time and clobber each others variables. Remove register declaration from local variables. Reviewed by: sam (mentor)
Diffstat (limited to 'sys/netinet/ip_icmp.c')
-rw-r--r--sys/netinet/ip_icmp.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 8f71b05..9c5d4d0 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -233,26 +233,22 @@ freeit:
m_freem(n);
}
-static struct sockaddr_in icmpsrc = { sizeof (struct sockaddr_in), AF_INET };
-static struct sockaddr_in icmpdst = { sizeof (struct sockaddr_in), AF_INET };
-static struct sockaddr_in icmpgw = { sizeof (struct sockaddr_in), AF_INET };
-
/*
* Process a received ICMP message.
*/
void
icmp_input(m, off)
- register struct mbuf *m;
+ struct mbuf *m;
int off;
{
+ struct icmp *icp;
+ struct in_ifaddr *ia;
+ struct ip *ip = mtod(m, struct ip *);
+ struct sockaddr_in icmpsrc, icmpdst, icmpgw;
int hlen = off;
- register struct icmp *icp;
- register struct ip *ip = mtod(m, struct ip *);
int icmplen = ip->ip_len;
- register int i;
- struct in_ifaddr *ia;
+ int i, code;
void (*ctlfunc)(int, struct sockaddr *, void *);
- int code;
/*
* Locate icmp structure in mbuf, and check
@@ -310,6 +306,18 @@ icmp_input(m, off)
*/
if (icp->icmp_type > ICMP_MAXTYPE)
goto raw;
+
+ /* Initialize */
+ bzero(&icmpsrc, sizeof(icmpsrc));
+ icmpsrc.sin_len = sizeof(struct sockaddr_in);
+ icmpsrc.sin_family = AF_INET;
+ bzero(&icmpdst, sizeof(icmpdst));
+ icmpdst.sin_len = sizeof(struct sockaddr_in);
+ icmpdst.sin_family = AF_INET;
+ bzero(&icmpgw, sizeof(icmpgw));
+ icmpgw.sin_len = sizeof(struct sockaddr_in);
+ icmpgw.sin_family = AF_INET;
+
icmpstat.icps_inhist[icp->icmp_type]++;
code = icp->icmp_code;
switch (icp->icmp_type) {
OpenPOWER on IntegriCloud