git: 450394af27bc - main - ifnet: use ck_pr(3) store & load setting ifnet pointer in ifindex

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 17:32:46 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=450394af27bcb61beb6b641ff3ee6a6af01d4bb7

commit 450394af27bcb61beb6b641ff3ee6a6af01d4bb7
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2021-12-04 17:49:35 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2021-12-06 17:32:30 +0000

    ifnet: use ck_pr(3) store & load setting ifnet pointer in ifindex
    
    The lockless access to the array is protected by the network epoch.
    
    Reviewed by:            bz, kp
    Differential revision:  https://reviews.freebsd.org/D33260
---
 sys/net/if.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index 520e8b4de393..8b820eb562ed 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -350,7 +350,7 @@ ifnet_byindex(u_short idx)
 	if (__predict_false(idx > V_if_index))
 		return (NULL);
 
-	return (V_ifindex_table[idx]);
+	return (ck_pr_load_ptr(&V_ifindex_table[idx]));
 }
 
 struct ifnet *
@@ -403,7 +403,7 @@ ifindex_free(u_short idx)
 
 	IFNET_WLOCK_ASSERT();
 
-	V_ifindex_table[idx] = NULL;
+	ck_pr_store_ptr(&V_ifindex_table[idx], NULL);
 	while (V_if_index > 0 &&
 	    V_ifindex_table[V_if_index] == NULL)
 		V_if_index--;
@@ -414,7 +414,7 @@ ifnet_setbyindex(u_short idx, struct ifnet *ifp)
 {
 
 	ifp->if_index = idx;
-	V_ifindex_table[idx] = ifp;
+	ck_pr_store_ptr(&V_ifindex_table[idx], ifp);
 }
 
 struct ifaddr *