mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
if_afdata lock was converted from mutex to rwlock a long ago, so we can
replace IF_AFDATA_LOCK() macro depending to the access type. Sponsored by: Yandex LLC MFC after: 1 week
This commit is contained in:
parent
6961891ea1
commit
5cf7ec13f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=243031
@ -121,11 +121,11 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
int error = 0;
|
||||
struct scope6_id *sid = NULL;
|
||||
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_WLOCK(ifp);
|
||||
sid = SID(ifp);
|
||||
|
||||
if (!sid) { /* paranoid? */
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_WUNLOCK(ifp);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
*/
|
||||
if (i == IPV6_ADDR_SCOPE_INTFACELOCAL &&
|
||||
idlist->s6id_list[i] != ifp->if_index) {
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_WUNLOCK(ifp);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
* IDs, but we check the consistency for
|
||||
* safety in later use.
|
||||
*/
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_WUNLOCK(ifp);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
sid->s6id_list[i] = idlist->s6id_list[i];
|
||||
}
|
||||
}
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_WUNLOCK(ifp);
|
||||
|
||||
return (error);
|
||||
}
|
||||
@ -180,18 +180,19 @@ scope6_set(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
int
|
||||
scope6_get(struct ifnet *ifp, struct scope6_id *idlist)
|
||||
{
|
||||
/* We only need to lock the interface's afdata for SID() to work. */
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
struct scope6_id *sid = SID(ifp);
|
||||
struct scope6_id *sid;
|
||||
|
||||
/* We only need to lock the interface's afdata for SID() to work. */
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
sid = SID(ifp);
|
||||
if (sid == NULL) { /* paranoid? */
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
*idlist = *sid;
|
||||
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -408,7 +409,7 @@ in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
|
||||
u_int32_t zoneid = 0;
|
||||
struct scope6_id *sid;
|
||||
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
|
||||
sid = SID(ifp);
|
||||
|
||||
@ -425,12 +426,12 @@ in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
|
||||
*/
|
||||
if (IN6_IS_ADDR_LOOPBACK(in6)) {
|
||||
if (!(ifp->if_flags & IFF_LOOPBACK)) {
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
return (EINVAL);
|
||||
} else {
|
||||
if (ret_id != NULL)
|
||||
*ret_id = 0; /* there's no ambiguity */
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -457,7 +458,7 @@ in6_setscope(struct in6_addr *in6, struct ifnet *ifp, u_int32_t *ret_id)
|
||||
zoneid = 0; /* XXX: treat as global. */
|
||||
break;
|
||||
}
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
|
||||
if (ret_id != NULL)
|
||||
*ret_id = zoneid;
|
||||
|
Loading…
Reference in New Issue
Block a user