diff options
author | 2014-09-03 08:53:54 +0000 | |
---|---|---|
committer | 2014-09-03 08:53:54 +0000 | |
commit | 09fa3e3c681ff8c0c896a1ffffeb358ab48fd332 (patch) | |
tree | 8d413c3131afee6f2fcf2f3b321c25eff57d119f | |
parent | Treat broadcast entries like local ones and give them the highest (diff) | |
download | wireguard-openbsd-09fa3e3c681ff8c0c896a1ffffeb358ab48fd332.tar.xz wireguard-openbsd-09fa3e3c681ff8c0c896a1ffffeb358ab48fd332.zip |
Make sure broadcast entries won't be freed by the arp timer so we can
use them for address lookups.
While here do let in_arpinput() overwrite local or broadcast entries.
ok mikeb@, florian@
-rw-r--r-- | sys/netinet/if_ether.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 4d40891c279..31a02254fd0 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.135 2014/08/26 15:09:26 mpi Exp $ */ +/* $OpenBSD: if_ether.c,v 1.136 2014/09/03 08:53:54 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -232,6 +232,18 @@ arp_rtrequest(int req, struct rtentry *rt) rt->rt_flags |= RTF_LLINFO; LIST_INSERT_HEAD(&llinfo_arp, la, la_list); + /* + * Routes to broadcast addresses must be incomplete + * arp entries so that they won't be picked up, but + * since we expect them to always be present in the + * routing table, make sure arptimer() won't free + * them. + */ + if (rt->rt_flags & RTF_BROADCAST) { + rt->rt_expire = 0; + break; + } + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if ((ifa->ifa_addr->sa_family == AF_INET) && ifatoia(ifa)->ia_addr.sin_addr.s_addr == @@ -629,7 +641,8 @@ in_arpinput(struct mbuf *m) if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) { if (sdl->sdl_alen) { if (memcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) { - if (rt->rt_flags & RTF_PERMANENT_ARP) { + if (rt->rt_flags & + (RTF_PERMANENT_ARP|RTF_LOCAL|RTF_BROADCAST)) { inet_ntop(AF_INET, &isaddr, addr, sizeof(addr)); log(LOG_WARNING, "arp: attempt to overwrite permanent " |