FBSD: Use CK_STAILQ_FOREACH for ifaces on FBSD 12

FreeBSD 12 changed how network interfaces and network addresses are
linked together; we're supposed to use CK_STAILQ_FOREACH to traverse
them now, instead of TAILQ_FOREACH. To try to keep this change
simpler, introduce a new macro, AFS_FBSD_NET_FOREACH, which picks the
right macro to use.

Based on a commit by tcreech@tcreech.com.

Change-Id: Iab0f93701dd60dcf4237a7fbbf461019bceaeb38
Reviewed-on: https://gerrit.openafs.org/13999
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2019-12-21 18:34:20 -06:00 committed by Benjamin Kaduk
parent 9e98d61ff4
commit 7c89322c45
3 changed files with 11 additions and 3 deletions

View File

@ -1364,7 +1364,7 @@ afs_SetServerPrefs(struct srvAddr *const sa)
struct rm_priotracker in_ifa_tracker;
CURVNET_SET(rx_socket->so_vnet);
IN_IFADDR_RLOCK(&in_ifa_tracker);
TAILQ_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
AFS_FBSD_NET_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
afsi_SetServerIPRank(sa, &ifa->ia_ifa);
}
IN_IFADDR_RUNLOCK(&in_ifa_tracker);

View File

@ -130,6 +130,14 @@ enum vcexcl { NONEXCL, EXCL };
#define FBSD_VOP_GETPAGES_BUSIED
#endif
/* r333813 changed network interfaces and addrs to be traversed via
* CK_STAILQ_FOREACH instead of TAILQ_FOREACH */
#if __FreeBSD_version >= 1200064
# define AFS_FBSD_NET_FOREACH CK_STAILQ_FOREACH
#else
# define AFS_FBSD_NET_FOREACH TAILQ_FOREACH
#endif
#else /* !defined(UKERNEL) */
/* This section for user space compiles only */

View File

@ -669,7 +669,7 @@ rxi_GetIFInfo(void)
# elif defined(AFS_FBSD_ENV)
CURVNET_SET(rx_socket->so_vnet);
IFNET_RLOCK();
TAILQ_FOREACH(ifn, &V_ifnet, if_link) {
AFS_FBSD_NET_FOREACH(ifn, &V_ifnet, if_link) {
if (i >= ADDRSPERSITE)
break;
# elif defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
@ -685,7 +685,7 @@ rxi_GetIFInfo(void)
break;
# elif defined(AFS_FBSD_ENV)
if_addr_rlock(ifn);
TAILQ_FOREACH(ifad, &ifn->if_addrhead, ifa_link) {
AFS_FBSD_NET_FOREACH(ifad, &ifn->if_addrhead, ifa_link) {
if (i >= ADDRSPERSITE)
break;
# elif defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)