summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-05-23 09:23:44 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-05-23 09:23:44 +0000
commitb4856dcc3b90f04613299ca718ecef538acdf847 (patch)
treee46fa98037f8d4923e904be7c03eafc4c122182b /sys/netinet
parentc59932302292f081c294e95c19ee2cbb6ac81662 (diff)
Pass a 'struct in_addr *' to arplookup() instead of always dereferencing
one.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/if_ether.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 267758c6a3c..91f24e2f10b 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.208 2016/05/23 09:09:04 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.209 2016/05/23 09:23:43 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -80,7 +80,7 @@ int arpt_down = 20; /* once declared down, don't send for 20 secs */
void arptfree(struct rtentry *);
void arptimer(void *);
-struct rtentry *arplookup(u_int32_t, int, int, u_int);
+struct rtentry *arplookup(struct in_addr *, int, int, unsigned int);
void in_arpinput(struct ifnet *, struct mbuf *);
void in_revarpinput(struct ifnet *, struct mbuf *);
int arpcache(struct ifnet *, struct ether_arp *, struct rtentry *);
@@ -316,8 +316,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
"local address\n", __func__, inet_ntop(AF_INET,
&satosin(dst)->sin_addr, addr, sizeof(addr)));
} else {
- rt = arplookup(satosin(dst)->sin_addr.s_addr, 1, 0,
- ifp->if_rdomain);
+ rt = arplookup(&satosin(dst)->sin_addr, 1, 0, ifp->if_rdomain);
if (rt != NULL) {
created = 1;
la = ((struct llinfo_arp *)rt->rt_llinfo);
@@ -500,8 +499,8 @@ in_arpinput(struct ifnet *ifp, struct mbuf *m)
goto out;
#endif
- /* Do we have an ARP cache for the sender? Create if we are target. */
- rt = arplookup(isaddr.s_addr, target, 0, rdomain);
+ /* Do we have an ARP cache for the sender? Create if we are target. */
+ rt = arplookup(&isaddr, target, 0, rdomain);
/* Check sender against our interface addresses. */
if (rtisvalid(rt) && ISSET(rt->rt_flags, RTF_LOCAL) &&
@@ -526,7 +525,7 @@ in_arpinput(struct ifnet *ifp, struct mbuf *m)
} else {
struct sockaddr_dl *sdl;
- rt = arplookup(itaddr.s_addr, 0, SIN_PROXY, rdomain);
+ rt = arplookup(&itaddr, 0, SIN_PROXY, rdomain);
if (rt == NULL)
goto out;
/* protect from possible duplicates only owner should respond */
@@ -675,7 +674,7 @@ arptfree(struct rtentry *rt)
* Lookup or enter a new address in arptab.
*/
struct rtentry *
-arplookup(u_int32_t addr, int create, int proxy, u_int tableid)
+arplookup(struct in_addr *inp, int create, int proxy, u_int tableid)
{
struct rtentry *rt;
struct sockaddr_inarp sin;
@@ -684,7 +683,7 @@ arplookup(u_int32_t addr, int create, int proxy, u_int tableid)
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = addr;
+ sin.sin_addr.s_addr = inp->s_addr;
sin.sin_other = proxy ? SIN_PROXY : 0;
flags = (create) ? RT_RESOLVE : 0;
@@ -727,7 +726,7 @@ arpproxy(struct in_addr in, unsigned int rtableid)
struct ifnet *ifp;
int found = 0;
- rt = arplookup(in.s_addr, 0, SIN_PROXY, rtableid);
+ rt = arplookup(&in, 0, SIN_PROXY, rtableid);
if (!rtisvalid(rt)) {
rtfree(rt);
return (0);