git: 242fa308f3c3 - main - carp: Explicitly mark tunnable net.inet.carp.allow with CTLFLAG_NOFETCH

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Sat, 09 Sep 2023 08:21:18 UTC
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=242fa308f3c3def32b2e61e0b78c11b3697e4492

commit 242fa308f3c3def32b2e61e0b78c11b3697e4492
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-09 08:10:32 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-09 08:10:32 +0000

    carp: Explicitly mark tunnable net.inet.carp.allow with CTLFLAG_NOFETCH
    
    With recent change 110113bc086f, a vnet tunable can be initialized when
    there is a corresponding kernel environment variable unless it is marked
    with the flag CTLFLAG_NOFETCH.
    
    The initialization may happen during early boot(linker preload), at that
    time vnet0 has not been created. The hander carp_allow_sysctl() for the
    tunable net.inet.carp.allow requires vnet, thus invoking it during early
    boot will cause kernel panic.
    
    The tunnable is initialized by vnet sysinit routine ipcarp_sysinit() so
    let's just mark it with flag CTLFLAG_NOFETCH.
    
    No functional change intended.
    
    Fixes:          110113bc086f sysctl(9): Enable vnet sysctl variables to be loader tunable
    MFC after:      2 week
    Differential Revision:  https://reviews.freebsd.org/D41525
---
 sys/netinet/ip_carp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 28c1e535b783..e8ed6afd3853 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -239,7 +239,7 @@ static int carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS);
 SYSCTL_NODE(_net_inet, IPPROTO_CARP, carp, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
     "CARP");
 SYSCTL_PROC(_net_inet_carp, OID_AUTO, allow,
-    CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+    CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE,
     &VNET_NAME(carp_allow), 0, carp_allow_sysctl, "I",
     "Accept incoming CARP packets");
 SYSCTL_PROC(_net_inet_carp, OID_AUTO, dscp,