diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-07-04 08:22:20 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-07-04 08:22:20 +0000 |
commit | 7b888444f73c10939da5e09e58c0d750db5a6426 (patch) | |
tree | cdfbd262ce4190d3edacf456ea4b8fb42e661097 /sys/netinet/if_ether.c | |
parent | 2853d72618abd8407e6323f5090f60b69c1e6e5c (diff) |
Rewrite the function used to determine if we do proxy ARP for one of
our addresses to reuse arplookup() and do only one list iteration.
Looks ok to claudio@, ok mikeb@
Diffstat (limited to 'sys/netinet/if_ether.c')
-rw-r--r-- | sys/netinet/if_ether.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index d2cd803b7b5..971c50844bc 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.101 2013/03/28 23:10:05 tedu Exp $ */ +/* $OpenBSD: if_ether.c,v 1.102 2013/07/04 08:22:19 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -853,6 +853,35 @@ arplookup(u_int32_t addr, int create, int proxy, u_int tableid) return ((struct llinfo_arp *)rt->rt_llinfo); } +/* + * Check whether we do proxy ARP for this address and we point to ourselves. + */ +int +arpproxy(struct in_addr in, u_int rdomain) +{ + struct llinfo_arp *la; + struct ifnet *ifp; + int found = 0; + + la = arplookup(in.s_addr, 0, SIN_PROXY, rdomain); + if (la == NULL) + return (0); + + TAILQ_FOREACH(ifp, &ifnet, if_list) { + if (ifp->if_rdomain != rdomain) + continue; + + if (!bcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway), + LLADDR((struct sockaddr_dl *)ifp->if_lladdr->ifa_addr), + ETHER_ADDR_LEN)) { + found = 1; + break; + } + } + + return (found); +} + void arp_ifinit(struct arpcom *ac, struct ifaddr *ifa) { |