From: mpi Date: Tue, 23 Jun 2015 13:20:17 +0000 (+0000) Subject: Pass a "struct ifnet *" instead of a "struct arpcom *" to arpresolve(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f47663ad1ab2e2faf61e4f34cc48ad4381881c8f;p=openbsd Pass a "struct ifnet *" instead of a "struct arpcom *" to arpresolve(). Most of the ARP layer already take an ifp pointer and this makes clear wich chunks of code are messing with ac_enaddr. Note that our Ethernet code assume that these pointer are interchangeable since the first element of the "struct arpcom" is a "struct ifnet". --- diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 94d7370a57f..2b77da1998b 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.206 2015/06/23 09:42:23 mpi Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.207 2015/06/23 13:20:17 mpi Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -197,7 +197,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, switch (dst->sa_family) { case AF_INET: - error = arpresolve(ac, rt, m, dst, edst); + error = arpresolve(ifp, rt, m, dst, edst); if (error) return (error == EAGAIN ? 0 : error); /* If broadcasting on a simplex interface, loopback a copy */ @@ -233,7 +233,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, sizeof(edst)); break; case AF_INET: - error = arpresolve(ac, rt, m, dst, edst); + error = arpresolve(ifp, rt, m, dst, edst); if (error) return (error == EAGAIN ? 0 : error); break; diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 9209706131d..9f133241417 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.155 2015/06/16 11:09:40 mpi Exp $ */ +/* $OpenBSD: if_ether.c,v 1.156 2015/06/23 13:20:17 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -326,9 +326,10 @@ arprequest(struct ifnet *ifp, u_int32_t *sip, u_int32_t *tip, u_int8_t *enaddr) * Any other return value indicates an error. */ int -arpresolve(struct arpcom *ac, struct rtentry *rt0, struct mbuf *m, +arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, struct sockaddr *dst, u_char *desten) { + struct arpcom *ac = (struct arpcom *)ifp; struct llinfo_arp *la; struct sockaddr_dl *sdl; struct rtentry *rt = NULL; @@ -346,7 +347,7 @@ arpresolve(struct arpcom *ac, struct rtentry *rt0, struct mbuf *m, } if (rt0 != NULL) { - error = rt_checkgate(&ac->ac_if, rt0, dst, + error = rt_checkgate(ifp, rt0, dst, m->m_pkthdr.ph_rtableid, &rt); if (error) { m_freem(m); @@ -369,7 +370,7 @@ arpresolve(struct arpcom *ac, struct rtentry *rt0, struct mbuf *m, &satosin(dst)->sin_addr, addr, sizeof(addr))); } else { if ((la = arplookup(satosin(dst)->sin_addr.s_addr, 1, 0, - ac->ac_if.if_rdomain)) != NULL) + ifp->if_rdomain)) != NULL) rt = la->la_rt; else log(LOG_DEBUG, @@ -398,7 +399,7 @@ arpresolve(struct arpcom *ac, struct rtentry *rt0, struct mbuf *m, memcpy(desten, LLADDR(sdl), sdl->sdl_alen); return (0); } - if (((struct ifnet *)ac)->if_flags & IFF_NOARP) { + if (ifp->if_flags & IFF_NOARP) { m_freem(m); return (EINVAL); } @@ -440,7 +441,7 @@ arpresolve(struct arpcom *ac, struct rtentry *rt0, struct mbuf *m, if (la->la_asked == 0 || rt->rt_expire != time_second) { rt->rt_expire = time_second; if (la->la_asked++ < arp_maxtries) - arprequest(&ac->ac_if, + arprequest(ifp, &satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr, &satosin(dst)->sin_addr.s_addr, #if NCARP > 0 diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index aa7394da822..5c544f93b75 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.56 2015/04/10 13:58:20 dlg Exp $ */ +/* $OpenBSD: if_ether.h,v 1.57 2015/06/23 13:20:17 mpi Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -192,7 +192,7 @@ extern struct niqueue arpintrq; void arpwhohas(struct arpcom *, struct in_addr *); void arpintr(void); -int arpresolve(struct arpcom *, +int arpresolve(struct ifnet *, struct rtentry *, struct mbuf *, struct sockaddr *, u_char *); void arp_ifinit(struct arpcom *, struct ifaddr *); void arp_rtrequest(int, struct rtentry *);