FBSD: Use CK_STAILQ_FOREACH for ifaces on FBSD 12 99/13999/7
authorAndrew Deason <adeason@dson.org>
Sun, 22 Dec 2019 00:34:20 +0000 (18:34 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 28 Feb 2021 03:31:11 +0000 (22:31 -0500)
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>

src/afs/afs_server.c
src/config/param.generic_fbsd.h
src/rx/rx_kcommon.c

index e705d0a..24d4cd3 100644 (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);
index c7a527d..f100f4f 100644 (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 */
index 97780d9..35f78e9 100644 (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)