summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/carp.417
-rw-r--r--sys/netinet/ip_carp.c23
2 files changed, 28 insertions, 12 deletions
diff --git a/share/man/man4/carp.4 b/share/man/man4/carp.4
index c1dfa57..d051377 100644
--- a/share/man/man4/carp.4
+++ b/share/man/man4/carp.4
@@ -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
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 75e0585..7afe1af 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -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 = {
OpenPOWER on IntegriCloud