Close a race where SIOCGIFMEDIA ioctl get inconsistent link status.
Because driver is accessing a common MII structure in mii_pollstat(), updating user supplied structure should be done before dropping a driver lock. Reported by: Karim (fodillemlinkarimi <> gmail dot com)
This commit is contained in:
parent
a906bdb04d
commit
57c81d92ae
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226478
@ -282,9 +282,9 @@ age_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->age_miibus);
|
||||
|
||||
mii_pollstat(mii);
|
||||
AGE_UNLOCK(sc);
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
AGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -349,9 +349,9 @@ alc_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->alc_miibus);
|
||||
|
||||
mii_pollstat(mii);
|
||||
ALC_UNLOCK(sc);
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ALC_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -270,9 +270,9 @@ ale_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->ale_miibus);
|
||||
|
||||
mii_pollstat(mii);
|
||||
ALE_UNLOCK(sc);
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ALE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1430,9 +1430,9 @@ lge_ifmedia_sts(ifp, ifmr)
|
||||
LGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->lge_miibus);
|
||||
mii_pollstat(mii);
|
||||
LGE_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
LGE_UNLOCK(sc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -995,9 +995,9 @@ msk_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc_if->msk_miibus);
|
||||
|
||||
mii_pollstat(mii);
|
||||
MSK_IF_UNLOCK(sc_if);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
MSK_IF_UNLOCK(sc_if);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2952,10 +2952,10 @@ nfe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
NFE_LOCK(sc);
|
||||
mii = device_get_softc(sc->nfe_miibus);
|
||||
mii_pollstat(mii);
|
||||
NFE_UNLOCK(sc);
|
||||
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
NFE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2417,9 +2417,9 @@ nge_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
NGE_LOCK(sc);
|
||||
mii = device_get_softc(sc->nge_miibus);
|
||||
mii_pollstat(mii);
|
||||
NGE_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
NGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1202,10 +1202,10 @@ nve_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
NVE_LOCK(sc);
|
||||
mii = device_get_softc(sc->miibus);
|
||||
mii_pollstat(mii);
|
||||
NVE_UNLOCK(sc);
|
||||
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
NVE_UNLOCK(sc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -3214,9 +3214,9 @@ re_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
|
||||
RL_LOCK(sc);
|
||||
mii_pollstat(mii);
|
||||
RL_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
RL_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1746,9 +1746,9 @@ sge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
return;
|
||||
}
|
||||
mii_pollstat(mii);
|
||||
SGE_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
SGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2237,9 +2237,9 @@ sis_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
SIS_LOCK(sc);
|
||||
mii = device_get_softc(sc->sis_miibus);
|
||||
mii_pollstat(mii);
|
||||
SIS_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
SIS_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2173,9 +2173,9 @@ vge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
return;
|
||||
}
|
||||
mii_pollstat(mii);
|
||||
VGE_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
VGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2155,9 +2155,9 @@ vr_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
return;
|
||||
}
|
||||
mii_pollstat(mii);
|
||||
VR_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
VR_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -284,9 +284,9 @@ vte_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->vte_miibus);
|
||||
|
||||
mii_pollstat(mii);
|
||||
VTE_UNLOCK(sc);
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
VTE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1199,9 +1199,9 @@ arge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->arge_miibus);
|
||||
ARGE_LOCK(sc);
|
||||
mii_pollstat(mii);
|
||||
ARGE_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
ARGE_UNLOCK(sc);
|
||||
}
|
||||
|
||||
struct arge_dmamap_arg {
|
||||
|
@ -945,9 +945,9 @@ kr_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
mii = device_get_softc(sc->kr_miibus);
|
||||
KR_LOCK(sc);
|
||||
mii_pollstat(mii);
|
||||
KR_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
KR_UNLOCK(sc);
|
||||
}
|
||||
|
||||
struct kr_dmamap_arg {
|
||||
|
@ -1932,9 +1932,9 @@ rl_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
|
||||
RL_LOCK(sc);
|
||||
mii_pollstat(mii);
|
||||
RL_UNLOCK(sc);
|
||||
ifmr->ifm_active = mii->mii_media_active;
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
RL_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user