FBSD: Avoid if_addr_rlock() when needed

FreeBSD commit 19e09f447fd9bbbc7e8b0271dfee7c74e9417047 (Remove
obsoleted KPIs that were used to access interface address lists.)
removed if_addr_rlock() and related functions. Instead, callers are
supposed to enter the net epoch, which is what if_addr_rlock() was
doing before it was removed. Change our callers to do this, adding new
wrappers AFS_IF_ADDR_*() to do the right thing.

Ideally we would enter the net epoch just once, outside of the parent
for() loop, but doing this on each entry makes it simpler to handle
the if_addr_rlock and non-if_addr_rlock cases.

Change-Id: I36817dd54098e830e15ce6b796bf1714fa9c2753
Reviewed-on: https://gerrit.openafs.org/15170
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2022-10-25 16:36:55 -05:00
parent 849fb93efb
commit 1f3f754c01
2 changed files with 11 additions and 2 deletions

View File

@ -138,6 +138,15 @@ enum vcexcl { NONEXCL, EXCL };
# define FBSD_UMA_GETPBUF
#endif
/* r353868 removed if_addr_rlock et al, use the net epoch instead */
#if __FreeBSD_version >= 1300054
# define AFS_IF_ADDR_RLOCK(ifn) RX_NET_EPOCH_ENTER()
# define AFS_IF_ADDR_RUNLOCK(ifn) RX_NET_EPOCH_EXIT()
#else
# define AFS_IF_ADDR_RLOCK(ifn) if_addr_rlock(ifn)
# define AFS_IF_ADDR_RUNLOCK(ifn) if_addr_runlock(ifn)
#endif
/* r355537 removed VI_DOOMED, use VN_IS_DOOMED instead */
#if __FreeBSD_version >= 1300064
# define AFS_IS_DOOMED(vp) VN_IS_DOOMED(vp)

View File

@ -678,7 +678,7 @@ rxi_GetIFInfo(void)
if (i >= ADDRSPERSITE)
break;
# elif defined(AFS_FBSD_ENV)
if_addr_rlock(ifn);
AFS_IF_ADDR_RLOCK(ifn);
AFS_FBSD_NET_FOREACH(ifad, &ifn->if_addrhead, ifa_link) {
if (i >= ADDRSPERSITE)
break;
@ -712,7 +712,7 @@ rxi_GetIFInfo(void)
}
}
# ifdef AFS_FBSD_ENV
if_addr_runlock(ifn);
AFS_IF_ADDR_RUNLOCK(ifn);
# endif
}
# endif /* !AFS_DARWIN80_ENV */