mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-12 09:58:36 +00:00
Change net.inet.carp.demotion sysctl to add the supplied value
to the current demotion factor instead of assigning it. This allows external scripts to control demotion factor together with kernel in a raceless manner.
This commit is contained in:
parent
e8db9937f3
commit
7951008b47
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=244681
@ -26,7 +26,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 29, 2012
|
||||
.Dd December 25, 2012
|
||||
.Dt CARP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -125,15 +125,14 @@ experiences problem with sending announcements, when an interface
|
||||
running a vhid goes down, or while the
|
||||
.Xr pfsync 4
|
||||
interface is not synchronized.
|
||||
The demotion value is writable, so that user may alter it
|
||||
depending on some external conditions, for example on the status of some
|
||||
daemon utility.
|
||||
However, altering the value should be performed with care, so as to
|
||||
not conflict with subsystems that adjust demotion factor
|
||||
automatically:
|
||||
The demotion factor can be adjusted writing to the sysctl oid.
|
||||
The signed value supplied to the
|
||||
.Xr sysctl 8
|
||||
command is added to current demotion factor.
|
||||
This allows to control
|
||||
.Nm
|
||||
and
|
||||
.Xr pfsync 4 .
|
||||
behaviour depending on some external conditions, for example on the status
|
||||
of some daemon utility.
|
||||
.It Va net.inet.carp.ifdown_demotion_factor
|
||||
This value is added to
|
||||
.Va net.inet.carp.demotion
|
||||
|
@ -192,6 +192,7 @@ static int carp_log = 1; /* Log level. */
|
||||
static int carp_demotion = 0; /* Global advskew demotion. */
|
||||
static int carp_senderr_adj = CARP_MAXSKEW; /* Send error demotion factor */
|
||||
static int carp_ifdown_adj = CARP_MAXSKEW; /* Iface down demotion factor */
|
||||
static int carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
SYSCTL_NODE(_net_inet, IPPROTO_CARP, carp, CTLFLAG_RW, 0, "CARP");
|
||||
SYSCTL_INT(_net_inet_carp, OID_AUTO, allow, CTLFLAG_RW, &carp_allow, 0,
|
||||
@ -200,8 +201,9 @@ SYSCTL_INT(_net_inet_carp, OID_AUTO, preempt, CTLFLAG_RW, &carp_preempt, 0,
|
||||
"High-priority backup preemption mode");
|
||||
SYSCTL_INT(_net_inet_carp, OID_AUTO, log, CTLFLAG_RW, &carp_log, 0,
|
||||
"CARP log level");
|
||||
SYSCTL_INT(_net_inet_carp, OID_AUTO, demotion, CTLFLAG_RW, &carp_demotion, 0,
|
||||
"Demotion factor (skew of advskew)");
|
||||
SYSCTL_PROC(_net_inet_carp, OID_AUTO, demotion, CTLTYPE_INT|CTLFLAG_RW,
|
||||
0, 0, carp_demote_adj_sysctl, "I",
|
||||
"Adjust demotion factor (skew of advskew)");
|
||||
SYSCTL_INT(_net_inet_carp, OID_AUTO, senderr_demotion_factor, CTLFLAG_RW,
|
||||
&carp_senderr_adj, 0, "Send error demotion factor adjustment");
|
||||
SYSCTL_INT(_net_inet_carp, OID_AUTO, ifdown_demotion_factor, CTLFLAG_RW,
|
||||
@ -1999,11 +2001,26 @@ carp_sc_state(struct carp_softc *sc)
|
||||
static void
|
||||
carp_demote_adj(int adj, char *reason)
|
||||
{
|
||||
carp_demotion += adj;
|
||||
atomic_add_int(&carp_demotion, adj);
|
||||
CARP_LOG("demoted by %d to %d (%s)\n", adj, carp_demotion, reason);
|
||||
taskqueue_enqueue(taskqueue_swi, &carp_sendall_task);
|
||||
}
|
||||
|
||||
static int
|
||||
carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
int new, error;
|
||||
|
||||
new = carp_demotion;
|
||||
error = sysctl_handle_int(oidp, &new, 0, req);
|
||||
if (error || !req->newptr)
|
||||
return (error);
|
||||
|
||||
carp_demote_adj(new, "sysctl");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef INET
|
||||
extern struct domain inetdomain;
|
||||
static struct protosw in_carp_protosw = {
|
||||
|
Loading…
Reference in New Issue
Block a user