aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Lytochkin <lytboris@gmail.com>2023-01-29 16:42:40 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-02-09 16:41:34 +0000
commit0169daa1f2cd62394e7d068cbb405d64a8316bbc (patch)
treed88c24e2fd271e8140dbaea3af8a95b79f503ffd
parent23d017b8d4c2a17bca15fe794dd0b2deb7e18f03 (diff)
downloadsrc-0169daa1f2cd62394e7d068cbb405d64a8316bbc.tar.gz
src-0169daa1f2cd62394e7d068cbb405d64a8316bbc.zip
carp: turn net.inet.carp.allow into a RW tunable
Currently CARP starts announcing its state when initialised, regardless of the state of the other services provided by the server. As a result, the device can become master while still loading the firewall ruleset or initialising long-starting service. This change adds the way to request delayed CARP start by setting the net.inet.carp.allow=0 in the loader.conf. Differential Revision: https://reviews.freebsd.org/D38167 MFC after: 2 weeks (cherry picked from commit ee49c5d33d93a6b10222f64a0dc16590ac2048a0)
-rw-r--r--sys/netinet/ip_carp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 71558be619d8..e84a85ebc11e 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -221,8 +221,8 @@ 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_RW | CTLFLAG_MPSAFE,
- 0, 0, carp_allow_sysctl, "I",
+ CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ &VNET_NAME(carp_allow), 0, carp_allow_sysctl, "I",
"Accept incoming CARP packets");
SYSCTL_PROC(_net_inet_carp, OID_AUTO, dscp,
CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
@@ -2238,6 +2238,15 @@ carp_mod_cleanup(void)
sx_destroy(&carp_sx);
}
+static void
+ipcarp_sysinit(void)
+{
+
+ /* Load allow as tunable so to postpone carp start after module load */
+ TUNABLE_INT_FETCH("net.inet.carp.allow", &V_carp_allow);
+}
+VNET_SYSINIT(ip_carp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, ipcarp_sysinit, NULL);
+
static int
carp_mod_load(void)
{