hyperv/hn: If synthetic parts are detached, don't touch them.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D8065
This commit is contained in:
Sepherosa Ziehau 2016-09-30 06:21:00 +00:00
parent 37e0abf2ef
commit fed9f4df75
2 changed files with 30 additions and 0 deletions

View File

@ -252,6 +252,7 @@ struct hn_softc {
#define HN_FLAG_CHIM_CONNECTED 0x0002
#define HN_FLAG_HAS_RSSKEY 0x0004
#define HN_FLAG_HAS_RSSIND 0x0008
#define HN_FLAG_SYNTH_ATTACHED 0x0010
#define HN_CAP_VLAN 0x0001
#define HN_CAP_MTU 0x0002

View File

@ -405,6 +405,9 @@ hn_rss_reconfig(struct hn_softc *sc)
HN_LOCK_ASSERT(sc);
if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0)
return (ENXIO);
/*
* Disable RSS first.
*
@ -1618,6 +1621,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
HN_LOCK(sc);
if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) {
HN_UNLOCK(sc);
break;
}
if ((sc->hn_caps & HN_CAP_MTU) == 0) {
/* Can't change MTU */
HN_UNLOCK(sc);
@ -1671,6 +1679,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
case SIOCSIFFLAGS:
HN_LOCK(sc);
if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) {
HN_UNLOCK(sc);
break;
}
if (ifp->if_flags & IFF_UP) {
/*
* If only the state of the PROMISC flag changed,
@ -1782,6 +1795,9 @@ hn_stop(struct hn_softc *sc)
HN_LOCK_ASSERT(sc);
KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED,
("synthetic parts were not attached"));
/* Clear RUNNING bit _before_ hn_suspend() */
atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING);
hn_suspend(sc);
@ -1858,6 +1874,9 @@ hn_init_locked(struct hn_softc *sc)
HN_LOCK_ASSERT(sc);
if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0)
return;
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
return;
@ -3377,6 +3396,9 @@ hn_synth_attach(struct hn_softc *sc, int mtu)
int error, nsubch, nchan, i;
uint32_t old_caps;
KASSERT((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0,
("synthetic parts were attached"));
/* Save capabilities for later verification. */
old_caps = sc->hn_caps;
sc->hn_caps = 0;
@ -3489,6 +3511,8 @@ hn_synth_attach(struct hn_softc *sc, int mtu)
error = hn_attach_subchans(sc);
if (error)
return (error);
sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED;
return (0);
}
@ -3502,6 +3526,9 @@ hn_synth_detach(struct hn_softc *sc)
{
HN_LOCK_ASSERT(sc);
KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED,
("synthetic parts were not attached"));
/* Detach the RNDIS first. */
hn_rndis_detach(sc);
@ -3510,6 +3537,8 @@ hn_synth_detach(struct hn_softc *sc)
/* Detach all of the channels. */
hn_detach_allchans(sc);
sc->hn_flags &= ~HN_FLAG_SYNTH_ATTACHED;
}
static void