arp_rtrequest() uses a default static sockaddr_dl which is only used
read-only: it is copied by rt_setgate().
I'd like to constify this structure to make it clear no value can be
trashed if code using it is run in parallel.
Also remove another reference to the name of the variable to make it
clear it is used only once.
ok?
Index: netinet/if_ether.c
===
RCS file: /home/ncvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.103
diff -u -p -r1.103 if_ether.c
--- netinet/if_ether.c 1 Aug 2013 08:27:43 - 1.103
+++ netinet/if_ether.c 8 Aug 2013 10:31:34 -
@@ -112,6 +112,8 @@ voiddb_print_llinfo(caddr_t);
intdb_show_radix_node(struct radix_node *, void *, u_int);
#endif
+static const struct sockaddr_dl null_sdl = { sizeof(null_sdl), AF_LINK };
+
/*
* Timeout routine. Age arp_tab entries periodically.
*/
@@ -143,7 +145,6 @@ arp_rtrequest(int req, struct rtentry *r
{
struct sockaddr *gate = rt-rt_gateway;
struct llinfo_arp *la = (struct llinfo_arp *)rt-rt_llinfo;
- static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
struct in_ifaddr *ia;
struct ifaddr *ifa;
struct mbuf *m;
@@ -234,7 +235,7 @@ arp_rtrequest(int req, struct rtentry *r
/*FALLTHROUGH*/
case RTM_RESOLVE:
if (gate-sa_family != AF_LINK ||
- gate-sa_len sizeof(null_sdl)) {
+ gate-sa_len sizeof(struct sockaddr_dl)) {
log(LOG_DEBUG, arp_rtrequest: bad gateway value\n);
break;
}