diff options
author | 2015-11-13 10:18:04 +0000 | |
---|---|---|
committer | 2015-11-13 10:18:04 +0000 | |
commit | df5ed9e3a3d6fea98959abaf7f01ea9cb263ec09 (patch) | |
tree | 347f37ace5a4174a58472dc96c56212faf4b18c9 /sys | |
parent | Use ph_ prefix for tag-related fields. (diff) | |
download | wireguard-openbsd-df5ed9e3a3d6fea98959abaf7f01ea9cb263ec09.tar.xz wireguard-openbsd-df5ed9e3a3d6fea98959abaf7f01ea9cb263ec09.zip |
Sore the index of the interface used for revarp instead of a pointer to
its descriptor. Get rid of a if_ref().
ok dlg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 6 | ||||
-rw-r--r-- | sys/netinet/if_ether.c | 21 | ||||
-rw-r--r-- | sys/netinet/if_ether.h | 4 |
3 files changed, 17 insertions, 14 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 41589ce3a80..b4662375189 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.405 2015/11/11 10:23:23 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.406 2015/11/13 10:18:04 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -887,8 +887,8 @@ if_detach(struct ifnet *ifp) rt_if_remove(ifp); rti_delete(ifp); #if NETHER > 0 && defined(NFSCLIENT) - if (ifp == revarp_ifp) - revarp_ifp = NULL; + if (ifp->if_index == revarp_ifidx) + revarp_ifidx = 0; #endif #ifdef MROUTING vif_delete(ifp); diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index bdb0b744089..644f673a31c 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.185 2015/11/06 23:45:21 bluhm Exp $ */ +/* $OpenBSD: if_ether.c,v 1.186 2015/11/13 10:18:04 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -110,7 +110,7 @@ int la_hold_total; /* revarp state */ struct in_addr revarp_myip, revarp_srvip; int revarp_finished; -struct ifnet *revarp_ifp; +unsigned int revarp_ifidx; #endif /* NFSCLIENT */ /* @@ -826,6 +826,7 @@ out: void in_revarpinput(struct mbuf *m) { + struct ifnet *ifp = NULL; struct ether_arp *ar; int op; @@ -843,14 +844,16 @@ in_revarpinput(struct mbuf *m) goto out; } #ifdef NFSCLIENT - if (revarp_ifp == NULL) + if (revarp_ifidx == 0) goto out; - if (revarp_ifp->if_index != m->m_pkthdr.ph_ifidx) /* !same interface */ + if (revarp_ifidx != m->m_pkthdr.ph_ifidx) /* !same interface */ goto out; if (revarp_finished) goto wake; - if (memcmp(ar->arp_tha, ((struct arpcom *)revarp_ifp)->ac_enaddr, - sizeof(ar->arp_tha))) + ifp = if_get(revarp_ifidx); + if (ifp == NULL) + goto out; + if (memcmp(ar->arp_tha, LLADDR(ifp->if_sadl), sizeof(ar->arp_tha))) goto out; memcpy(&revarp_srvip, ar->arp_spa, sizeof(revarp_srvip)); memcpy(&revarp_myip, ar->arp_tpa, sizeof(revarp_myip)); @@ -861,6 +864,7 @@ wake: /* Do wakeup every time in case it was missed. */ out: m_freem(m); + if_put(ifp); } /* @@ -915,15 +919,14 @@ revarpwhoarewe(struct ifnet *ifp, struct in_addr *serv_in, if (revarp_finished) return EIO; - revarp_ifp = if_ref(ifp); + revarp_ifidx = ifp->if_index; while (count--) { revarprequest(ifp); result = tsleep((caddr_t)&revarp_myip, PSOCK, "revarp", hz/2); if (result != EWOULDBLOCK) break; } - if_put(revarp_ifp); - revarp_ifp = NULL; + revarp_ifidx = 0; if (!revarp_finished) return ENETUNREACH; diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index db6a744f9f4..e5a7894da74 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.62 2015/10/27 15:22:58 mpi Exp $ */ +/* $OpenBSD: if_ether.h,v 1.63 2015/11/13 10:18:04 mpi Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -269,7 +269,7 @@ do { \ } while (/* CONSTCOND */ 0) #ifdef NFSCLIENT -extern struct ifnet *revarp_ifp; +extern unsigned int revarp_ifidx; #endif /* NFSCLIENT */ void arprequest(struct ifnet *, u_int32_t *, u_int32_t *, u_int8_t *); |